This documents an old version of bs::framework. Click here to see the latest release.
GUILayout Class Reference

Description

Base class for layout GUI element.

Layout element positions and sizes any child elements according to element styles and layout options.

Inherits GUIElementBase.

Inherited by GUILayoutX, GUILayoutY, and GUIPanel.

Methods

 GUILayout (const GUIDimensions &dimensions)
 
template<class Type , class... Args>
TypeaddNewElement (Args &&...args)
 Creates a new element and adds it to the layout after all existing elements. More...
 
template<class Type , class... Args>
TypeinsertNewElement (UINT32 idx, Args &&...args)
 Creates a new element and inserts it before the element at the specified index. More...
 
void addElement (GUIElementBase *element)
 Adds a new element to the layout after all existing elements. More...
 
void removeElement (GUIElementBase *element)
 Removes the specified element from the layout. More...
 
void removeElementAt (UINT32 idx)
 Removes a child element at the specified index. More...
 
void insertElement (UINT32 idx, GUIElementBase *element)
 Inserts a GUI element before the element at the specified index. More...
 
void clear ()
 Removes all child elements and destroys them. More...
 
UINT32 getNumChildren () const
 Returns number of child elements in the layout. More...
 
Internal
LayoutSizeRange _getLayoutSizeRange () const override
 Returns element size range constrained by its layout options. More...
 
LayoutSizeRange _getCachedSizeRange () const
 Returns a size range that was cached during the last GUIElementBase::_updateOptimalLayoutSizes call. More...
 
const Vector< LayoutSizeRange > & _getCachedChildSizeRanges () const
 Returns a size ranges for all children that was cached during the last GUIElementBase::_updateOptimalLayoutSizes call.
 
Vector2I _getOptimalSize () const override
 Returns previously calculated optimal size for this element. More...
 
const RectOffset_getPadding () const override
 Returns element padding that determines how far apart to space out this element from other elements in a layout. More...
 
Type _getType () const override
 Returns specific sub-type of this object. More...
 
- Methods inherited from GUIElementBase
 GUIElementBase (const GUIDimensions &dimensions)
 
void setPosition (INT32 x, INT32 y)
 Sets element position relative to parent GUI panel. More...
 
void setWidth (UINT32 width)
 Sets element width in pixels. More...
 
void setFlexibleWidth (UINT32 minWidth=0, UINT32 maxWidth=0)
 Sets element width in pixels. More...
 
void setHeight (UINT32 height)
 Sets element height in pixels. More...
 
void setSize (UINT32 width, UINT32 height)
 Sets width and height of a GUI element in pixels. More...
 
void setFlexibleHeight (UINT32 minHeight=0, UINT32 maxHeight=0)
 Sets element height in pixels. More...
 
virtual void resetDimensions ()
 Resets element dimensions to their initial values dictated by the element's style. More...
 
void setVisible (bool visible)
 Hides or shows this element and recursively applies the same state to all the child elements. More...
 
void setActive (bool active)
 Activates or deactives this element and recursively applies the same state to all the child elements. More...
 
void setDisabled (bool disabled)
 Disables or enables the element. More...
 
Rect2I getBounds (GUIPanel *relativeTo=nullptr)
 Returns non-clipped bounds of the GUI element. More...
 
void setBounds (const Rect2I &bounds)
 Sets the bounds of the GUI element. More...
 
Rect2I getGlobalBounds ()
 Returns non-clipped bounds of the GUI element. More...
 
Rect2I getScreenBounds () const
 Returns non-clipped bounds of the GUI element in screenspace. More...
 
virtual Rect2I getVisibleBounds ()
 Returns non-clipped visible bounds of the GUI element (bounds exclude the margins). More...
 
virtual void _updateLayout (const GUILayoutData &data)
 Updates child elements positions, sizes, clip rectangles and depths so they fit into the provided bounds, while respecting their layout options. More...
 
virtual void _updateOptimalLayoutSizes ()
 Calculates optimal sizes of all child elements, as determined by their style and layout options. More...
 
virtual void _updateLayoutInternal (const GUILayoutData &data)
 Updates child elements positions, sizes, clip rectangles and depths so they fit into the provided bounds, while respecting their layout options. More...
 
virtual void _getElementAreas (const Rect2I &layoutArea, Rect2I *elementAreas, UINT32 numElements, const Vector< LayoutSizeRange > &sizeRanges, const LayoutSizeRange &mySizeRange) const
 Calculates positions & sizes of all elements in the layout. More...
 
virtual void _setLayoutData (const GUILayoutData &data)
 Updates layout data that determines GUI elements final position & depth in the GUI widget. More...
 
const GUILayoutData_getLayoutData () const
 Retrieves layout data that determines GUI elements final position & depth in the GUI widget. More...
 
void _setParent (GUIElementBase *parent)
 Sets a new parent for this element. More...
 
UINT32 _getNumChildren () const
 Returns number of child elements. More...
 
GUIElementBase_getChild (UINT32 idx) const
 Return the child element at the specified index. More...
 
