class GUIScrollBar

Inherits: GUIInteractable

GUI element representing an element with a draggable handle of a variable size.

Public

Methods

SetScrollHandlePosition

void SetScrollHandlePosition(float pct)

Position of the scroll handle in percent (ranging [0, 1]).

GetScrollHandlePosition

float GetScrollHandlePosition() const

SetScrollHandleSize

void SetScrollHandleSize(float pct)

Size of the scroll handle in percent (ranging [0, 1]) of the total scroll bar area.

GetScrollHandleSize

float GetScrollHandleSize() const

Scroll

void Scroll(float amount)

Moves the handle by some amount.

Amount is specified in the percentage of the entire scrollable area. Values out of range will be clamped.

GetScrollableSize

GUIPhysicalUnit GetScrollableSize() const

Returns the maximum scrollable size the handle can move within (for example scroll bar length).

SetTint

void SetTint(const Color &color) override

Sets the tint of the GUI element.

IsInInteractionBounds

bool IsInInteractionBounds(const GUIPhysicalPoint &position) const override

Checks is the specified position within interactable bounds of a GUI element.

These are the bounds that will be used for hit tests for e.g. mouse cursor. By default this is the same as the absolute clipped bounds of the GUI element. Position is relative to parent GUI widget.

Fields

OnScrollOrResize

Event<void (float, float)> OnScrollOrResize

Triggered whenever the scrollbar handle is moved or resized.

Values provided are the handle position and size in percent (ranging [0, 1]).

Internal

Methods

GetStyleSheetElement

const char *GetStyleSheetElement() const override

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

SetHandleSizeInternal

void SetHandleSizeInternal(float pct)

Sets the size of the handle in percent (ranging [0, 1]) of the total scroll bar area.

SetScrollPosInternal

void SetScrollPosInternal(float pct)

Sets the position of the scroll handle in percent (ranging [0, 1]).

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

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

UpdateLayoutForChildren

void UpdateLayoutForChildren() override

Calculates sizes and relative positions for all child elements.

Should be preceded with a call to UpdateOptimalLayoutSizes().

Protected

Constructors

GUIScrollBar

GUIScrollBar(bool horizontal, bool resizable, const String &styleName, const GUISizeConstraints &dimensions)

Constructs a new scrollbar.

horizontal
If true the scroll bar will have a horizontal moving handle, otherwise it will be a vertical one.
resizable
If true the scrollbar will have additional handles that allow the scroll handle to be resized. This allows you to adjust the size of the visible scroll area.
styleName
Optional style to use for the element. Style will be retrieved from GUISkin of the GUIWidget the element is used on. If not specified default style is used.
dimensions
Determines valid dimensions (size) of the element.

Methods

~GUIScrollBar

virtual ~GUIScrollBar() noexcept

UpdateRenderElements

void UpdateRenderElements() override

Recreates the internal render elements.

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

GetRenderElementDepthRange

u32 GetRenderElementDepthRange() const override

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

Private

Methods

HandleMoved

void HandleMoved(float handlePct, float sizePct)

Triggered whenever the scroll handle moves.

Provided value represents the new position and size of the handle in percent (ranging [0, 1]).

UpButtonClicked

void UpButtonClicked()

Triggered when scroll up button is clicked.

DownButtonClicked

void DownButtonClicked()

Triggered when scroll down button is clicked.

Fields

mLayout

GUILayout * mLayout

mBackgroundSprite

GUIBackgroundSprite mBackgroundSprite

mUpBtn

GUIButton * mUpBtn

mDownBtn

GUIButton * mDownBtn

mHandleBtn

GUISliderHandle * mHandleBtn

mHorizontal

bool mHorizontal