summaryrefslogtreecommitdiffstats
path: root/native/src/widget/container.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-20 15:09:55 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-20 15:14:08 +0700
commita0ad3996225601aaa1ebe051cba115374b55c80e (patch)
tree8420a91cd319a63b1ed257a6334453a1a673bdfb /native/src/widget/container.rs
parent5fae6e59ffbc5913761df638dc7f0c35b7f43bc9 (diff)
downloadiced-a0ad3996225601aaa1ebe051cba115374b55c80e.tar.gz
iced-a0ad3996225601aaa1ebe051cba115374b55c80e.tar.bz2
iced-a0ad3996225601aaa1ebe051cba115374b55c80e.zip
Refactor alignment types into an `alignment` module
Diffstat (limited to 'native/src/widget/container.rs')
-rw-r--r--native/src/widget/container.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs
index ae18db25..0e86ab62 100644
--- a/native/src/widget/container.rs
+++ b/native/src/widget/container.rs
@@ -1,12 +1,13 @@
//! Decorate content and apply alignment.
use std::hash::Hash;
+use crate::alignment::{self, Alignment};
use crate::event::{self, Event};
use crate::layout;
use crate::overlay;
use crate::{
- Align, Clipboard, CrossAlign, Element, Hasher, Layout, Length, Padding,
- Point, Rectangle, Widget,
+ Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
+ Widget,
};
use std::u32;
@@ -21,8 +22,8 @@ pub struct Container<'a, Message, Renderer: self::Renderer> {
height: Length,
max_width: u32,
max_height: u32,
- horizontal_alignment: Align,
- vertical_alignment: Align,
+ horizontal_alignment: alignment::Horizontal,
+ vertical_alignment: alignment::Vertical,
style: Renderer::Style,
content: Element<'a, Message, Renderer>,
}
@@ -42,8 +43,8 @@ where
height: Length::Shrink,
max_width: u32::MAX,
max_height: u32::MAX,
- horizontal_alignment: Align::Start,
- vertical_alignment: Align::Start,
+ horizontal_alignment: alignment::Horizontal::Left,
+ vertical_alignment: alignment::Vertical::Top,
style: Renderer::Style::default(),
content: content.into(),
}
@@ -80,26 +81,26 @@ where
}
/// Sets the content alignment for the horizontal axis of the [`Container`].
- pub fn align_x(mut self, alignment: Align) -> Self {
+ pub fn align_x(mut self, alignment: alignment::Horizontal) -> Self {
self.horizontal_alignment = alignment;
self
}
/// Sets the content alignment for the vertical axis of the [`Container`].
- pub fn align_y(mut self, alignment: Align) -> Self {
+ pub fn align_y(mut self, alignment: alignment::Vertical) -> Self {
self.vertical_alignment = alignment;
self
}
/// Centers the contents in the horizontal axis of the [`Container`].
pub fn center_x(mut self) -> Self {
- self.horizontal_alignment = Align::Center;
+ self.horizontal_alignment = alignment::Horizontal::Center;
self
}
/// Centers the contents in the vertical axis of the [`Container`].
pub fn center_y(mut self) -> Self {
- self.vertical_alignment = Align::Center;
+ self.vertical_alignment = alignment::Vertical::Center;
self
}
@@ -144,8 +145,8 @@ where
self.padding.top.into(),
));
content.align(
- CrossAlign::from(self.horizontal_alignment),
- CrossAlign::from(self.vertical_alignment),
+ Alignment::from(self.horizontal_alignment),
+ Alignment::from(self.vertical_alignment),
size,
);