T48a Docs · Frame: a Docs tab, /docs/ and /docs/$page/, Markdown guides with a rail, an on-this-page list, previous and next and code blocks; full Rust samples are compiled examples shown as text
This commit is contained in:
1 parent
157176e2fb
commit
fba90c22e6
12 files changed
+305
-6
No files matched your search
@@ -0,0 +1,55 @@
|
||||
use ely_gpui_component::{Assets, buttons::Button, primitives::FocusScope, theme::ActiveTheme};
|
||||
use gpui::{
|
||||
App, AppContext, Context, FocusHandle, IntoElement, ParentElement, Render, Styled, Window,
|
||||
WindowOptions,
|
||||
};
|
||||
|
||||
struct Hello {
|
||||
focus: FocusHandle,
|
||||
presses: usize,
|
||||
}
|
||||
|
||||
impl Render for Hello {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let colors = &cx.theme().colors;
|
||||
let this = cx.entity();
|
||||
FocusScope::new(&self.focus)
|
||||
.root()
|
||||
.size_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap_4()
|
||||
.bg(colors.bg)
|
||||
.text_color(colors.fg)
|
||||
.child(format!("Pressed {} times", self.presses))
|
||||
.child(
|
||||
Button::new("press", "Press")
|
||||
.primary()
|
||||
.on_click(move |_, _, cx| {
|
||||
this.update(cx, |hello, cx| {
|
||||
hello.presses += 1;
|
||||
cx.notify();
|
||||
});
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
gpui_platform::application()
|
||||
.with_assets(Assets)
|
||||
.run(|cx: &mut App| {
|
||||
ely_gpui_component::init(cx);
|
||||
cx.open_window(WindowOptions::default(), |window, cx| {
|
||||
cx.new(|cx| {
|
||||
let focus = cx.focus_handle();
|
||||
window.focus(&focus, cx);
|
||||
Hello { focus, presses: 0 }
|
||||
})
|
||||
})
|
||||
.expect("window failed to open");
|
||||
cx.activate(true);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user