Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
G3D::Widget Class Reference


Interface for 2D or 3D objects that experience standard virtual world events and are rendered. More...

Inherits G3D::Surface2D.

Inherited by G3D::CallbackWidget, G3D::Discovery::Server, G3D::FullScreenWidget, G3D::GameController, G3D::GConsole, G3D::GuiWindow, G3D::Manipulator, G3D::WidgetManager, and G3D::XRWidget.

Public Member Functions

virtual Rect2D bounds () const override
 Inherited from Surface2D. More...
 
virtual float depth () const override
 Inherited from Surface2D. More...
 
virtual void fireEvent (const GEvent &event)
 Fire an event on the containing window. More...
 
WidgetManagermanager () const
 
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 > > &surfaceArray, Array< shared_ptr< Surface2D > > &surface2DArray)
 
Appends a posed model for this object to the array, if it has a graphic representation. More...
 
virtual void onSimulation (RealTime rdt, SimTime sdt, SimTime idt)
 
virtual void onUserInput (UserInput *ui)
 
virtual float positionalEventZ (const Point2 &pixel) const
 The camera-space z position that this Widget considers this pixel to be at. More...
 
virtual void render (RenderDevice *rd) const override
 Inherited from Surface2D. More...
 
virtual void setDepth (float d)
 Called by the WidgetManager. More...
 
virtual void setManager (WidgetManager *m)
 Called by the WidgetManager when this module is added to it. More...
 
virtual OSWindowwindow () const
 Returns the operating system window that is currently rendering this Widget. More...
 

Static Public Member Functions

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

 Widget ()
 

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

float m_depth
 
WidgetManagerm_manager
 The manager, set by setManager(). More...
 

Detailed Description


Interface for 2D or 3D objects that experience standard virtual world events and are rendered.

Widget is an interface for GUI-like objects. You could think of it as a bare-bones scene graph.

Widgets are objects like the G3D::FirstPersonController, G3D::GConsole, and debug text overlay that need to receive almost the same set of events (onXXX methods) as G3D::GApp and that you would like to be called from the corresponding methods of a G3D::GApp. They are a way to break large pieces of functionality for UI and debugging off so that they can be mixed and matched.

Widget inherits G3D::Surface2D because it is often convenient to implement a 2D widget whose onPose method adds itself to the rendering array rather than using a proxy object.

See also
Entity, GuiControl

Constructor & Destructor Documentation

◆ Widget()

G3D::Widget::Widget ( )
inlineprotected

Member Function Documentation

◆ bounds()

virtual Rect2D G3D::Widget::bounds ( ) const
inlineoverridevirtual

Inherited from Surface2D.

Implements G3D::Surface2D.

Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ depth()

virtual float G3D::Widget::depth ( ) const
inlineoverridevirtual

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.

◆ fireEvent()

virtual void G3D::Widget::fireEvent ( const GEvent event)
virtual

Fire an event on the containing window.

Reimplemented in G3D::WidgetManager.

◆ manager()

WidgetManager* G3D::Widget::manager ( ) const
inline

◆ onAfterEvents()

virtual void G3D::Widget::onAfterEvents ( )
inlinevirtual

Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget.

Reimplemented in G3D::WidgetManager, and G3D::GameController.

◆ onAI()

virtual void G3D::Widget::onAI ( )
inlinevirtual

◆ onBeforeGraphics()

virtual void G3D::Widget::onBeforeGraphics ( )
inlinevirtual

Invoked by WidgetManager immediately before GApp::onGraphics runs.

Reimplemented in G3D::WidgetManager, G3D::CallbackWidget, and G3D::XRWidget.

◆ onEvent()

virtual bool G3D::Widget::onEvent ( const GEvent event)
inlinevirtual

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 in G3D::GuiWindow, G3D::WidgetManager, G3D::ThirdPersonManipulator, G3D::GConsole, G3D::Discovery::Client, G3D::SceneEditorWindow, G3D::FirstPersonManipulator, G3D::VideoRecordDialog, G3D::UprightSplineManipulator, G3D::CameraControlWindow, G3D::GuiMenu, G3D::ControlPointEditor, G3D::DeveloperWindow, and G3D::ArticulatedModelSpecificationEditorDialog.

◆ onNetwork()

virtual void G3D::Widget::onNetwork ( )
inlinevirtual

◆ onPose()

virtual void G3D::Widget::onPose ( Array< shared_ptr< Surface > > &  surfaceArray,
Array< shared_ptr< Surface2D > > &  surface2DArray 
)
inlinevirtual


Appends a posed model for this object to the array, if it has a graphic representation.

The posed model appended is allowed to reference the agent and is allowed to mutate if the agent is mutated.

Reimplemented in G3D::GuiWindow, G3D::WidgetManager, G3D::Discovery::Client, G3D::SceneEditorWindow, G3D::CallbackWidget, G3D::FullScreenWidget, G3D::UprightSplineManipulator, and G3D::ControlPointEditor.

◆ onSimulation()

virtual void G3D::Widget::onSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
inlinevirtual

◆ onUserInput()

virtual void G3D::Widget::onUserInput ( UserInput ui)
inlinevirtual

◆ positionalEventZ()

virtual float G3D::Widget::positionalEventZ ( const Point2 pixel) const
inlinevirtual

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.

◆ render()

virtual void G3D::Widget::render ( RenderDevice rd) const
inlineoverridevirtual

Inherited from Surface2D.

Implements G3D::Surface2D.

Reimplemented in G3D::GConsole, G3D::GuiWindow, G3D::GuiMenu, and G3D::DebugTextWidget.

◆ setDepth()

virtual void G3D::Widget::setDepth ( float  d)
inlinevirtual

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.

◆ setManager()

virtual void G3D::Widget::setManager ( WidgetManager m)
inlinevirtual

◆ sort()

static void G3D::Surface2D::sort ( Array< shared_ptr< Surface2D >> &  array)
staticinherited

Sorts from farthest to nearest.

◆ sortAndRender()

static void G3D::Surface2D::sortAndRender ( RenderDevice rd,
Array< shared_ptr< Surface2D >> &  array 
)
staticinherited

Calls sort, RenderDevice::push2D, and then render on all elements.

◆ window()

virtual OSWindow* G3D::Widget::window ( ) const
virtual

Returns the operating system window that is currently rendering this Widget.

Reimplemented in G3D::WidgetManager.

Referenced by G3D::FullScreenWidget::bounds().

Member Data Documentation

◆ m_depth

float G3D::Widget::m_depth
protected

Referenced by depth(), and setDepth().

◆ m_manager

WidgetManager* G3D::Widget::m_manager
protected

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 manager(), G3D::GuiWindow::manager(), setManager(), and G3D::GuiWindow::setVisible().


documentation generated on Wed Nov 24 2021 08:02:02 using doxygen 1.8.15