From a7bb7bb2eaaae5a016721788fcaf03c4c7413acd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 1 Jan 2021 15:28:38 +0100 Subject: Implement split highlight on hover for `PaneGrid` --- style/src/lib.rs | 1 + style/src/pane_grid.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 style/src/pane_grid.rs (limited to 'style') diff --git a/style/src/lib.rs b/style/src/lib.rs index 7e0a9f49..f09b5f9d 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -10,6 +10,7 @@ pub mod button; pub mod checkbox; pub mod container; pub mod menu; +pub mod pane_grid; pub mod pick_list; pub mod progress_bar; pub mod radio; diff --git a/style/src/pane_grid.rs b/style/src/pane_grid.rs new file mode 100644 index 00000000..e39ee797 --- /dev/null +++ b/style/src/pane_grid.rs @@ -0,0 +1,51 @@ +//! Let your users split regions of your application and organize layout +//! dynamically. +use iced_core::Color; + +/// A set of rules that dictate the style of a container. +pub trait StyleSheet { + /// The [`Line`] to draw when a split is picked. + fn picked_split(&self) -> Option; + + /// The [`Line`] to draw when a split is hovered. + fn hovered_split(&self) -> Option; +} + +/// A line. +/// +/// It is normally used to define the highlight of something, like a split. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Line { + /// The [`Color`] of the [`Line`]. + pub color: Color, + + /// The width of the [`Line`]. + pub width: f32, +} + +struct Default; + +impl StyleSheet for Default { + fn picked_split(&self) -> Option { + None + } + + fn hovered_split(&self) -> Option { + None + } +} + +impl std::default::Default for Box { + fn default() -> Self { + Box::new(Default) + } +} + +impl From for Box +where + T: 'static + StyleSheet, +{ + fn from(style: T) -> Self { + Box::new(style) + } +} -- cgit From 2969558afd7da2443641e81ee84b4faa99eceba4 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 29 Jan 2021 14:08:14 +0900 Subject: impl Clone and Copy for all Style types in iced_style --- style/src/button.rs | 2 +- style/src/checkbox.rs | 2 +- style/src/progress_bar.rs | 2 +- style/src/radio.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'style') diff --git a/style/src/button.rs b/style/src/button.rs index 43d27216..2281e32f 100644 --- a/style/src/button.rs +++ b/style/src/button.rs @@ -2,7 +2,7 @@ use iced_core::{Background, Color, Vector}; /// The appearance of a button. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Style { pub shadow_offset: Vector, pub background: Option, diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs index 1c5f2460..566136bb 100644 --- a/style/src/checkbox.rs +++ b/style/src/checkbox.rs @@ -2,7 +2,7 @@ use iced_core::{Background, Color}; /// The appearance of a checkbox. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Style { pub background: Background, pub checkmark_color: Color, diff --git a/style/src/progress_bar.rs b/style/src/progress_bar.rs index 36be63f9..d0878c84 100644 --- a/style/src/progress_bar.rs +++ b/style/src/progress_bar.rs @@ -2,7 +2,7 @@ use iced_core::{Background, Color}; /// The appearance of a progress bar. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Style { pub background: Background, pub bar: Background, diff --git a/style/src/radio.rs b/style/src/radio.rs index 83310e05..c41b70c0 100644 --- a/style/src/radio.rs +++ b/style/src/radio.rs @@ -2,7 +2,7 @@ use iced_core::{Background, Color}; /// The appearance of a radio button. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Style { pub background: Background, pub dot_color: Color, -- cgit From 0864e63bde129b95261590b960efdc46c6d2d4d0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 31 Mar 2021 20:06:03 +0200 Subject: Bump versions :tada: --- style/Cargo.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'style') diff --git a/style/Cargo.toml b/style/Cargo.toml index ac16f8ee..a3086477 100644 --- a/style/Cargo.toml +++ b/style/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_style" -version = "0.2.0" +version = "0.3.0" authors = ["Héctor Ramón Jiménez "] edition = "2018" description = "The default set of styles of Iced" @@ -10,5 +10,6 @@ documentation = "https://docs.rs/iced_style" keywords = ["gui", "ui", "graphics", "interface", "widgets"] categories = ["gui"] -[dependencies] -iced_core = { version = "0.3", path = "../core" } +[dependencies.iced_core] +version = "0.4" +path = "../core" -- cgit From 662889bb8355d9e388d5eda6c69bf065f156884a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Date: Tue, 1 Jun 2021 18:32:56 +0700 Subject: Implement `Default` for `Style` in `rule` --- style/src/rule.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'style') diff --git a/style/src/rule.rs b/style/src/rule.rs index 5021340b..be4c86d1 100644 --- a/style/src/rule.rs +++ b/style/src/rule.rs @@ -79,6 +79,17 @@ pub struct Style { pub fill_mode: FillMode, } +impl std::default::Default for Style { + fn default() -> Self { + Style { + color: [0.6, 0.6, 0.6, 0.51].into(), + width: 1, + radius: 0.0, + fill_mode: FillMode::Percent(90.0), + } + } +} + /// A set of rules that dictate the style of a rule. pub trait StyleSheet { /// Produces the style of a rule. @@ -89,12 +100,7 @@ struct Default; impl StyleSheet for Default { fn style(&self) -> Style { - Style { - color: [0.6, 0.6, 0.6, 0.51].into(), - width: 1, - radius: 0.0, - fill_mode: FillMode::Percent(90.0), - } + Style::default() } } -- cgit From 52a185fbab728b85cf414d4997567f52ebc66205 Mon Sep 17 00:00:00 2001 From: Kaiden42 Date: Sat, 19 Sep 2020 18:44:27 +0200 Subject: Implement `Toggler` widget for iced_native --- style/src/lib.rs | 1 + style/src/toggler.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 style/src/toggler.rs (limited to 'style') diff --git a/style/src/lib.rs b/style/src/lib.rs index f09b5f9d..08d9f044 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -18,3 +18,4 @@ pub mod rule; pub mod scrollable; pub mod slider; pub mod text_input; +pub mod toggler; diff --git a/style/src/toggler.rs b/style/src/toggler.rs new file mode 100644 index 00000000..5a155123 --- /dev/null +++ b/style/src/toggler.rs @@ -0,0 +1,57 @@ +//! Show toggle controls using togglers. +use iced_core::Color; + +/// The appearance of a toggler. +#[derive(Debug)] +pub struct Style { + pub background: Color, + pub background_border: Option, + pub foreground: Color, + pub foreground_border: Option, +} + +/// A set of rules that dictate the style of a toggler. +pub trait StyleSheet { + fn active(&self, is_active: bool) -> Style; + + fn hovered(&self, is_active: bool) -> Style; +} + +struct Default; + +impl StyleSheet for Default { + fn active(&self, is_active: bool) -> Style { + Style { + background: if is_active { + Color::from_rgb(0.0, 1.0, 0.0) + } else { + Color::from_rgb(0.7, 0.7, 0.7) + }, + background_border: None, + foreground: Color::WHITE, + foreground_border: None, + } + } + + fn hovered(&self, is_active: bool) -> Style { + Style { + foreground: Color::from_rgb(0.95, 0.95, 0.95), + ..self.active(is_active) + } + } +} + +impl std::default::Default for Box { + fn default() -> Self { + Box::new(Default) + } +} + +impl From for Box +where + T: 'static + StyleSheet, +{ + fn from(style: T) -> Self { + Box::new(style) + } +} -- cgit From 1b3606884747374f1e5599e3c783f36a2f2cac6f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 22 Jul 2021 20:13:14 +0700 Subject: Introduce `placeholder_color` to `pick_list::Style` --- style/src/pick_list.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'style') diff --git a/style/src/pick_list.rs b/style/src/pick_list.rs index a757ba98..d1801e5f 100644 --- a/style/src/pick_list.rs +++ b/style/src/pick_list.rs @@ -5,6 +5,7 @@ use iced_core::{Background, Color}; #[derive(Debug, Clone, Copy)] pub struct Style { pub text_color: Color, + pub placeholder_color: Color, pub background: Background, pub border_radius: f32, pub border_width: f32, @@ -16,6 +17,7 @@ impl std::default::Default for Style { fn default() -> Self { Self { text_color: Color::BLACK, + placeholder_color: [0.4, 0.4, 0.4].into(), background: Background::Color([0.87, 0.87, 0.87].into()), border_radius: 0.0, border_width: 1.0, -- cgit