use crate::{LayoutType, Node};
pub trait Cache {
type Node: Node;
fn width(&self, node: &Self::Node) -> f32;
fn height(&self, node: &Self::Node) -> f32;
fn posx(&self, node: &Self::Node) -> f32;
fn posy(&self, node: &Self::Node) -> f32;
fn set_bounds(&mut self, node: &Self::Node, posx: f32, posy: f32, width: f32, height: f32);
}
pub(crate) trait CacheExt: Cache {
fn set_rect(
&mut self,
node: &Self::Node,
parent_layout_type: LayoutType,
main_pos: f32,
cross_pos: f32,
main: f32,
cross: f32,
) {
match parent_layout_type {
LayoutType::Row => self.set_bounds(node, main_pos, cross_pos, main, cross),
LayoutType::Column => self.set_bounds(node, cross_pos, main_pos, cross, main),
_ => {}
}
}
}
impl<C: Cache> CacheExt for C {}