pub use euclid::Rect;
use crate::{
geometry::{Area, Size2D},
node::Node,
prelude::{BoxModel, Gaps},
};
#[derive(Debug, PartialEq, Clone, Default)]
pub struct NodeAreas {
pub area: Area,
pub inner_area: Area,
pub inner_sizes: Size2D,
pub margin: Gaps,
}
impl NodeAreas {
pub fn box_area(&self) -> Area {
self.area.box_area(&self.margin)
}
}
pub trait NodeKey: Clone + PartialEq + Eq + std::hash::Hash + Copy + std::fmt::Debug {}
impl NodeKey for usize {}
#[cfg(feature = "dioxus")]
impl NodeKey for dioxus_native_core::NodeId {}
pub trait DOMAdapter<NodeKey> {
fn get_node(&self, node_id: &NodeKey) -> Option<Node>;
fn height(&self, node_id: &NodeKey) -> Option<u16>;
fn parent_of(&self, node_id: &NodeKey) -> Option<NodeKey>;
fn children_of(&self, node_id: &NodeKey) -> Vec<NodeKey>;
fn is_node_valid(&self, node_id: &NodeKey) -> bool;
fn closest_common_parent(&self, node_id_a: &NodeKey, node_id_b: &NodeKey) -> Option<NodeKey>;
}