class GUIRenderable

Inherits: GUIElement

Represents a GUI element that can be rendered (i.e. has a visual representation).

Renderable element can have a particular style, and provides one or multiple render elements to be drawn.

Public

Constructors

GUIRenderable

GUIRenderable(String styleClass, const GUISizeConstraints &sizeConstraints)

GUIRenderable

GUIRenderable(const char *styleClass, const GUISizeConstraints &sizeConstraints)

Methods

~GUIRenderable

~GUIRenderable() noexcept override = default

GetStyleSheetElement

virtual const char *GetStyleSheetElement() const

Returns the name of the GUI element type to be used for style lookup in the style sheet.

GetStyleSheetClass

virtual const String &GetStyleSheetClass() const

Returns a user-specified class that will be used for style lookup in the style sheet.

GetStyleSheetId

virtual const String &GetStyleSheetId() const

Returns an user-specific ID will be used for style lookup in the style sheet.

SetStyleSheetClass

void SetStyleSheetClass(const String &styleClass)

Sets new style class to be used by the element.

IsUsingStyleSheets

bool IsUsingStyleSheets() const

Returns true if the GUI elements wants to use the new style sheet approach for styling.

SetTint

virtual void SetTint(const Color &color)

Sets the tint of the GUI element.

GetTint

Color GetTint() const

Returns the tint that is applied to the GUI element.

ResetSizeConstraints

void ResetSizeConstraints() override

Resets element size constraints to their initial values dictated by the element's style.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

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

Internal

Methods

GetRenderElements

const TInlineArray<GUIRenderElement, 4> &GetRenderElements() const

Returns information about all renderable elements in this GUI element, including their mesh, material and general information.

FillBuffer

virtual void FillBuffer(u8 *vertices, u32 *indices, u32 vertexOffset, u32 indexOffset, const Vector2I &offset, u32 maxVertexCount, u32 maxIndexCount, u32 renderElementIndex) const

Fill the pre-allocated vertex, uv and index buffers with the mesh data for the specified render element.

vertices
Previously allocated buffer where to store the vertices. Output is expected to match the GUIMeshType as returned by getRenderElements() for the specified element.
indices
Previously allocated buffer where to store the indices.
vertexOffset
At which vertex should the method start filling the buffer.
offset
Offset that should be applied to all output vertex positions.
indexOffset
At which index should the method start filling the buffer.
maxVertexCount
Total number of vertices the buffers were allocated for. Used only for memory safety.
maxIndexCount
Total number of indices the buffers were allocated for. Used only for memory safety.
renderElementIndex
Zero-based index of the render element.

GetRenderElementVertexAndIndexData

virtual void GetRenderElementVertexAndIndexData(u32 renderElementIndex, u32 vertexOffset, u32 indexOffset, DataRange &outPositions, DataRange &outUVs, DataRange &outIndices) const

Retrieves vertex and index data from GUI render element and outputs them to the provided buffers.

GUI render elements must have been previously populated by calling UpdateRenderElements().

renderElementIndex
Zero-based index of the render element from which to retrieve the data.
vertexOffset
At which vertex should the method start writing to the output position/uv buffer.
indexOffset
At which index should the method start writing to the output index buffer.
outPositions
Previously allocated buffer where to store the vertex positions. Caller must ensure size and data type match the mesh type and vertex count retrieved from GetRenderElements() for the specified element.
outUVs
Previously allocated buffer where to store the vertex UVs. Caller must ensure size and data type match the mesh type and vertex count retrieved from GetRenderElements() for the specified element. Can be null if not needed.
outIndices
Previously allocated buffer where to store the indices. Caller must ensure size and data type match the mesh type and index count retrieved from GetRenderElements() for the specified element.

UpdateRenderElements

virtual void UpdateRenderElements()

Recreates the internal render elements.

Must be called before GetRenderElementVertexAndIndexData/FillBuffer if element is dirty. Marks the element as non dirty.

SetElementDepth

void SetElementDepth(u8 depth)

Set element part of element depth.

Less significant than both widget and area depth.

GetElementDepth

u8 GetElementDepth() const

Retrieve element part of element depth.

Less significant than both widget and area depth.

GetRenderElementDepthRange

virtual u32 GetRenderElementDepthRange() const

Returns the range of depths that the child elements can be rendered it.

RefreshStyle

void RefreshStyle()

Updates element style based on active GUI style sheet.

Call this after active style sheet changes, or element class/id changes.

GetDepth

u32 GetDepth() const

Returns GUI element depth.

This includes widget and area depth, but does not include specific per-render-element depth.

GetMargins

const RectOffset &GetMargins() const override

Returns GUI element margins.

Margins are modified by changing element style and determines minimum distance between GUI element border and surrounding GUI elements.

GetPadding

const RectOffset &GetPadding() const override

Returns GUI element padding.

Padding is modified by changing element style and determines minimum distance between GUI element border and contents.

SetLayoutData

void SetLayoutData(const GUILayoutData &data) override

Updates layout data that determines GUI elements relative position, size and depth in the GUI widget.

ChangeParentWidget

void ChangeParentWidget(GUIWidget *widget) override

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.

Protected

Methods

NotifyStyleChanged

virtual void NotifyStyleChanged()

Method that gets triggered whenever element style changes.

GetContentBounds

virtual GUILogicalArea GetContentBounds() const

Similar to GetAbsoluteContentBounds(), except the bounds are relative to the parent GUI element rather than the parent widget.

GetScaledContentBounds

GUIPhysicalArea GetScaledContentBounds() const

Similar to GetContentBounds(), but scaling has been applied to the position/size.

GetAbsoluteContentBounds

GUIPhysicalArea GetAbsoluteContentBounds() const

Returns bounds of the content contained within the GUI element.

This will be the bounds returned by GetAbsoluteBounds(), minus the border and the padding. Relative to parent widget.

GetContentOffset

GUILogicalPoint GetContentOffset() const

Calculates the offset from the origin of the GUI element to the area containing content (combined border + padding offsets).

GetScaledContentOffset

GUIPhysicalPoint GetScaledContentOffset() const

Similar to GetContentOffset(), but scaling has been applied.

RegisterPseudoElement

u32 RegisterPseudoElement(const char *name)

Registers a new pseudo-element for the GUI element.

Pseudo-element can be used for providing additional style sheet rules for a GUI element.

name
Name of the pseudo-element. This will correspond to the pseudo-element in the style sheet (e.g. toggle::checkmark will provide a checkmark pseudo-element for the toggle GUI element).

Returns: Index you can use to retrieve pseudo-element style information from GetPseudoElementStyleSheetRuleInformation().

GetPseudoElementStyleSheetRuleInformation

const GUIStyleSheetRuleInformation &GetPseudoElementStyleSheetRuleInformation(u32 pseudoElementIndex) const

Returns style information for a pseudo-element at the specified index.

Fields

mRenderElements

TInlineArray<GUIRenderElement, 4> mRenderElements

mStateFlags

GUIElementStateFlags mStateFlags

mColor

Color mColor

mPseudoElementStyleSheetRules

TInlineArray<GUIStyleSheetRuleInformation, 2> mPseudoElementStyleSheetRules

mStyleSheetRuleInformation

GUIStyleSheetRuleInformation mStyleSheetRuleInformation

mStyleClass

String mStyleClass