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) -> LayoutSnapshot
pub fn new(viewport_size: LayoutSize) -> LayoutSnapshot
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 moreSource§impl Debug for LayoutSnapshot
impl Debug for LayoutSnapshot
Source§impl Default for LayoutSnapshot
impl Default for LayoutSnapshot
Source§fn default() -> LayoutSnapshot
fn default() -> LayoutSnapshot
Source§impl<'de> Deserialize<'de> for LayoutSnapshot
impl<'de> Deserialize<'de> for LayoutSnapshot
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutSnapshot, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutSnapshot, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for LayoutSnapshot
impl PartialEq for LayoutSnapshot
Source§impl Serialize for LayoutSnapshot
impl Serialize for LayoutSnapshot
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for LayoutSnapshot
Auto Trait Implementations§
impl Freeze for LayoutSnapshot
impl RefUnwindSafe for LayoutSnapshot
impl Send for LayoutSnapshot
impl Sync for LayoutSnapshot
impl Unpin for LayoutSnapshot
impl UnsafeUnpin for LayoutSnapshot
impl UnwindSafe for LayoutSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.