diff options
author | 2024-03-06 11:36:33 +0100 | |
---|---|---|
committer | 2024-03-06 11:36:49 +0100 | |
commit | 69bc1df252382a662228c8b0da6f60358e90f376 (patch) | |
tree | 6365e00118e78f24f2f4c308358360477be6258a /style | |
parent | 40af65c3aa4a96281db8f642cfa1641479314d27 (diff) | |
download | iced-69bc1df252382a662228c8b0da6f60358e90f376.tar.gz iced-69bc1df252382a662228c8b0da6f60358e90f376.tar.bz2 iced-69bc1df252382a662228c8b0da6f60358e90f376.zip |
Simplify theming for `Svg` widget
Diffstat (limited to 'style')
-rw-r--r-- | style/src/lib.rs | 1 | ||||
-rw-r--r-- | style/src/svg.rs | 28 | ||||
-rw-r--r-- | style/src/theme.rs | 47 |
3 files changed, 0 insertions, 76 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs index 3e439f07..259ad793 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -20,7 +20,6 @@ pub mod application; pub mod menu; pub mod pane_grid; pub mod pick_list; -pub mod svg; pub mod text_editor; pub mod theme; diff --git a/style/src/svg.rs b/style/src/svg.rs deleted file mode 100644 index 3fe5546b..00000000 --- a/style/src/svg.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! Change the appearance of a svg. - -use iced_core::Color; - -/// The appearance of an SVG. -#[derive(Debug, Default, Clone, Copy)] -pub struct Appearance { - /// The [`Color`] filter of an SVG. - /// - /// Useful for coloring a symbolic icon. - /// - /// `None` keeps the original color. - pub color: Option<Color>, -} - -/// The stylesheet of a svg. -pub trait StyleSheet { - /// The supported style of the [`StyleSheet`]. - type Style: Default; - - /// Produces the [`Appearance`] of the svg. - fn appearance(&self, style: &Self::Style) -> Appearance; - - /// Produces the hovered [`Appearance`] of a svg content. - fn hovered(&self, style: &Self::Style) -> Appearance { - self.appearance(style) - } -} diff --git a/style/src/theme.rs b/style/src/theme.rs index 993e3d68..27d5b5e0 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -8,7 +8,6 @@ use crate::core::widget::text; use crate::menu; use crate::pane_grid; use crate::pick_list; -use crate::svg; use crate::text_editor; use crate::core::{Background, Border, Color}; @@ -440,52 +439,6 @@ impl pane_grid::StyleSheet for Theme { } } -/** - * Svg - */ -#[derive(Default)] -pub enum Svg { - /// No filtering to the rendered SVG. - #[default] - Default, - /// A custom style. - Custom(Box<dyn svg::StyleSheet<Style = Theme>>), -} - -impl Svg { - /// Creates a custom [`Svg`] style. - pub fn custom_fn(f: fn(&Theme) -> svg::Appearance) -> Self { - Self::Custom(Box::new(f)) - } -} - -impl svg::StyleSheet for Theme { - type Style = Svg; - - fn appearance(&self, style: &Self::Style) -> svg::Appearance { - match style { - Svg::Default => svg::Appearance::default(), - Svg::Custom(custom) => custom.appearance(self), - } - } - - fn hovered(&self, style: &Self::Style) -> svg::Appearance { - self.appearance(style) - } -} - -impl svg::StyleSheet for fn(&Theme) -> svg::Appearance { - type Style = Theme; - - fn appearance(&self, style: &Self::Style) -> svg::Appearance { - (self)(style) - } - - fn hovered(&self, style: &Self::Style) -> svg::Appearance { - self.appearance(style) - } -} - impl text::StyleSheet for Theme {} /// The style of a text input. |