Refactor alignment types into an alignment module

This commit is contained in:
Héctor Ramón Jiménez 2021-09-20 15:09:55 +07:00
parent 5fae6e59ff
commit a0ad399622
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
54 changed files with 402 additions and 377 deletions

View file

@ -1,7 +1,8 @@
//! Write some text for your users to read.
use crate::alignment;
use crate::layout;
use crate::{
layout, Color, Element, Hasher, HorizontalAlignment, Layout, Length, Point,
Rectangle, Size, VerticalAlignment, Widget,
Color, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget,
};
pub use iced_core::text::Hit;
@ -29,8 +30,8 @@ pub struct Text<Renderer: self::Renderer> {
font: Renderer::Font,
width: Length,
height: Length,
horizontal_alignment: HorizontalAlignment,
vertical_alignment: VerticalAlignment,
horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical,
}
impl<Renderer: self::Renderer> Text<Renderer> {
@ -43,8 +44,8 @@ impl<Renderer: self::Renderer> Text<Renderer> {
font: Default::default(),
width: Length::Shrink,
height: Length::Shrink,
horizontal_alignment: HorizontalAlignment::Left,
vertical_alignment: VerticalAlignment::Top,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
}
}
@ -83,14 +84,17 @@ impl<Renderer: self::Renderer> Text<Renderer> {
/// Sets the [`HorizontalAlignment`] of the [`Text`].
pub fn horizontal_alignment(
mut self,
alignment: HorizontalAlignment,
alignment: alignment::Horizontal,
) -> Self {
self.horizontal_alignment = alignment;
self
}
/// Sets the [`VerticalAlignment`] of the [`Text`].
pub fn vertical_alignment(mut self, alignment: VerticalAlignment) -> Self {
pub fn vertical_alignment(
mut self,
alignment: alignment::Vertical,
) -> Self {
self.vertical_alignment = alignment;
self
}
@ -215,8 +219,8 @@ pub trait Renderer: crate::Renderer {
size: u16,
font: Self::Font,
color: Option<Color>,
horizontal_alignment: HorizontalAlignment,
vertical_alignment: VerticalAlignment,
horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical,
) -> Self::Output;
}