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/radio.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'native/src/widget/radio.rs') diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index b95ccc5b..22aeb4ce 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -50,7 +50,7 @@ where on_click: Message, label: String, width: Length, - size: u16, + size: f32, spacing: u16, text_size: Option, font: Renderer::Font, @@ -64,7 +64,7 @@ where Renderer::Theme: StyleSheet, { /// The default size of a [`Radio`] button. - pub const DEFAULT_SIZE: u16 = 28; + pub const DEFAULT_SIZE: f32 = 28.0; /// The default spacing of a [`Radio`] button. pub const DEFAULT_SPACING: u16 = 15; @@ -101,14 +101,14 @@ where } /// Sets the size of the [`Radio`] button. - 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 [`Radio`] button. - 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 } @@ -163,11 +163,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).width(self.width).size( self.text_size.unwrap_or_else(|| renderer.default_size()), )) -- 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/radio.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'native/src/widget/radio.rs') diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 22aeb4ce..62bc2447 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -8,8 +8,8 @@ use crate::text; use crate::touch; use crate::widget::{self, Row, Text, Tree}; use crate::{ - Alignment, Clipboard, Color, Element, Layout, Length, Point, Rectangle, - Shell, Widget, + Alignment, Clipboard, Color, Element, Layout, Length, Pixels, Point, + Rectangle, Shell, Widget, }; pub use iced_style::radio::{Appearance, StyleSheet}; @@ -52,7 +52,7 @@ where width: Length, size: f32, spacing: u16, - text_size: Option, + text_size: Option, font: Renderer::Font, style: ::Style, } @@ -119,8 +119,8 @@ where } /// Sets the text size of the [`Radio`] button. - 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/radio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/radio.rs') diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 62bc2447..4477b810 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -101,8 +101,8 @@ where } /// Sets the size of the [`Radio`] button. - 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/radio.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/widget/radio.rs') diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 4477b810..9daddfbc 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -51,7 +51,7 @@ where label: String, width: Length, size: f32, - spacing: u16, + spacing: f32, text_size: Option, font: Renderer::Font, style: ::Style, @@ -67,7 +67,7 @@ where pub const DEFAULT_SIZE: f32 = 28.0; /// The default spacing of a [`Radio`] button. - pub const DEFAULT_SPACING: u16 = 15; + pub const DEFAULT_SPACING: f32 = 15.0; /// Creates a new [`Radio`] button. /// @@ -113,8 +113,8 @@ where } /// Sets the spacing between the [`Radio`] button 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