sensors are now normal
This commit is contained in:
1 parent
8ecd8bb171
commit
fee03fddc8
7 files changed
+109
-202
No files matched your search
+5
-32
@@ -3,10 +3,9 @@ use image::DynamicImage;
|
||||
use crate::{
|
||||
core::{TextEdit, TextEditCtx},
|
||||
layout::{
|
||||
ActiveSensors, Layers, PainterCtx, Sensor, SensorMap, StaticWidgetId, TextData,
|
||||
TextureHandle, Textures, Vec2, Widget, WidgetId, WidgetInstance, WidgetLike,
|
||||
Layers, PainterCtx, Sensor, SensorMap, StaticWidgetId, TextData, TextureHandle, Textures,
|
||||
Vec2, Widget, WidgetId, WidgetInstance, WidgetLike,
|
||||
},
|
||||
render::Primitives,
|
||||
util::{DynBorrower, HashMap, HashSet, Id, IdTracker},
|
||||
};
|
||||
use std::{
|
||||
@@ -23,12 +22,12 @@ pub struct Ui<Ctx> {
|
||||
pub(super) send: Sender<Id>,
|
||||
size: Vec2,
|
||||
// TODO: make these non pub(crate)
|
||||
pub(crate) layers: Layers<Primitives>,
|
||||
pub(crate) layers: Layers,
|
||||
pub(crate) textures: Textures,
|
||||
pub(crate) text: TextData,
|
||||
full_redraw: bool,
|
||||
|
||||
pub(crate) active: Active,
|
||||
pub(crate) active: ActiveWidgets,
|
||||
pub(super) sensor_map: SensorMap<Ctx>,
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ impl<Ctx> Ui<Ctx> {
|
||||
}
|
||||
|
||||
pub fn active_widgets(&self) -> usize {
|
||||
self.active.widgets.len()
|
||||
self.active.len()
|
||||
}
|
||||
|
||||
pub fn add_sensor<W>(&mut self, id: &WidgetId<W>, f: Sensor<Ctx>) {
|
||||
@@ -357,29 +356,3 @@ impl<Ctx> Default for Ui<Ctx> {
|
||||
}
|
||||
|
||||
pub type ActiveWidgets = HashMap<Id, WidgetInstance>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Active {
|
||||
pub sensors: ActiveSensors,
|
||||
pub widgets: ActiveWidgets,
|
||||
}
|
||||
|
||||
impl Active {
|
||||
pub fn clear(&mut self) {
|
||||
self.sensors.clear();
|
||||
self.widgets.clear();
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, id: &Id) -> Option<WidgetInstance> {
|
||||
let instance = self.widgets.remove(id);
|
||||
self.sensors.remove(id);
|
||||
instance
|
||||
}
|
||||
|
||||
pub fn add(&mut self, id: &Id, instance: WidgetInstance, widgets: &Widgets) {
|
||||
if widgets.data(id).is_some_and(|w| w.sensor) {
|
||||
self.sensors.insert(id.duplicate(), instance.region);
|
||||
}
|
||||
self.widgets.insert(id.duplicate(), instance);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user