www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Recomended cairo bindings

reply "Paul Z. Barsan" <paulz.barsan gmail.com> writes:
Hello,

I want to use a cairo XlibSurface for painting in a project of 
mine and I don't know what bindings should I use. I've started 
with deimos.cairo which has a C-style syntax and works well on my 
linux machine. After I heard about dub, I switched to this build 
system and I ran into problems:

First of all, the cairo version in the dub registry is different 
from the deimos version. CairoD (dub pkg) has support for more 
surfaces and provides D-style wrappers but I get compile-time 
errors. When I try to get an instance of XlibSurface I get an 
"undefined identifier XlibSurface" error.At a closer inspection, 
I see that CAIRO_HAS_XLIB_SURFACE is set to false in 
cairo/c/config.d even though I have a cairo library with xlib 
support. I'm sure about this because I've checked the headers in 
/usr/include/cairo/cairo-features.h. Looking into the deimos 
version, I see that the CairoHasXlibSurface flag is set to true. 
As a conclusion, I think that both config.d(cairod) and 
features.d(deimos.cairo) should be generated while building the 
liibraries to mirror the cairo-features.h header.

A second problem with cairoD from dub registry is that it depends 
uppon std.c.linux.X11.* which doesn't exist on my machine. I have 
libphobos-devel 2.066.0-1 installed and I've looked into my dir 
structure but I've failed to find something related to X11. I've 
also looked in the online docs 
http://dlang.org/library/std/c/linux/tipc.html and the X11 
bindings are not there. I suppose that X11 bindings went from 
phobos to deimos and now deimos ussage is depprecated because of 
dub. So the dub version of cairo bindings should use the dub 
version of libX11, but they don't.

I want to use cairoD for dub but at this point it seems to be 
unusable.I can live with a C-Style syntax but I want to have 
cross-platform support and the deimos version has only the xlib 
surface.Aiming for a long term project, I want to know which 
version of cairo bindings are going to be continued ? What do you 
recommend ?
Sep 14 2014
next sibling parent "Robert burner Schadek" <rburners gmail.com> writes:
On Sunday, 14 September 2014 at 13:30:28 UTC, Paul Z. Barsan 
wrote:
 Hello,

 I want to use a cairo XlibSurface for painting in a project of 
 mine and I don't know what bindings should I use. I've started 
 with deimos.cairo which has a C-style syntax and works well on 
 my linux machine. After I heard about dub, I switched to this 
 build system and I ran into problems:

 First of all, the cairo version in the dub registry is 
 different from the deimos version. CairoD (dub pkg) has support 
 for more surfaces and provides D-style wrappers but I get 
 compile-time errors. When I try to get an instance of 
 XlibSurface I get an "undefined identifier XlibSurface" 
 error.At a closer inspection, I see that CAIRO_HAS_XLIB_SURFACE 
 is set to false in cairo/c/config.d even though I have a cairo 
 library with xlib support. I'm sure about this because I've 
 checked the headers in /usr/include/cairo/cairo-features.h. 
 Looking into the deimos version, I see that the 
 CairoHasXlibSurface flag is set to true. As a conclusion, I 
 think that both config.d(cairod) and features.d(deimos.cairo) 
 should be generated while building the liibraries to mirror the 
 cairo-features.h header.

 A second problem with cairoD from dub registry is that it 
 depends uppon std.c.linux.X11.* which doesn't exist on my 
 machine. I have libphobos-devel 2.066.0-1 installed and I've 
 looked into my dir structure but I've failed to find something 
 related to X11. I've also looked in the online docs 
 http://dlang.org/library/std/c/linux/tipc.html and the X11 
 bindings are not there. I suppose that X11 bindings went from 
 phobos to deimos and now deimos ussage is depprecated because 
 of dub. So the dub version of cairo bindings should use the dub 
 version of libX11, but they don't.

 I want to use cairoD for dub but at this point it seems to be 
 unusable.I can live with a C-Style syntax but I want to have 
 cross-platform support and the deimos version has only the xlib 
 surface.Aiming for a long term project, I want to know which 
 version of cairo bindings are going to be continued ? What do 
 you recommend ?
