SliderBar - LiruJ/GuiCookie GitHub Wiki

Overview

A SliderBar extends ProgressBar and allows changing of the value using a MouseHandler.

Components

private, OnFullSetup()

This is used to handle the player clicking on the SliderBar so that it may update its value. An exception is thrown if this component is not found.

If the SliderBar has a handle element and the handle element's StyleState does not have a MouseHandler, it will be set to the SliderBar's MouseHandler. This allows the handle's style to react to the player interacting with the SliderBar.

Element Properties

Handle

Element, OnFullSetup(), "Handle"

This is the element treated as the visual handle of the SliderBar, it is repositioned when the value is changed and its size is used to determine the usable area of the SliderBar.

For example; if the handle is 50% of the width of a horizontal SliderBar, then 25% of the left and 25% of the right of the SliderBar are considered unusable, as the handle cannot move outside of the bar. Therefore; 25% from the left is treated as the minimum value, and 25% from the right is treated as the maximum value, any clicks within these areas are clamped. If there is no handle, then the entire SliderBar's area is used.

Note that the position of the handle is calculated from the value, every time the value is changed. The value is not calculated from the handle's position at any point.

Properties

See ProgressBar to see all inherited properties.

ValueNoSignal

float

Gets or sets the value. If the value is set through this property, the OnValueChanged signal will not be invoked, but the handle's position will still be recalculated.

UsableSize

float

Gets the total usable space along the slider's axis that is taken into account when the SliderBar is clicked. This is the width or height of the SliderBar, minus the width or height of the handle if there is one.

Signals

OnValueChanged

This is invoked whenever the value is changed, unless the value is being set through ValueNoSignal.

LeftClicked

Invoked whenever the bar is left clicked, forwarded from MouseHandler.

RightClicked

Invoked whenever the bar is right clicked, forwarded from MouseHandler.

Functions

ConnectValueChanged(Action)

public, void

Connects the given action to the OnValueChanged signal.

CalculateHandlePosition()

public, void

Recalculates the position of the handle so that it reflects the current value of the SliderBar. This is performed automatically whenever the value is changed.

ResizeHandleRange(float)

public, void

Resizes the handle so that it covers the range argument. For example; if the slider's minimum value is 0 and the maximum value is 2, and the given argument is 1, the handle will fill 50% of the slider bar.

onValueRecalculated(float)

public, override, void

Called by the underlying ProgressBar class whenever the value is changed, and is used to call CalculateHandlePosition().

drawFill(IGuiCamera)

protected, override, void

Called by the underlying ProgressBar class whenever the fill should be drawn. If there is no handle, then the base function is called, otherwise the fill is drawn up to the centre of the handle.

⚠️ **GitHub.com Fallback** ⚠️