type Slider struct {
// contains filtered or unexported fields
}
Slider paints a horizontal or vertical scalar control. Values remain
application state: the application turns a pointer coordinate into a value
with ValueAt (the pointer events of the held thumb carry it, with capture while
it is dragged) and a key into one with SliderKeyDown, and passes the result back.
Constructors
BeginRangeSlider#
func BeginRangeSlider(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, thumbs []SliderThumbValue) Slider
BeginRangeSlider starts a multi-thumb 0..100 slider declaration without
copying thumbs. The caller must keep the slice stable for the paint pass.
BeginSlider#
func BeginSlider(canvas *ui.Canvas, theme ui.Theme, id ui.ID, bounds ui.Rect, value float32) Slider
BeginSlider starts a single-thumb 0..100 slider declaration.
Methods
Disabled#
func (slider Slider) Disabled() Slider
Disabled renders and routes the slider as inert.
Paint#
func (slider Slider) Paint(label string) SliderGeometry
Paint draws the track, selected range, thumbs, and stable hit regions.
Range#
func (slider Slider) Range(minimum, maximum float32) Slider
Range sets the inclusive scalar range. Invalid or reversed ranges collapse
to minimum rather than introducing undefined paint geometry.
Step#
func (slider Slider) Step(step float32) Slider
Step snaps both painted and coordinate-derived values to a positive step.
ThumbBounds#
func (slider Slider) ThumbBounds(index int) ui.Rect
ThumbBounds returns one thumb's geometry without painting.
ThumbCount#
func (slider Slider) ThumbCount() int
ThumbCount returns the stable number of painted thumbs.
ValueAt#
func (slider Slider) ValueAt(position float32) float32
ValueAt maps a caller-supplied logical coordinate to the slider range. The
coordinate is x for horizontal and y for vertical sliders.
ValueText#
func (slider Slider) ValueText(value string) Slider
ValueText supplies caller-formatted accessibility value text without
formatting or allocating in the paint path.
Vertical#
func (slider Slider) Vertical() Slider
Vertical maps minimum to the bottom and maximum to the top.