pub struct Slider<'a, T, Message, Renderer>where
Renderer: Renderer,
<Renderer as Renderer>::Theme: StyleSheet,{ /* private fields */ }
Expand description
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
#[derive(Clone)]
pub enum Message {
SliderChanged(f32),
}
let value = 50.0;
Slider::new(0.0..=100.0, value, Message::SliderChanged);
Implementations
sourceimpl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer>where
T: Copy + From<u8> + PartialOrd<T>,
Message: Clone,
Renderer: Renderer,
<Renderer as Renderer>::Theme: StyleSheet,
impl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer>where
T: Copy + From<u8> + PartialOrd<T>,
Message: Clone,
Renderer: Renderer,
<Renderer as Renderer>::Theme: StyleSheet,
sourcepub const DEFAULT_HEIGHT: u16 = 22u16
pub const DEFAULT_HEIGHT: u16 = 22u16
The default height of a Slider
.
sourcepub fn new<F>(
range: RangeInclusive<T>,
value: T,
on_change: F
) -> Slider<'a, T, Message, Renderer>where
F: 'a + Fn(T) -> Message,
pub fn new<F>(
range: RangeInclusive<T>,
value: T,
on_change: F
) -> Slider<'a, T, Message, Renderer>where
F: 'a + Fn(T) -> Message,
sourcepub fn on_release(self, on_release: Message) -> Slider<'a, T, Message, Renderer>
pub fn on_release(self, on_release: Message) -> Slider<'a, T, Message, Renderer>
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.
sourcepub fn width(self, width: Length) -> Slider<'a, T, Message, Renderer>
pub fn width(self, width: Length) -> Slider<'a, T, Message, Renderer>
Sets the width of the Slider
.
sourcepub fn height(self, height: u16) -> Slider<'a, T, Message, Renderer>
pub fn height(self, height: u16) -> Slider<'a, T, Message, Renderer>
Sets the height of the Slider
.
Trait Implementations
sourceimpl<'a, T, Message, Renderer> Widget<Message, Renderer> for Slider<'a, T, Message, Renderer>where
T: Copy + Into<f64> + FromPrimitive,
Message: Clone,
Renderer: Renderer,
<Renderer as Renderer>::Theme: StyleSheet,
impl<'a, T, Message, Renderer> Widget<Message, Renderer> for Slider<'a, T, Message, Renderer>where
T: Copy + Into<f64> + FromPrimitive,
Message: Clone,
Renderer: Renderer,
<Renderer as Renderer>::Theme: StyleSheet,
sourcefn on_event(
&mut self,
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>
) -> Status
fn on_event(
&mut self,
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>
) -> Status
sourcefn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &<Renderer as Renderer>::Theme,
_style: &Style,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle<f32>
)
fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &<Renderer as Renderer>::Theme,
_style: &Style,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle<f32>
)
Draws the
Widget
using the associated Renderer
.sourcefn mouse_interaction(
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle<f32>,
_renderer: &Renderer
) -> Interaction
fn mouse_interaction(
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle<f32>,
_renderer: &Renderer
) -> Interaction
sourcefn children(&self) -> Vec<Tree, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
fn children(&self) -> Vec<Tree, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
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>::Theme as StyleSheet>::Style: Unpin,
impl<'a, T, Message, Renderer> !UnwindSafe for Slider<'a, T, Message, Renderer>
Blanket Implementations
sourceimpl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
sourcefn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method Read more
sourcefn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default Read more
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
sourcefn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
sourceimpl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
sourcefn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
sourcefn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an
OutOfBounds
error is returned which contains
the unclamped color. Read more