summaryrefslogtreecommitdiffstats
path: root/core/src/theme.rs
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2024-12-17 17:28:46 +0100
committerLibravatar GitHub <noreply@github.com>2024-12-17 17:28:46 +0100
commitf2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470 (patch)
tree4941905adf134468acc079610bb6f25d7461d543 /core/src/theme.rs
parenta687a837653a576cb0599f7bc8ecd9c6054213a9 (diff)
parente5545aaa579f428e45853d125ac86155d8395104 (diff)
downloadiced-f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470.tar.gz
iced-f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470.tar.bz2
iced-f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470.zip
Merge pull request #2698 from iced-rs/feature/test-crate
Headless Mode Testing
Diffstat (limited to 'core/src/theme.rs')
-rw-r--r--core/src/theme.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/src/theme.rs b/core/src/theme.rs
index 6b2c04da..23480cec 100644
--- a/core/src/theme.rs
+++ b/core/src/theme.rs
@@ -3,6 +3,8 @@ pub mod palette;
pub use palette::Palette;
+use crate::Color;
+
use std::fmt;
use std::sync::Arc;
@@ -246,3 +248,35 @@ impl fmt::Display for Custom {
write!(f, "{}", self.name)
}
}
+
+/// The base style of a [`Theme`].
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub struct Style {
+ /// The background [`Color`] of the application.
+ pub background_color: Color,
+
+ /// The default text [`Color`] of the application.
+ pub text_color: Color,
+}
+
+/// The default blank style of a [`Theme`].
+pub trait Base {
+ /// Returns the default base [`Style`] of a [`Theme`].
+ fn base(&self) -> Style;
+}
+
+impl Base for Theme {
+ fn base(&self) -> Style {
+ default(self)
+ }
+}
+
+/// The default [`Style`] of a built-in [`Theme`].
+pub fn default(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ Style {
+ background_color: palette.background.base.color,
+ text_color: palette.background.base.text,
+ }
+}