2024-01-25 06:03:53 +00:00
|
|
|
use gpui::*;
|
|
|
|
|
|
|
|
struct HelloWorld {
|
|
|
|
text: SharedString,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Render for HelloWorld {
|
|
|
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
|
|
div()
|
|
|
|
.flex()
|
|
|
|
.bg(rgb(0x2e7d32))
|
2024-02-01 08:01:50 +00:00
|
|
|
.size(Length::Definite(Pixels(300.0).into()))
|
2024-01-25 06:03:53 +00:00
|
|
|
.justify_center()
|
|
|
|
.items_center()
|
2024-02-01 08:01:50 +00:00
|
|
|
.shadow_lg()
|
|
|
|
.border()
|
|
|
|
.border_color(rgb(0x0000ff))
|
2024-01-25 06:03:53 +00:00
|
|
|
.text_xl()
|
|
|
|
.text_color(rgb(0xffffff))
|
|
|
|
.child(format!("Hello, {}!", &self.text))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::new().run(|cx: &mut AppContext| {
|
2024-03-05 00:08:29 +00:00
|
|
|
let options = WindowOptions {
|
|
|
|
bounds: WindowBounds::Fixed(Bounds {
|
|
|
|
size: size(px(600.0), px(600.0)).into(),
|
|
|
|
origin: Default::default(),
|
|
|
|
}),
|
|
|
|
center: true,
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
cx.open_window(options, |cx| {
|
2024-01-25 06:03:53 +00:00
|
|
|
cx.new_view(|_cx| HelloWorld {
|
|
|
|
text: "World".into(),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|