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/checkbox.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index f6298a8c..d2b5157a 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -8,8 +8,8 @@ use crate::text; use crate::touch; use crate::widget::{self, Row, Text, Tree}; use crate::{ - Alignment, Clipboard, Element, Layout, Length, Point, Rectangle, Shell, - Widget, + Alignment, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, + Shell, Widget, }; pub use iced_style::checkbox::{Appearance, StyleSheet}; @@ -52,7 +52,7 @@ where on_toggle: Box Message + 'a>, label: String, width: Length, - size: u16, + size: f32, spacing: u16, text_size: Option, font: Renderer::Font, @@ -66,7 +66,7 @@ where Renderer::Theme: StyleSheet + widget::text::StyleSheet, { /// The default size of a [`Checkbox`]. - const DEFAULT_SIZE: u16 = 20; + const DEFAULT_SIZE: f32 = 20.0; /// The default spacing of a [`Checkbox`]. const DEFAULT_SPACING: u16 = 15; @@ -102,14 +102,14 @@ where } /// Sets the size of the [`Checkbox`]. - pub fn size(mut self, size: u16) -> Self { - self.size = size; + pub fn size(mut self, size: impl Into) -> Self { + self.size = size.into().0; self } /// Sets the width of the [`Checkbox`]. - 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 } @@ -172,11 +172,7 @@ where .width(self.width) .spacing(self.spacing) .align_items(Alignment::Center) - .push( - Row::new() - .width(Length::Units(self.size)) - .height(Length::Units(self.size)), - ) + .push(Row::new().width(self.size).height(self.size)) .push( Text::new(&self.label) .font(self.font.clone()) -- 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/checkbox.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index d2b5157a..835a0651 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -54,7 +54,7 @@ where width: Length, size: f32, spacing: u16, - text_size: Option, + text_size: Option, font: Renderer::Font, icon: Icon, style: ::Style, @@ -120,8 +120,8 @@ where } /// Sets the text size of the [`Checkbox`]. - 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 fd3a141024a11e17bba0c568f0df7ff34b79315b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 16:18:27 +0100 Subject: Use `f32` for `Icon::size` in `checkbox` --- native/src/widget/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 835a0651..dc00052d 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -15,14 +15,14 @@ use crate::{ pub use iced_style::checkbox::{Appearance, StyleSheet}; /// The icon in a [`Checkbox`]. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq)] pub struct Icon { /// Font that will be used to display the `code_point`, pub font: Font, /// The unicode code point that will be used as the icon. pub code_point: char, /// Font size of the content. - pub size: Option, + pub size: Option, } /// A box that can be checked. -- 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/checkbox.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index dc00052d..9b69e574 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -53,7 +53,7 @@ where label: String, width: Length, size: f32, - spacing: u16, + spacing: f32, text_size: Option, font: Renderer::Font, icon: Icon, @@ -69,7 +69,7 @@ where const DEFAULT_SIZE: f32 = 20.0; /// The default spacing of a [`Checkbox`]. - const DEFAULT_SPACING: u16 = 15; + const DEFAULT_SPACING: f32 = 15.0; /// Creates a new [`Checkbox`]. /// @@ -114,8 +114,8 @@ where } /// Sets the spacing between the [`Checkbox`] 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