1use gpui::*;
2
3struct HelloWorld {}
4
5impl Render for HelloWorld {
6 fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
7 let text = "The longest word in any of the major English language δ»₯εδΈζηζ΅θ― dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.";
8 div()
9 .id("page")
10 .size_full()
11 .flex()
12 .flex_col()
13 .p_2()
14 .gap_2()
15 .bg(gpui::white())
16 .child(
17 div()
18 .flex()
19 .flex_row()
20 .gap_2()
21 .child(
22 div()
23 .flex()
24 .border_1()
25 .border_color(gpui::red())
26 .text_ellipsis()
27 .child("longer text in flex 1"),
28 )
29 .child(
30 div()
31 .flex()
32 .border_1()
33 .border_color(gpui::red())
34 .text_ellipsis()
35 .child("short flex"),
36 )
37 .child(
38 div()
39 .overflow_hidden()
40 .border_1()
41 .border_color(gpui::red())
42 .text_ellipsis()
43 .child("A short text in normal div"),
44 ),
45 )
46 .child(
47 div()
48 .text_xl()
49 .overflow_hidden()
50 .text_ellipsis()
51 .border_1()
52 .border_color(gpui::red())
53 .child("ELLIPSIS: ".to_owned() + text),
54 )
55 .child(
56 div()
57 .text_xl()
58 .overflow_hidden()
59 .truncate()
60 .border_1()
61 .border_color(gpui::green())
62 .child("TRUNCATE: ".to_owned() + text),
63 )
64 .child(
65 div()
66 .text_xl()
67 .whitespace_nowrap()
68 .overflow_hidden()
69 .border_1()
70 .border_color(gpui::blue())
71 .child("NOWRAP: ".to_owned() + text),
72 )
73 .child(div().text_xl().w_full().child(text))
74 }
75}
76
77fn main() {
78 App::new().run(|cx: &mut AppContext| {
79 let bounds = Bounds::centered(None, size(px(600.0), px(480.0)), cx);
80 cx.open_window(
81 WindowOptions {
82 window_bounds: Some(WindowBounds::Windowed(bounds)),
83 ..Default::default()
84 },
85 |cx| cx.new_view(|_cx| HelloWorld {}),
86 )
87 .unwrap();
88 });
89}