[][src]Struct iced_native::widget::slider::Slider

pub struct Slider<'a, T, Message, Renderer: Renderer> { /* fields omitted */ }

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.

The Slider range of numeric values is generic and its step size defaults to 1 unit.

Example

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);

Slider drawn by Coffee's renderer

Implementations

impl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer> where
    T: Copy + From<u8> + PartialOrd,
    Renderer: Renderer
[src]

pub fn new<F>(
    state: &'a mut State,
    range: RangeInclusive<T>,
    value: T,
    on_change: F
) -> Self where
    F: 'static + Fn(T) -> Message, 
[src]

Creates a new Slider.

It expects:

  • the local State of the Slider
  • an inclusive range of possible values
  • the current value of the Slider
  • a function that will be called when the Slider is dragged. It receives the new value of the Slider and must produce a Message.

pub fn on_release(self, on_release: Message) -> Self[src]

Sets the release message of the Slider. This is called when the mouse is released from the slider.

Typically, the user's interaction with the slider is finished when this message is produced. This is useful if you need to spawn a long-running task from the slider's result, where the default on_change message could create too many events.

pub fn width(self, width: Length) -> Self[src]

Sets the width of the Slider.

pub fn height(self, height: u16) -> Self[src]

Sets the height of the Slider.

pub fn style(self, style: impl Into<Renderer::Style>) -> Self[src]

Sets the style of the Slider.

pub fn step(self, step: T) -> Self[src]

Sets the step size of the Slider.

Trait Implementations

impl<'a, T, Message, Renderer> From<Slider<'a, T, Message, Renderer>> for Element<'a, Message, Renderer> where
    T: 'a + Copy + Into<f64> + FromPrimitive,
    Renderer: 'a + Renderer,
    Message: 'a + Clone
[src]

impl<'a, T, Message, Renderer> Widget<Message, Renderer> for Slider<'a, T, Message, Renderer> where
    T: Copy + Into<f64> + FromPrimitive,
    Renderer: Renderer,
    Message: Clone
[src]

Auto Trait Implementations

impl<'a, T, Message, Renderer> !RefUnwindSafe for Slider<'a, T, Message, Renderer>

impl<'a, T, Message, Renderer> !Send for Slider<'a, T, Message, Renderer>

impl<'a, T, Message, Renderer> !Sync for Slider<'a, T, Message, Renderer>

impl<'a, T, Message, Renderer> Unpin for Slider<'a, T, Message, Renderer> where
    Message: Unpin,
    T: Unpin,
    <Renderer as Renderer>::Style: Unpin

impl<'a, T, Message, Renderer> !UnwindSafe for Slider<'a, T, Message, Renderer>

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,