GUIWidget Class Reference

Description

A top level container for all types of GUI elements.

Every GUI element, layout or area must be assigned to a widget in order to be rendered.

Widgets are the only GUI objects that may be arbitrarily transformed, allowing you to create 3D interfaces.

Methods

void setSkin (const HGUISkin &skin)
 Sets the skin used for all GUI elements in the widget. More...
 
const GUISkingetSkin () const
 Returns the currently active GUI skin. More...
 
const HGUISkingetSkinResource () const
 Returns the currently active GUI skin resource. More...
 
GUIPanelgetPanel () const
 Returns the root GUI panel for the widget. More...
 
UINT8 getDepth () const
 Returns the depth to render the widget at. More...
 
void setDepth (UINT8 depth)
 Changes the depth to render the widget at. More...
 
bool inBounds (const Vector2I &position) const
 Checks are the specified coordinates within widget bounds. More...
 
const Rect2IgetBounds () const
 Returns bounds of the widget, relative to the parent window. More...
 
bool isDirty (bool cleanIfDirty)
 Return true if widget or any of its elements are dirty. More...
 
ViewportgetTarget () const
 Returns the viewport that this widget will be rendered on. More...
 
SPtr< CameragetCamera () const
 Returns the camera this widget is being rendered to. More...
 
void setCamera (const SPtr< Camera > &camera)
 Changes to which camera does the widget output its contents. More...
 
const Vector< GUIElement * > & getElements () const
 Returns a list of all elements parented to this widget. More...
 
const Matrix4 getWorldTfrm () const
 Returns the world transform that all GUI elements beloning to this widget will be transformed by. More...
 
bool getIsActive () const
 Checks whether the widget should be rendered or not. More...
 
void setIsActive (bool active)
 Sets whether the widget should be rendered or not. More...
 
Internal
void _registerElement (GUIElementBase *elem)
 Registers a new element as a child of the widget. More...
 
void _unregisterElement (GUIElementBase *elem)
 Unregisters an element from the widget. More...
 
void _markMeshDirty (GUIElementBase *elem)
 Marks the widget mesh dirty requiring a mesh rebuild. More...
 
void _markContentDirty (GUIElementBase *elem)
 Marks the elements content as dirty, meaning its internal mesh will need to be rebuilt (this implies the entire widget mesh will be rebuilt as well).
 
void _updateLayout ()
 Updates the layout of all child elements, repositioning and resizing them as needed. More...
 
void _updateLayout (GUIElementBase *elem)
 Updates the layout of the provided element, and queues content updates. More...
 
void _updateTransform (const HSceneObject &parent)
 Updates internal transform values from the specified scene object, in case that scene object's transform changed since the last call. More...
 
void _updateRT ()
 Checks if the render target of the destination camera changed, and updates the widget with new information if it has. More...
 
void _destroy ()
 Destroys the GUI widget and all child GUI elements. More...
 

Static methods

static SPtr< GUIWidgetcreate (const SPtr< Camera > &camera)
 Creates a new GUI widget that will be rendered on the provided camera. More...
 
static SPtr< GUIWidgetcreate (const HCamera &camera)
 Creates a new GUI widget that will be rendered on the provided camera. More...
 

Fields

Event< void()> onOwnerTargetResized
 Triggered when the widget's viewport size changes. More...
 
Event< void()> onOwnerWindowFocusChanged
 Triggered when the parent window gained or lost focus. More...
 

Method documentation

void _destroy ( )

Destroys the GUI widget and all child GUI elements.

This is called automatically when GUIWidget is deleted.

void _markMeshDirty ( GUIElementBase elem)

Marks the widget mesh dirty requiring a mesh rebuild.

Provided element is the one that requested the mesh update.

void _registerElement ( GUIElementBase elem)

Registers a new element as a child of the widget.

void _unregisterElement ( GUIElementBase elem)

Unregisters an element from the widget.

Usually called when the element is destroyed, or reparented to another widget.

void _updateLayout ( )

Updates the layout of all child elements, repositioning and resizing them as needed.

void _updateLayout ( GUIElementBase elem)

Updates the layout of the provided element, and queues content updates.

void _updateRT ( )

Checks if the render target of the destination camera changed, and updates the widget with new information if it has.

Should be called every frame.

void _updateTransform ( const HSceneObject parent)

Updates internal transform values from the specified scene object, in case that scene object's transform changed since the last call.

Note
Assumes the same scene object will be provided every time.
void construct ( const SPtr< Camera > &  camera)
protected

Common code for constructors.

static SPtr<GUIWidget> create ( const SPtr< Camera > &  camera)
static

Creates a new GUI widget that will be rendered on the provided camera.

static SPtr<GUIWidget> create ( const HCamera camera)
static

Creates a new GUI widget that will be rendered on the provided camera.

const Rect2I& getBounds ( ) const

Returns bounds of the widget, relative to the parent window.

SPtr<Camera> getCamera ( ) const

Returns the camera this widget is being rendered to.

UINT8 getDepth ( ) const

Returns the depth to render the widget at.

If two widgets overlap the widget with the lower depth will be rendered in front.

const Vector<GUIElement*>& getElements ( ) const

Returns a list of all elements parented to this widget.

bool getIsActive ( ) const

Checks whether the widget should be rendered or not.

GUIPanel* getPanel ( ) const

Returns the root GUI panel for the widget.

const GUISkin& getSkin ( ) const

Returns the currently active GUI skin.

const HGUISkin& getSkinResource ( ) const

Returns the currently active GUI skin resource.

Viewport* getTarget ( ) const

Returns the viewport that this widget will be rendered on.

const Matrix4 getWorldTfrm ( ) const

Returns the world transform that all GUI elements beloning to this widget will be transformed by.

bool inBounds ( const Vector2I position) const

Checks are the specified coordinates within widget bounds.

Coordinates should be relative to the parent window.

bool isDirty ( bool  cleanIfDirty)

Return true if widget or any of its elements are dirty.

Parameters
[in]cleanIfDirtyIf true, all dirty elements will be updated and widget will be marked as clean.
Returns
True if dirty, false if not. If "cleanIfDirty" is true, the returned state is the one before cleaning.
virtual void ownerTargetResized ( )
protectedvirtual

Called when the viewport size changes and widget elements need to be updated.

virtual void ownerWindowFocusChanged ( )
protectedvirtual

Called when the parent window gained or lost focus.

void setCamera ( const SPtr< Camera > &  camera)

Changes to which camera does the widget output its contents.

void setDepth ( UINT8  depth)

Changes the depth to render the widget at.

If two widgets overlap the widget with the lower depth will be rendered in front.

void setIsActive ( bool  active)

Sets whether the widget should be rendered or not.

void setSkin ( const HGUISkin skin)

Sets the skin used for all GUI elements in the widget.

This will update the look of all current elements.

Member Data Documentation

Event<void()> onOwnerTargetResized

Triggered when the widget's viewport size changes.

Event<void()> onOwnerWindowFocusChanged

Triggered when the parent window gained or lost focus.

Constructor & Destructor Documentation

GUIWidget ( const SPtr< Camera > &  camera)
protected

Constructs a new GUI widget that will be rendered on the provided camera.

GUIWidget ( const HCamera camera)
protected

Constructs a new GUI widget that will be rendered on the provided camera.