Module: ui.widgets.slider

Source: ./ui/widgets/slider.reef


Overview

ui/widgets/slider.reef - Value slider control Part of reef-stdlib UI module

The Slider widget allows users to select a value from a range by dragging a thumb along a track.

Sliders support:

  • Horizontal and vertical orientations
  • Configurable min/max range
  • Step values for discrete selections
  • Custom colors
  • Keyboard control

Types

SliderOrientation (enum)

Variants:

  • Horizontal
  • Vertical

Objects

Slider

Extends: widget.Widget

Fields:

Name Type
value float
min_value float
max_value float
step_value float
orientation SliderOrientation
focused bool
dragging bool
custom_track_color core.Color
use_custom_track bool
custom_thumb_color core.Color
use_custom_thumb bool
track_height float
thumb_size float

proc init(id: widget.WidgetId, min: float, max: float)

Methods:

override shared fn kind(): string

exclusive proc set_value(value: float)

exclusive proc set_range(min: float, max: float)

exclusive proc set_step(step_value: float)

exclusive proc set_orientation(orientation: SliderOrientation)

exclusive proc set_enabled(enabled: bool)

exclusive proc set_track_color(color: core.Color)

exclusive proc set_thumb_color(color: core.Color)

exclusive proc set_dragging(dragging: bool)

exclusive proc set_focused(focused: bool)

shared fn clone(): Slider

D2 (docs/design/2026-09-08-ui-modernization.md): a SHALLOW copy. Setters mutate the receiver (reef-lang#62), so "give me a variant and leave the original alone" has to be asked for explicitly. Referenced objects are shared, not deep-copied.

shared fn preferred_size(th: theme.Theme): core.Size

exclusive proc layout(constraints: layout.Constraints, th: theme.Theme)

override exclusive fn handle_event(e: event.Event): widget.EventResult

override exclusive proc paint(surf: surface.Surface, th: theme.Theme)


Functions

fn orientation_horizontal(): SliderOrientation

fn orientation_vertical(): SliderOrientation

fn is_orientation_horizontal(o: SliderOrientation): bool

fn is_orientation_vertical(o: SliderOrientation): bool

fn slider(min: float, max: float): Slider

fn slider_with_value(min: float, max: float, value: float): Slider

fn handle_mouse_event(s: Slider, me: event.MouseEvent, bounds: core.Rect): widget.EventResult

fn update_value_from_position(s: Slider, x: float, y: float, bounds: core.Rect): Slider

fn handle_key_event(s: Slider, ke: event.KeyEvent): widget.EventResult

fn handle_focus_event(s: Slider, fe: event.FocusEvent): widget.EventResult

fn get_track_color(s: Slider, colors: theme.ThemeColors): core.Color

fn get_thumb_color(s: Slider, colors: theme.ThemeColors): core.Color

fn get_step_amount(s: Slider): float

fn point_in_rect(px: float, py: float, r: core.Rect): bool


Procedures

proc paint_horizontal_slider(s: Slider, surf: surface.Surface, bounds: core.Rect, track_color: core.Color, filled_color: core.Color, thumb_color: core.Color, colors: theme.ThemeColors)

proc paint_vertical_slider(s: Slider, surf: surface.Surface, bounds: core.Rect, track_color: core.Color, filled_color: core.Color, thumb_color: core.Color, colors: theme.ThemeColors)

proc draw_rect_border(surf: surface.Surface, x: float, y: float, w: float, h: float, color: core.Color, width: float)


Generated by reefc doc