Function collect_hit_rects

Source
pub fn collect_hit_rects<A>(tree: &ElementTree<A>) -> Vec<(ElementId, Rect)>
Expand description

Collects the local paint bounds of every element with committed layout.

Elements without a crate::layout::LayoutResult are omitted. Returned rectangles remain in their element’s local logical-pixel coordinate space; use absolute_paint_bounds when global coordinates are required. Because the retained tree uses hash-map storage, output order is unspecified.

§Examples

use ailloli_ui_core::Rect;
use ailloli_ui_runtime::{element::{ElementKind, ElementTree}, input::collect_hit_rects, layout::LayoutResult};
let mut tree = ElementTree::<()>::new();
let root = tree.create_element(ElementKind::Empty, None, None);
let mut layout = LayoutResult::empty();
layout.paint_bounds = Rect::new(1.0, 2.0, 30.0, 20.0);
tree.get_mut(root).unwrap().layout = Some(layout);
assert_eq!(collect_hit_rects(&tree), vec![(root, Rect::new(1.0, 2.0, 30.0, 20.0))]);