UXSlider
UXSlider is a knob on a track. The value maps linearly to the knob position
and back, so a click or drag sets the value and the value places the knob. The
value↔position arithmetic is pure and unit-testable without a window. Drawing
and click conversion go through the
UXControl seam. On backends with a native
slider (macOS NSSlider, Win32 trackbar, iOS UISlider, Android SeekBar,
GTK GtkScale) the driver realizes one and this object holds its state. On GEM
and the web the control draws itself from the theme’s slider.htrack and
slider.knob sprites.
#use <UXKit>Overview
Section titled “Overview”UXSlider* s = new UXSlider();s.setRange(0, 255);s.setValue(128);s.setAction(&controller.onLevel); // fires on every value changecontent.addSubview(s, UXGeom.make(8, 8, 180, 20));The action fires as the value moves: once per click or drag step on the self-drawn path, and whenever the native control reports a user change elsewhere. The handler reads the value from the sender:
void onLevel(UXControl* sender) { i32 level = ((UXSlider* ?)sender).intValue(); ...}Conforms to
Section titled “Conforms to”- Inherits
UXControl: theweak:bound-method action, enable/disable, the fire path.
Topics
Section titled “Topics”Value · setRange · setValue · intValue Geometry · knobX · valueForX Realization · kind
setRange
Section titled “setRange”void setRange(i32 lo, i32 hi)Sets the bounds and clamps the current value into them. A degenerate range
is repaired (hi becomes lo + 1), so the position arithmetic never
divides by zero.
setValue
Section titled “setValue”void setValue(i32 v)Sets the value programmatically, clamped to the range. Does not fire the action. Actions report the user’s changes; code that sets the value already knows it.
intValue
Section titled “intValue”i32 intValue(void)The current value. The neutral object holds it, whatever realized the control.
i32 knobX(i16 trackW)The knob’s left edge for the current value within a track trackW wide.
Pure arithmetic; the tests call it without a window.
valueForX
Section titled “valueForX”i32 valueForX(i16 lx, i16 trackW)The value for a local x (the click or drag point), centring the knob under the pointer, clamped to the track.
UXKind kind(void)UXKindSlider: native where the backend has one, themed sprites elsewhere.
The driver decides; the control does not know which.
Platform appearance
Section titled “Platform appearance”
The theme’s slider.htrack groove and round slider.knob, the same Aristo art GEM draws, on canvas.

A real UISlider. Value changes arrive through its own target-action and land in the peer before the action fires.

A real SeekBar. User progress reports through OnSeekBarChangeListener (the bridge dex); programmatic sets stay silent.

A real NSSlider overlay.

A real trackbar (msctls_trackbar32).

A real GtkScale, its value-changed signal feeding the peer. GTK draws its own widgets, so this capture is the Linux look wherever GTK4 runs.

The same themed groove and knob, drawn by the same drawRect.
Example
Section titled “Example”A brightness control that applies live while dragging:
UXSlider* bright = new UXSlider();bright.setRange(0, 100);bright.setValue(80);bright.setAction(&controller.onBrightness);content.addSubview(bright, UXGeom.make(8, 8, 200, 20));
void onBrightness(UXControl* sender) { display.setBrightness(((UXSlider* ?)sender).intValue());}