summaryrefslogtreecommitdiffstats
path: root/native/src/widget/checkbox.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-04 12:24:13 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-17 15:40:17 +0100
commit7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd (patch)
treeac9aac5eb82f175990da17813985d2f864897080 /native/src/widget/checkbox.rs
parentf75e0202575ca6e3ebf7d817eecbf51e198506fd (diff)
downloadiced-7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd.tar.gz
iced-7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd.tar.bz2
iced-7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd.zip
Use `f32` in `Length::Units` and rename it to `Fixed`
Diffstat (limited to 'native/src/widget/checkbox.rs')
-rw-r--r--native/src/widget/checkbox.rs22
1 files changed, 9 insertions, 13 deletions
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<dyn Fn(bool) -> Message + 'a>,
label: String,
width: Length,
- size: u16,
+ size: f32,
spacing: u16,
text_size: Option<u16>,
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<Pixels>) -> 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<Length>) -> 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())