Support Forum G3D Web Page |
Manages a group of G3D::Widget.
More...
Inherits G3D::Widget.
Classes | |
class | DelayedEvent |
Manages events that have been delayed by a lock. More... | |
Public Member Functions | |
void | add (const shared_ptr< Widget > &m) |
If a lock is in effect, the add may be delayed until the unlock. More... | |
void | beginLock () |
Between beginLock and endLock, add and remove operations are delayed so that iteration is safe. More... | |
virtual Rect2D | bounds () const override |
Inherited from Surface2D. More... | |
void | clear () |
Removes all widgets on this manager. More... | |
bool | contains (const shared_ptr< Widget > &m) const |
If this widget has been added to the WidgetManager, or has a pending add (but not a subsequent pending remove) while in a lock. More... | |
void | defocusWidget (const shared_ptr< Widget > &m) |
Removes focus from this module if it had focus, otherwise does nothing. More... | |
virtual float | depth () const override |
Inherited from Surface2D. More... | |
void | endLock () |
void | fireEvent (const GEvent &event) |
Queues an event on the window associated with this manager. More... | |
shared_ptr< Widget > | focusedWidget () const |
At most one Widget has focus at a time. More... | |
WidgetManager * | manager () const |
void | moveWidgetToBack (const shared_ptr< Widget > &widget) |
Pushes this widget to the back of the z order. More... | |
virtual void | onAfterEvents () |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget. More... | |
virtual void | onAI () |
virtual void | onBeforeGraphics () |
Invoked by WidgetManager immediately before GApp::onGraphics runs. More... | |
virtual bool | onEvent (const GEvent &event) |
Returning true consumes the event and prevents other GModules from seeing it. More... | |
virtual void | onNetwork () |
virtual void | onPose (Array< shared_ptr< Surface > > &posedArray, Array< shared_ptr< Surface2D > > &posed2DArray) |
Calls onPose on all children. More... | |
virtual void | onSimulation (RealTime rdt, SimTime sdt, SimTime idt) |
virtual void | onUserInput (UserInput *ui) |
const shared_ptr< Widget > & | operator[] (int i) const |
Returns a module by index number. More... | |
virtual float | positionalEventZ (const Point2 &pixel) const |
The camera-space z position that this Widget considers this pixel to be at. More... | |
void | remove (const shared_ptr< Widget > &m) |
If a lock is in effect, then the remove will be delayed until the unlock. More... | |
virtual void | render (RenderDevice *rd) const override |
Inherited from Surface2D. More... | |
virtual void | setDepth (float d) |
Called by the WidgetManager. More... | |
void | setFocusedWidget (const shared_ptr< Widget > &m, bool bringToFront=true) |
The Widget must have already been added. More... | |
virtual void | setManager (WidgetManager *m) |
Called by the WidgetManager when this module is added to it. More... | |
int | size () const |
Number of installed widgets. More... | |
const Array< shared_ptr< Widget > > & | widgetArray () const |
Widgets currently executing. More... | |
virtual OSWindow * | window () const |
Returns the operating system window that is currently rendering this Widget. More... | |
Static Public Member Functions | |
static shared_ptr< WidgetManager > | create (OSWindow *window) |
static bool | onEvent (const GEvent &event, shared_ptr< WidgetManager > &a, shared_ptr< WidgetManager > &b) |
static bool | onEvent (const GEvent &event, shared_ptr< WidgetManager > &a) |
static void | sort (Array< shared_ptr< Surface2D >> &array) |
Sorts from farthest to nearest. More... | |
static void | sortAndRender (RenderDevice *rd, Array< shared_ptr< Surface2D >> &array) |
Calls sort, RenderDevice::push2D, and then render on all elements. More... | |
Protected Member Functions | |
WidgetManager () | |
void | updateWidgetDepths () |
Assigns a depth to each widget based on its current position in m_moduleArray and then sorts by depth. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
Array< DelayedEvent > | m_delayedEvent |
To be processed in endLock. More... | |
float | m_depth |
shared_ptr< Widget > | m_focusedModule |
The widget that will receive events first. More... | |
bool | m_locked |
WidgetManager * | m_manager |
The manager, set by setManager(). More... | |
Array< shared_ptr< Widget > > | m_moduleArray |
Events are delivered in DECREASING index order. More... | |
OSWindow * | m_window |
Operating system window. More... | |
Manages a group of G3D::Widget.
This is used internally by G3D::GApp to process its modules. It also enables use of Widgets without the G3D::GApp infrastructure. Most users do not need to use this class.
You can use G3D::Widget without this class.
|
protected |
void G3D::WidgetManager::add | ( | const shared_ptr< Widget > & | m | ) |
If a lock is in effect, the add may be delayed until the unlock.
Priorities should generally not be used; they are largely for supporting debugging components at HIGH_PRIORITY that intercept events before they can hit the regular infrastructure.
void G3D::WidgetManager::beginLock | ( | ) |
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Implements G3D::Surface2D.
Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.
void G3D::WidgetManager::clear | ( | ) |
Removes all widgets on this manager.
bool G3D::WidgetManager::contains | ( | const shared_ptr< Widget > & | m | ) | const |
If this widget has been added to the WidgetManager, or has a pending add (but not a subsequent pending remove) while in a lock.
|
static |
window | The window that generates events for this manager. |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
void G3D::WidgetManager::defocusWidget | ( | const shared_ptr< Widget > & | m | ) |
Removes focus from this module if it had focus, otherwise does nothing.
The widget will move down one z-order level in focus. See moveWidgetToBack() to push it all of the way to the back.
Referenced by G3D::GuiWindow::setVisible().
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Controls the depth of objects when rendering. Subclasses may override this but it can interfere with the normal handling of rendering and event delivery. depth = 0 is usually the "top" widget and depth = 1 is usually the "bottom" widget.
Implements G3D::Surface2D.
Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.
void G3D::WidgetManager::endLock | ( | ) |
|
virtual |
Queues an event on the window associated with this manager.
Reimplemented from G3D::Widget.
shared_ptr<Widget> G3D::WidgetManager::focusedWidget | ( | ) | const |
At most one Widget has focus at a time.
May be nullptr.
Note that a G3D::GuiWindow is a single Widget that then delegates key focus to one GuiControl within itself.
|
inlineinherited |
void G3D::WidgetManager::moveWidgetToBack | ( | const shared_ptr< Widget > & | widget | ) |
Pushes this widget to the back of the z order.
This window will render first and receive events last. This is the opposite of focussing a window.
|
virtual |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget.
Reimplemented from G3D::Widget.
|
virtual |
Reimplemented from G3D::Widget.
|
virtual |
Invoked by WidgetManager immediately before GApp::onGraphics runs.
Reimplemented from G3D::Widget.
|
static |
|
static |
|
virtual |
Returning true consumes the event and prevents other GModules from seeing it.
Motion events (GEventType::MOUSEMOTION, GEventType::JOYHATMOTION, JGEventType::OYBALLMOTION, and GEventType::JOYAXISMOTION) cannot be cancelled.
Reimplemented from G3D::Widget.
|
virtual |
Reimplemented from G3D::Widget.
|
virtual |
Calls onPose on all children.
Reimplemented from G3D::Widget.
Reimplemented from G3D::Widget.
|
virtual |
Reimplemented from G3D::Widget.
const shared_ptr<Widget>& G3D::WidgetManager::operator[] | ( | int | i | ) | const |
Returns a module by index number.
The highest index is the one that receives events first.
|
inlinevirtualinherited |
The camera-space z position that this Widget considers this pixel to be at.
Used for positional event (e.g., mouse click) delivery. Higher means closer.
Large negative values are far away. 0 is the closest 3D object. Values greater than zero are used for 2D objects. Returning fnan() [the default] requests the WidgetManager to set hte positionalEventZ to the object's normal event zorder.
See the implementation of ControlPointEditor::positionalEventZ for an example of how to use this with a 3D object.
Reimplemented in G3D::ControlPointEditor.
void G3D::WidgetManager::remove | ( | const shared_ptr< Widget > & | m | ) |
If a lock is in effect, then the remove will be delayed until the unlock.
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Implements G3D::Surface2D.
Reimplemented in G3D::GConsole, G3D::GuiWindow, G3D::GuiMenu, and G3D::DebugTextWidget.
|
inlinevirtualinherited |
Called by the WidgetManager.
This is the depth that the Widget is expected to use when posed as a Surface2D. Subclasses may override or ignore this but it can interfere with the normal handling of rendering.
void G3D::WidgetManager::setFocusedWidget | ( | const shared_ptr< Widget > & | m, |
bool | bringToFront = true |
||
) |
The Widget must have already been added.
This widget will be moved to the top of the priority list (i.e., it will receive events first). You can set the focussed widget to nullptr.
If you change the focus during a lock, the actual focus change will not take effect until the lock is released.
Setting the focus automatically brings a module to the front of the event processing list unless bringToFront is false
|
inlinevirtualinherited |
Called by the WidgetManager when this module is added to it.
The argument may be nullptr
Reimplemented in G3D::SceneEditorWindow, G3D::ControlPointEditor, G3D::CameraControlWindow, G3D::GameController, G3D::DeveloperWindow, G3D::ProfilerWindow, G3D::TextureBrowserWindow, and G3D::SettingsWindow.
int G3D::WidgetManager::size | ( | ) | const |
Number of installed widgets.
Sorts from farthest to nearest.
|
staticinherited |
Calls sort, RenderDevice::push2D, and then render on all elements.
|
protected |
Assigns a depth to each widget based on its current position in m_moduleArray and then sorts by depth.
The sorting pass is needed because some widgets will not accept their assigned position and will move up or down the array anyway.
Widgets currently executing.
Note that some widgets may have already been added but if the WidgetManager is locked they will not appear in this array yet.
|
virtual |
Returns the operating system window that is currently rendering this Widget.
Reimplemented from G3D::Widget.
|
protected |
To be processed in endLock.
|
protectedinherited |
Referenced by G3D::Widget::depth(), and G3D::Widget::setDepth().
|
protected |
The widget that will receive events first.
This is usually but not always the top Widget in m_moduleArray.
|
protected |
|
protectedinherited |
The manager, set by setManager().
This cannot be a reference counted pointer because that would create a cycle between the Widget and its manager.
Referenced by G3D::Widget::manager(), G3D::GuiWindow::manager(), G3D::Widget::setManager(), and G3D::GuiWindow::setVisible().
Events are delivered in DECREASING index order.
Referenced by widgetArray().
|
protected |
Operating system window.