mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-24 07:32:51 +00:00
gpui: Add hello world example (#6465)
Added hello world example to the gpui crate copied from https://gpui.rs Release Notes: - N/A
This commit is contained in:
parent
cf3b2ba146
commit
5fcc75be1f
1 changed files with 29 additions and 0 deletions
29
crates/gpui/examples/hello_world.rs
Normal file
29
crates/gpui/examples/hello_world.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
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))
|
||||
.size_full()
|
||||
.justify_center()
|
||||
.items_center()
|
||||
.text_xl()
|
||||
.text_color(rgb(0xffffff))
|
||||
.child(format!("Hello, {}!", &self.text))
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
App::new().run(|cx: &mut AppContext| {
|
||||
cx.open_window(WindowOptions::default(), |cx| {
|
||||
cx.new_view(|_cx| HelloWorld {
|
||||
text: "World".into(),
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue