-
Notifications
You must be signed in to change notification settings - Fork 14
GLElement
GLElement is the new approach for creating a structured objected oriented way for creating OpenGL based visualizations.
important classes:
-
GLElement
is the basic element -
GLElementContainer
composite pattern implementation. It uses aIGLLayout2
layouter object to position children -
AnimatedGLElementContainer
similar toGLElementContainer
but the transition between different layout result will be animated. -
GLElementDecorator
decorator / wrapper over anotherGLElement
-
PickableGLElement
everyGLElement
can be made pickable, this special subclass is just a utility to simplify this task and react on picking events
besides the elements itself renderers (IGLRenderer
) are used for rendering simple task. For example to add an element, which renders a simple colored quad, you could either create a subclass of a GLElement
and render the quad or just instantiate a GLElement
and give it a corresponding renderer.
GLButton
GLSpinner
GLComboBox
GLSlider
Every GLElement has two different render stages: render
and picking
. The former one will be displayed to the use, while the latter one will be used for picking. The advantages of splitting this two render stages are:
- simpler picking you normally just need to render a simple quad for picking, while the rendering stage could render a text, color, stashing,...
- better caching it is often the case that you need to adapt the rendering to user interaction, e.g. change the color if the user hovers the element. However, this won't affect the picking at all, which therefore can be simpler cached.
Every element needs to be enabled to be pickable by setting the visibility of the element to PICKABLE
. Afterwards IPickingListener
can be registered using the onPick
method. A simplified version is to use the PickableGLElement
, which already registered a picking listener and provides simple methods to override.
Besides the single picking id per element, one can request and manage additional picking ids by its own. During the init
phase, one can request additional picking ids from the context. Be sure, that you release the picking ids again, during the takeDown
phase. Additional utility class PickingPool
for managing a range of picking ids, targeting the same picking listener but with different picking object ids.
You normally don't need to care about putting the content of an GLElement into a display list. This will be automatically handled for you. To be more precise, every element has an internal state, how long it is stable (= no repaint request during the last render stage). If the element is stable and the content is complex enough, it will be cached within a display list. Depending on the type of the element this could include a whole subtree of element tree.
The caching is done for the render and picking state independently. A important step is to notify the element that should be repainted, either using repaint
, repaintPick
or repaintAll
. The last one is just a shorthand for calling both previous methods. If you call one of the methods all parent element as well as itself will be queued for repainting and all associated caches will be deleted.