diff options
author | 2020-06-02 20:34:13 +0200 | |
---|---|---|
committer | 2020-06-11 00:18:24 +0200 | |
commit | c3643eaf6d90dc8b60c0b762200bf1f8097cdfe9 (patch) | |
tree | 6651e8db73202abf3482dedbfd9b65e28319f488 /examples | |
parent | baa1389f71e419383429eb10ac051b1aaf0a3e26 (diff) | |
download | iced-c3643eaf6d90dc8b60c0b762200bf1f8097cdfe9.tar.gz iced-c3643eaf6d90dc8b60c0b762200bf1f8097cdfe9.tar.bz2 iced-c3643eaf6d90dc8b60c0b762200bf1f8097cdfe9.zip |
Add `step` member to slider widgets
Both the native and the web slider now have a member `step` to control
the least possible change of the slider's value. It defaults to 1.0
for all sliders and can be adjusted with the step method.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/color_palette/src/main.rs | 12 | ||||
-rw-r--r-- | examples/integration/src/controls.rs | 39 | ||||
-rw-r--r-- | examples/tour/src/main.rs | 27 |
3 files changed, 51 insertions, 27 deletions
diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs index cec6ac79..9f39fe56 100644 --- a/examples/color_palette/src/main.rs +++ b/examples/color_palette/src/main.rs @@ -288,9 +288,15 @@ impl<C: 'static + ColorSpace + Copy> ColorPicker<C> { .spacing(10) .align_items(Align::Center) .push(Text::new(C::LABEL).width(Length::Units(50))) - .push(Slider::new(s1, cr1, c1, move |v| C::new(v, c2, c3))) - .push(Slider::new(s2, cr2, c2, move |v| C::new(c1, v, c3))) - .push(Slider::new(s3, cr3, c3, move |v| C::new(c1, c2, v))) + .push( + Slider::new(s1, cr1, c1, move |v| C::new(v, c2, c3)).step(0.01), + ) + .push( + Slider::new(s2, cr2, c2, move |v| C::new(c1, v, c3)).step(0.01), + ) + .push( + Slider::new(s3, cr3, c3, move |v| C::new(c1, c2, v)).step(0.01), + ) .push( Text::new(color.to_string()) .width(Length::Units(185)) diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index e6e74995..824f9f53 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -48,24 +48,33 @@ impl Program for Controls { let sliders = Row::new() .width(Length::Units(500)) .spacing(20) - .push(Slider::new(r, 0.0..=1.0, background_color.r, move |r| { - Message::BackgroundColorChanged(Color { - r, - ..background_color + .push( + Slider::new(r, 0.0..=1.0, background_color.r, move |r| { + Message::BackgroundColorChanged(Color { + r, + ..background_color + }) }) - })) - .push(Slider::new(g, 0.0..=1.0, background_color.g, move |g| { - Message::BackgroundColorChanged(Color { - g, - ..background_color + .step(0.01), + ) + .push( + Slider::new(g, 0.0..=1.0, background_color.g, move |g| { + Message::BackgroundColorChanged(Color { + g, + ..background_color + }) }) - })) - .push(Slider::new(b, 0.0..=1.0, background_color.b, move |b| { - Message::BackgroundColorChanged(Color { - b, - ..background_color + .step(0.01), + ) + .push( + Slider::new(b, 0.0..=1.0, background_color.b, move |b| { + Message::BackgroundColorChanged(Color { + b, + ..background_color + }) }) - })); + .step(0.01), + ); Row::new() .width(Length::Fill) diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index c9678b9d..43627cc3 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -500,15 +500,24 @@ impl<'a> Step { .push( Row::new() .spacing(10) - .push(Slider::new(red, 0.0..=1.0, color.r, move |r| { - StepMessage::TextColorChanged(Color { r, ..color }) - })) - .push(Slider::new(green, 0.0..=1.0, color.g, move |g| { - StepMessage::TextColorChanged(Color { g, ..color }) - })) - .push(Slider::new(blue, 0.0..=1.0, color.b, move |b| { - StepMessage::TextColorChanged(Color { b, ..color }) - })), + .push( + Slider::new(red, 0.0..=1.0, color.r, move |r| { + StepMessage::TextColorChanged(Color { r, ..color }) + }) + .step(0.01), + ) + .push( + Slider::new(green, 0.0..=1.0, color.g, move |g| { + StepMessage::TextColorChanged(Color { g, ..color }) + }) + .step(0.01), + ) + .push( + Slider::new(blue, 0.0..=1.0, color.b, move |b| { + StepMessage::TextColorChanged(Color { b, ..color }) + }) + .step(0.01), + ), ); Self::container("Text") |