Skip to content

UISlider Class

Definition

Namespace: Brine2D.UI

Slider UI component for adjusting numeric values.

C#
public class UISlider : Brine2D.UI.IUIComponent, Brine2D.UI.IAnchoredUIComponent

Inheritance System.Object → UISlider

Implements IUIComponent, IAnchoredUIComponent

Properties
Anchor The screen anchor point this component is positioned relative to.
AnchorOffset Pixel offset from the resolved anchor point.
FillColor Fill color \(filled portion\).
FocusColor Color of the focus ring drawn around the slider when it has keyboard focus.
HandleColor Handle \(thumb\) color.
HandleHoverColor Handle color when hovered.
HandleSize Handle size in pixels.
IsDragging Returns whether the slider is currently being dragged.
IsFocused Whether this slider currently has keyboard focus.
Label Optional label text rendered adjacent to the slider track. Empty or null disables label rendering.
LabelColor Label text color.
LabelFont Optional font for the label \(null = renderer default\).
LabelPosition Where the label is drawn relative to the slider track. Defaults to Brine2D.UI.SliderLabelPosition.Left.
LabelSpacing Gap in pixels between the label and the slider track.
MaxValue Maximum value.
MinValue Minimum value.
Orientation Whether the slider moves horizontally or vertically.
ShowValue Whether to show the value as text.
Step Step size for value increments \(0 = continuous\).
TrackColor Track color \(background bar\).
Value Current value \(between MinValue and MaxValue\).
ValueFormat Value display format \(e\.g\., "0\.00" for 2 decimal places\).
ValueTextColor Text color for value display.
Methods
EndDrag() Called by UICanvas when mouse drag ends.
GetNormalizedValue() Gets the normalized value \(0\.0 to 1\.0\).
NudgeValue\(float\) Nudges the slider value by one step \(or 1% of the range when [Step](Step.md 'Brine2D\.UI\.UISlider\.Step') is 0\). Called by UICanvas when the focused slider receives an arrow-key press.
SetFocused\(bool\) Called by UICanvas to set keyboard focus on this slider.
SetHovered\(bool\) Called by UICanvas when mouse hovers over slider.
StartDrag() Called by UICanvas when mouse drag starts.
UpdateDrag\(Vector2\) Called by UICanvas during mouse drag.
Events
OnFocusGained Event fired when this slider gains keyboard focus.
OnFocusLost Event fired when this slider loses keyboard focus.
OnValueChanged Event fired when value changes.