move widgets on draw if region size is same
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user