From 54a9a232f8110364972a8eef966b7b7477573f4f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 14:48:33 +0700 Subject: Draw scrollbar in `Widget::draw` for `Scrollable` --- web/src/widget/scrollable.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/scrollable.rs b/web/src/widget/scrollable.rs index 847bf5a0..595eb26e 100644 --- a/web/src/widget/scrollable.rs +++ b/web/src/widget/scrollable.rs @@ -14,7 +14,7 @@ pub struct Scrollable<'a, Message> { max_height: u32, content: Column<'a, Message>, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } impl<'a, Message> Scrollable<'a, Message> { @@ -27,7 +27,7 @@ impl<'a, Message> Scrollable<'a, Message> { height: Length::Shrink, max_height: u32::MAX, content: Column::new(), - style: Default::default(), + style_sheet: Default::default(), } } @@ -78,8 +78,11 @@ impl<'a, Message> Scrollable<'a, Message> { } /// Sets the style of the [`Scrollable`] . - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style<'b>(mut self, style_sheet: &'b dyn StyleSheet) -> Self + where + 'b: 'a, + { + self.style_sheet = style_sheet; self } -- cgit 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` --- web/src/widget/container.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index 24aa7cef..e61600c4 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -19,7 +19,7 @@ pub struct Container<'a, Message> { max_height: u32, horizontal_alignment: alignment::Horizontal, vertical_alignment: alignment::Vertical, - style_sheet: Box, + style_sheet: &'a dyn StyleSheet, content: Element<'a, Message>, } @@ -89,8 +89,8 @@ impl<'a, Message> Container<'a, Message> { } /// Sets the style of the [`Container`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style_sheet = style.into(); + pub fn style(mut self, style: &'a dyn StyleSheet) -> Self { + self.style_sheet = style; self } } -- 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` --- web/src/widget/button.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/button.rs b/web/src/widget/button.rs index cd450b55..1ae78201 100644 --- a/web/src/widget/button.rs +++ b/web/src/widget/button.rs @@ -51,7 +51,7 @@ pub struct Button<'a, Message> { #[allow(dead_code)] min_height: u32, padding: Padding, - style: Box, + style: &'a dyn StyleSheet, } impl<'a, Message> Button<'a, Message> { @@ -104,8 +104,8 @@ impl<'a, Message> Button<'a, Message> { } /// Sets the style of the [`Button`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style(mut self, style: &'a dyn StyleSheet) -> Self { + self.style = style; self } -- cgit From 11bcb1342796a6fabc7c5b89a15c22c754b014ce Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 15:50:42 +0700 Subject: Wire up styling to `Slider` in `iced_native` --- web/src/widget/slider.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/slider.rs b/web/src/widget/slider.rs index f457aa4c..7ec84475 100644 --- a/web/src/widget/slider.rs +++ b/web/src/widget/slider.rs @@ -41,7 +41,7 @@ pub struct Slider<'a, T, Message> { #[allow(dead_code)] width: Length, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } impl<'a, T, Message> Slider<'a, T, Message> @@ -85,7 +85,7 @@ where step: T::from(1), on_change: Rc::new(Box::new(on_change)), width: Length::Fill, - style: Default::default(), + style_sheet: Default::default(), } } @@ -96,8 +96,8 @@ where } /// Sets the style of the [`Slider`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + self.style_sheet = style_sheet.into(); self } -- cgit From e914888f57394e4b67b40e42f1ad9df4ae8147e6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 18:40:39 +0700 Subject: Implement `Widget::draw` for `TextInput` --- web/src/widget/text_input.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/text_input.rs b/web/src/widget/text_input.rs index e4877f2a..99f765bb 100644 --- a/web/src/widget/text_input.rs +++ b/web/src/widget/text_input.rs @@ -39,7 +39,7 @@ pub struct TextInput<'a, Message> { size: Option, on_change: Rc Message>>, on_submit: Option, - style_sheet: Box, + style_sheet: &'a dyn StyleSheet, } impl<'a, Message> TextInput<'a, Message> { @@ -112,8 +112,8 @@ impl<'a, Message> TextInput<'a, Message> { } /// Sets the style of the [`TextInput`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style_sheet = style.into(); + pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + self.style_sheet = style_sheet; self } } -- cgit From d39ad717ed0ab85acbe935d7ab883166b36e7bc7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 19:06:53 +0700 Subject: Wire up styling to `Radio` in `iced_native` --- web/src/widget/radio.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/radio.rs b/web/src/widget/radio.rs index fbc88d29..5e9eaa3f 100644 --- a/web/src/widget/radio.rs +++ b/web/src/widget/radio.rs @@ -31,17 +31,17 @@ use dodrio::bumpalo; /// /// ![Radio buttons drawn by Coffee's renderer](https://github.com/hecrj/coffee/blob/bda9818f823dfcb8a7ad0ff4940b4d4b387b5208/images/ui/radio.png?raw=true) #[allow(missing_debug_implementations)] -pub struct Radio { +pub struct Radio<'a, Message> { is_selected: bool, on_click: Message, label: String, id: Option, name: Option, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } -impl Radio { +impl<'a, Message> Radio<'a, Message> { /// Creates a new [`Radio`] button. /// /// It expects: @@ -66,13 +66,13 @@ impl Radio { label: label.into(), id: None, name: None, - style: Default::default(), + style_sheet: Default::default(), } } /// Sets the style of the [`Radio`] button. - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + self.style_sheet = style_sheet; self } @@ -89,7 +89,7 @@ impl Radio { } } -impl Widget for Radio +impl<'a, Message> Widget for Radio<'a, Message> where Message: 'static + Clone, { @@ -142,11 +142,11 @@ where } } -impl<'a, Message> From> for Element<'a, Message> +impl<'a, Message> From> for Element<'a, Message> where Message: 'static + Clone, { - fn from(radio: Radio) -> Element<'a, Message> { + fn from(radio: Radio<'a, Message>) -> Element<'a, Message> { Element::new(radio) } } -- cgit From 7c08c6bd138207b862933ee479752a4f1d18c4f2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 Oct 2021 18:50:27 +0700 Subject: Remove `Renderer` trait for `Checkbox` --- web/src/widget/checkbox.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 43110aa7..095ef47d 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -24,17 +24,17 @@ use std::rc::Rc; /// /// ![Checkbox drawn by Coffee's renderer](https://github.com/hecrj/coffee/blob/bda9818f823dfcb8a7ad0ff4940b4d4b387b5208/images/ui/checkbox.png?raw=true) #[allow(missing_debug_implementations)] -pub struct Checkbox { +pub struct Checkbox<'a, Message> { is_checked: bool, on_toggle: Rc Message>, label: String, id: Option, width: Length, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } -impl Checkbox { +impl<'a, Message> Checkbox<'a, Message> { /// Creates a new [`Checkbox`]. /// /// It expects: @@ -53,7 +53,7 @@ impl Checkbox { label: label.into(), id: None, width: Length::Shrink, - style: Default::default(), + style_sheet: Default::default(), } } @@ -64,8 +64,8 @@ impl Checkbox { } /// Sets the style of the [`Checkbox`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + self.style_sheet = style_sheet; self } @@ -76,7 +76,7 @@ impl Checkbox { } } -impl Widget for Checkbox +impl<'a, Message> Widget for Checkbox<'a, Message> where Message: 'static, { @@ -137,11 +137,11 @@ where } } -impl<'a, Message> From> for Element<'a, Message> +impl<'a, Message> From> for Element<'a, Message> where Message: 'static, { - fn from(checkbox: Checkbox) -> Element<'a, Message> { + fn from(checkbox: Checkbox<'a, Message>) -> Element<'a, Message> { Element::new(checkbox) } } -- 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` --- web/src/widget/button.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/button.rs b/web/src/widget/button.rs index 1ae78201..88137607 100644 --- a/web/src/widget/button.rs +++ b/web/src/widget/button.rs @@ -51,7 +51,7 @@ pub struct Button<'a, Message> { #[allow(dead_code)] min_height: u32, padding: Padding, - style: &'a dyn StyleSheet, + style: Box, } impl<'a, Message> Button<'a, Message> { @@ -104,8 +104,8 @@ impl<'a, Message> Button<'a, Message> { } /// Sets the style of the [`Button`]. - pub fn style(mut self, style: &'a dyn StyleSheet) -> Self { - self.style = style; + pub fn style(mut self, style: impl Into>) -> Self { + self.style = style.into(); self } -- cgit From fcc282bd76c88f389d510411b0ae73e1a4eaf317 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 16:58:02 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Checkbox` --- web/src/widget/checkbox.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 095ef47d..844bf862 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -31,7 +31,7 @@ pub struct Checkbox<'a, Message> { id: Option, width: Length, #[allow(dead_code)] - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, Message> Checkbox<'a, Message> { @@ -64,8 +64,11 @@ impl<'a, Message> Checkbox<'a, Message> { } /// Sets the style of the [`Checkbox`]. - 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>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } -- 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` --- web/src/widget/container.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index e61600c4..8e345b9a 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -19,7 +19,7 @@ pub struct Container<'a, Message> { max_height: u32, horizontal_alignment: alignment::Horizontal, vertical_alignment: alignment::Vertical, - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, content: Element<'a, Message>, } @@ -89,8 +89,8 @@ impl<'a, Message> Container<'a, Message> { } /// Sets the style of the [`Container`]. - pub fn style(mut self, style: &'a dyn StyleSheet) -> Self { - self.style_sheet = style; + pub fn style(mut self, style: impl Into>) -> Self { + self.style_sheet = style.into(); self } } -- cgit From d758006ee91aa0fdb70eaa67abbfad36be02c7be Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:08:19 +0700 Subject: Introduce state lifetime for `style_sheet` in `ProgressBar` --- web/src/widget/progress_bar.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/progress_bar.rs b/web/src/widget/progress_bar.rs index 7d77616e..01f412f8 100644 --- a/web/src/widget/progress_bar.rs +++ b/web/src/widget/progress_bar.rs @@ -18,15 +18,15 @@ use std::ops::RangeInclusive; /// /// ![Progress bar](https://user-images.githubusercontent.com/18618951/71662391-a316c200-2d51-11ea-9cef-52758cab85e3.png) #[allow(missing_debug_implementations)] -pub struct ProgressBar { +pub struct ProgressBar<'a> { range: RangeInclusive, value: f32, width: Length, height: Option, - style: Box, + style: Box, } -impl ProgressBar { +impl<'a> ProgressBar<'a> { /// Creates a new [`ProgressBar`]. /// /// It expects: @@ -61,7 +61,7 @@ impl ProgressBar { } } -impl Widget for ProgressBar { +impl<'a, Message> Widget for ProgressBar<'a> { fn node<'b>( &self, bump: &'b bumpalo::Bump, @@ -106,11 +106,11 @@ impl Widget for ProgressBar { } } -impl<'a, Message> From for Element<'a, Message> +impl<'a, Message> From> for Element<'a, Message> where Message: 'static, { - fn from(container: ProgressBar) -> Element<'a, Message> { + fn from(container: ProgressBar<'a>) -> Element<'a, Message> { Element::new(container) } } -- cgit From bd7b086ec1f9d428945f05fb12bda157f9e77dfd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:14:10 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Radio` --- web/src/widget/radio.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/radio.rs b/web/src/widget/radio.rs index 5e9eaa3f..03b2922b 100644 --- a/web/src/widget/radio.rs +++ b/web/src/widget/radio.rs @@ -38,7 +38,7 @@ pub struct Radio<'a, Message> { id: Option, name: Option, #[allow(dead_code)] - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, Message> Radio<'a, Message> { @@ -71,8 +71,11 @@ impl<'a, Message> Radio<'a, Message> { } /// Sets the style of the [`Radio`] button. - 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>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } -- cgit From eed19dcf81334d0849744f1918ba880d5a7acc1c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:39:24 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Scrollable` --- web/src/widget/scrollable.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/scrollable.rs b/web/src/widget/scrollable.rs index 595eb26e..22cb61be 100644 --- a/web/src/widget/scrollable.rs +++ b/web/src/widget/scrollable.rs @@ -14,7 +14,7 @@ pub struct Scrollable<'a, Message> { max_height: u32, content: Column<'a, Message>, #[allow(dead_code)] - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, Message> Scrollable<'a, Message> { @@ -78,11 +78,11 @@ impl<'a, Message> Scrollable<'a, Message> { } /// Sets the style of the [`Scrollable`] . - pub fn style<'b>(mut self, style_sheet: &'b dyn StyleSheet) -> Self - where - 'b: 'a, - { - self.style_sheet = style_sheet; + pub fn style( + mut self, + style_sheet: impl Into>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } -- cgit From 0c76e0307ff7d4450c354812f8a25047f24948b4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:42:43 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Slider` --- web/src/widget/slider.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/slider.rs b/web/src/widget/slider.rs index 7ec84475..8cbf5bd0 100644 --- a/web/src/widget/slider.rs +++ b/web/src/widget/slider.rs @@ -41,7 +41,7 @@ pub struct Slider<'a, T, Message> { #[allow(dead_code)] width: Length, #[allow(dead_code)] - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, T, Message> Slider<'a, T, Message> @@ -96,7 +96,10 @@ where } /// Sets the style of the [`Slider`]. - pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + pub fn style( + mut self, + style_sheet: impl Into>, + ) -> Self { self.style_sheet = style_sheet.into(); self } -- cgit From 0d3c9ef7bd3d0a0abecdf8e8b5391e32773ca20e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:45:57 +0700 Subject: Reintroduce `Box` for `style_sheet` in `TextInput` --- web/src/widget/text_input.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/text_input.rs b/web/src/widget/text_input.rs index 99f765bb..c5874485 100644 --- a/web/src/widget/text_input.rs +++ b/web/src/widget/text_input.rs @@ -39,7 +39,7 @@ pub struct TextInput<'a, Message> { size: Option, on_change: Rc Message>>, on_submit: Option, - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, Message> TextInput<'a, Message> { @@ -112,8 +112,11 @@ impl<'a, Message> TextInput<'a, Message> { } /// Sets the style of the [`TextInput`]. - 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>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } } -- cgit