Re: Order of widgets when displayed on top of each other



I work around this by removing and re-adding the widgets to the layout. For example:

       gtk_widget_ref( GTK_WIDGET( cview ) );
       gtk_container_remove( GTK_CONTAINER( wview->fixed ),
               GTK_WIDGET( cview ) );
       gtk_fixed_put( GTK_FIXED( wview->fixed ),
               GTK_WIDGET( cview ), cview->lx, cview->ly );
       gtk_widget_unref( GTK_WIDGET( cview ) );

will pop cview to the front of the fixed. The _ref()/_unref() pair stop cview being destroyed when it is removed from the container. Wrap an event box around each of the things you want to be able to drag around to get them to paint over each other properly.

This produces sort-of acceptable results. You could try my application:

 http://www.vips.ecs.soton.ac.uk/

to see how well it works in practice. The main issue is slowness on drag: when you do a gtk_fixed_move() to shift one of these things around, it will trigger a repaint of large areas of your application.

Although this is easy, it is not really supported. GTK does not strictly allow overlapping widgets, and as other people have said, something like the canvas widget would be a better long-term choice.

John

J. Davison de St. Germain wrote:
We are displaying widgets (containing GL windows) on "top" of each
other in our application.  We can drag the widgets around on a
"canvas".  Needless to say, when one widget is dragged over another,
it obscures the former widget.  It appears that the widgets are
rendered in the order that they are created/mapped.  My question is,
how can I change this order?  Ie, I would like to be able to toggle
which widget is on top.  Any help would be greatly appreciated.

use the GnomeCanvas, which has z-order stacking. its not so cool for
widgets as it it for native canvas items, but it will work.


My understanding is that this would require us to be dependent on yet
another library (libgnome? or some such) and to learn another API.
Does the Gnome lib provide us with more then this ability; is it worth
using for other things (ie: what does it do for us over and beyond
direct GTK)?  Is the lack of z-order stacking for GTK widgets a bug,
or a known issue, or something that the only fix is to use the Gnome
canvas?  I assume that implementor of the Gnome canvas somehow "worked
around" the GTK problem.  Is it possible for us to use this same work
around to reorder widgets (without using libGnome)?

Thank you for the suggestion and any other information you can
provide.  I will discuss it with our development team.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]