View previous topic :: View next topic |
Author |
Message |
maelp
Joined: 23 Sep 2007 Posts: 12
|
Posted: Mon Oct 06, 2008 7:18 am Post subject: addOnExpose won't add the function ? |
|
|
I have some code that worked with a previous (don't-remember-which) release of gtkD, but that no longer works.
I'm subclassing a DrawingArea widget, and adding this code :
addEvents( EventMask.EXPOSURE_MASK |
EventMask.STRUCTURE_MASK );
addOnExpose( &onExpose );
addOnSizeAllocate( &onSizeAllocate );
the onSizeAllocate function will get called, but the onExpose one won't... someone has a clue on what is going on?
EDIT: when using addOnExpose on a MainWindow widget, everything works fine. By adding crude "debug-Stdout.formatln-code" to gtkD, I see that when calling addOnExpose in the DrawingArea code, it adds it to the listener queue, but then the onExposeCallback function of the gtkD library does not get called (whereas it does in the MainWindow code)
thanks |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Oct 06, 2008 12:24 pm Post subject: |
|
|
Some of the GtkD demos use this approach of overriding gtk.DrawingArea an setting a expose callback with addOnExpose, and they seen to work correctly. So i'm not sure whats going on.
One recent change in gtkD that affects events is that the return value of the callbacks is returned to Gtk so if you add more than one callback and one of them returns true, it's posible thet the other ones don't get called. |
|
Back to top |
|
|
maelp
Joined: 23 Sep 2007 Posts: 12
|
Posted: Tue Oct 07, 2008 10:20 am Post subject: |
|
|
Okay, I don't know what I'm doing wrong here, because I can compile the gtkD examples and it works, but the code I'm compiling don't... maybe the widget isn't displayed in the window, and therefore the expose events aren't sent ? That's the most probable explanation, but I don't know what I'm doing wrong, since I'm only using win.showAll() ... maybe it's linked to the fact that I rewrite the onSizeAllocate handler ?
Could you just look quickly at the code here and tell me if you see something ?
http://github.com/maelp/dvision/tree/master/apps/imView
(VW.d is the widget which onExpose callback doesn't get called, ImView.d is the
MainWindow)
Thanks |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Tue Oct 07, 2008 3:29 pm Post subject: |
|
|
I got it working with the following change:
Code: | --- VW.d~ 2008-10-07 23:16:00.000000000 +0200
+++ VW.d 2008-10-07 23:16:15.000000000 +0200
@@ -761,7 +761,7 @@
onSizeAllocate( GtkAllocation* allocation, Widget widget )
{
Stdout.formatln("OnSizeAllocate");
- widget.getWidgetStruct().allocation = *allocation ;
+ widget.sizeAllocate( allocation );
// widget.setAllocation( *allocation ) ;
setSizeRequest( allocation.width, allocation.height );
|
The reason setting the allocation directly in the struct doesn't work is because the structs are not wrapped correctly.
i see that you were using the manually added setAllocation before, I recently dropped this for sizeAllocate with is part of Gtk. |
|
Back to top |
|
|
maelp
Joined: 23 Sep 2007 Posts: 12
|
Posted: Tue Oct 07, 2008 4:02 pm Post subject: |
|
|
Okay thank you!!
EDIT: There ought to be some advanced tutorials on those matters for Gtk2.0 in general, and for GtkD in particular... |
|
Back to top |
|
|
|