From ae3f5ba1a33f47692bc39080a0d2e12b8106499f Mon Sep 17 00:00:00 2001 From: Giuliano Bellini s294739 Date: Sat, 27 Jan 2024 21:56:28 +0100 Subject: [PATCH 1/2] add border widths to toggler stylesheet --- style/src/theme.rs | 6 ++++-- style/src/toggler.rs | 8 ++++++-- widget/src/toggler.rs | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/style/src/theme.rs b/style/src/theme.rs index 96f9126015..e579a1c20d 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -797,13 +797,15 @@ impl toggler::StyleSheet for Theme { } else { palette.background.strong.color }, - background_border: None, + background_border_width: 0.0, + background_border_color: Color::TRANSPARENT, foreground: if is_active { palette.primary.strong.text } else { palette.background.base.color }, - foreground_border: None, + foreground_border_width: 0.0, + foreground_border_color: Color::TRANSPARENT, } } Toggler::Custom(custom) => custom.active(self, is_active), diff --git a/style/src/toggler.rs b/style/src/toggler.rs index abc73f2a25..731e87ceb8 100644 --- a/style/src/toggler.rs +++ b/style/src/toggler.rs @@ -6,12 +6,16 @@ use iced_core::Color; pub struct Appearance { /// The background [`Color`] of the toggler. pub background: Color, + /// The width of the background border of the toggler. + pub background_border_width: f32, /// The [`Color`] of the background border of the toggler. - pub background_border: Option, + pub background_border_color: Color, /// The foreground [`Color`] of the toggler. pub foreground: Color, + /// The width of the foreground border of the toggler. + pub foreground_border_width: f32, /// The [`Color`] of the foreground border of the toggler. - pub foreground_border: Option, + pub foreground_border_color: Color, } /// A set of rules that dictate the style of a toggler. diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index 1d313df3ba..4e3925bad5 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -315,8 +315,8 @@ where bounds: toggler_background_bounds, border: Border { radius: border_radius.into(), - width: 1.0, - color: style.background_border.unwrap_or(style.background), + width: style.background_border_width, + color: style.background_border_color, }, ..renderer::Quad::default() }, @@ -340,8 +340,8 @@ where bounds: toggler_foreground_bounds, border: Border { radius: border_radius.into(), - width: 1.0, - color: style.foreground_border.unwrap_or(style.foreground), + width: style.foreground_border_width, + color: style.foreground_border_color, }, ..renderer::Quad::default() }, From cecfa1c467124f255fd86077bdb9e610690d4a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 7 Feb 2024 20:30:18 +0100 Subject: [PATCH 2/2] Update `CHANGELOG` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 518124e716..6d28c45c2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `interaction` method for `MouseArea`. [#2207](https://github.com/iced-rs/iced/pull/2207) - `hovered` styling for `Svg` widget. [#2163](https://github.com/iced-rs/iced/pull/2163) - Customizable style for `TextEditor`. [#2159](https://github.com/iced-rs/iced/pull/2159) +- Border width styling for `Toggler`. [#2219](https://github.com/iced-rs/iced/pull/2219) - `RawText` variant for `Primitive` in `iced_graphics`. [#2158](https://github.com/iced-rs/iced/pull/2158) - `Stream` support for `Command`. [#2150](https://github.com/iced-rs/iced/pull/2150) - Access to bounds/content bounds from a `Scrollable` viewport. [#2072](https://github.com/iced-rs/iced/pull/2072)