class GUIWidget

Inherits: Component

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.

Public

Constructors

GUIWidget

GUIWidget()

Methods

~GUIWidget

virtual ~GUIWidget() noexcept = default

GetStyleSheetCascade

const GUIStyleSheetCascade &GetStyleSheetCascade() const

Determines the style sheets that all GUI elements part of this widget will lookup styles in.

GetStyleSheetCascadeAsShared

const SPtr<const GUIStyleSheetCascade> &GetStyleSheetCascadeAsShared() const

SetStyleSheetCascade

void SetStyleSheetCascade(const SPtr<const GUIStyleSheetCascade> &styleSheetCascade)

GetPanel

GUIPanel *GetPanel() const

Returns the root GUI panel for the widget.

SetDepth

void SetDepth(u8 depth)

Determines the depth to render the widget at.

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

GetDepth

u8 GetDepth() const

InBounds

bool InBounds(const GUIPhysicalPoint &position) const

Checks are the specified coordinates within widget bounds.

Coordinates should be relative to the parent window.

GetBounds

const GUIPhysicalArea &GetBounds() const

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

GetDPIScale

float GetDPIScale() const

Returns currently set DPI scale.

Scale of 1.0 corresponds to 96 DPI. physical pixel = logical pixel * DPI scale logical pixel = physical pixel / DPI ccale;

SetDPIScale

void SetDPIScale(float dpiScale)

Changes the DPI scale of all the GUI elements in the widget.

Triggers a full GUI rebuild.

GetTarget

Viewport *GetTarget() const

SetCamera

void SetCamera(const HCamera &camera)

Changes to which camera does the widget output its contents.

GetCamera

HCamera GetCamera() const

Returns the camera this widget is being rendered to.

GetElements

const Vector<GUIRenderable *> &GetElements() const

Returns a list of all elements parented to this widget.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Fields

OnOwnerTargetResized

Event<void ()> OnOwnerTargetResized

Triggered when the widget's viewport size changes.

OnOwnerWindowFocusChanged

Event<void ()> OnOwnerWindowFocusChanged

Triggered when the parent window gained or lost focus.

Internal

Methods

RegisterElement

void RegisterElement(GUIElement *guiElement)

Registers a new element as a child of the widget.

UnregisterElement

void UnregisterElement(GUIElement *guiElementBase)

Unregisters an element from the widget.

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

NotifyElementVisibilityChanged

void NotifyElementVisibilityChanged(GUIElement *guiElement, bool isVisible)

Called when a registered GUI element is hidden, culled or visible.

Only needs to be called if visibility changes after registration.

GetDefaultNavGroupInternal

SPtr<GUINavGroup> GetDefaultNavGroupInternal() const

Returns the default navigation group assigned to all elements of this widget that don't have an explicit nav- group.

See GUIElement::setNavGroup().

MarkMeshDirty

void MarkMeshDirty(GUIElement *elem)

Marks the widget mesh dirty requiring a mesh rebuild.

Provided element is the one that requested the mesh update.

MarkContentDirty

void MarkContentDirty(GUIElement *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).

MarkLayoutDirty

void MarkLayoutDirty(GUIElement *element)

Marks the element layout as dirty.

This means layout for the element and all child elements will be re-calculated.

Note you almost always want to call this method on a parent of the GUI element whose layout needs to update. In particular, you want to call it on the top-most parent that doesn't have a fixed size. This is because size changes in a child element can affect its siblings as well as parents, if those elements are using automatic layouts.

If is null, then entire widget's layout will be marked as dirty.

MarkAbsoluteCoordinatesDirty

void MarkAbsoluteCoordinatesDirty(GUIElement *element)

Marks the element's absolute coordinates as dirty.

This will trigger a recalculation of absolute coordinates for all the children of . You should call this when a GUI element moves, or when the area its children are viewed through changes (e.g. scroll area is scrolled).

UpdateLayout

void UpdateLayout()

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

UpdateLayout

void UpdateLayout(GUIElement *element)

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

UpdateRenderTarget

void UpdateRenderTarget()

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.

RebuildDirtyRenderData

GUIDrawGroupRenderDataUpdate RebuildDirtyRenderData()

Rebuilds any dirty data required for GUI element rendering and returns the data required for updating the GUI renderer.

Protected

Constructors

GUIWidget

GUIWidget(const HSceneObject &parent, const HCamera &camera)

Constructs a new GUI widget attached to the specified parent scene object.

Widget elements will be rendered on the provided camera.

Methods

Update

void Update() override

Called once per frame.

Only called if the component is in Running state.

OnCreated

void OnCreated() override

Called once when the component has been created.

Called regardless of the state the component is in.

OnDestroyed

void OnDestroyed() override

Called once just before the component is destroyed.

Called regardless of the state the component is in.

OnTransformChanged

void OnTransformChanged(TransformChangedFlags flags) override

Called when the component's parent scene object has changed.

Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().

OwnerTargetResized

virtual void OwnerTargetResized()

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

OwnerWindowFocusChanged

virtual void OwnerWindowFocusChanged()

Called when the parent window gained or lost focus.

Private

Methods

UpdateBounds

void UpdateBounds() const

Calculates widget bounds using the bounds of all child elements.

UpdateRootPanel

void UpdateRootPanel()

Updates the size of the primary GUI panel based on the viewport.

Fields

mCamera

HCamera mCamera

mElements

Vector<GUIRenderable *> mElements

mBatches

mPanel

GUIPanel * mPanel

mDepth

u8 mDepth

mDefaultNavGroup

SPtr<GUINavGroup> mDefaultNavGroup

mDPIScale

float mDPIScale

mDirtyContents

Set<GUIRenderable *> mDirtyContents

mDirtyContentsTemp

Set<GUIRenderable *> mDirtyContentsTemp

mDirtyLayoutOrAbsoluteCoordinates

UnorderedSet<GUIElement *> mDirtyLayoutOrAbsoluteCoordinates

mCachedRTId

u64 mCachedRTId

mWidgetIsDirty

bool mWidgetIsDirty

mBounds

GUIPhysicalArea mBounds

mStyleSheetCascade

SPtr<const GUIStyleSheetCascade> mStyleSheetCascade