From 7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Feb 2023 12:24:13 +0100 Subject: Use `f32` in `Length::Units` and rename it to `Fixed` --- native/src/widget/toggler.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'native/src/widget/toggler.rs') diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs index f0a944a3..13d0124d 100644 --- a/native/src/widget/toggler.rs +++ b/native/src/widget/toggler.rs @@ -38,7 +38,7 @@ where on_toggle: Box Message + 'a>, label: Option, width: Length, - size: u16, + size: f32, text_size: Option, text_alignment: alignment::Horizontal, spacing: u16, @@ -52,7 +52,7 @@ where Renderer::Theme: StyleSheet, { /// The default size of a [`Toggler`]. - pub const DEFAULT_SIZE: u16 = 20; + pub const DEFAULT_SIZE: f32 = 20.0; /// Creates a new [`Toggler`]. /// @@ -85,14 +85,14 @@ where } /// Sets the size of the [`Toggler`]. - pub fn size(mut self, size: u16) -> Self { + pub fn size(mut self, size: f32) -> Self { self.size = size; self } /// Sets the width of the [`Toggler`]. - pub fn width(mut self, width: Length) -> Self { - self.width = width; + pub fn width(mut self, width: impl Into) -> Self { + self.width = width.into(); self } @@ -169,11 +169,7 @@ where ); } - row = row.push( - Row::new() - .width(Length::Units(2 * self.size)) - .height(Length::Units(self.size)), - ); + row = row.push(Row::new().width(2.0 * self.size).height(self.size)); row.layout(renderer, limits) } -- cgit From 570600ce513e7e02b23c1da8322c68fbb876d1b0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Feb 2023 16:41:18 +0100 Subject: Use `Pixels` for `Text::size` --- native/src/widget/toggler.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'native/src/widget/toggler.rs') diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs index 13d0124d..eda8f85f 100644 --- a/native/src/widget/toggler.rs +++ b/native/src/widget/toggler.rs @@ -7,8 +7,8 @@ use crate::renderer; use crate::text; use crate::widget::{self, Row, Text, Tree}; use crate::{ - Alignment, Clipboard, Element, Event, Layout, Length, Point, Rectangle, - Shell, Widget, + Alignment, Clipboard, Element, Event, Layout, Length, Pixels, Point, + Rectangle, Shell, Widget, }; pub use iced_style::toggler::{Appearance, StyleSheet}; @@ -39,7 +39,7 @@ where label: Option, width: Length, size: f32, - text_size: Option, + text_size: Option, text_alignment: alignment::Horizontal, spacing: u16, font: Renderer::Font, @@ -97,8 +97,8 @@ where } /// Sets the text size o the [`Toggler`]. - pub fn text_size(mut self, text_size: u16) -> Self { - self.text_size = Some(text_size); + pub fn text_size(mut self, text_size: impl Into) -> Self { + self.text_size = Some(text_size.into().0); self } -- cgit From 0872d078e2e3200e2aa2f5ee0005c34fff9effb7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 15:56:19 +0100 Subject: Use `Pixels` for `size` methods --- native/src/widget/toggler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/toggler.rs') diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs index eda8f85f..62bdce4a 100644 --- a/native/src/widget/toggler.rs +++ b/native/src/widget/toggler.rs @@ -85,8 +85,8 @@ where } /// Sets the size of the [`Toggler`]. - pub fn size(mut self, size: f32) -> Self { - self.size = size; + pub fn size(mut self, size: impl Into) -> Self { + self.size = size.into().0; self } -- cgit From a467a037c3aee6cf659ec11a8deb744ca0408c59 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 16:23:29 +0100 Subject: Use `Pixels` for `spacing` --- native/src/widget/toggler.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/widget/toggler.rs') diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs index 62bdce4a..a434af65 100644 --- a/native/src/widget/toggler.rs +++ b/native/src/widget/toggler.rs @@ -41,7 +41,7 @@ where size: f32, text_size: Option, text_alignment: alignment::Horizontal, - spacing: u16, + spacing: f32, font: Renderer::Font, style: ::Style, } @@ -78,7 +78,7 @@ where size: Self::DEFAULT_SIZE, text_size: None, text_alignment: alignment::Horizontal::Left, - spacing: 0, + spacing: 0.0, font: Renderer::Font::default(), style: Default::default(), } @@ -109,8 +109,8 @@ where } /// Sets the spacing between the [`Toggler`] and the text. - pub fn spacing(mut self, spacing: u16) -> Self { - self.spacing = spacing; + pub fn spacing(mut self, spacing: impl Into) -> Self { + self.spacing = spacing.into().0; self } -- cgit