use std::collections::HashMap; use domain::WidgetId; use crate::BoundingBox; pub struct RenderTree { pub widget_bounds: HashMap, } impl RenderTree { pub fn get_widget_bounds(&self, id: WidgetId) -> Option<&BoundingBox> { self.widget_bounds.get(&id) } pub fn diff(&self, other: &RenderTree) -> Vec { let mut changed = Vec::new(); for (id, bounds) in &self.widget_bounds { match other.widget_bounds.get(id) { Some(prev) if prev == bounds => {} _ => changed.push(*id), } } for id in other.widget_bounds.keys() { if !self.widget_bounds.contains_key(id) { changed.push(*id); } } changed } }