1use gpui::{
2 App, Application, Bounds, Context, FontStyle, FontWeight, StyledText, Window, WindowBounds,
3 WindowOptions, div, prelude::*, px, size,
4};
5
6struct HelloWorld {}
7
8impl Render for HelloWorld {
9 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
10 div()
11 .bg(gpui::white())
12 .flex()
13 .flex_col()
14 .gap_2()
15 .p_4()
16 .size_full()
17 .child(div().child("Text left"))
18 .child(div().text_center().child("Text center"))
19 .child(div().text_right().child("Text right"))
20 .child(div().text_decoration_1().child("Text left (underline)"))
21 .child(
22 div()
23 .text_center()
24 .text_decoration_1()
25 .child("Text center (underline)"),
26 )
27 .child(
28 div()
29 .text_right()
30 .text_decoration_1()
31 .child("Text right (underline)"),
32 )
33 .child(div().line_through().child("Text left (line_through)"))
34 .child(
35 div()
36 .text_center()
37 .line_through()
38 .child("Text center (line_through)"),
39 )
40 .child(
41 div()
42 .text_right()
43 .line_through()
44 .child("Text right (line_through)"),
45 )
46 .child(
47 div()
48 .flex()
49 .gap_2()
50 .justify_between()
51 .child(
52 div()
53 .w(px(400.))
54 .border_1()
55 .border_color(gpui::blue())
56 .p_1()
57 .whitespace_nowrap()
58 .overflow_hidden()
59 .text_center()
60 .child("A long non-wrapping text align center"),
61 )
62 .child(
63 div()
64 .w_32()
65 .border_1()
66 .border_color(gpui::blue())
67 .p_1()
68 .whitespace_nowrap()
69 .overflow_hidden()
70 .text_right()
71 .child("100%"),
72 ),
73 )
74 .child(div().flex().gap_2().justify_between().child(
75 StyledText::new("ABCD").with_highlights([
76 (0..1, FontWeight::EXTRA_BOLD.into()),
77 (2..3, FontStyle::Italic.into()),
78 ]),
79 ))
80 }
81}
82
83fn main() {
84 Application::new().run(|cx: &mut App| {
85 let bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);
86 cx.open_window(
87 WindowOptions {
88 window_bounds: Some(WindowBounds::Windowed(bounds)),
89 ..Default::default()
90 },
91 |_, cx| cx.new(|_| HelloWorld {}),
92 )
93 .unwrap();
94 cx.activate(true);
95 });
96}