diff --git a/editor/src/plugins/debug/hider.rs b/editor/src/plugins/debug/hider.rs index 2258652df2..314f2e8b00 100644 --- a/editor/src/plugins/debug/hider.rs +++ b/editor/src/plugins/debug/hider.rs @@ -1,5 +1,6 @@ use crate::objects::ID; -use ezgui::{Key, UserInput}; +use crate::plugins::PluginCtx; +use ezgui::Key; use std::collections::HashSet; pub struct Hider { @@ -17,21 +18,31 @@ impl Hider { !self.items.contains(&id) } - pub fn event(&mut self, input: &mut UserInput, selected: Option) -> bool { - if input.action_chosen("unhide everything") { - info!("Unhiding {} things", self.items.len()); - self.items.clear(); - return true; + // Weird, true here means selection state changed. + pub fn event(&mut self, ctx: &mut PluginCtx) -> bool { + if !self.items.is_empty() { + // TODO Add non-prompt lines listing how much stuff is hidden. And if the numbers + // align, "and a partridge in a pear tree..." + ctx.input.set_mode("Object Hider", &ctx.canvas); + + if ctx.input.modal_action("unhide everything") { + info!("Unhiding {} things", self.items.len()); + self.items.clear(); + return true; + } } - let item = match selected { + let item = match ctx.primary.current_selection { // No real use case for hiding moving stuff Some(ID::Car(_)) | Some(ID::Pedestrian(_)) | None => { return false; } Some(id) => id, }; - if input.contextual_action(Key::H, &format!("hide {:?}", item)) { + if ctx + .input + .contextual_action(Key::H, &format!("hide {:?}", item)) + { self.items.insert(item); info!("Hiding {:?}", item); return true; diff --git a/editor/src/plugins/debug/mod.rs b/editor/src/plugins/debug/mod.rs index 3f3e0cd8c0..5a6a486c5a 100644 --- a/editor/src/plugins/debug/mod.rs +++ b/editor/src/plugins/debug/mod.rs @@ -41,9 +41,7 @@ impl Plugin for DebugMode { fn blocking_event(&mut self, ctx: &mut PluginCtx) -> bool { // Always run ambient plugins. If either returns true, the selection state could have // changed. - if self.hider.event(ctx.input, ctx.primary.current_selection) - || self.layers.event(ctx.input) - { + if self.hider.event(ctx) || self.layers.event(ctx.input) { *ctx.recalculate_current_selection = true; ctx.primary.current_selection = None; } diff --git a/editor/src/ui.rs b/editor/src/ui.rs index d0ba107d74..2382d4ecb1 100644 --- a/editor/src/ui.rs +++ b/editor/src/ui.rs @@ -36,7 +36,6 @@ impl GUI for UI { vec![ (Key::C, "find chokepoints"), (Key::I, "validate map geometry"), - (Key::K, "unhide everything"), (Key::Num1, "show/hide buildings"), (Key::Num2, "show/hide intersections"), (Key::Num3, "show/hide lanes"), @@ -162,6 +161,7 @@ impl GUI for UI { vec![(Key::R, "quit"), (Key::L, "show route for all agents")], ), ModalMenu::new("Active Traffic Visualizer", vec![(Key::A, "quit")]), + ModalMenu::new("Object Hider", vec![(Key::K, "unhide everything")]), ] }