Expose styling types for slider
in iced_web
This commit is contained in:
parent
ad13b466d2
commit
c2dad29429
@ -6,6 +6,8 @@
|
|||||||
//! [`State`]: struct.State.html
|
//! [`State`]: struct.State.html
|
||||||
use crate::{Bus, Css, Element, Length, Widget};
|
use crate::{Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
|
pub use iced_style::slider::{Handle, HandleShape, Style, StyleSheet};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::{ops::RangeInclusive, rc::Rc};
|
use std::{ops::RangeInclusive, rc::Rc};
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ pub struct Slider<'a, Message> {
|
|||||||
value: f32,
|
value: f32,
|
||||||
on_change: Rc<Box<dyn Fn(f32) -> Message>>,
|
on_change: Rc<Box<dyn Fn(f32) -> Message>>,
|
||||||
width: Length,
|
width: Length,
|
||||||
|
style: Box<dyn StyleSheet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message> Slider<'a, Message> {
|
impl<'a, Message> Slider<'a, Message> {
|
||||||
@ -68,6 +71,7 @@ impl<'a, Message> Slider<'a, Message> {
|
|||||||
range,
|
range,
|
||||||
on_change: Rc::new(Box::new(on_change)),
|
on_change: Rc::new(Box::new(on_change)),
|
||||||
width: Length::Fill,
|
width: Length::Fill,
|
||||||
|
style: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +82,14 @@ impl<'a, Message> Slider<'a, Message> {
|
|||||||
self.width = width;
|
self.width = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the style of the [`Slider`].
|
||||||
|
///
|
||||||
|
/// [`Slider`]: struct.Slider.html
|
||||||
|
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||||
|
self.style = style.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message> Widget<Message> for Slider<'a, Message>
|
impl<'a, Message> Widget<Message> for Slider<'a, Message>
|
||||||
@ -103,7 +115,7 @@ where
|
|||||||
let event_bus = bus.clone();
|
let event_bus = bus.clone();
|
||||||
|
|
||||||
// TODO: Make `step` configurable
|
// TODO: Make `step` configurable
|
||||||
// TODO: Complete styling
|
// TODO: Styling
|
||||||
input(bump)
|
input(bump)
|
||||||
.attr("type", "range")
|
.attr("type", "range")
|
||||||
.attr("step", "0.01")
|
.attr("step", "0.01")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user