ZIm/crates/gpui/examples/shadow.rs
Marshall Bowers a8afc63a91
gpui: Remove use of use gpui::* in examples (#22311)
This PR removes the use of `use gpui::*` in the GPUI examples, as this
is not how consumers should be importing GPUI.

Release Notes:

- N/A
2024-12-20 23:09:30 +00:00

32 lines
837 B
Rust

use gpui::{
div, prelude::*, px, rgb, size, App, AppContext, Bounds, ViewContext, WindowBounds,
WindowOptions,
};
struct Shadow {}
impl Render for Shadow {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.flex()
.bg(rgb(0xffffff))
.size_full()
.justify_center()
.items_center()
.child(div().size_8().shadow_sm())
}
}
fn main() {
App::new().run(|cx: &mut AppContext| {
let bounds = Bounds::centered(None, size(px(300.0), px(300.0)), cx);
cx.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(bounds)),
..Default::default()
},
|cx| cx.new_view(|_cx| Shadow {}),
)
.unwrap();
});
}