ailloli_ui_widgets/overlay/layered.rs
1//! Helpers for base + overlay scenes (correct z-order).
2
3use ailloli_ui_core::{ClipShape, Rect};
4use ailloli_ui_runtime::{DrawCmd, Scene};
5
6/// Builds a scene with a base layer then an overlay layer on top.
7///
8/// `base_clip` is an optional logical-pixel rectangular clip applied only to
9/// base commands. Overlay commands are unclipped and paint after the base;
10/// command order inside each input vector is preserved and vectors are moved.
11///
12/// # Examples
13///
14/// ```
15/// use ailloli_ui_core::Rect;
16/// use ailloli_ui_runtime::Scene;
17/// use ailloli_ui_widgets::overlay::scene_base_overlay;
18/// let scene: Scene = scene_base_overlay(Some(Rect::new(0.0, 0.0, 80.0, 40.0)), vec![], vec![]);
19/// let _ = scene;
20/// ```
21pub fn scene_base_overlay(
22 base_clip: Option<Rect>,
23 base_cmds: Vec<DrawCmd>,
24 overlay_cmds: Vec<DrawCmd>,
25) -> Scene {
26 let base_clip = base_clip.map(ClipShape::Rect);
27 Scene::from_base_and_overlay(base_clip, base_cmds, None, overlay_cmds)
28}