Original Post
Hello,
Even the most simple GUI system needs a way of "picking" primitives - by that I mean algorithms and processes responsible for determining which parts of the GUI are being manipulated by the user. Are there any "classic" solutions to this?
For example, I could model everything as boxes (windows, buttons, widgets in general, would have bounding volumes), and ray cast into the "GUI-scene" to determine if a mouse click hit something. Taking a scrollbar as an example, I would need to know, specifically, if I hit the actual scrolling control or some other part of the widget - so maybe there's a bounding box for the entire scrollbar and another, contained box, representing the "scroll button"
But what about more arbitrary graphical representations for widgets? A round button can still use the bounding volume, but you're obviously not getting a perfect fit - *and* you might not even *need* that kind of precision. Still, I wonder if it's plausible to represent "pickable" controls and areas using bitmaps, with pixel-perfect collision detection - not really for precision, but rather for more flexibility or ease of defining those areas by artists and designers. We might use an artist created bitmap as input for a pre-processor that maps "pickable" widget parts by pixel color or alpha values, and feed that to the GUI picker.
Also, a hierarchical organization for GUI items seems like a win here, because we can filter unnecessary picking tests faster than say, using a flat list of widgets and testing them all against a pick event.
I'm not sure if I'm being too vague or not, but I've never really found any decent references on this specific part of a GUI system. Or is this one of those "in-the-end-everyone-ends-up-with-a-custom-solution" problems?
Cheers!
Even the most simple GUI system needs a way of "picking" primitives - by that I mean algorithms and processes responsible for determining which parts of the GUI are being manipulated by the user. Are there any "classic" solutions to this?
For example, I could model everything as boxes (windows, buttons, widgets in general, would have bounding volumes), and ray cast into the "GUI-scene" to determine if a mouse click hit something. Taking a scrollbar as an example, I would need to know, specifically, if I hit the actual scrolling control or some other part of the widget - so maybe there's a bounding box for the entire scrollbar and another, contained box, representing the "scroll button"
But what about more arbitrary graphical representations for widgets? A round button can still use the bounding volume, but you're obviously not getting a perfect fit - *and* you might not even *need* that kind of precision. Still, I wonder if it's plausible to represent "pickable" controls and areas using bitmaps, with pixel-perfect collision detection - not really for precision, but rather for more flexibility or ease of defining those areas by artists and designers. We might use an artist created bitmap as input for a pre-processor that maps "pickable" widget parts by pixel color or alpha values, and feed that to the GUI picker.
Also, a hierarchical organization for GUI items seems like a win here, because we can filter unnecessary picking tests faster than say, using a flat list of widgets and testing them all against a pick event.
I'm not sure if I'm being too vague or not, but I've never really found any decent references on this specific part of a GUI system. Or is this one of those "in-the-end-everyone-ends-up-with-a-custom-solution" problems?
Cheers!