diff options
-rw-r--r-- | examples/color_palette/src/main.rs | 2 | ||||
-rw-r--r-- | examples/game_of_life/src/main.rs | 15 | ||||
-rw-r--r-- | examples/game_of_life/src/style.rs | 54 | ||||
-rw-r--r-- | examples/pure/game_of_life/src/main.rs | 5 | ||||
-rw-r--r-- | examples/pure/game_of_life/src/style.rs | 54 | ||||
-rw-r--r-- | examples/pure/tour/src/main.rs | 4 | ||||
-rw-r--r-- | examples/styling/src/main.rs | 58 | ||||
-rw-r--r-- | native/src/widget/slider.rs | 4 | ||||
-rw-r--r-- | pure/src/widget/slider.rs | 5 |
9 files changed, 23 insertions, 178 deletions
diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs index f5fab251..98f68f9d 100644 --- a/examples/color_palette/src/main.rs +++ b/examples/color_palette/src/main.rs @@ -288,7 +288,7 @@ impl<C: 'static + ColorSpace + Copy> ColorPicker<C> { range: RangeInclusive<f64>, component: f32, update: impl Fn(f32) -> C + 'static, - ) -> Slider<f64, C> { + ) -> Slider<f64, C, iced::Renderer> { Slider::new(state, range, f64::from(component), move |v| { update(v as f32) }) diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index 3e9c24a0..080cbac3 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -850,15 +850,12 @@ impl Controls { .width(Length::Fill) .align_items(Alignment::Center) .spacing(10) - .push( - Slider::new( - &mut self.speed_slider, - 1.0..=1000.0, - speed as f32, - Message::SpeedChanged, - ) - .style(style::Slider), - ) + .push(Slider::new( + &mut self.speed_slider, + 1.0..=1000.0, + speed as f32, + Message::SpeedChanged, + )) .push(Text::new(format!("x{}", speed)).size(16)); Row::new() diff --git a/examples/game_of_life/src/style.rs b/examples/game_of_life/src/style.rs index 688635e0..ea215dd8 100644 --- a/examples/game_of_life/src/style.rs +++ b/examples/game_of_life/src/style.rs @@ -1,16 +1,4 @@ -use iced::{container, pick_list, slider, Background, Color}; - -const ACTIVE: Color = Color::from_rgb( - 0x72 as f32 / 255.0, - 0x89 as f32 / 255.0, - 0xDA as f32 / 255.0, -); - -const HOVERED: Color = Color::from_rgb( - 0x67 as f32 / 255.0, - 0x7B as f32 / 255.0, - 0xC4 as f32 / 255.0, -); +use iced::{container, pick_list, Background, Color}; const BACKGROUND: Color = Color::from_rgb( 0x2F as f32 / 255.0, @@ -32,46 +20,6 @@ impl container::StyleSheet for Container { } } -pub struct Slider; - -impl slider::StyleSheet for Slider { - fn active(&self) -> slider::Style { - slider::Style { - rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }), - handle: slider::Handle { - shape: slider::HandleShape::Circle { radius: 9.0 }, - color: ACTIVE, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }, - } - } - - fn hovered(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: HOVERED, - ..active.handle - }, - ..active - } - } - - fn dragging(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: Color::from_rgb(0.85, 0.85, 0.85), - ..active.handle - }, - ..active - } - } -} - pub struct PickList; impl pick_list::StyleSheet for PickList { diff --git a/examples/pure/game_of_life/src/main.rs b/examples/pure/game_of_life/src/main.rs index 0eded2ce..87c7a204 100644 --- a/examples/pure/game_of_life/src/main.rs +++ b/examples/pure/game_of_life/src/main.rs @@ -178,10 +178,7 @@ fn view_controls<'a>( .width(Length::Fill) .align_items(Alignment::Center) .spacing(10) - .push( - slider(1.0..=1000.0, speed as f32, Message::SpeedChanged) - .style(style::Slider), - ) + .push(slider(1.0..=1000.0, speed as f32, Message::SpeedChanged)) .push(text(format!("x{}", speed)).size(16)); row() diff --git a/examples/pure/game_of_life/src/style.rs b/examples/pure/game_of_life/src/style.rs index dbd70c26..773b88eb 100644 --- a/examples/pure/game_of_life/src/style.rs +++ b/examples/pure/game_of_life/src/style.rs @@ -1,16 +1,4 @@ -use iced::{container, pick_list, slider, Color}; - -const ACTIVE: Color = Color::from_rgb( - 0x72 as f32 / 255.0, - 0x89 as f32 / 255.0, - 0xDA as f32 / 255.0, -); - -const HOVERED: Color = Color::from_rgb( - 0x67 as f32 / 255.0, - 0x7B as f32 / 255.0, - 0xC4 as f32 / 255.0, -); +use iced::{container, pick_list, Color}; pub const BACKGROUND: Color = Color::from_rgb( 0x2F as f32 / 255.0, @@ -29,46 +17,6 @@ impl container::StyleSheet for Container { } } -pub struct Slider; - -impl slider::StyleSheet for Slider { - fn active(&self) -> slider::Style { - slider::Style { - rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }), - handle: slider::Handle { - shape: slider::HandleShape::Circle { radius: 9.0 }, - color: ACTIVE, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }, - } - } - - fn hovered(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: HOVERED, - ..active.handle - }, - ..active - } - } - - fn dragging(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: Color::from_rgb(0.85, 0.85, 0.85), - ..active.handle - }, - ..active - } - } -} - pub struct PickList; impl pick_list::StyleSheet for PickList { diff --git a/examples/pure/tour/src/main.rs b/examples/pure/tour/src/main.rs index 2002ad98..700e4216 100644 --- a/examples/pure/tour/src/main.rs +++ b/examples/pure/tour/src/main.rs @@ -6,7 +6,7 @@ use iced::pure::{ }; use iced::pure::{Element, Sandbox}; use iced::theme; -use iced::{Color, Length, Settings}; +use iced::{Color, Length, Renderer, Settings}; pub fn main() -> iced::Result { env_logger::init(); @@ -622,7 +622,7 @@ fn button<'a, Message: Clone>(label: &str) -> Button<'a, Message> { fn color_slider<'a>( component: f32, update: impl Fn(f32) -> Color + 'a, -) -> Slider<'a, f64, StepMessage> { +) -> Slider<'a, f64, StepMessage, Renderer> { slider(0.0..=1.0, f64::from(component), move |c| { StepMessage::TextColorChanged(update(c as f32)) }) diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index e6c4ac37..82876cb4 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -92,8 +92,7 @@ impl Sandbox for Styling { 0.0..=100.0, self.slider_value, Message::SliderChanged, - ) - .style(self.theme); + ); let progress_bar = ProgressBar::new(0.0..=100.0, self.slider_value).style(self.theme); @@ -159,8 +158,8 @@ impl Sandbox for Styling { mod style { use iced::{ - checkbox, container, progress_bar, radio, rule, scrollable, slider, - text_input, toggler, + checkbox, container, progress_bar, radio, rule, scrollable, text_input, + toggler, }; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -215,15 +214,6 @@ mod style { } } - impl<'a> From<Theme> for Box<dyn slider::StyleSheet + 'a> { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Slider.into(), - } - } - } - impl From<Theme> for Box<dyn progress_bar::StyleSheet> { fn from(theme: Theme) -> Self { match theme { @@ -262,7 +252,7 @@ mod style { mod dark { use iced::{ - checkbox, container, progress_bar, radio, rule, scrollable, slider, + checkbox, container, progress_bar, radio, rule, scrollable, text_input, toggler, Color, }; @@ -408,46 +398,6 @@ mod style { } } - pub struct Slider; - - impl slider::StyleSheet for Slider { - fn active(&self) -> slider::Style { - slider::Style { - rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }), - handle: slider::Handle { - shape: slider::HandleShape::Circle { radius: 9.0 }, - color: ACTIVE, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }, - } - } - - fn hovered(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: HOVERED, - ..active.handle - }, - ..active - } - } - - fn dragging(&self) -> slider::Style { - let active = self.active(); - - slider::Style { - handle: slider::Handle { - color: Color::from_rgb(0.85, 0.85, 0.85), - ..active.handle - }, - ..active - } - } - } - pub struct ProgressBar; impl progress_bar::StyleSheet for ProgressBar { diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index 7042e0ad..bda31327 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -25,8 +25,10 @@ pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet}; /// /// # Example /// ``` -/// # use iced_native::widget::slider::{self, Slider}; +/// # use iced_native::widget::slider; +/// # use iced_native::renderer::Null; /// # +/// # type Slider<'a, T, Message> = slider::Slider<'a, T, Message, Null>; /// #[derive(Clone)] /// pub enum Message { /// SliderChanged(f32), diff --git a/pure/src/widget/slider.rs b/pure/src/widget/slider.rs index 9bc32f08..fed979e5 100644 --- a/pure/src/widget/slider.rs +++ b/pure/src/widget/slider.rs @@ -23,7 +23,10 @@ pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet}; /// /// # Example /// ``` -/// # use iced_pure::widget::Slider; +/// # use iced_pure::widget::slider; +/// # use iced_native::renderer::Null; +/// # +/// # type Slider<'a, T, Message> = slider::Slider<'a, T, Message, Null>; /// # /// #[derive(Clone)] /// pub enum Message { |