summaryrefslogtreecommitdiffstats
path: root/examples/pane_grid
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 /examples/pane_grid
parent2933ac7355d5c14aa4f04a64a67197cd97e7608c (diff)
downloadiced-97555e67af8b4bcc77df69c5e72156e14948150e.tar.gz
iced-97555e67af8b4bcc77df69c5e72156e14948150e.tar.bz2
iced-97555e67af8b4bcc77df69c5e72156e14948150e.zip
Implement theme styling for `Container`
Diffstat (limited to 'examples/pane_grid')
-rw-r--r--examples/pane_grid/src/main.rs74
1 files changed, 35 insertions, 39 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index 4c955b6a..fca1116e 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -193,9 +193,9 @@ impl Application for Example {
.controls(pane.controls.view(id, total_panes, *is_pinned))
.padding(10)
.style(if is_focused {
- style::TitleBar::Focused
+ style::title_bar_focused
} else {
- style::TitleBar::Active
+ style::title_bar_active
});
pane_grid::Content::new(Responsive::new(responsive, move |size| {
@@ -203,9 +203,9 @@ impl Application for Example {
}))
.title_bar(title_bar)
.style(if is_focused {
- style::Pane::Focused
+ style::pane_focused
} else {
- style::Pane::Active
+ style::pane_active
})
})
.width(Length::Fill)
@@ -387,51 +387,47 @@ impl Controls {
}
mod style {
- use iced::{container, Background, Color};
+ use iced::{container, Theme};
- const SURFACE: Color = Color::from_rgb(
- 0xF2 as f32 / 255.0,
- 0xF3 as f32 / 255.0,
- 0xF5 as f32 / 255.0,
- );
+ pub fn title_bar_active(theme: &Theme) -> container::Appearance {
+ let palette = theme.extended_palette();
- pub enum TitleBar {
- Active,
- Focused,
+ container::Appearance {
+ text_color: Some(palette.background.strong.text),
+ background: Some(palette.background.strong.color.into()),
+ ..Default::default()
+ }
}
- impl container::StyleSheet for TitleBar {
- fn style(&self) -> container::Style {
- let pane = match self {
- Self::Active => Pane::Active,
- Self::Focused => Pane::Focused,
- }
- .style();
+ pub fn title_bar_focused(theme: &Theme) -> container::Appearance {
+ let palette = theme.extended_palette();
- container::Style {
- text_color: Some(Color::WHITE),
- background: Some(pane.border_color.into()),
- ..Default::default()
- }
+ container::Appearance {
+ text_color: Some(palette.primary.strong.text),
+ background: Some(palette.primary.strong.color.into()),
+ ..Default::default()
}
}
- pub enum Pane {
- Active,
- Focused,
+ pub fn pane_active(theme: &Theme) -> container::Appearance {
+ let palette = theme.extended_palette();
+
+ container::Appearance {
+ background: Some(palette.background.weak.color.into()),
+ border_width: 2.0,
+ border_color: palette.background.strong.color,
+ ..Default::default()
+ }
}
- impl container::StyleSheet for Pane {
- fn style(&self) -> container::Style {
- container::Style {
- background: Some(Background::Color(SURFACE)),
- border_width: 2.0,
- border_color: match self {
- Self::Active => Color::from_rgb(0.7, 0.7, 0.7),
- Self::Focused => Color::BLACK,
- },
- ..Default::default()
- }
+ pub fn pane_focused(theme: &Theme) -> container::Appearance {
+ let palette = theme.extended_palette();
+
+ container::Appearance {
+ background: Some(palette.background.weak.color.into()),
+ border_width: 2.0,
+ border_color: palette.primary.strong.color,
+ ..Default::default()
}
}
}