const GUIDimensions_getDimensions () const
 Returns layout options that determine how is the element positioned and sized. More...
 
virtual LayoutSizeRange _calculateLayoutSizeRange () const
 Calculates element size range constrained by its layout options. More...
 
GUIElementBase_getParent () const
 Returns parent GUI base element. More...
 
GUIElementBase_getUpdateParent () const
 Returns the parent element whose layout needs to be updated when this elements contents change. More...
 
GUIWidget_getParentWidget () const
 Returns parent GUI widget, can be null. More...
 
bool _isVisible () const
 Checks if element is visible or hidden. More...
 
bool _isActive () const
 Checks if element is active or inactive. More...
 
bool _isDisabled () const
 Checks if element is disabled. More...
 
void _setVisible (bool visible)
 Internal version of setVisible() that doesn't modify local visibility, instead it is only meant to be called on child elements of the element whose visibility was modified.
 
void _setActive (bool active)
 Internal version of setActive() that doesn't modify local state, instead it is only meant to be called on child elements of the element whose state was modified. More...
 
void _setDisabled (bool disabled)
 Internal version of setDisabled() that doesn't modify local state, instead it is only meant to be called on child elements of the element whose state was modified. More...
 
virtual void _changeParentWidget (GUIWidget *widget)
 Changes the active GUI element widget. More...
 
void _registerChildElement (GUIElementBase *element)
 Registers a new child element. More...
 
void _unregisterChildElement (GUIElementBase *element)
 Unregisters an existing child element. More...
 
virtual bool _isDestroyed () const
 Checks if element has been destroyed and is queued for deletion. More...
 
void _markLayoutAsDirty ()
 Marks the element's dimensions as dirty, triggering a layout rebuild. More...
 
void _markContentAsDirty ()
 Marks the element's contents as dirty, which causes the sprite meshes to be recreated from scratch. More...
 
void _markMeshAsDirty ()
 Mark only the elements that operate directly on the sprite mesh without requiring the mesh to be recreated as dirty. More...
 
bool _isDirty () const
 Returns true if elements contents have changed since last update. More...
 
void _markAsClean ()
 Marks the element contents to be up to date (meaning it's processed by the GUI system). More...
 

Static methods

static void destroy (GUILayout *layout)
 Destroy the layout. More...
 

Additional Inherited Members

- Public Types inherited from GUIElementBase
enum  Type {
  Layout, Element, FixedSpace, FlexibleSpace,
  Panel
}
 Valid types of GUI base elements. More...
 
- Protected Types inherited from GUIElementBase
enum  GUIElementFlags {
  GUIElem_Dirty = 0x01, GUIElem_Hidden = 0x02, GUIElem_Inactive = 0x04, GUIElem_HiddenSelf = 0x08,
  GUIElem_InactiveSelf = 0x10, GUIElem_Disabled = 0x20, GUIElem_DisabledSelf = 0x40
}
 Flags that signal the state of the GUI element. More...
 

Method documentation

◆ _getCachedSizeRange()

LayoutSizeRange _getCachedSizeRange ( ) const

Returns a size range that was cached during the last GUIElementBase::_updateOptimalLayoutSizes call.

◆ _getLayoutSizeRange()

LayoutSizeRange _getLayoutSizeRange ( ) const
overridevirtual

Returns element size range constrained by its layout options.

This is different from _calculateLayoutSizeRange() because this method may return cached size range.

Reimplemented from GUIElementBase.

◆ _getOptimalSize()

Vector2I _getOptimalSize ( ) const
overridevirtual

Returns previously calculated optimal size for this element.

Implements GUIElementBase.

◆ _getPadding()

const RectOffset& _getPadding ( ) const
overridevirtual

Returns element padding that determines how far apart to space out this element from other elements in a layout.

Implements GUIElementBase.

◆ _getType()

Type _getType ( ) const
overridevirtual

Returns specific sub-type of this object.

Implements GUIElementBase.

Reimplemented in GUIPanel.

◆ addElement()

void addElement ( GUIElementBase element)

Adds a new element to the layout after all existing elements.

◆ addNewElement()

Type* addNewElement ( Args &&...  args)

Creates a new element and adds it to the layout after all existing elements.

◆ clear()

void clear ( )

Removes all child elements and destroys them.

◆ destroy()

static void destroy ( GUILayout layout)
static

Destroy the layout.

Removes it from parent and widget, and deletes it.

◆ getNumChildren()

UINT32 getNumChildren ( ) const

Returns number of child elements in the layout.

◆ insertElement()

void insertElement ( UINT32  idx,
GUIElementBase element 
)

Inserts a GUI element before the element at the specified index.

◆ insertNewElement()

Type* insertNewElement ( UINT32  idx,
Args &&...  args 
)

Creates a new element and inserts it before the element at the specified index.

◆ removeElement()

void removeElement ( GUIElementBase element)

Removes the specified element from the layout.

◆ removeElementAt()

void removeElementAt ( UINT32  idx)

Removes a child element at the specified index.