1use gpui::{
2 div, prelude::*, px, size, App, Application, Bounds, Context, Window, WindowBounds,
3 WindowOptions,
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_3()
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(
21 div()
22 .flex()
23 .gap_2()
24 .justify_between()
25 .child(
26 div()
27 .w(px(400.))
28 .border_1()
29 .border_color(gpui::blue())
30 .p_1()
31 .whitespace_nowrap()
32 .overflow_hidden()
33 .text_center()
34 .child("A long non-wrapping text align center"),
35 )
36 .child(
37 div()
38 .w_32()
39 .border_1()
40 .border_color(gpui::blue())
41 .p_1()
42 .whitespace_nowrap()
43 .overflow_hidden()
44 .text_right()
45 .child("100%"),
46 ),
47 )
48 }
49}
50
51fn main() {
52 Application::new().run(|cx: &mut App| {
53 let bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);
54 cx.open_window(
55 WindowOptions {
56 window_bounds: Some(WindowBounds::Windowed(bounds)),
57 ..Default::default()
58 },
59 |_, cx| cx.new(|_| HelloWorld {}),
60 )
61 .unwrap();
62 cx.activate(true);
63 });
64}