From d61cb58d92b6fcd520f665deb093f3747ffd5e5c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 15:36:32 +0700 Subject: Wire up `container` styling to `iced_native` --- examples/pane_grid/src/main.rs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'examples/pane_grid') diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 69872bad..844b604d 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -177,7 +177,11 @@ impl Application for Example { let title_bar = pane_grid::TitleBar::new(title) .controls(pane.controls.view(id, total_panes, pane.is_pinned)) .padding(10) - .style(style::TitleBar { is_focused }); + .style(if is_focused { + &style::TitleBar::Focused + } else { + &style::TitleBar::Active + }); pane_grid::Content::new(pane.content.view( id, @@ -185,7 +189,11 @@ impl Application for Example { pane.is_pinned, )) .title_bar(title_bar) - .style(style::Pane { is_focused }) + .style(if is_focused { + &style::Pane::Focused + } else { + &style::Pane::Active + }) }) .width(Length::Fill) .height(Length::Fill) @@ -387,14 +395,16 @@ mod style { 0xC4 as f32 / 255.0, ); - pub struct TitleBar { - pub is_focused: bool, + pub enum TitleBar { + Active, + Focused, } impl container::StyleSheet for TitleBar { fn style(&self) -> container::Style { - let pane = Pane { - is_focused: self.is_focused, + let pane = match self { + Self::Active => Pane::Active, + Self::Focused => Pane::Focused, } .style(); @@ -406,8 +416,9 @@ mod style { } } - pub struct Pane { - pub is_focused: bool, + pub enum Pane { + Active, + Focused, } impl container::StyleSheet for Pane { @@ -415,10 +426,9 @@ mod style { container::Style { background: Some(Background::Color(SURFACE)), border_width: 2.0, - border_color: if self.is_focused { - Color::BLACK - } else { - Color::from_rgb(0.7, 0.7, 0.7) + border_color: match self { + Self::Active => Color::from_rgb(0.7, 0.7, 0.7), + Self::Focused => Color::BLACK, }, ..Default::default() } -- cgit From 3140cdc4babcefc444f1c1d30eb0f5f4ed1df054 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 16:02:30 +0700 Subject: Wire up styling to `Button` in `iced_native` --- examples/pane_grid/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'examples/pane_grid') diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 844b604d..4126485d 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -158,7 +158,7 @@ impl Application for Example { let pin_button = Button::new(&mut pane.pin_button, Text::new(text).size(14)) .on_press(Message::TogglePin(id)) - .style(style::Button::Pin) + .style(&style::Button::Pin) .padding(3); let title = Row::with_children(vec![ @@ -316,13 +316,13 @@ impl Content { split_horizontally, "Split horizontally", Message::Split(pane_grid::Axis::Horizontal, pane), - style::Button::Primary, + &style::Button::Primary, )) .push(button( split_vertically, "Split vertically", Message::Split(pane_grid::Axis::Vertical, pane), - style::Button::Primary, + &style::Button::Primary, )); if total_panes > 1 && !is_pinned { @@ -330,7 +330,7 @@ impl Content { close, "Close", Message::Close(pane), - style::Button::Destructive, + &style::Button::Destructive, )); } @@ -364,7 +364,7 @@ impl Controls { ) -> Element { let mut button = Button::new(&mut self.close, Text::new("Close").size(14)) - .style(style::Button::Control) + .style(&style::Button::Control) .padding(3); if total_panes > 1 && !is_pinned { button = button.on_press(Message::Close(pane)); -- cgit From d36ce33a95c277ee8fe45555df17daf21ef02ef8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 16:53:18 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Button` --- examples/pane_grid/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'examples/pane_grid') diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 4126485d..844b604d 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -158,7 +158,7 @@ impl Application for Example { let pin_button = Button::new(&mut pane.pin_button, Text::new(text).size(14)) .on_press(Message::TogglePin(id)) - .style(&style::Button::Pin) + .style(style::Button::Pin) .padding(3); let title = Row::with_children(vec![ @@ -316,13 +316,13 @@ impl Content { split_horizontally, "Split horizontally", Message::Split(pane_grid::Axis::Horizontal, pane), - &style::Button::Primary, + style::Button::Primary, )) .push(button( split_vertically, "Split vertically", Message::Split(pane_grid::Axis::Vertical, pane), - &style::Button::Primary, + style::Button::Primary, )); if total_panes > 1 && !is_pinned { @@ -330,7 +330,7 @@ impl Content { close, "Close", Message::Close(pane), - &style::Button::Destructive, + style::Button::Destructive, )); } @@ -364,7 +364,7 @@ impl Controls { ) -> Element { let mut button = Button::new(&mut self.close, Text::new("Close").size(14)) - .style(&style::Button::Control) + .style(style::Button::Control) .padding(3); if total_panes > 1 && !is_pinned { button = button.on_press(Message::Close(pane)); -- cgit From 40a5de581144886571504b762719f057dbb2e871 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:02:59 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Container` --- examples/pane_grid/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/pane_grid') diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 844b604d..8225e9e7 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -178,9 +178,9 @@ impl Application for Example { .controls(pane.controls.view(id, total_panes, pane.is_pinned)) .padding(10) .style(if is_focused { - &style::TitleBar::Focused + style::TitleBar::Focused } else { - &style::TitleBar::Active + style::TitleBar::Active }); pane_grid::Content::new(pane.content.view( @@ -190,9 +190,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) -- cgit