Window
Window
represents a platform window, it allows you to control many aspects of the window's functionality.
Bounds
Gives the origin and size of the platform window.
use gpui::{AppContext, Application, Context, Empty, IntoElement, Render, Window, WindowOptions};
struct RootView;
impl Render for RootView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
Empty
}
}
fn main() {
Application::new().run(|app| {
app.open_window(WindowOptions::default(), |window, app| {
println!("{:?}", window.bounds());
app.new(|_cx| RootView)
})
.unwrap();
});
}
Mouse Position
Gives the x and y position of the mouse relative to the window.
use gpui::{AppContext, Application, Context, Empty, IntoElement, Render, Window, WindowOptions};
struct RootView;
impl Render for RootView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
Empty
}
}
fn main() {
Application::new().run(|app| {
app.open_window(WindowOptions::default(), |window, app| {
println!("{:?}", window.mouse_position());
app.new(|_cx| RootView)
})
.unwrap();
});
}