From 7d2d813343baae10c2667590463385d50abb784c Mon Sep 17 00:00:00 2001 From: Giuliano Bellini s294739 Date: Mon, 23 Jan 2023 16:57:24 +0100 Subject: added new style for scrollable, to be applied when mouse is over the scrollable area --- style/src/scrollable.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'style/src') diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs index 64ed8462..a3f3db20 100644 --- a/style/src/scrollable.rs +++ b/style/src/scrollable.rs @@ -45,6 +45,11 @@ pub trait StyleSheet { self.hovered(style) } + /// Produces the style of a scrollbar when mouse is over the scrollable area. + fn focused(&self, style: &Self::Style) -> Scrollbar { + self.active(style) + } + /// Produces the style of an active horizontal scrollbar. fn active_horizontal(&self, style: &Self::Style) -> Scrollbar { self.active(style) @@ -59,4 +64,9 @@ pub trait StyleSheet { fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar { self.hovered_horizontal(style) } + + /// Produces the style of a horizontal scrollbar when mouse is over the scrollable area. + fn focused_horizontal(&self, style: &Self::Style) -> Scrollbar { + self.active_horizontal(style) + } } -- cgit From 49e9a9a5379c1e9a9469045ca9a51ffb860ee620 Mon Sep 17 00:00:00 2001 From: Giuliano Bellini s294739 Date: Mon, 23 Jan 2023 17:56:39 +0100 Subject: added function focused and focused_horizontal to theme.rs --- style/src/theme.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index 55bfa4ca..8d40bda1 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -935,6 +935,13 @@ impl scrollable::StyleSheet for Theme { } } + fn focused(&self, style: &Self::Style) -> scrollable::Scrollbar { + match style { + Scrollable::Default => self.active(style), + Scrollable::Custom(custom) => custom.focused(self), + } + } + fn active_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { Scrollable::Default => self.active(style), @@ -958,6 +965,16 @@ impl scrollable::StyleSheet for Theme { Scrollable::Custom(custom) => custom.dragging_horizontal(self), } } + + fn focused_horizontal( + &self, + style: &Self::Style, + ) -> scrollable::Scrollbar { + match style { + Scrollable::Default => self.active_horizontal(style), + Scrollable::Custom(custom) => custom.focused_horizontal(self), + } + } } /// The style of text. -- cgit From 3a0d34c0240f4421737a6a08761f99d6f8140d02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Mar 2023 05:37:11 +0100 Subject: Create `iced_widget` subcrate and re-organize the whole codebase --- style/src/lib.rs | 3 +-- style/src/text.rs | 2 +- style/src/theme.rs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'style/src') diff --git a/style/src/lib.rs b/style/src/lib.rs index 59eb1eb8..286ff9db 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -18,7 +18,7 @@ #![deny(missing_docs, unused_results)] #![forbid(unsafe_code, rust_2018_idioms)] #![allow(clippy::inherent_to_string, clippy::type_complexity)] -pub use iced_core::{Background, Color}; +pub use iced_core as core; pub mod application; pub mod button; @@ -33,7 +33,6 @@ pub mod rule; pub mod scrollable; pub mod slider; pub mod svg; -pub mod text; pub mod text_input; pub mod theme; pub mod toggler; diff --git a/style/src/text.rs b/style/src/text.rs index f31c2306..d5a16bef 100644 --- a/style/src/text.rs +++ b/style/src/text.rs @@ -1,5 +1,5 @@ //! Change the appearance of text. -use iced_core::Color; +use crate::core::Color; /// The style sheet of some text. pub trait StyleSheet { diff --git a/style/src/theme.rs b/style/src/theme.rs index 4ba4facf..b507d096 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -8,6 +8,7 @@ use crate::application; use crate::button; use crate::checkbox; use crate::container; +use crate::core::widget::text; use crate::menu; use crate::pane_grid; use crate::pick_list; @@ -17,7 +18,6 @@ use crate::rule; use crate::scrollable; use crate::slider; use crate::svg; -use crate::text; use crate::text_input; use crate::toggler; -- cgit From c337bf297d1836c429cd24964e8b3bdcc13850be Mon Sep 17 00:00:00 2001 From: Giuliano Bellini s294739 Date: Sat, 25 Mar 2023 01:05:56 +0100 Subject: renamed scrollable styles --- style/src/scrollable.rs | 14 +++++++------- style/src/theme.rs | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'style/src') diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs index a3f3db20..f3c04235 100644 --- a/style/src/scrollable.rs +++ b/style/src/scrollable.rs @@ -38,15 +38,15 @@ pub trait StyleSheet { fn active(&self, style: &Self::Style) -> Scrollbar; /// Produces the style of a hovered scrollbar. - fn hovered(&self, style: &Self::Style) -> Scrollbar; + fn hovered_scrollbar(&self, style: &Self::Style) -> Scrollbar; /// Produces the style of a scrollbar that is being dragged. fn dragging(&self, style: &Self::Style) -> Scrollbar { - self.hovered(style) + self.hovered_scrollbar(style) } /// Produces the style of a scrollbar when mouse is over the scrollable area. - fn focused(&self, style: &Self::Style) -> Scrollbar { + fn hovered(&self, style: &Self::Style) -> Scrollbar { self.active(style) } @@ -56,17 +56,17 @@ pub trait StyleSheet { } /// Produces the style of a hovered horizontal scrollbar. - fn hovered_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered(style) + fn hovered_scrollbar_horizontal(&self, style: &Self::Style) -> Scrollbar { + self.hovered_scrollbar(style) } /// Produces the style of a horizontal scrollbar that is being dragged. fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered_horizontal(style) + self.hovered_scrollbar_horizontal(style) } /// Produces the style of a horizontal scrollbar when mouse is over the scrollable area. - fn focused_horizontal(&self, style: &Self::Style) -> Scrollbar { + fn hovered_horizontal(&self, style: &Self::Style) -> Scrollbar { self.active_horizontal(style) } } diff --git a/style/src/theme.rs b/style/src/theme.rs index 1d262562..9a3105b5 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -906,7 +906,7 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered_scrollbar(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { Scrollable::Default => { let palette = self.extended_palette(); @@ -924,21 +924,21 @@ impl scrollable::StyleSheet for Theme { }, } } - Scrollable::Custom(custom) => custom.hovered(self), + Scrollable::Custom(custom) => custom.hovered_scrollbar(self), } } fn dragging(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered(style), + Scrollable::Default => self.hovered_scrollbar(style), Scrollable::Custom(custom) => custom.dragging(self), } } - fn focused(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { Scrollable::Default => self.active(style), - Scrollable::Custom(custom) => custom.focused(self), + Scrollable::Custom(custom) => custom.hovered(self), } } @@ -949,10 +949,10 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered_scrollbar_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered(style), - Scrollable::Custom(custom) => custom.hovered_horizontal(self), + Scrollable::Default => self.hovered_scrollbar(style), + Scrollable::Custom(custom) => custom.hovered_scrollbar_horizontal(self), } } @@ -966,13 +966,13 @@ impl scrollable::StyleSheet for Theme { } } - fn focused_horizontal( + fn hovered_horizontal( &self, style: &Self::Style, ) -> scrollable::Scrollbar { match style { Scrollable::Default => self.active_horizontal(style), - Scrollable::Custom(custom) => custom.focused_horizontal(self), + Scrollable::Custom(custom) => custom.hovered_horizontal(self), } } } -- cgit From c407b4504cd5e7dcb04a8fd31ad0400c891fc3e1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 27 Mar 2023 15:51:32 +0200 Subject: Introduce `is_mouse_over_scrollbar` to `StyleSheet::hovered` for `Scrollable` --- style/src/scrollable.rs | 32 ++++++++++++------------- style/src/theme.rs | 63 ++++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 49 deletions(-) (limited to 'style/src') diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs index f3c04235..64a91b69 100644 --- a/style/src/scrollable.rs +++ b/style/src/scrollable.rs @@ -37,17 +37,16 @@ pub trait StyleSheet { /// Produces the style of an active scrollbar. fn active(&self, style: &Self::Style) -> Scrollbar; - /// Produces the style of a hovered scrollbar. - fn hovered_scrollbar(&self, style: &Self::Style) -> Scrollbar; + /// Produces the style of a scrollbar when the scrollable is being hovered. + fn hovered( + &self, + style: &Self::Style, + is_mouse_over_scrollbar: bool, + ) -> Scrollbar; /// Produces the style of a scrollbar that is being dragged. fn dragging(&self, style: &Self::Style) -> Scrollbar { - self.hovered_scrollbar(style) - } - - /// Produces the style of a scrollbar when mouse is over the scrollable area. - fn hovered(&self, style: &Self::Style) -> Scrollbar { - self.active(style) + self.hovered(style, true) } /// Produces the style of an active horizontal scrollbar. @@ -55,18 +54,17 @@ pub trait StyleSheet { self.active(style) } - /// Produces the style of a hovered horizontal scrollbar. - fn hovered_scrollbar_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered_scrollbar(style) + /// Produces the style of a horizontal scrollbar when the scrollable is being hovered. + fn hovered_horizontal( + &self, + style: &Self::Style, + is_mouse_over_scrollbar: bool, + ) -> Scrollbar { + self.hovered(style, is_mouse_over_scrollbar) } /// Produces the style of a horizontal scrollbar that is being dragged. fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered_scrollbar_horizontal(style) - } - - /// Produces the style of a horizontal scrollbar when mouse is over the scrollable area. - fn hovered_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.active_horizontal(style) + self.hovered(style, true) } } diff --git a/style/src/theme.rs b/style/src/theme.rs index 9a3105b5..0ebd82a4 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -906,42 +906,45 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered_scrollbar(&self, style: &Self::Style) -> scrollable::Scrollbar { + fn hovered( + &self, + style: &Self::Style, + is_mouse_over_scrollbar: bool, + ) -> scrollable::Scrollbar { match style { Scrollable::Default => { - let palette = self.extended_palette(); + if is_mouse_over_scrollbar { + let palette = self.extended_palette(); - scrollable::Scrollbar { - background: palette.background.weak.color.into(), - border_radius: 2.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, - scroller: scrollable::Scroller { - color: palette.primary.strong.color, + scrollable::Scrollbar { + background: palette.background.weak.color.into(), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, - }, + scroller: scrollable::Scroller { + color: palette.primary.strong.color, + border_radius: 2.0, + border_width: 0.0, + border_color: Color::TRANSPARENT, + }, + } + } else { + self.active(style) } } - Scrollable::Custom(custom) => custom.hovered_scrollbar(self), + Scrollable::Custom(custom) => { + custom.hovered(self, is_mouse_over_scrollbar) + } } } fn dragging(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered_scrollbar(style), + Scrollable::Default => self.hovered(style, true), Scrollable::Custom(custom) => custom.dragging(self), } } - fn hovered(&self, style: &Self::Style) -> scrollable::Scrollbar { - match style { - Scrollable::Default => self.active(style), - Scrollable::Custom(custom) => custom.hovered(self), - } - } - fn active_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { match style { Scrollable::Default => self.active(style), @@ -949,30 +952,26 @@ impl scrollable::StyleSheet for Theme { } } - fn hovered_scrollbar_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar { - match style { - Scrollable::Default => self.hovered_scrollbar(style), - Scrollable::Custom(custom) => custom.hovered_scrollbar_horizontal(self), - } - } - - fn dragging_horizontal( + fn hovered_horizontal( &self, style: &Self::Style, + is_mouse_over_scrollbar: bool, ) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.hovered_horizontal(style), - Scrollable::Custom(custom) => custom.dragging_horizontal(self), + Scrollable::Default => self.hovered(style, is_mouse_over_scrollbar), + Scrollable::Custom(custom) => { + custom.hovered_horizontal(self, is_mouse_over_scrollbar) + } } } - fn hovered_horizontal( + fn dragging_horizontal( &self, style: &Self::Style, ) -> scrollable::Scrollbar { match style { - Scrollable::Default => self.active_horizontal(style), - Scrollable::Custom(custom) => custom.hovered_horizontal(self), + Scrollable::Default => self.hovered_horizontal(style, true), + Scrollable::Custom(custom) => custom.dragging_horizontal(self), } } } -- cgit From dcccf7064d506abb3aab15227e6cdf34d852514d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 27 Mar 2023 15:57:51 +0200 Subject: Fix inconsistency in default implementation of `scrollable::StyleSheet` --- style/src/scrollable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'style/src') diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs index 64a91b69..b528c444 100644 --- a/style/src/scrollable.rs +++ b/style/src/scrollable.rs @@ -65,6 +65,6 @@ pub trait StyleSheet { /// Produces the style of a horizontal scrollbar that is being dragged. fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar { - self.hovered(style, true) + self.hovered_horizontal(style, true) } } -- cgit From 7b369842959511f17d5c27941fd0308484bff8ea Mon Sep 17 00:00:00 2001 From: Casper Storm Date: Mon, 13 Feb 2023 11:38:05 +0100 Subject: feat: added handle to text_input --- style/src/text_input.rs | 2 ++ style/src/theme.rs | 3 +++ 2 files changed, 5 insertions(+) (limited to 'style/src') diff --git a/style/src/text_input.rs b/style/src/text_input.rs index d97016dc..5e703e61 100644 --- a/style/src/text_input.rs +++ b/style/src/text_input.rs @@ -12,6 +12,8 @@ pub struct Appearance { pub border_width: f32, /// The border [`Color`] of the text input. pub border_color: Color, + /// The handle [`Color`] of the text input. + pub handle_color: Color, } /// A set of rules that dictate the style of a text input. diff --git a/style/src/theme.rs b/style/src/theme.rs index 0ebd82a4..de46d7d4 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1028,6 +1028,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.background.strong.color, + handle_color: palette.background.weak.text, } } @@ -1043,6 +1044,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.background.base.text, + handle_color: palette.background.weak.text, } } @@ -1058,6 +1060,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.primary.strong.color, + handle_color: palette.primary.weak.text, } } -- cgit From bfc5db9009f10a67ed277ce9d1997bcdea3f6acd Mon Sep 17 00:00:00 2001 From: Casper Storm Date: Mon, 13 Feb 2023 12:00:08 +0100 Subject: Updated `handle_color` for focused state --- style/src/theme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index de46d7d4..4837e10b 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1060,7 +1060,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.primary.strong.color, - handle_color: palette.primary.weak.text, + handle_color: palette.background.weak.text, } } -- cgit From d24a4a46895ed711ddfc3199a0445f0b69a812e4 Mon Sep 17 00:00:00 2001 From: Casper Storm Date: Thu, 16 Feb 2023 14:32:59 +0100 Subject: Changed `Handle` to `Icon` to be consistent --- style/src/text_input.rs | 4 ++-- style/src/theme.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'style/src') diff --git a/style/src/text_input.rs b/style/src/text_input.rs index 5e703e61..73b05852 100644 --- a/style/src/text_input.rs +++ b/style/src/text_input.rs @@ -12,8 +12,8 @@ pub struct Appearance { pub border_width: f32, /// The border [`Color`] of the text input. pub border_color: Color, - /// The handle [`Color`] of the text input. - pub handle_color: Color, + /// The icon [`Color`] of the text input. + pub icon_color: Color, } /// A set of rules that dictate the style of a text input. diff --git a/style/src/theme.rs b/style/src/theme.rs index 4837e10b..0d974a19 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1028,7 +1028,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.background.strong.color, - handle_color: palette.background.weak.text, + icon_color: palette.background.weak.text, } } @@ -1044,7 +1044,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.background.base.text, - handle_color: palette.background.weak.text, + icon_color: palette.background.weak.text, } } @@ -1060,7 +1060,7 @@ impl text_input::StyleSheet for Theme { border_radius: 2.0, border_width: 1.0, border_color: palette.primary.strong.color, - handle_color: palette.background.weak.text, + icon_color: palette.background.weak.text, } } -- cgit From f10e936f00d4b83dcacfdebd2727b1a5cd1add95 Mon Sep 17 00:00:00 2001 From: Dan Mishin Date: Fri, 3 Mar 2023 10:01:49 +0300 Subject: Introduce disabled state for `TextInput` --- style/src/text_input.rs | 6 ++++++ style/src/theme.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'style/src') diff --git a/style/src/text_input.rs b/style/src/text_input.rs index 73b05852..2616ad5a 100644 --- a/style/src/text_input.rs +++ b/style/src/text_input.rs @@ -33,6 +33,9 @@ pub trait StyleSheet { /// Produces the [`Color`] of the value of a text input. fn value_color(&self, style: &Self::Style) -> Color; + /// Produces the [`Color`] of the value of a disabled text input. + fn disabled_color(&self, style: &Self::Style) -> Color; + /// Produces the [`Color`] of the selection of a text input. fn selection_color(&self, style: &Self::Style) -> Color; @@ -40,4 +43,7 @@ pub trait StyleSheet { fn hovered(&self, style: &Self::Style) -> Appearance { self.focused(style) } + + /// Produces the style of a disabled text input. + fn disabled(&self, style: &Self::Style) -> Appearance; } diff --git a/style/src/theme.rs b/style/src/theme.rs index 0d974a19..e13edb05 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1093,4 +1093,30 @@ impl text_input::StyleSheet for Theme { palette.primary.weak.color } + + fn disabled(&self, style: &Self::Style) -> text_input::Appearance { + if let TextInput::Custom(custom) = style { + return custom.disabled(self); + } + + let palette = self.extended_palette(); + + text_input::Appearance { + background: palette.background.base.color.into(), + border_radius: 2.0, + border_width: 1.0, + border_color: palette.background.weak.color, + icon_color: palette.background.weak.color, + } + } + + fn disabled_color(&self, style: &Self::Style) -> Color { + if let TextInput::Custom(custom) = style { + return custom.value_color(self); + } + + let palette = self.extended_palette(); + + palette.secondary.strong.color + } } -- cgit From 1de794aabfaa651f021ff2e5831397d7ce9fc53c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 04:34:37 +0200 Subject: Fine-tune built-in styling of disabled `TextInput` --- style/src/theme.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index e13edb05..6bd82a96 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1102,21 +1102,19 @@ impl text_input::StyleSheet for Theme { let palette = self.extended_palette(); text_input::Appearance { - background: palette.background.base.color.into(), + background: palette.background.weak.color.into(), border_radius: 2.0, border_width: 1.0, - border_color: palette.background.weak.color, - icon_color: palette.background.weak.color, + border_color: palette.background.strong.color, + icon_color: palette.background.strong.color, } } fn disabled_color(&self, style: &Self::Style) -> Color { if let TextInput::Custom(custom) = style { - return custom.value_color(self); + return custom.disabled_color(self); } - let palette = self.extended_palette(); - - palette.secondary.strong.color + self.placeholder_color(style) } } -- cgit From de51bc3f41752634c0ccce8484d0a9bade62a45a Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Fri, 6 Jan 2023 14:55:09 +1300 Subject: Introduce left and right colors for slider rails --- style/src/slider.rs | 17 ++++++++++++++++- style/src/theme.rs | 14 ++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'style/src') diff --git a/style/src/slider.rs b/style/src/slider.rs index 4b52fad3..c143915e 100644 --- a/style/src/slider.rs +++ b/style/src/slider.rs @@ -5,11 +5,26 @@ use iced_core::Color; #[derive(Debug, Clone, Copy)] pub struct Appearance { /// The colors of the rail of the slider. - pub rail_colors: (Color, Color), + pub rail: Rail, /// The appearance of the [`Handle`] of the slider. pub handle: Handle, } +/// The appearance of a slider rail +#[derive(Debug, Clone, Copy)] +pub struct Rail { + /// The colors of the rail of the slider. + pub colors: (Color, Color), + /// The height of a slider rail and the width of a vertical slider. + pub size: f32, + /// The border radius of the slider. + pub border_radius: f32, + /// The border width of the slider. + pub border_width: f32, + /// The border [`Color`] of the slider. + pub border_color: Color, +} + /// The appearance of the handle of a slider. #[derive(Debug, Clone, Copy)] pub struct Handle { diff --git a/style/src/theme.rs b/style/src/theme.rs index 6bd82a96..417680a1 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -416,10 +416,16 @@ impl slider::StyleSheet for Theme { }; slider::Appearance { - rail_colors: ( - palette.primary.base.color, - Color::TRANSPARENT, - ), + rail: slider::Rail { + colors: ( + palette.primary.base.color, + palette.primary.base.color, + ), + size: 2.0, + border_radius: 0.0, + border_width: 0.0, + border_color: Color::TRANSPARENT, + }, handle: slider::Handle { color: palette.background.base.color, border_color: palette.primary.base.color, -- cgit From c2cc9a835d8281c1d26c861ecac7991a924c3785 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 05:21:46 +0200 Subject: Remove `border_width` support in `slider::Rail` --- style/src/slider.rs | 4 ---- style/src/theme.rs | 2 -- 2 files changed, 6 deletions(-) (limited to 'style/src') diff --git a/style/src/slider.rs b/style/src/slider.rs index c143915e..bb36a176 100644 --- a/style/src/slider.rs +++ b/style/src/slider.rs @@ -19,10 +19,6 @@ pub struct Rail { pub size: f32, /// The border radius of the slider. pub border_radius: f32, - /// The border width of the slider. - pub border_width: f32, - /// The border [`Color`] of the slider. - pub border_color: Color, } /// The appearance of the handle of a slider. diff --git a/style/src/theme.rs b/style/src/theme.rs index 417680a1..669d9157 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -423,8 +423,6 @@ impl slider::StyleSheet for Theme { ), size: 2.0, border_radius: 0.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, }, handle: slider::Handle { color: palette.background.base.color, -- cgit From 6e6804c5c9d0dba921f2e25d2c888b136d22d35e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 05:25:27 +0200 Subject: Use a `border_radius` of `2.0` for slider rails in built-in theme --- style/src/theme.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index 669d9157..2eb825e6 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -422,7 +422,7 @@ impl slider::StyleSheet for Theme { palette.primary.base.color, ), size: 2.0, - border_radius: 0.0, + border_radius: 2.0, }, handle: slider::Handle { color: palette.background.base.color, -- cgit From 9b39a17628e92b66ac3649e879478ed23635fa76 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 05:27:32 +0200 Subject: Rename `Rail::size` to `width` --- style/src/slider.rs | 4 ++-- style/src/theme.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'style/src') diff --git a/style/src/slider.rs b/style/src/slider.rs index bb36a176..d5db1853 100644 --- a/style/src/slider.rs +++ b/style/src/slider.rs @@ -15,8 +15,8 @@ pub struct Appearance { pub struct Rail { /// The colors of the rail of the slider. pub colors: (Color, Color), - /// The height of a slider rail and the width of a vertical slider. - pub size: f32, + /// The width of the stroke of a slider rail. + pub width: f32, /// The border radius of the slider. pub border_radius: f32, } diff --git a/style/src/theme.rs b/style/src/theme.rs index 2eb825e6..b195940e 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -421,7 +421,7 @@ impl slider::StyleSheet for Theme { palette.primary.base.color, palette.primary.base.color, ), - size: 2.0, + width: 2.0, border_radius: 2.0, }, handle: slider::Handle { -- cgit From 52c84c4975d75baf313243d422d96581daca19bf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 13 Apr 2023 05:53:40 +0200 Subject: Remove `border_radius` support for `slider::Rail` Our current quad shader may produce weird-looking results with non-integral scaling factors. --- style/src/slider.rs | 2 -- style/src/theme.rs | 1 - 2 files changed, 3 deletions(-) (limited to 'style/src') diff --git a/style/src/slider.rs b/style/src/slider.rs index d5db1853..884d3871 100644 --- a/style/src/slider.rs +++ b/style/src/slider.rs @@ -17,8 +17,6 @@ pub struct Rail { pub colors: (Color, Color), /// The width of the stroke of a slider rail. pub width: f32, - /// The border radius of the slider. - pub border_radius: f32, } /// The appearance of the handle of a slider. diff --git a/style/src/theme.rs b/style/src/theme.rs index b195940e..6711fd72 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -422,7 +422,6 @@ impl slider::StyleSheet for Theme { palette.primary.base.color, ), width: 2.0, - border_radius: 2.0, }, handle: slider::Handle { color: palette.background.base.color, -- cgit From 47016a37dfe51ebc3cdf290d8afb34ceadb8edae Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 27 Apr 2023 15:36:45 -0700 Subject: Do not require `Copy` for text `StyleSheet::Style` For most widgets, `Style` only requires `Default`. A few require `Clone`. Only this one requires `Copy`. Some of the types in the default theme has a custom variant requiring `Box`, or `Rc` to provide `Clone`, but this isn't possible if `Copy` is required. It would be good to also address the inconsistency of requiring `Clone` in some places and not others. This removes `style/src/text.rs` which is unused in this branch and thus confusing. If there's a reason to keep it, that can be removed from the change. --- style/src/text.rs | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 style/src/text.rs (limited to 'style/src') diff --git a/style/src/text.rs b/style/src/text.rs deleted file mode 100644 index d5a16bef..00000000 --- a/style/src/text.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Change the appearance of text. -use crate::core::Color; - -/// The style sheet of some text. -pub trait StyleSheet { - /// The supported style of the [`StyleSheet`]. - type Style: Default + Copy; - - /// Produces the [`Appearance`] of some text. - fn appearance(&self, style: Self::Style) -> Appearance; -} - -/// The apperance of some text. -#[derive(Debug, Clone, Copy, Default)] -pub struct Appearance { - /// The [`Color`] of the text. - /// - /// The default, `None`, means using the inherited color. - pub color: Option, -} -- cgit From 6551a0b2ab6c831dd1d3646ecf55180339275e22 Mon Sep 17 00:00:00 2001 From: Bingus Date: Thu, 11 May 2023 09:12:06 -0700 Subject: Added support for gradients as background variants + other optimizations. --- style/src/button.rs | 3 +++ style/src/theme.rs | 3 +++ 2 files changed, 6 insertions(+) (limited to 'style/src') diff --git a/style/src/button.rs b/style/src/button.rs index a564a2b7..32ec28b7 100644 --- a/style/src/button.rs +++ b/style/src/button.rs @@ -68,6 +68,9 @@ pub trait StyleSheet { a: color.a * 0.5, ..color }), + Background::Gradient(gradient) => { + Background::Gradient(gradient.mul_alpha(0.5)) + } }), text_color: Color { a: active.text_color.a * 0.5, diff --git a/style/src/theme.rs b/style/src/theme.rs index d9893bcf..1b47e2f9 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -217,6 +217,9 @@ impl button::StyleSheet for Theme { a: color.a * 0.5, ..color }), + Background::Gradient(gradient) => { + Background::Gradient(gradient.mul_alpha(0.5)) + } }), text_color: Color { a: active.text_color.a * 0.5, -- cgit From 99aa54cd88d7eb99149699d539ee4d59e08047b1 Mon Sep 17 00:00:00 2001 From: Joao Freitas <51237625+jhff@users.noreply.github.com> Date: Tue, 16 May 2023 16:12:29 +0100 Subject: Add pane_grid functionality to split a pane with another pane --- style/src/pane_grid.rs | 18 +++++++++++++++++- style/src/theme.rs | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'style/src') diff --git a/style/src/pane_grid.rs b/style/src/pane_grid.rs index fd8fc05f..ec422e86 100644 --- a/style/src/pane_grid.rs +++ b/style/src/pane_grid.rs @@ -1,11 +1,14 @@ //! Change the appearance of a pane grid. -use iced_core::Color; +use iced_core::{Background, Color}; /// A set of rules that dictate the style of a container. pub trait StyleSheet { /// The supported style of the [`StyleSheet`]. type Style: Default; + /// The [`Region`] to draw when a pane is hovered. + fn hovered_region(&self, style: &Self::Style) -> Region; + /// The [`Line`] to draw when a split is picked. fn picked_split(&self, style: &Self::Style) -> Option; @@ -13,6 +16,19 @@ pub trait StyleSheet { fn hovered_split(&self, style: &Self::Style) -> Option; } +/// The appearance of the hovered region of a pane grid. +#[derive(Debug, Clone, Copy)] +pub struct Region { + /// The [`Background`] of the hovered pane region. + pub background: Background, + /// The border width of the hovered pane region. + pub border_width: f32, + /// The border [`Color`] of the hovered pane region. + pub border_color: Color, + /// The border radius of the hovered pane region. + pub border_radius: f32, +} + /// A line. /// /// It is normally used to define the highlight of something, like a split. diff --git a/style/src/theme.rs b/style/src/theme.rs index d9893bcf..c7b2bada 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -703,6 +703,25 @@ pub enum PaneGrid { impl pane_grid::StyleSheet for Theme { type Style = PaneGrid; + fn hovered_region(&self, style: &Self::Style) -> pane_grid::Region { + match style { + PaneGrid::Default => { + let palette = self.extended_palette(); + + pane_grid::Region { + background: Background::Color(Color { + a: 0.5, + ..palette.primary.base.color + }), + border_width: 2.0, + border_color: palette.primary.strong.color, + border_radius: 0.0, + } + } + PaneGrid::Custom(custom) => custom.hovered_region(self), + } + } + fn picked_split(&self, style: &Self::Style) -> Option { match style { PaneGrid::Default => { -- cgit From 4c1a082f0468a59099bbf8aa8991420a41234948 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 May 2023 03:32:21 +0200 Subject: Remove `Builder` abstractions for gradients --- style/src/theme.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index 1b47e2f9..c9835ca3 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -371,7 +371,7 @@ impl container::StyleSheet for Theme { container::Appearance { text_color: None, - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -896,7 +896,7 @@ impl scrollable::StyleSheet for Theme { let palette = self.extended_palette(); scrollable::Scrollbar { - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -923,7 +923,7 @@ impl scrollable::StyleSheet for Theme { let palette = self.extended_palette(); scrollable::Scrollbar { - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, -- cgit From 96aa0379d58ff799493097e3bd0572f9a87da453 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 May 2023 03:43:11 +0200 Subject: Implement `custom` helper for `theme::Button` --- style/src/theme.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index c9835ca3..477bd27b 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -139,6 +139,15 @@ pub enum Button { Custom(Box>), } +impl Button { + /// Creates a custom [`Button`] style variant. + pub fn custom( + style_sheet: impl button::StyleSheet