From 28d09bfff1dde55190986bab10d7aaeb0ceb49de Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 27 May 2022 01:26:57 +0200 Subject: Implement theme styling for `Radio` --- examples/scrollable/src/style.rs | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) (limited to 'examples/scrollable/src/style.rs') diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs index 0ed38b00..0581a8c8 100644 --- a/examples/scrollable/src/style.rs +++ b/examples/scrollable/src/style.rs @@ -1,4 +1,4 @@ -use iced::{container, radio, rule, scrollable}; +use iced::{container, rule, scrollable}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Theme { @@ -25,15 +25,6 @@ impl<'a> From for Box { } } -impl<'a> From for Box { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Radio.into(), - } - } -} - impl<'a> From for Box { fn from(theme: Theme) -> Self { match theme { @@ -53,7 +44,7 @@ impl From for Box { } mod dark { - use iced::{container, radio, rule, scrollable, Color}; + use iced::{container, rule, scrollable, Color}; const BACKGROUND: Color = Color::from_rgb( 0x36 as f32 / 255.0, @@ -73,12 +64,6 @@ mod dark { 0xE9 as f32 / 255.0, ); - const ACTIVE: Color = Color::from_rgb( - 0x72 as f32 / 255.0, - 0x89 as f32 / 255.0, - 0xDA as f32 / 255.0, - ); - const SCROLLBAR: Color = Color::from_rgb( 0x2E as f32 / 255.0, 0x33 as f32 / 255.0, @@ -107,27 +92,6 @@ mod dark { } } - pub struct Radio; - - impl radio::StyleSheet for Radio { - fn active(&self) -> radio::Style { - radio::Style { - background: SURFACE.into(), - dot_color: ACTIVE, - border_width: 1.0, - border_color: ACTIVE, - text_color: None, - } - } - - fn hovered(&self) -> radio::Style { - radio::Style { - background: Color { a: 0.5, ..SURFACE }.into(), - ..self.active() - } - } - } - pub struct Scrollable; impl scrollable::StyleSheet for Scrollable { -- cgit From c275fde67a7f5d1d5789540dc7905250a2f01fe7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jun 2022 01:56:46 +0200 Subject: Implement theme styling for `Rule` --- examples/scrollable/src/style.rs | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'examples/scrollable/src/style.rs') diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs index 0581a8c8..e15bf125 100644 --- a/examples/scrollable/src/style.rs +++ b/examples/scrollable/src/style.rs @@ -1,4 +1,4 @@ -use iced::{container, rule, scrollable}; +use iced::{container, scrollable}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Theme { @@ -34,17 +34,8 @@ impl<'a> From for Box { } } -impl From for Box { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Rule.into(), - } - } -} - mod dark { - use iced::{container, rule, scrollable, Color}; + use iced::{container, scrollable, Color}; const BACKGROUND: Color = Color::from_rgb( 0x36 as f32 / 255.0, @@ -139,17 +130,4 @@ mod dark { } } } - - pub struct Rule; - - impl rule::StyleSheet for Rule { - fn style(&self) -> rule::Style { - rule::Style { - color: SURFACE, - width: 2, - radius: 1.0, - fill_mode: rule::FillMode::Percent(30.0), - } - } - } } -- cgit From ce53d3933c860cd958636cce415ac97c04aee746 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jun 2022 01:11:35 +0200 Subject: Implement theme styling for `TextInput` --- examples/scrollable/src/style.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'examples/scrollable/src/style.rs') diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs index e15bf125..64922ae4 100644 --- a/examples/scrollable/src/style.rs +++ b/examples/scrollable/src/style.rs @@ -43,12 +43,6 @@ mod dark { 0x3F as f32 / 255.0, ); - const SURFACE: Color = Color::from_rgb( - 0x40 as f32 / 255.0, - 0x44 as f32 / 255.0, - 0x4B as f32 / 255.0, - ); - const ACCENT: Color = Color::from_rgb( 0x6F as f32 / 255.0, 0xFF as f32 / 255.0, -- cgit From de21a651c0616307bb6bfd36da1a06119e629b10 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jun 2022 03:26:48 +0200 Subject: Implement theme styling for `Scrollable` --- examples/scrollable/src/style.rs | 79 +--------------------------------------- 1 file changed, 2 insertions(+), 77 deletions(-) (limited to 'examples/scrollable/src/style.rs') diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs index 64922ae4..c2c48470 100644 --- a/examples/scrollable/src/style.rs +++ b/examples/scrollable/src/style.rs @@ -1,4 +1,4 @@ -use iced::{container, scrollable}; +use iced::container; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Theme { @@ -25,17 +25,8 @@ impl<'a> From for Box { } } -impl<'a> From for Box { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Scrollable.into(), - } - } -} - mod dark { - use iced::{container, scrollable, Color}; + use iced::{container, Color}; const BACKGROUND: Color = Color::from_rgb( 0x36 as f32 / 255.0, @@ -43,24 +34,6 @@ mod dark { 0x3F as f32 / 255.0, ); - const ACCENT: Color = Color::from_rgb( - 0x6F as f32 / 255.0, - 0xFF as f32 / 255.0, - 0xE9 as f32 / 255.0, - ); - - const SCROLLBAR: Color = Color::from_rgb( - 0x2E as f32 / 255.0, - 0x33 as f32 / 255.0, - 0x38 as f32 / 255.0, - ); - - const SCROLLER: Color = Color::from_rgb( - 0x20 as f32 / 255.0, - 0x22 as f32 / 255.0, - 0x25 as f32 / 255.0, - ); - pub struct Container; impl container::StyleSheet for Container { @@ -76,52 +49,4 @@ mod dark { } } } - - pub struct Scrollable; - - impl scrollable::StyleSheet for Scrollable { - fn active(&self) -> scrollable::Scrollbar { - scrollable::Scrollbar { - background: Color { - a: 0.8, - ..SCROLLBAR - } - .into(), - border_radius: 2.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, - scroller: scrollable::Scroller { - color: Color { a: 0.7, ..SCROLLER }, - border_radius: 2.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }, - } - } - - fn hovered(&self) -> scrollable::Scrollbar { - let active = self.active(); - - scrollable::Scrollbar { - background: SCROLLBAR.into(), - scroller: scrollable::Scroller { - color: SCROLLER, - ..active.scroller - }, - ..active - } - } - - fn dragging(&self) -> scrollable::Scrollbar { - let hovered = self.hovered(); - - scrollable::Scrollbar { - scroller: scrollable::Scroller { - color: ACCENT, - ..hovered.scroller - }, - ..hovered - } - } - } } -- cgit From 2933ac7355d5c14aa4f04a64a67197cd97e7608c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jun 2022 03:28:41 +0200 Subject: Remove `style` module leftover in `scrollable` example --- examples/scrollable/src/style.rs | 52 ---------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 examples/scrollable/src/style.rs (limited to 'examples/scrollable/src/style.rs') diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs deleted file mode 100644 index c2c48470..00000000 --- a/examples/scrollable/src/style.rs +++ /dev/null @@ -1,52 +0,0 @@ -use iced::container; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Theme { - Light, - Dark, -} - -impl Theme { - pub const ALL: [Theme; 2] = [Theme::Light, Theme::Dark]; -} - -impl Default for Theme { - fn default() -> Theme { - Theme::Light - } -} - -impl<'a> From for Box { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Container.into(), - } - } -} - -mod dark { - use iced::{container, Color}; - - const BACKGROUND: Color = Color::from_rgb( - 0x36 as f32 / 255.0, - 0x39 as f32 / 255.0, - 0x3F as f32 / 255.0, - ); - - pub struct Container; - - impl container::StyleSheet for Container { - fn style(&self) -> container::Style { - container::Style { - background: Color { - a: 0.99, - ..BACKGROUND - } - .into(), - text_color: Color::WHITE.into(), - ..container::Style::default() - } - } - } -} -- cgit