summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-06 21:27:03 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-06 21:27:03 +0100
commit7c4bf70023a8092faad9630c2c87fbf41bd6ab76 (patch)
treea02aa7fa62276e4e9b870f4f88ba448c0a264e2b /style
parent34e7c6593a9e0f56cee5db18b7258717cf6bc11b (diff)
downloadiced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.gz
iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.bz2
iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.zip
Simplify theming for `Application`
Diffstat (limited to 'style')
-rw-r--r--style/src/application.rs23
-rw-r--r--style/src/lib.rs1
-rw-r--r--style/src/theme.rs45
3 files changed, 0 insertions, 69 deletions
diff --git a/style/src/application.rs b/style/src/application.rs
deleted file mode 100644
index e9a1f4ff..00000000
--- a/style/src/application.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-//! Change the appearance of an application.
-use iced_core::Color;
-
-/// A set of rules that dictate the style of an application.
-pub trait StyleSheet {
- /// The supported style of the [`StyleSheet`].
- type Style: Default;
-
- /// Returns the [`Appearance`] of the application for the provided [`Style`].
- ///
- /// [`Style`]: Self::Style
- fn appearance(&self, style: &Self::Style) -> Appearance;
-}
-
-/// The appearance of an application.
-#[derive(Debug, Clone, Copy, PartialEq)]
-pub struct Appearance {
- /// The background [`Color`] of the application.
- pub background_color: Color,
-
- /// The default text [`Color`] of the application.
- pub text_color: Color,
-}
diff --git a/style/src/lib.rs b/style/src/lib.rs
index 1aea2d80..bc0e37e9 100644
--- a/style/src/lib.rs
+++ b/style/src/lib.rs
@@ -16,7 +16,6 @@
)]
pub use iced_core as core;
-pub mod application;
pub mod theme;
pub use theme::Theme;
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 41e76d99..21ba2a37 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -3,8 +3,6 @@ pub mod palette;
pub use palette::Palette;
-use crate::application;
-
use std::fmt;
use std::sync::Arc;
@@ -221,46 +219,3 @@ impl fmt::Display for Custom {
write!(f, "{}", self.name)
}
}
-
-/// The style of an application.
-#[derive(Default)]
-pub enum Application {
- /// The default style.
- #[default]
- Default,
- /// A custom style.
- Custom(Box<dyn application::StyleSheet<Style = Theme>>),
-}
-
-impl Application {
- /// Creates a custom [`Application`] style.
- pub fn custom(
- custom: impl application::StyleSheet<Style = Theme> + 'static,
- ) -> Self {
- Self::Custom(Box::new(custom))
- }
-}
-
-impl application::StyleSheet for Theme {
- type Style = Application;
-
- fn appearance(&self, style: &Self::Style) -> application::Appearance {
- let palette = self.extended_palette();
-
- match style {
- Application::Default => application::Appearance {
- background_color: palette.background.base.color,
- text_color: palette.background.base.text,
- },
- Application::Custom(custom) => custom.appearance(self),
- }
- }
-}
-
-impl<T: Fn(&Theme) -> application::Appearance> application::StyleSheet for T {
- type Style = Theme;
-
- fn appearance(&self, style: &Self::Style) -> application::Appearance {
- (self)(style)
- }
-}