Re: [gtkmm] Drawing primitves on top of widgets: (how) can it be done?

>I'm wondering whether it's possible in gtkmm to draw graphics primitives such 
>as lines over the top of widgets, and have them stay there when the widget is 

you know that it is, from our previous conversations :)

>	   I had hoped that this would be possible with a Gnome::Canvas, but 
>from playing around with the demo code, it appears that it is not, since the 
>widgets are always drawn on top of the graphics.

the simple, and i believe correct answer: don't use any widgets.

>What I'm trying to do is implement a "modular synth" style gui, where there 
>are a number of modules which can be dragged around the window.  Each module 
>can contain arbitrary widgets such as sliders, as well as "ports," which 
>appear as holes in the modules' surfaces.  Ports can be connected with wires, 
>which will be parabolic curves a few pixels thick.  These should be drawn 
>over the top of the modules, and should follow the ports around when a module 
>is dragged.
>The only way I can think of to do this is to render the wires simultaneously 
>into a DrawingArea and a bitmap, and use the bitmap as a shape_combine_mask 
>on the DrawingArea's window.  This is obviously a lot of work, though, and 
>I'm not sure how well it would work, so if anyone knows of an easier or 
>better way, please let me know.  I'd be really interested to know how other 
>people on this list would approach this problem.

as i know you know, i've already done this. the widget is called a
gtktransparency, and it only visible on those pixels where drawing has
been done. the code was all part of quasimodo. its still available
from ardour CVS (

if i was doing this again (and i may well be soon-ish), i would use
the canvas. i would implement all "control elements" as canvas
items. canvas items are really, really easy to write, especially if
for drawing you just use the RGB macros i posted on gtkmm-main the
other day (originally written by john trowbridge and havoc
pennington; they are also in ardour CVS).

GTK+ itself is very slowly evolving toward an almost entirely
canvas-based approach anyway (less and less widgets have their own
windows - this is the first visible sign of this), and it would be
much more useful to have a set of canvas items that act as knobs or
sliders or switches. we'd be well on the way to a useful vstgui-like
system then.


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