use gtkd they have a cairo binding
Sep 14 2014
prev sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
On Sunday, 14 September 2014 at 13:30:28 UTC, Paul Z. Barsan 
wrote:
 First of all, the cairo version in the dub registry is 
 different from the deimos version. CairoD (dub pkg) has support 
 for more surfaces and provides D-style wrappers but I get 
 compile-time errors. When I try to get an instance of 
 XlibSurface I get an "undefined identifier XlibSurface" 
 error.At a closer inspection, I see that CAIRO_HAS_XLIB_SURFACE 
 is set to false in cairo/c/config.d even though I have a cairo 
 library with xlib support. I'm sure about this because I've 
 checked the headers in /usr/include/cairo/cairo-features.h. 
 Looking into the deimos version, I see that the 
 CairoHasXlibSurface flag is set to true. As a conclusion, I 
 think that both config.d(cairod) and features.d(deimos.cairo) 
 should be generated while building the liibraries to mirror the 
 cairo-features.h header.
try adding CAIRO_HAS_XLIB_SURFACE version identifier in your dub project, may help with this problem(i mean cairoD from dub don't have configuration system so possibly you need to specify everything manually, hopefully you won't mess with source, just try different versions)
 A second problem with cairoD from dub registry is that it 
 depends uppon std.c.linux.X11.* which doesn't exist on my 
 machine. I have libphobos-devel 2.066.0-1 installed and I've 
 looked into my dir structure but I've failed to find something 
 related to X11. I've also looked in the online docs 
 http://dlang.org/library/std/c/linux/tipc.html and the X11 
 bindings are not there. I suppose that X11 bindings went from 
 phobos to deimos and now deimos ussage is depprecated because 
 of dub. So the dub version of cairo bindings should use the dub 
 version of libX11, but they don't.
never heard deimos deprecated, dub and deimos has different purpose, dub is dependency tracking and build tool, deimos is just an "extension" to phobos containing only C-bindings(!).
 I want to use cairoD for dub but at this point it seems to be 
 unusable.I can live with a C-Style syntax but I want to have 
 cross-platform support and the deimos version has only the xlib 
 surface.Aiming for a long term project, I want to know which 
 version of cairo bindings are going to be continued ? What do 
 you recommend ?
either use deimos only(both x11 and cairo), or possibly you will need to update(?) dub cairoD to use deimos x11. the problem with this is that cairoD looks abandoned, it will possibly require to maintain your own fork of it if start using it.
Sep 14 2014
parent reply "Paul Z. Barsan" <paulz.barsan gmail.com> writes:
On Sunday, 14 September 2014 at 14:37:05 UTC, Robert burner 
Schadek wrote:
 use gtkd they have a cairo binding
Well, umm.. the fact is that I want to make my own lightweight cross-platform widget toolkit from scratch and a gtkd dependency is a big no-no. On Sunday, 14 September 2014 at 14:45:49 UTC, evilrat wrote:
 try adding CAIRO_HAS_XLIB_SURFACE version identifier in your 
 dub project, may help with this problem(i mean cairoD from dub 
 don't have configuration system so possibly you need to specify 
 everything manually, hopefully you won't mess with source, just 
 try different versions)
Variables like CAIRO_HAS_XLIB_SURFACE are platform specific, xlib and xcb surfaces are for linux, win32 and directfb surfaces are for windows and so on.. I will search in dubs documentation how can I specify this sort of variables but I have a gut feeling that running a pre-build script(rdmd ?) is the way of setting them such that they will work for everybody.
 never heard deimos deprecated, dub and deimos has different 
 purpose, dub is dependency tracking and build tool, deimos is 
 just an "extension" to phobos containing only C-bindings(!).
