Use f32 in Length::Units and rename it to Fixed

This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 12:24:13 +01:00
parent f75e020257
commit 7b8b01f560
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
43 changed files with 269 additions and 262 deletions

View file

@ -6,8 +6,8 @@ use crate::overlay;
use crate::renderer;
use crate::widget::{Operation, Tree};
use crate::{
Alignment, Clipboard, Element, Layout, Length, Padding, Point, Rectangle,
Shell, Widget,
Alignment, Clipboard, Element, Layout, Length, Padding, Pixels, Point,
Rectangle, Shell, Widget,
};
/// A container that distributes its contents vertically.
@ -17,7 +17,7 @@ pub struct Column<'a, Message, Renderer> {
padding: Padding,
width: Length,
height: Length,
max_width: u32,
max_width: f32,
align_items: Alignment,
children: Vec<Element<'a, Message, Renderer>>,
}
@ -37,7 +37,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
padding: Padding::ZERO,
width: Length::Shrink,
height: Length::Shrink,
max_width: u32::MAX,
max_width: f32::INFINITY,
align_items: Alignment::Start,
children,
}
@ -60,20 +60,20 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
}
/// Sets the width of the [`Column`].
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
}
/// Sets the height of the [`Column`].
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}
/// Sets the maximum width of the [`Column`].
pub fn max_width(mut self, max_width: u32) -> Self {
self.max_width = max_width;
pub fn max_width(mut self, max_width: impl Into<Pixels>) -> Self {
self.max_width = max_width.into().0;
self
}