Skip to content

[Feature] Slider widget #153

@vmarcella

Description

@vmarcella

Overview

Add a slider widget for selecting a numeric value within a range by dragging.

Current State

No response

Scope

Goals:

  • Horizontal slider with track and thumb
  • Configurable min/max/current value
  • Drag to change value
  • Value change callback

Non-Goals:

  • Vertical slider
  • Stepped values
  • Multi-thumb

Proposed API

pub struct Slider {
  min: f32,
  max: f32,
  value: f32,
  on_change: Option<Box<dyn Fn(f32)>>,
}

impl Slider {
  pub fn new(min: f32, max: f32, initial: f32) -> Self;
  pub fn on_change(self, callback: impl Fn(f32) + 'static) -> Self;
  pub fn value(&self) -> f32;
  pub fn set_value(&mut self, value: f32);
  pub fn normalized(&self) -> f32; // 0.0 to 1.0
}

impl Widget for Slider {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
  fn hit_test(&self, x: f32, y: f32) -> bool;
}

Acceptance Criteria

  • Slider displays track and thumb
  • Dragging thumb changes value
  • Value clamped to min/max range
  • Callback fires on value change
  • Clicking on track jumps thumb to position

Affected Crates

lambda-rs

Notes

  • Thumb position = lerp(track_start, track_end, normalized)
  • Consider touch-friendly thumb size

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIAll things user interface relatedenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions