vizia_core/layout/
cache.rs
1use crate::cache::CachedData;
2use morphorm::Cache;
3
4use crate::prelude::*;
5use bitflags::bitflags;
6
7bitflags! {
8 #[derive(Debug, Clone, Copy)]
10 pub struct GeoChanged: u8 {
11 const POSX_CHANGED = 1 << 0;
13 const POSY_CHANGED = 1 << 1;
15 const WIDTH_CHANGED = 1 << 2;
17 const HEIGHT_CHANGED = 1 << 3;
19 }
20}
21
22impl Cache for CachedData {
23 type Node = Entity;
24
25 fn set_bounds(&mut self, node: &Self::Node, posx: f32, posy: f32, width: f32, height: f32) {
26 if let Some(bounds) = self.relative_bounds.get_mut(*node) {
27 bounds.x = posx.round();
28 bounds.y = posy.round();
29 bounds.w = width;
30 bounds.h = height;
31 }
32 }
33
34 fn posx(&self, node: &Self::Node) -> f32 {
35 self.get_posx(*node)
36 }
37
38 fn posy(&self, node: &Self::Node) -> f32 {
39 self.get_posy(*node)
40 }
41
42 fn width(&self, node: &Self::Node) -> f32 {
43 self.get_width(*node)
44 }
45
46 fn height(&self, node: &Self::Node) -> f32 {
47 self.get_height(*node)
48 }
49}