1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use iced_native::{Color, Font, HorizontalAlignment, Point, VerticalAlignment};
#[derive(Debug, Clone)]
pub struct Text {
pub content: String,
pub position: Point,
pub color: Color,
pub size: f32,
pub font: Font,
pub horizontal_alignment: HorizontalAlignment,
pub vertical_alignment: VerticalAlignment,
}
impl Default for Text {
fn default() -> Text {
Text {
content: String::new(),
position: Point::ORIGIN,
color: Color::BLACK,
size: 16.0,
font: Font::Default,
horizontal_alignment: HorizontalAlignment::Left,
vertical_alignment: VerticalAlignment::Top,
}
}
}
impl From<String> for Text {
fn from(content: String) -> Text {
Text {
content,
..Default::default()
}
}
}
impl From<&str> for Text {
fn from(content: &str) -> Text {
String::from(content).into()
}
}