pub fn deferred(child: impl IntoElement) -> DeferredExpand description
Creates a Deferred element that draws child after the rest of the tree.
Use it for content that must appear on top of its surroundings, such as a popover, a menu or a
drag preview. The child takes part in layout where it is, so its size and position follow the
normal rules. Its prepaint and paint are postponed until the rest of the tree has been drawn.
The priority defaults to 0. See Deferred::priority.
ยงExample
use gpui::{
Context, IntoElement, Render, TestApp, Window, anchored, deferred, div, point, prelude::*,
px,
};
struct Overlay;
impl Render for Overlay {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div().size_full().child(
deferred(
anchored()
.position(point(px(10.), px(10.)))
.child(div().w(px(40.)).h(px(40.))),
)
.priority(1),
)
}
}
let mut app = TestApp::new();
let mut window = app.open_window(|_window, _cx| Overlay);
window.draw();