Skip to main content

freya_core/style/
text_align.rs

1use freya_engine::prelude::SkTextAlign;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Default, Debug, Copy, Clone, Hash, PartialEq, Eq)]
5pub enum TextAlign {
6    #[default]
7    Left = 0,
8    Right = 1,
9    Center = 2,
10    Justify = 3,
11    Start = 4,
12    End = 5,
13}
14
15impl From<TextAlign> for SkTextAlign {
16    fn from(value: TextAlign) -> Self {
17        match value {
18            TextAlign::Left => SkTextAlign::Left,
19            TextAlign::Right => SkTextAlign::Right,
20            TextAlign::Center => SkTextAlign::Center,
21            TextAlign::Justify => SkTextAlign::Justify,
22            TextAlign::Start => SkTextAlign::Start,
23            TextAlign::End => SkTextAlign::End,
24        }
25    }
26}
27
28impl TextAlign {
29    pub fn pretty(&self) -> String {
30        match self {
31            Self::Left => "left".to_string(),
32            Self::Right => "right".to_string(),
33            Self::Center => "center".to_string(),
34            Self::Justify => "justify".to_string(),
35            Self::Start => "start".to_string(),
36            Self::End => "end".to_string(),
37        }
38    }
39}