class GUIScrollArea

A GUI element container with support for vertical

& horizontal scrolling.

Public

Methods

staticGetGuiTypeName

static const String &GetGuiTypeName()

Returns type name of the GUI element used for finding GUI element styles.

~GUIScrollArea

~GUIScrollArea() noexcept = default

GetLayout

GUILayout *GetLayout() const

Returns the scroll area layout that you may use to add elements inside the scroll area.

ScrollUp

void ScrollUp(GUIPhysicalUnit pixels)

Scrolls the area up by specified amount of pixels, if possible.

ScrollDown

void ScrollDown(GUIPhysicalUnit pixels)

Scrolls the area down by specified amount of pixels, if possible.

ScrollLeft

void ScrollLeft(GUIPhysicalUnit pixels)

Scrolls the area left by specified amount of pixels, if possible.

ScrollRight

void ScrollRight(GUIPhysicalUnit pixels)

Scrolls the area right by specified amount of pixels, if possible.

ScrollUp

void ScrollUp(float percent)

Scrolls the area up by specified percentage (ranging [0, 1]), if possible.

ScrollDown

void ScrollDown(float percent)

Scrolls the area down by specified percentage (ranging [0, 1]), if possible.

ScrollLeft

void ScrollLeft(float percent)

Scrolls the area left by specified percentage (ranging [0, 1]), if possible.

ScrollRight

void ScrollRight(float percent)

Scrolls the area right by specified percentage (ranging [0, 1]), if possible.

ScrollToVertical

void ScrollToVertical(float pct)

Scrolls the contents to the specified position (0 meaning top-most part of the content is visible, and 1 meaning bottom-most part is visible).

ScrollToHorizontal

void ScrollToHorizontal(float pct)

Scrolls the contents to the specified position (0 meaning left-most part of the content is visible, and 1 meaning right-most part is visible)

GetVerticalScroll

float GetVerticalScroll() const

Returns how much is the scroll area scrolled in the vertical direction.

Returned value represents percentage where 0 means no scrolling is happening, and 1 means area is fully scrolled to the bottom.

GetHorizontalScroll

float GetHorizontalScroll() const

Returns how much is the scroll area scrolled in the horizontal direction.

Returned value represents percentage where 0 means no scrolling is happening, and 1 means area is fully scrolled to the right.

GetContentBounds

GUIPhysicalArea GetContentBounds()

Returns the bounds of the scroll area not including the scroll bars (meaning only the portion that contains the contents).

SetEnableCulling

void SetEnableCulling(bool enable)

Enables/disables culling of child elements.

If culling is enabled all child elements that are fully outside of the parent visible bounds will be marked as culled. Culled elements will never have their contents or mesh updated, their absolute coordinate will not be updated and they wont be drawn This is useful for layouts with a large amount of children, but comes with an overhead so it is disabled by default. Note this has no impact on layout update, which may still be expensive with many elements.

GetScrollBarSize

GUILogicalUnit GetScrollBarSize() const

Returns the width or height of the scrollbar.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

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

staticCreate

static GUIElementType *Create(const ContentType &contents, const String &styleClass, const TInlineArray<GUIOption, 4> &options)

Creates a new GUI element.

contents
Structure describing the contents of the GUI element to create.
styleClass
Style class that will be used for determining GUI element visuals from the current style sheet. If no class is provided, default style is determined based on GUI element type.
options
Additional options that control GUI element size and position. This will override options set in the style sheet.

Internal

Constructors

GUIScrollArea

GUIScrollArea(PrivatelyConstruct, const GUIScrollAreaContent &content, const String &styleClass, const GUISizeConstraints &sizeConstraints)

Protected

Methods

GetConstrainedSizeRange

GUIConstrainedSizeRange GetConstrainedSizeRange() const override

Returns element size constrained by its size constraints.

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

CalculateConstrainedSizeRange

GUIConstrainedSizeRange CalculateConstrainedSizeRange() const override

Calculates element size based on its optimal size constrained by its size constraint options.

UpdateOptimalLayoutSizes

void UpdateOptimalLayoutSizes() override

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().

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

Calculates the optimal size for the GUI element, ignoring size constraints.

Private

Methods

DoOnMouseEvent

bool DoOnMouseEvent(const GUIMouseEvent &ev) override

Called when a mouse event is received on any GUI element the mouse is interacting with.

Return true if you have processed the event and don't want other elements to process it.

DoOnVerticalScrollUpdate

void DoOnVerticalScrollUpdate(float scrollHandlePosition)

Called when the vertical scrollbar moves.

scrollHandlePosition
Scrollbar position ranging [0, 1].

DoOnHorizontalScrollUpdate

void DoOnHorizontalScrollUpdate(float scrollHandlePosition)

Called when the horizontal scrollbar moves.

scrollHandlePosition
Scrollbar position ranging [0, 1].

UpdateLayoutForChildren

void UpdateLayoutForChildren() override

Calculates sizes and relative positions for all child elements.

Should be preceded with a call to UpdateOptimalLayoutSizes().

UpdateAbsoluteCoordinatesForChildren

void UpdateAbsoluteCoordinatesForChildren() override

Calls UpdateAbsoluteCoordinates() on all child elements.

CalculateRelativeElementAreas

void CalculateRelativeElementAreas(const GUILogicalSize &scrollAreaSize, GUILogicalPoint *outElementPositions, GUILogicalSize *outElementSizes, u32 elementCount, const Vector<GUIConstrainedSizeRange> &constrainedSizeRanges, GUILogicalSize &outVisibleSize) const

Calculates the position and size of the scroll area child layout and the scroll bars.

Fields

mContent

mContentLayout

GUILayout * mContentLayout

mVerticalScrollBar

GUIVerticalScrollBar * mVerticalScrollBar

mHorizontalScrollBar

GUIHorizontalScrollBar * mHorizontalScrollBar

mVerticalOffset

float mVerticalOffset

mHorizontalOffset

float mHorizontalOffset

mRecalculateVerticalOffset

bool mRecalculateVerticalOffset

mRecalculateHorizontalOffset

bool mRecalculateHorizontalOffset

mDragInProgress

bool mDragInProgress

mDragStartPosition

GUIPhysicalPoint mDragStartPosition

mDragStartOffset

GUIPhysicalPoint mDragStartOffset

mVisibleSize

GUILogicalSize mVisibleSize

mContentSize

GUILogicalSize mContentSize

mChildSizeRanges

Vector<GUIConstrainedSizeRange> mChildSizeRanges

mSizeRange