class
GUIElement
Base class for all GUI elements.
Provides general functionality such as element size/position, as well as handling child/parent relationships.
Public
Constructors
GUIElement
GUIElement
Methods
~GUIElement
SetPosition
Sets element position relative to parent GUI panel.
Values should be provided in logical pixel units.
Be aware that this value will be ignored if GUI element is part of a layout since then the layout controls its placement.
SetPosition
Sets element position relative to parent GUI panel.
Values should be provided in logical pixel units.
Be aware that this value will be ignored if GUI element is part of a layout since then the layout controls its placement.
SetWidth
Sets fixed element width.
Value should be in logical pixel units.
SetFlexibleWidth
Sets flexible element width.
Element will be resized according to its contents and parent layout but will always stay within the provided range. If maximum width is zero, the element is allowed to expand as much as it needs. Values should be in logical pixel units.
SetHeight
Sets fixed element height.
Value should be in logical pixel units.
SetFlexibleHeight
Sets flexible element height.
Element will be resized according to its contents and parent layout but will always stay within the provided range. If maximum height is zero, the element is allowed to expand as much as it needs. Values provided should be in logical pixel units.
SetSize
Sets fixed width and height of a GUI element.
Values provided should be in logical pixel units.
ResetSizeConstraints
Resets element size constraints to their initial values dictated by the element's style.
SetScale
Sets the scale of the GUI element.
Note that scale will not affect the size of this GUI element, but will rather scale all of its contents.
SetHidden
Hides or shows this element and recursively applies the same state to all the child elements.
This will not remove the element from the layout, the room for it will still be reserved but it just won't be visible.
SetActive
Activates or deactives this element and recursively applies the same state to all the child elements.
This has the same effect as setVisible(), but when disabled it will also remove the element from the layout, essentially having the same effect is if you destroyed the element.
SetDisabled
Disables or enables the element.
Disabled elements cannot be interacted with and have a faded out appearance.
GetLayoutCalculatedSize
Returns width/height of the GUI element.
This will be the fixed width/height if set by the user, or automatically determined by the layout update pass if not fixed. Size is provided in logical pixel units.
Always returns value calculated by last layout update. This means out of date value may be returned if the layout has been dirtied since then.
CalculateSizeInLayout
Returns width/height of the GUI element.
This will be the fixed width/height if set by the user, or automatically determined by the layout update pass if not fixed. Size is provided in logical pixel units.
CalculatePositionRelativeTo
Calculates position of the GUI element, relative to the provided parent element (or parent panel if null).
The value is provided in logical pixel units.
- relativeTo
- Parent element of the provided element relative to which to return the position. If null the position relative to parent panel is returned. Behavior is undefined if provided parent is not a parent of the element.
CalculateAbsoluteBoundsRelativeTo
Calculates bounds of the GUI element, relative to the provided parent element (or parent panel if null), with scaling applied.
The values are provided in physical pixel units.
- relativeTo
- Parent element of the provided element relative to which to return the bounds. If null the bounds relative to parent panel are returned. Behavior is undefined if provided parent is not a parent of the element.
CalculateAbsoluteBounds
Calculates bounds of the GUI element, relative to the parent GUI widget, with scaling applied.
The values are provided in physical pixel units.
CalculateScreenBounds
Calculates bounds of the GUI element in screen space.
GetAbsoluteBounds
Returns bounds of the GUI element, relative to the parent GUI widget.
Absolute values represent the final position and size of the GUI element, affected by DPI scale, parent scale and self scale. The values are provided in physical pixel units.
Always returns value calculated by last layout update. This means out of date value may be returned if the layout has been dirtied since then.
WidgetToElementSpace
Converts a point relative to the parent widget, into a point relative to this element.
ElementToWidgetSpace
Converts a point relative to this element, into a point relative to the parent widget.
WidgetToElementSpace
Converts an area relative to the parent widget, into an area relative to this element.
ElementToWidgetSpace
Converts an area relative to this element, into an area relative to the parent widget.
GetAbsolutePosition
Returns the position of the GUI element, relative to the parent widget.
Absolute values represent the final position of the GUI element, affected by DPI scale and parent scale. The values are provided in physical pixel units.
Always returns value calculated by last layout update. This means out of date value may be returned if the layout has been dirtied since then.
GetAbsoluteScale
Combined local and parent scale.
Destroy
Destroy the element.
Removes it from parent and widget, and queues it for deletion. Element memory will be released delayed, next frame.
IsPendingDestroy
Checks if element is queued for deletion.
staticGetRttiStatic
Internal
Methods
UpdateOptimalLayoutSizes
Calculates optimal sizes of all child elements, as determined by their style and layout options.
This is performed recursively over all child elements, starting with the bottom-most child element. This should be called before UpdateLayoutRecursive().
UpdateLayout
Calculates element positions and sizes based on their options and layout.
This is an expensive operation that requires multiple passes over all child GUI elements. The operation is performed in three passes:
- Optimal sizes for all elements are determined. This is done for the bottom-most child first, and then for parent elements.
- Layout calculations are performed for all elements, starting with the top-most element. This determines relative positions and final element size.
- Absolute coordinate calculations are performed for all elements, starting with the top-most element. This adds parent coordinates to the element's local coordinates, and calculates the visible area of the element (area of the element as clipped by the parent, e.g. for elements in a scroll area that might not be fully visible).
UpdateLayoutForChildren
Calculates sizes and relative positions for all child elements.
Should be preceded with a call to UpdateOptimalLayoutSizes().
UpdateLayoutIfDirty
Triggers a layout update immediately if the layout has been dirtied.
UpdateAbsoluteCoordinates
Updates the absolute coordinates of the GUI element using the currently assigned relative coordinates and the provided .
Also calculates the visible area clip rectangle and marks culled elements if they have no visible area. This should be called after updating the layout (as layout update calculates the needed relative coordinates). This may also be called independently of layout update, which is useful for scroll areas that then do not require a full layout pass to scroll their children.
- parentOrigin
- Absolute origin to add to the relative coordinates, in order to determine the absolute element coordinates.
- parentScale
- Scale of the parent GUI element.
- parentVisibleArea
- Absolute visible (clipped) area though which this element may be seen. This will be used for culling and clipping.
UpdateAbsoluteCoordinatesForChildren
Calls UpdateAbsoluteCoordinates() on all child elements.
SetLayoutData
Updates layout data that determines GUI elements relative position, size and depth in the GUI widget.
GetLayoutData
Retrieves layout data that determines GUI elements relative position, size and depth in the GUI widget.
GetChildCount
Returns number of child elements.
GetVisibleChildren
Returns all children that can be seen through the parent's visible area (i.e. all elements that are not culled or explicitly made invisible).
Note this may return all child elements on GUI elements that do not support culling. Only well defined after layout update.
CalculateUnconstrainedOptimalSize
Calculates the optimal size for the GUI element, ignoring size constraints.
CalculateConstrainedOptimalSize
Returns the result of CalculateUnconstrainedOptimalSize() with size constrains applied.
GetSizeConstraints
Returns size constraints that determine how is the GUI element allowed to be resized by the layout.
CalculateConstrainedSizeRange
Calculates element size based on its optimal size constrained by its size constraint options.
GetConstrainedSizeRange
Returns element size constrained by its size constraints.
This is different from CalculateConstrainedSize() because this method may return cached size.
GetMargins
Returns GUI element margins.
Margins are modified by changing element style and determines minimum distance between GUI element border and surrounding GUI elements.
GetPadding
Returns GUI element padding.
Padding is modified by changing element style and determines minimum distance between GUI element border and contents.
IsHidden
Checks if element is explicitly hidden.
IsActive
Checks if element is active or inactive.
Inactive elements are not visible, don't take up space in their parent layouts, and can't be interacted with.
IsDisabled
Checks if element is disabled.
Disabled elements cannot be interacted with and have a faded out appearance.
IsCulled
Returns true if the element is not visible due to being culled by its parent bounds.
IsHiddenOrCulled
Checks if element is invisible.
Either due to explicitly being hidden or due to being culled by the parent.
SetHiddenRecursive
Internal version of SetHidden() that doesn't modify local visibility, instead it is only meant to be called on child elements of the element whose visibility was modified.
SetActiveRecursive
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. @copydoc SetActive
SetDisabledRecursive
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. @copydoc SetDisabled
SetCulled
Marks the object and all children as culled.
ChangeParentWidget
Changes the active GUI element widget.
This allows you to move an element to a different viewport, or change element style by using a widget with a different skin. You are allowed to pass null here, but elements with no parent will be unmanaged. You will be responsible for deleting them manually, and they will not render anywhere.
RegisterChildElement
Registers a new child element.
UnregisterChildElement
Unregisters an existing child element.
MarkLayoutAsDirty
Marks the element's dimensions as dirty, triggering a layout rebuild.
MarkAbsoluteCoordinatesAsDirty
Marks the element's absolute coordinates as dirty.
This is usually true when the parent moves but relative positions/sizes of children remain unchanged. Or when area through which children are seen changes. Both cases are common for scroll areas.
MarkContentAsDirty
Marks the element's contents as dirty, which causes the sprite meshes to be recreated from scratch.
MarkMeshAsDirty
Mark only the elements that operate directly on the sprite mesh without requiring the mesh to be recreated as dirty.
This includes position, depth and clip rectangle. This will cause the parent widget mesh to be rebuilt from its child element's meshes.
IsLayoutDirty
Returns true if the element requires layout update (e.g. if its optimal size has changed).
AreAbsoluteCoordinatesDirty
Returns true if absolute coordinates of child elements need to be updated (e.g. element is a scroll area and it has been scrolled).
MarkAsClean
Marks the element contents to be up to date (meaning it's processed by the GUI system).
SetQuadTreeId
ID of the element in a quad-tree managed by its direct parent.
Quad-tree can be used for speeding up lookup for elements containing many children.
GetQuadTreeId
GetAbsoluteClippedArea
Returns the position and size of the GUI element, relative to the parent widget.
The returned area is clipped by the visible area as specified by the parent GUI element (e.g. if the parent is a scroll area or similar, only some or none of the GUI element may be visible, if it's scrolled out of view). Provided value is in physical pixel units.
Always returns value calculated by last layout update. This means out of date value may be returned if the layout has been dirtied since then.
GetIntermediateAbsolutePosition
Similar to GetAbsolutePosition(), but contains floating point data that is not rounded, useful primarily for calculating child absolute coordinates without losing precision.
GetIntermediateAbsoluteClippedArea
Similar to GetAbsoluteClippedArea(), but contains floating point data that is not rounded, useful primarily for calculating child absolute coordinates without losing precision.
GetClippedAreaTranslatedRelativeToParent
Same as GetAbsoluteClippedArea(), except the area position is made relative to this GUI element.
Protected
Methods
UpdateAbsoluteCoordinatesWithExplicitContentSize
Same as UpdateAbsoluteCoordinates, but allows the user to provide explicit size of this GUI element's contents.
This is useful for e.g. scroll areas where the content size may be larger than the layout calculated area used by default.
UpdatePanelAndLayoutUpdateParents
Finds anchor and update parents and recursively assigns them to all children.
RefreshLayoutUpdateParentsForChildren
Refreshes update parents of all child elements.
FindLayoutUpdateParent
Finds the first parent element whose size doesn't depend on child sizes.
SetPanelParent
Helper method for recursion in UpdatePanelAndLayoutUpdateParents().
Sets the provided anchor parent for all children recursively. Recursion stops when a child anchor is detected.
SetLayoutUpdateParent
Helper method for recursion in UpdatePanelAndLayoutUpdateParents().
Sets the provided update parent for all children recursively. Recursion stops when a child update parent is detected.
DestroyChildElements
Unregisters and destroys all child elements.
Fields
mParentWidget
mLayoutUpdateParent
Parent on which we need to call layout update if this element's size changes.
This will be the first parent GUI element that doesn't have fixed bounds.
mChildren
mFlags
mIsPendingDestroy
mQuadTreeId
If the parent GUI element maintains a quad tree of its children, this will be ID of the element within the quad-tree.
mSizeConstraints
Constraints on the element size as set by the style sheet, or set explicitly at runtime.
mScale
Scale to apply to the GUI element and all children.
mLayoutData
Relative position (to parent), size, depth and other information, calculated during a layout update.
mAbsolutePosition
Absolute position of the GUI element (relative to parent GUI widget).
Only valid after layout update
& absolute coordinate update.
mAbsoluteSize
Final size to use for the element.
Same as GUILayoutData::Size, scaled by GUI element scale.
mAbsoluteScale
Combined local and parent scale.
mAbsoluteClippedArea
Absolute area of the GUI element as clipped by the parent visible bounds (e.g. if a parent is a scroll area).
Only valid after layout update
& absolute coordinate update.