diff options
author | 2021-10-31 17:02:59 +0700 | |
---|---|---|
committer | 2021-10-31 17:02:59 +0700 | |
commit | 40a5de581144886571504b762719f057dbb2e871 (patch) | |
tree | d931882c7840367c6ddd766e7d9e8cec62d0130f /native/src | |
parent | fcc282bd76c88f389d510411b0ae73e1a4eaf317 (diff) | |
download | iced-40a5de581144886571504b762719f057dbb2e871.tar.gz iced-40a5de581144886571504b762719f057dbb2e871.tar.bz2 iced-40a5de581144886571504b762719f057dbb2e871.zip |
Reintroduce `Box` for `style_sheet` in `Container`
Diffstat (limited to 'native/src')
-rw-r--r-- | native/src/widget/container.rs | 9 | ||||
-rw-r--r-- | native/src/widget/pane_grid/content.rs | 9 | ||||
-rw-r--r-- | native/src/widget/pane_grid/title_bar.rs | 9 | ||||
-rw-r--r-- | native/src/widget/tooltip.rs | 9 |
4 files changed, 24 insertions, 12 deletions
diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 006e07c6..5ad07d6d 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -28,7 +28,7 @@ pub struct Container<'a, Message, Renderer> { max_height: u32, horizontal_alignment: alignment::Horizontal, vertical_alignment: alignment::Vertical, - style_sheet: &'a dyn StyleSheet, + style_sheet: Box<dyn StyleSheet + 'a>, content: Element<'a, Message, Renderer>, } @@ -109,8 +109,11 @@ where } /// Sets the style of the [`Container`]. - pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { - self.style_sheet = style_sheet; + pub fn style( + mut self, + style_sheet: impl Into<Box<dyn StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } } diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 83d96917..d8da6d33 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -14,7 +14,7 @@ use crate::{Clipboard, Element, Hasher, Layout, Point, Rectangle, Size}; pub struct Content<'a, Message, Renderer> { title_bar: Option<TitleBar<'a, Message, Renderer>>, body: Element<'a, Message, Renderer>, - style_sheet: &'a dyn container::StyleSheet, + style_sheet: Box<dyn container::StyleSheet + 'a>, } impl<'a, Message, Renderer> Content<'a, Message, Renderer> @@ -40,8 +40,11 @@ where } /// Sets the style of the [`Content`]. - pub fn style(mut self, style_sheet: &'a dyn container::StyleSheet) -> Self { - self.style_sheet = style_sheet; + pub fn style( + mut self, + style_sheet: impl Into<Box<dyn container::StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } } diff --git a/native/src/widget/pane_grid/title_bar.rs b/native/src/widget/pane_grid/title_bar.rs index 2d66ba6c..ffd59488 100644 --- a/native/src/widget/pane_grid/title_bar.rs +++ b/native/src/widget/pane_grid/title_bar.rs @@ -17,7 +17,7 @@ pub struct TitleBar<'a, Message, Renderer> { controls: Option<Element<'a, Message, Renderer>>, padding: Padding, always_show_controls: bool, - style_sheet: &'a dyn container::StyleSheet, + style_sheet: Box<dyn container::StyleSheet + 'a>, } impl<'a, Message, Renderer> TitleBar<'a, Message, Renderer> @@ -54,8 +54,11 @@ where } /// Sets the style of the [`TitleBar`]. - pub fn style(mut self, style: &'a dyn container::StyleSheet) -> Self { - self.style_sheet = style; + pub fn style( + mut self, + style: impl Into<Box<dyn container::StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style.into(); self } diff --git a/native/src/widget/tooltip.rs b/native/src/widget/tooltip.rs index a7f3a042..5a6cd923 100644 --- a/native/src/widget/tooltip.rs +++ b/native/src/widget/tooltip.rs @@ -20,7 +20,7 @@ pub struct Tooltip<'a, Message, Renderer: text::Renderer> { content: Element<'a, Message, Renderer>, tooltip: Text<Renderer>, position: Position, - style_sheet: &'a dyn container::StyleSheet, + style_sheet: Box<dyn container::StyleSheet + 'a>, gap: u16, padding: u16, } @@ -77,8 +77,11 @@ where } /// Sets the style of the [`Tooltip`]. - pub fn style(mut self, style_sheet: &'a dyn container::StyleSheet) -> Self { - self.style_sheet = style_sheet; + pub fn style( + mut self, + style_sheet: impl Into<Box<dyn container::StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } } |