View previous topic :: View next topic |
Author |
Message |
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Mon Jul 10, 2006 6:20 pm Post subject: (Duit compiles!) But, trying to get Cairo working |
|
|
I finally got Ubuntu 6.06 installed and was able to get Duit to compile and all the examples compiled and worked too!
It wasn't easy as I had to change some lines here and there to get it compiling. But now I'm happy!
But, I've been trying to get Cairo running in a Gdk window. It seems there's only one html page that needs to be wrapped: http://developer.gnome.org/doc/API/2.0/gdk/gdk-Cairo-Interaction.html
The function that is the most important is Code: | cairo_t* gdk_cairo_create (GdkDrawable *drawable); | Which creates a surface for the Cairo context. If this function was wrapped, it seems to me that it might be possible to use Cairo in a DrawingArea in Duit.
But as I boldly tried to get the wrap/utils stuff compiled I noticed that a file called /utils/HTODConvert.d is missing. Is this a mistake or something else that I haven't noticed? |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Wed Jul 12, 2006 11:31 am Post subject: Re: (Duit compiles!) But, trying to get Cairo working |
|
|
satelliittipupu wrote: | I finally got Ubuntu 6.06 installed and was able to get Duit to compile and all the examples compiled and worked too!
It wasn't easy as I had to change some lines here and there to get it compiling. But now I'm happy! |
ummm... what type of things? it works fine for me...?
satelliittipupu wrote: | But, I've been trying to get Cairo running in a Gdk window. It seems there's only one html page that needs to be wrapped: http://developer.gnome.org/doc/API/2.0/gdk/gdk-Cairo-Interaction.html
The function that is the most important is Code: | cairo_t* gdk_cairo_create (GdkDrawable *drawable); | Which creates a surface for the Cairo context. If this function was wrapped, it seems to me that it might be possible to use Cairo in a DrawingArea in Duit.
But as I boldly tried to get the wrap/utils stuff compiled I noticed that a file called /utils/HTODConvert.d is missing. Is this a mistake or something else that I haven't noticed? |
I never had time to test cairo at all.
I'll check if the HTODConvert.d is an old file or just missing on the repository.
can you manually add the wrap to gdk_cairo_create (GdkDrawable *drawable) and see if it works?
I don't know how dificult that would be.
Beware that all the D source is generated automatically.
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Wed Jul 12, 2006 6:22 pm Post subject: I got it to work now! |
|
|
Yes, I was able to manually add the gdk_cairo_create(GdkDrawable) to all the right places and now after some hours of trying I also got cairo working inside a Duit window, in a drawingarea widget.
Here's a screenshot:
http://www.flickr.com/photo_zoom.gne?id=188394668&size=o
I don't remember all the stuff that I did, and it wouldn't really help, as I didn't know how to make those changes in the automatic wrapping stuff.
But basically I worked a little bit on gdk.Cairo and renamed it to gdk/GdkCairo.d and the class was also renamed GdkCairo (I'm not sure if that was necessary, but I thought it might conflict with the cairoLib.Cairo.
I wrapped the gdk_cairo_create as Cairo createFromDrawable( Drawable ); much in the same way that some other functions were wrapped in cairoLib.Cairo. And some other stuff on various files... don't remember just now.Ofcourse the names of the functions, and exact way how to wrap things should be considered by someone who knows what is possible.
Hopefully, if I have time, I'll rewrite the famous cairo-clock C/C++ examples to D. |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Thu Jul 13, 2006 6:18 am Post subject: Re: I got it to work now! |
|
|
satelliittipupu wrote: | Yes, I was able to manually add the gdk_cairo_create(GdkDrawable) to all the right places and now after some hours of trying I also got cairo working inside a Duit window, in a drawingarea widget.
Here's a screenshot: |
thank you, I can probably take it from here more confident that it will work.
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Fri Jul 14, 2006 4:54 pm Post subject: Cairo clock almost works... |
|
|
Here's a screenshot of cairo_clock example almost working with Duit.
http://www.flickr.com/photo_zoom.gne?id=189680263&size=o
The cairo parts work perfectly. The only thing missing is to create a Timeout that would call a callback to update the drawingarea once every second.
I don't know how this should be done, as the Timeout.add only accepts GSourceFunc as it's callback, and I don't know how could I make a D delegate transfer into one of those?
Other "complaint" would be that Gdk.Rectangle doesn't have a constructor that would allow creating it like Rectangle(int x, int y, int width, int height). Infact, it only has a constructor for creating it from a GdkRectangle*. But I guess this is just automatically generated, and there hasn't been any need for those Gdk.Rectangles yet.
Duit is great! |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Fri Jul 14, 2006 6:56 pm Post subject: Re: Cairo clock almost works... |
|
|
satelliittipupu wrote: | Here's a screenshot of cairo_clock example almost working with Duit.
http://www.flickr.com/photo_zoom.gne?id=189680263&size=o
The cairo parts work perfectly. The only thing missing is to create a Timeout that would call a callback to update the drawingarea once every second. |
Thank you for testing cairo on Duit!
Is the source available? What's the license?
Can I include it on Duit demos?
check http://dsource.org/projects/dui/browser/trunk/src/gtk/Timeout.d
GLib has a timeout function I added a new API that seems more like the rest of Duit. The new API allows for multiple D callback methods (delegates) associated with only one GLib callback.
Check Duit demos for an example of Timeout use (the Idle demo).
For now Duit uses the deprecated gtk timeout. I'll change it to the new glib timeout. If you use the Duit API the change you be transparent to you.
satelliittipupu wrote: | Other "complaint" would be that Gdk.Rectangle doesn't have a constructor that would allow creating it like Rectangle(int x, int y, int width, int height). Infact, it only has a constructor for creating it from a GdkRectangle*. But I guess this is just automatically generated, and there hasn't been any need for those Gdk.Rectangles yet. |
I missed that one, it's an obviously a usefull constructor.
probaly I missed many others - it's easy to add them.
satelliittipupu wrote: | Duit is great! |
thank you, I agree!
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Thu Jul 20, 2006 5:58 pm Post subject: It works now |
|
|
You can use it for Duit demos!
As far as I'm concerned this little example is freeware, but there was no licences with the cairo examples in GTK+ and Gtkmm that this is based on. But I'm quite sure you can use it and make changes to it as much as you like.
I left some random comments into a function called onSecondsElapsed as it is not made with a good API. It should be made a lot simpler than this.
Screenshot (with three generations of programming languages represented by three generations of cairo clock examples. From the left: C (GTK+), C++ (Gtkmm) and D (Duit)):
http://www.flickr.com/photo_zoom.gne?id=194309411&size=o
Code:
http://pupuedit.sourceforge.net/temppi/duit_cairo_clock.tar.gz
Binary for Ubuntu 6.06 (Copy the modified libDuit.a into /usr/local/lib):
http://pupuedit.sourceforge.net/temppi/duit_cairo_clock_ubuntu_6_06_binary.tar.gz
There's a bug somewhere, as I tried all the C, C++ and D clocks together, and after an hour or so the D version stopped updating itself, but the C and the C++ version kept on going. But other than that it works (if you modify Duit).
The getWindow I had to make for invalidateRect was an exact copy of getDrawable:
Code: | Window getWindow()
{
//GtkWidget* wid = cast(GtkWidget*)getStruct();
//return new Window( cast(GdkWindow*) wid.window );
int* pt =cast(int*)getStruct();
pt += 52/4;
return new Window(cast(GdkWindow*)(*pt));
} |
|
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sat Jul 22, 2006 6:44 am Post subject: |
|
|
I fixed the bug I had there. It was just an issue with the garbage collection, and my inexperience with D. A silly mistake. The Timeout object has to be member of the class, otherwise the GC will clean it up. Now it works forever (I hope).
I replaced the files with the new ones, so you can use the old links above. |
|
Back to top |
|
|
Raedwulf
Joined: 21 Jan 2007 Posts: 9
|
Posted: Fri Jan 26, 2007 12:39 am Post subject: |
|
|
I've almost got cairo working, but I don't have the version specified in the paths.d
libcairo-1.0-0.dll
Btw TestWindow.exe has an unresolved external when compiled with gtkd (and not in duit)
Code: | C:\dmd\projects\gtkd\gtkD\demos\build>build @demo
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
C:\dmd\projects\gtkd\gtkD\demos\cairo\clock.obj(clock)
Error 42: Symbol Undefined _D3gdk8GdkCairo8GdkCairo6createFC3gdk8Drawable8Drawa
bleZC8cairoLib5Cairo5Cairo |
Another cairo problem
Any Suggestions, Cheers
Looks good so far, I need to dig into this D (I'm new )
Ralph _________________ Raedwulf |
|
Back to top |
|
|
Raedwulf
Joined: 21 Jan 2007 Posts: 9
|
Posted: Fri Jan 26, 2007 1:03 pm Post subject: |
|
|
Finally got it compiled
changed the reference of libcairo-1.0-0.dll to libcairo-2.dll
Cheers. _________________ Raedwulf |
|
Back to top |
|
|
|