class GUISlider

A slider with a draggable handle that can be vertical or horizontal.

Public

Methods

SetHandlePositionInPercent

void SetHandlePositionInPercent(float percent)

Current position of the slider handle, in percent ranging [0.0f, 1.0f].

GetHandlePositionInPercent

float GetHandlePositionInPercent() const

SetHandlePositionInRange

void SetHandlePositionInRange(float value)

Current position of the slider handle, scaled within the current minimum and maximum range, rounded up to nearest step increment.

If no range is provided, the range is [0, 1].

GetHandlePositionInRange

float GetHandlePositionInRange() const

SetRange

void SetRange(float minimum, float maximum)

Sets a minimum and maximum allow values in the input field.

Set to large negative/positive values if you don't require clamping.

GetRangeMinimum

float GetRangeMinimum() const

Returns the minimum value of the slider

GetRangeMaximum

float GetRangeMaximum() const

Returns the maximum value of the slider

SetStep

void SetStep(float step)

Step that defines the minimal increment the value can be increased/decreased by.

Set to zero to have no step.

GetStep

float GetStep() const

SetTint

void SetTint(const Color &color) override

Sets the tint of the GUI element.

Fields

OnChanged

Event<void (float)> OnChanged

Triggered when the user changes the value of the slider.

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.

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

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

Protected

Constructors

GUISlider

GUISlider(bool horizontal, const String &styleName, const GUISizeConstraints &dimensions)

Methods

~GUISlider

virtual ~GUISlider() noexcept

UpdateLayoutForChildren

void UpdateLayoutForChildren() override

Calculates sizes and relative positions for all child elements.

Should be preceded with a call to UpdateOptimalLayoutSizes().

OnHandleMoved

void OnHandleMoved(float newPosition, float newSize)

Triggered when the slider handles moves.

DoOnCommandEvent

bool DoOnCommandEvent(const GUICommandEvent &ev) override

Called when a command event is triggered.

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

Private

Fields

mSliderHandle

GUISliderHandle * mSliderHandle

mBackground

GUITexture * mBackground

mFillBackground

GUITexture * mFillBackground

mHorizontal

bool mHorizontal

mMinRange

float mMinRange

mMaxRange

float mMaxRange

mHasFocus

bool mHasFocus

mHandleMovedConn

HEvent mHandleMovedConn