I probably epressed myself in the wrong way but the ussage of dub is encouraged and I've seen many deimos libraries being moved to dubs registry(ctrl+F for "deimos" in http://code.dlang.org/ ), one of them being libX11.The package maintainer of libX11 said in the project description and I quote: "This repository is a clone of the Deimos X11 repository. I've purposely not forked because the overall structure has been changed to suit the dub build tool. Hopefully this is a temporary measure until the entirety of Deimos is moved to dub." I don't see the point of maintaining two versions of the same library, especially for a small comunity like D users.
 either use deimos only(both x11 and cairo), or possibly you 
 will need to update(?) dub cairoD to use deimos x11. the 
 problem with this is that cairoD looks abandoned, it will 
 possibly require to maintain your own fork of it if start using 
 it.
If you look at deimos.cairo you will see that the latest commit was made 2 years ago while cairoD was last updated 6 months ago. I made my choice: I will stick to dub, fork cairoD, merge everything from deimos.cairo into cairoDs C-style bindings & wrappers, update cairoDs dependencies to use dub pkgs and then provide and rdmd script to configure platform specific stuff. I have plenty of time and if I succed, everyone can benefit from my work. :)
Sep 15 2014
next sibling parent reply "Edwin van Leeuwen" <edder tkwsping.nl> writes:
On Monday, 15 September 2014 at 12:11:09 UTC, Paul Z. Barsan 
wrote:
 On Sunday, 14 September 2014 at 14:37:05 UTC, Robert burner 
 Schadek wrote:

 If you look at deimos.cairo you will see that the latest commit 
 was made 2 years ago while cairoD was last updated 6 months ago.
I think the latest commit was made when I submitted a bug report. It seems that there is no ongoing development, but the maintainer/developer did react to my bug report very quickly, so it is/was still maintained at that time.
 I made my choice: I will stick to dub, fork cairoD, merge 
 everything from deimos.cairo into cairoDs C-style bindings & 
 wrappers, update cairoDs dependencies to use dub pkgs and then 
 provide and rdmd script to configure platform specific stuff. I 
 have plenty of time and if I succed, everyone can benefit from 
 my work. :)
Out of curiosity: What does deimos.cairo add to cairoD? More higher level/d-like API? Cheers, Edwin
Sep 15 2014
parent "Paul Z. Barsan" <paulz.barsan gmail.com> writes:
On Monday, 15 September 2014 at 12:19:11 UTC, Edwin van Leeuwen 
wrote:

 Out of curiosity: What does deimos.cairo add to cairoD? More 
 higher level/d-like API?

 Cheers, Edwin
It's the other way around: cairoD adds D-style wrappers but underneath they use C-style bindings(found in cairoD/src/cairo/c/*) similar to deimos.cairo. Deimos.cairo provides more bindings such as script, script_interpreter, xlib_xrender ... and cairoD has support for win32 surface. The coding-style in deimos.cairo seems nicer, the lib beeing maintained by Walter Bright, and if I merge everything from deimos.cairo into cairo.c.*(cairoD) then the projects that were using deimos.cairo can easyly switch to dub and cairoD just by changing the imports.
Sep 15 2014
prev sibling parent "evilrat" <evilrat666 gmail.com> writes:
On Monday, 15 September 2014 at 12:11:09 UTC, Paul Z. Barsan 
wrote:
 Variables like CAIRO_HAS_XLIB_SURFACE are platform specific, 
 xlib and xcb surfaces are for linux, win32 and directfb 
 surfaces are for windows and so on.. I will search in dubs 
 documentation how can I specify this sort of variables but I 
 have a gut feeling that running a pre-build script(rdmd ?) is 
 the way of setting them such that they will work for everybody.
well, there is configurations in dub, add specific linux configuration and required build flags. by default dub picks most appropriate config so this should be enough(from memory): --- ... "configurations": [ { "name": "linux", "platforms": ["linux"], "flags" : ["CAIRO_HAS_XLIB_SURFACE"], } ... name possibly not required, and having this would add xlib surface flag only if invoked on linux
Sep 15 2014