summaryrefslogtreecommitdiffstats
path: root/style/src/theme.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 04:11:24 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 04:11:24 +0200
commit97555e67af8b4bcc77df69c5e72156e14948150e (patch)
tree6af3db6e439fdcb40f94ac9b1db96296fb66e86e /style/src/theme.rs
parent2933ac7355d5c14aa4f04a64a67197cd97e7608c (diff)
downloadiced-97555e67af8b4bcc77df69c5e72156e14948150e.tar.gz
iced-97555e67af8b4bcc77df69c5e72156e14948150e.tar.bz2
iced-97555e67af8b4bcc77df69c5e72156e14948150e.zip
Implement theme styling for `Container`
Diffstat (limited to '')
-rw-r--r--style/src/theme.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 3eb4ea70..0e9a5964 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -5,6 +5,7 @@ pub use self::palette::Palette;
use crate::application;
use crate::button;
use crate::checkbox;
+use crate::container;
use crate::pane_grid;
use crate::progress_bar;
use crate::radio;
@@ -127,7 +128,6 @@ impl button::StyleSheet for Theme {
/*
* Checkbox
*/
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Checkbox {
Primary,
@@ -228,6 +228,50 @@ fn checkbox_appearance(
}
/*
+ * Container
+ */
+#[derive(Clone, Copy)]
+pub enum Container {
+ Transparent,
+ Box,
+ Custom(fn(&Theme) -> container::Appearance),
+}
+
+impl Default for Container {
+ fn default() -> Self {
+ Self::Transparent
+ }
+}
+
+impl From<fn(&Theme) -> container::Appearance> for Container {
+ fn from(f: fn(&Theme) -> container::Appearance) -> Self {
+ Self::Custom(f)
+ }
+}
+
+impl container::StyleSheet for Theme {
+ type Style = Container;
+
+ fn appearance(&self, style: Self::Style) -> container::Appearance {
+ match style {
+ Container::Transparent => Default::default(),
+ Container::Box => {
+ let palette = self.extended_palette();
+
+ container::Appearance {
+ text_color: None,
+ background: palette.background.weak.color.into(),
+ border_radius: 2.0,
+ border_width: 0.0,
+ border_color: Color::TRANSPARENT,
+ }
+ }
+ Container::Custom(f) => f(self),
+ }
+ }
+}
+
+/*
* Slider
*/
impl slider::StyleSheet for Theme {