Re: Drawing area feature?

Yes It's exactly what I want. But even if the gnomecanvas is the best
widget for my purpose, I will probably had to only use Gtk.
You said "traverse your list of objects to see which one was clicked".
There is no way to do this with a smart trick? With a "mask color" for
example? Or something else... any idea?

Use a double buffer and draw your objects in the back buffer,
(exactly as in a normal draw), each object with a different color.
Then you just have to compare the color of the pixel where the
user clicked with the color of the objects, to see which one
was selected.

If you do this in a clever way, you can prepare a very simple
hash function which gives you automatically the address
of the object selected, from the r,g,b color codes of the x,y
pixel where the user clicked, you don't need to go around
checking colors one at a time.

This is very fast, it's a standard technique that you can use
everytime you need to write code to select objects.

With complex objects and different classes of objects,
particularly in 3D space, with complex projections, lights, etc...
this is the only way to do selections, really.

I use this myself, in my Gtk/Mesa code, so I can
give you more details if you need.


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