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