From 5fae6e59ffbc5913761df638dc7f0c35b7f43bc9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 20 Sep 2021 14:33:02 +0700 Subject: Introduce and use `CrossAlign` enum for `Column` and `Row` --- native/src/widget/checkbox.rs | 4 ++-- native/src/widget/column.rs | 8 ++++---- native/src/widget/container.rs | 10 +++++++--- native/src/widget/radio.rs | 6 +++--- native/src/widget/row.rs | 8 ++++---- native/src/widget/scrollable.rs | 6 +++--- native/src/widget/toggler.rs | 6 +++--- 7 files changed, 26 insertions(+), 22 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 0f21c873..e74515c6 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -8,7 +8,7 @@ use crate::row; use crate::text; use crate::touch; use crate::{ - Align, Clipboard, Color, Element, Hasher, HorizontalAlignment, Layout, + Clipboard, Color, CrossAlign, Element, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; @@ -138,7 +138,7 @@ where Row::<(), Renderer>::new() .width(self.width) .spacing(self.spacing) - .align_items(Align::Center) + .align_items(CrossAlign::Center) .push( Row::new() .width(Length::Units(self.size)) diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 52a2e80c..83e5760a 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -5,7 +5,7 @@ use crate::event::{self, Event}; use crate::layout; use crate::overlay; use crate::{ - Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point, + Clipboard, CrossAlign, Element, Hasher, Layout, Length, Padding, Point, Rectangle, Widget, }; @@ -20,7 +20,7 @@ pub struct Column<'a, Message, Renderer> { height: Length, max_width: u32, max_height: u32, - align_items: Align, + align_items: CrossAlign, children: Vec>, } @@ -41,7 +41,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { height: Length::Shrink, max_width: u32::MAX, max_height: u32::MAX, - align_items: Align::Start, + align_items: CrossAlign::Start, children, } } @@ -87,7 +87,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { } /// Sets the horizontal alignment of the contents of the [`Column`] . - pub fn align_items(mut self, align: Align) -> Self { + pub fn align_items(mut self, align: CrossAlign) -> Self { self.align_items = align; self } diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 69aee64d..ae18db25 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -5,8 +5,8 @@ use crate::event::{self, Event}; use crate::layout; use crate::overlay; use crate::{ - Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point, - Rectangle, Widget, + Align, Clipboard, CrossAlign, Element, Hasher, Layout, Length, Padding, + Point, Rectangle, Widget, }; use std::u32; @@ -143,7 +143,11 @@ where self.padding.left.into(), self.padding.top.into(), )); - content.align(self.horizontal_alignment, self.vertical_alignment, size); + content.align( + CrossAlign::from(self.horizontal_alignment), + CrossAlign::from(self.vertical_alignment), + size, + ); layout::Node::with_children(size.pad(self.padding), vec![content]) } diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index dee82d1f..1ab51051 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::{layout, Color}; use crate::{ - Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, - Point, Rectangle, Row, Text, VerticalAlignment, Widget, + Clipboard, CrossAlign, Element, Hasher, HorizontalAlignment, Layout, + Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; /// A circular button representing a choice. @@ -153,7 +153,7 @@ where Row::<(), Renderer>::new() .width(self.width) .spacing(self.spacing) - .align_items(Align::Center) + .align_items(CrossAlign::Center) .push( Row::new() .width(Length::Units(self.size)) diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 9ebc9145..e200e697 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -3,7 +3,7 @@ use crate::event::{self, Event}; use crate::layout; use crate::overlay; use crate::{ - Align, Clipboard, Element, Hasher, Layout, Length, Padding, Point, + Clipboard, CrossAlign, Element, Hasher, Layout, Length, Padding, Point, Rectangle, Widget, }; @@ -19,7 +19,7 @@ pub struct Row<'a, Message, Renderer> { height: Length, max_width: u32, max_height: u32, - align_items: Align, + align_items: CrossAlign, children: Vec>, } @@ -40,7 +40,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { height: Length::Shrink, max_width: u32::MAX, max_height: u32::MAX, - align_items: Align::Start, + align_items: CrossAlign::Start, children, } } @@ -86,7 +86,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { } /// Sets the vertical alignment of the contents of the [`Row`] . - pub fn align_items(mut self, align: Align) -> Self { + pub fn align_items(mut self, align: CrossAlign) -> Self { self.align_items = align; self } diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 68da2e67..0a2155cc 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -6,8 +6,8 @@ use crate::mouse; use crate::overlay; use crate::touch; use crate::{ - Align, Clipboard, Column, Element, Hasher, Layout, Length, Padding, Point, - Rectangle, Size, Vector, Widget, + Clipboard, Column, CrossAlign, Element, Hasher, Layout, Length, Padding, + Point, Rectangle, Size, Vector, Widget, }; use std::{f32, hash::Hash, u32}; @@ -84,7 +84,7 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> { } /// Sets the horizontal alignment of the contents of the [`Scrollable`] . - pub fn align_items(mut self, align_items: Align) -> Self { + pub fn align_items(mut self, align_items: CrossAlign) -> Self { self.content = self.content.align_items(align_items); self } diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs index 4035276c..34dc52a0 100644 --- a/native/src/widget/toggler.rs +++ b/native/src/widget/toggler.rs @@ -2,8 +2,8 @@ use std::hash::Hash; use crate::{ - event, layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher, - HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, + event, layout, mouse, row, text, Clipboard, CrossAlign, Element, Event, + Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; @@ -132,7 +132,7 @@ where let mut row = Row::<(), Renderer>::new() .width(self.width) .spacing(self.spacing) - .align_items(Align::Center); + .align_items(CrossAlign::Center); if let Some(label) = &self.label { row = row.push( -- cgit