We too are working on a GUI system for our application. What we’ve done is made a hierarchy of Shape3D’s, under a FG node with a scaling matrix that translates 3D FG coords into the exact matching 2D screen pixels, and vice versa. The different widget flavors (Buttons, Text, etc) are responsive to our application’s custom event notification of cursor positioning, but naturally that’s assuming the widget is flat-on to the camera, etc.
We had a real problem with the Text and clipping. We determined that due to UV floating, the only way a Text texture map would render correctly was if the texture AND the Shape3D was a power-of-2 size. However, that left a dilemma about how to clip the text when the window itself wasn’t a power-of-2 sized. We ended up discovering the Graphics2D.setClip() function… now we create power-of-2 sized textures and quads, but call Graphics2D.setClip() with the actual window size, such that the text drawn onto the texture doesn’t go outside of the bounds of the actual window. The rest of the texture is filled in with a 100% transparent color, and nobody ever knows…
http://jeramiehicks.no-ip.com/ConsoleImg.gif
The System window can be moved and resized correctly. The buttons work correctly. The Text windows can be dynamically modified during runtime, and they can be resized correctly. The red box indicates the actual size of the Shape3D and texture on the bottom window, although the drawing of the text onto the texture is clipped to within the widget boundary. If the text widget is resized to the point of needing a different power-of-2 size, it automatically recreates the texture/quad.
The hierarchy for this example looks like this. Note that “quads” are Shape3Ds, while “widgets” are our own custom objects that extend BranchGroup (thereby containing quads or more widgets):
System widget
- Background quad (purple)
- Title quad (light blue)
- Menu button widget
— Button image quad
- Maximize button widget
— Button image quad
- Minimize button widget
— Button image quad
- Close button widget
— Button image quad
- Title text widget
— Text quad
- Content widget
— Background quad (grey)
— Chat buffer text widget
------ Text quad
— Chat input text widget
------ Text quad
Note that isn’t a Swing window. It’s a stack of Shape3Ds that’s simply designed to look like one.
We don’t use layout managers at all. We define the top, bottom, left, and right of each widget as being measured from the parent top/left, parent bottom/right, as a distance from the parent middle (vertical or horizonal), or as a position/size combo. It makes for a radically cleaner and more predictable design, avoids the headache of layout manager implementation and usage, and does everything we need to do.