GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
feat(scene): paint_root_into for composing multiple top-level widgets (Phase 3)
Expose paint_root_into(ui, root, &mut PaintCtx) so apps that compose several top-level widgets plus their own chrome (rather than one root_window tree) can build a single DisplayList. paint_tree now delegates to it.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
src/scene/painter.rs | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/scene/painter.rs b/src/scene/painter.rs
index 0e36d1f..ba27589 100644
--- a/src/scene/painter.rs
+++ b/src/scene/painter.rs
@@ -25,10 +25,19 @@ type ElemPtr = *mut (dyn Element + 'static);
/// invariant the rest of the toolkit relies on for its `*mut dyn Element` tree.
pub fn paint_tree(ui: &UiContext, root: ElemPtr) -> DisplayList {
let mut pc = PaintCtx::new();
- paint_node(ui, root, &mut pc);
+ paint_root_into(ui, root, &mut pc);
pc.finish()
}
+/// Walk one root subtree into an existing [`PaintCtx`], for apps that compose several top-level
+/// widgets (and their own chrome) into a single display list rather than one `root_window` tree.
+///
+/// # Safety
+/// Same as [`paint_tree`]: `root` and its reachable subtree must be live widgets.
+pub fn paint_root_into(ui: &UiContext, root: ElemPtr, pc: &mut PaintCtx) {
+ paint_node(ui, root, pc);
+}
+
fn paint_node(ui: &UiContext, ptr: ElemPtr, pc: &mut PaintCtx) {
unsafe {
if !(*ptr).visible() {