Re: transparent glass layer over windows



Havoc Pennington wrote:
Martin Portman <mrp cre canon co uk> writes:

i want to put a transparent 'glass' frame over a window, to intercept
mouse events, possbily draw on the glass, and pass mouse events on to
what's below the glass.

think of a gesture recogniser, receiving mouse events/signals, drawing
the stroke, but sending key events down, and removing the stroke.

in java i'd use the glassPane part of root panes to do this.

how do i do this using gtk?

To intercept events you could use a GDK_INPUT_ONLY GdkWindow, which is
invisible. However, there is no particularly good way to implement
drawing on the pane in GTK. (To support it cleanly GTK would need to work
more like Java/Swing or GnomeCanvas, and avoid having any X windows
inside the GTK toplevel window.)

The best hack I can think of is to draw your stroke on the GtkWindow
using GDK_INCLUDE_INFERIORS for the subwindow mode, then to clear the
stroke call gtk_widget_queue_draw() on the whole window. But this will
break if any widget happens to redraw during the stroke.


SDPGTK, a C++ wrapper for GTK+, provides the sdpGtkScreenOverlay class for doing this - internally, it is implemented as a drawing area inside a top-level window, with a mask bitmap which controls the transparency of the drawing area through a call to gdk_window_shape_combine_mask(). Separate GCs are maintained, so you can draw on the drawing area or the mask. I use it to provide an animated pen-stroke effect (much like MacOS help, if you're familiar) for highlighting widgets in tutorials. See sdpGtkWidget::InteractiveHighlight() for the code.

http://www.k-3d.com

Regards,
Timothy M. Shead





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