pub struct LayoutSnapshot {
pub nodes: HashMap<NodeId, LayoutNodeGeometry>,
pub constraints: HashMap<NodeId, BoxConstraints>,
pub viewport_size: LayoutSize,
}Expand description
The complete output of a layout pass.
LayoutSnapshot maps every node to its computed geometry and records the
viewport size that was used. It is the primary interface between the layout
engine and downstream consumers (the renderer, hit testing, accessibility).
§Example
use fission_layout::{LayoutSnapshot, LayoutSize};
use fission_ir::NodeId;
let snapshot = LayoutSnapshot::new(LayoutSize::new(800.0, 600.0));
assert_eq!(snapshot.viewport_size.width, 800.0);Fields§
§nodes: HashMap<NodeId, LayoutNodeGeometry>Computed geometry for every node, keyed by NodeId.
constraints: HashMap<NodeId, BoxConstraints>The constraints that were passed to each node during layout. Useful for debugging. Skipped during serialization.
viewport_size: LayoutSizeThe viewport size used for this layout pass.
Implementations§
Source§impl LayoutSnapshot
impl LayoutSnapshot
Sourcepub fn new(viewport_size: LayoutSize) -> Self
pub fn new(viewport_size: LayoutSize) -> Self
Creates an empty snapshot for the given viewport size.
Sourcepub fn get_node_geometry(&self, node_id: NodeId) -> Option<&LayoutNodeGeometry>
pub fn get_node_geometry(&self, node_id: NodeId) -> Option<&LayoutNodeGeometry>
Returns the full geometry (rect + content size) for a node, or None if
the node was not part of this layout pass.
Sourcepub fn get_node_rect(&self, node_id: NodeId) -> Option<LayoutRect>
pub fn get_node_rect(&self, node_id: NodeId) -> Option<LayoutRect>
Returns just the bounding rectangle for a node, or None if not found.
Sourcepub fn get_node_constraints(&self, node_id: NodeId) -> Option<BoxConstraints>
pub fn get_node_constraints(&self, node_id: NodeId) -> Option<BoxConstraints>
Returns the constraints that were passed to a node during layout, or None
if not found. Useful for debugging layout issues.
Trait Implementations§
Source§impl Clone for LayoutSnapshot
impl Clone for LayoutSnapshot
Source§fn clone(&self) -> LayoutSnapshot
fn clone(&self) -> LayoutSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more