move widgets on draw if region size is same

This commit is contained in:
2025-09-27 16:11:30 -04:00
parent 5f2dffc189
commit 95f049acb4
13 changed files with 204 additions and 176 deletions

View File

@@ -113,7 +113,7 @@ impl<Ctx: 'static> UiModule for SensorModule<Ctx> {
self.active
.entry(inst.layer)
.or_default()
.insert(inst.id.duplicate(), inst.region);
.insert(inst.id, inst.region);
}
}
@@ -126,17 +126,21 @@ impl<Ctx: 'static> UiModule for SensorModule<Ctx> {
fn on_remove(&mut self, id: &Id) {
self.map.remove(id);
}
fn on_move(&mut self, inst: &WidgetInstance) {
if let Some(map) = self.active.get_mut(&inst.layer)
&& let Some(region) = map.get_mut(&inst.id)
{
*region = inst.region;
}
}
}
impl<Ctx> SensorModule<Ctx> {
pub fn merge(&mut self, other: Self) {
for (id, group) in other.map {
for sensor in group.sensors {
self.map
.entry(id.duplicate())
.or_default()
.sensors
.push(sensor);
self.map.entry(id).or_default().sensors.push(sensor);
}
}
}