diff options
author | 2019-11-22 22:14:04 +0100 | |
---|---|---|
committer | 2019-11-22 22:14:04 +0100 | |
commit | fa227255b02adbbfa99801a7baaa4d6d387f7302 (patch) | |
tree | 1b9b4c97a6b6a054ff73cd69ac9b1493f50392c3 /web/src/widget/slider.rs | |
parent | 048909b45dfecef73bfacf3b5aa67462470ccca2 (diff) | |
download | iced-fa227255b02adbbfa99801a7baaa4d6d387f7302.tar.gz iced-fa227255b02adbbfa99801a7baaa4d6d387f7302.tar.bz2 iced-fa227255b02adbbfa99801a7baaa4d6d387f7302.zip |
Write docs for `iced_web`
Diffstat (limited to '')
-rw-r--r-- | web/src/widget/slider.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/web/src/widget/slider.rs b/web/src/widget/slider.rs index acdef0a1..16e20b82 100644 --- a/web/src/widget/slider.rs +++ b/web/src/widget/slider.rs @@ -1,8 +1,37 @@ +//! Display an interactive selector of a single value from a range of values. +//! +//! A [`Slider`] has some local [`State`]. +//! +//! [`Slider`]: struct.Slider.html +//! [`State`]: struct.State.html use crate::{Bus, Element, Length, Widget}; use dodrio::bumpalo; use std::{ops::RangeInclusive, rc::Rc}; +/// An horizontal bar and a handle that selects a single value from a range of +/// values. +/// +/// A [`Slider`] will try to fill the horizontal space of its container. +/// +/// [`Slider`]: struct.Slider.html +/// +/// # Example +/// ``` +/// # use iced_web::{slider, Slider}; +/// # +/// pub enum Message { +/// SliderChanged(f32), +/// } +/// +/// let state = &mut slider::State::new(); +/// let value = 50.0; +/// +/// Slider::new(state, 0.0..=100.0, value, Message::SliderChanged); +/// ``` +/// +///  +#[allow(missing_debug_implementations)] pub struct Slider<'a, Message> { _state: &'a mut State, range: RangeInclusive<f32>, @@ -108,9 +137,16 @@ where } } +/// The local state of a [`Slider`]. +/// +/// [`Slider`]: struct.Slider.html +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub struct State; impl State { + /// Creates a new [`State`]. + /// + /// [`State`]: struct.State.html pub fn new() -> Self { Self } |