delete old run_sensors
This commit is contained in:
@@ -96,49 +96,6 @@ pub struct SenseData {
|
||||
pub trait SenseFn<Ctx>: FnMut(&mut Ctx, SenseData) + 'static {}
|
||||
impl<F: FnMut(&mut Ctx, SenseData) + 'static, Ctx> SenseFn<Ctx> for F {}
|
||||
|
||||
// pub fn run_sensors<Ctx: UiCtx>(ctx: &mut Ctx, cursor: &CursorState, window_size: Vec2) {
|
||||
// let mut layers = std::mem::take(&mut ctx.ui().layers);
|
||||
// let mut map = std::mem::take(&mut ctx.ui().event_map);
|
||||
// // temp solution, should probably cache somewhere
|
||||
// let mut bruh = Vec::new();
|
||||
// for (i, _) in layers.iter_mut() {
|
||||
// bruh.push(i)
|
||||
// }
|
||||
// for i in bruh.into_iter().rev() {
|
||||
// let layer = &layers[i];
|
||||
// let mut ran = false;
|
||||
// for (id, shape) in &layer.sensors {
|
||||
// let group = &mut map.get_mut(id).unwrap();
|
||||
// let region = shape.to_screen(window_size);
|
||||
// let in_shape = cursor.exists && region.contains(cursor.pos);
|
||||
// group.hover.update(in_shape);
|
||||
// if group.hover == ActivationState::Off {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// for sensor in &mut group.sensors {
|
||||
// if should_run(&sensor.senses, &cursor.buttons, group.hover) {
|
||||
// ran = true;
|
||||
// let sctx = SenseCtx {
|
||||
// cursor: cursor.pos - region.top_left,
|
||||
// size: region.bot_right - region.top_left,
|
||||
// };
|
||||
// (sensor.f)(ctx, sctx);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if ran {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// let ui = ctx.ui();
|
||||
// std::mem::swap(&mut ui.event_map, &mut map);
|
||||
// // TODO: this removes existing sensors (if a new one is added to an id) lol
|
||||
// // the proper code is easy but writing this comment is easier and I'm tired
|
||||
// ui.event_map.extend(map);
|
||||
// ui.layers = layers;
|
||||
// }
|
||||
|
||||
pub struct SensorModule<Ctx> {
|
||||
map: SensorMap<Ctx>,
|
||||
active: HashMap<usize, HashMap<Id, SenseShape>>,
|
||||
|
||||
Reference in New Issue
Block a user