diff --git a/src/app.rs b/src/app.rs index 999f700..ff30ba7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1200,7 +1200,7 @@ impl SearchState { if !self.result_cache.contains_key(entry.entry_id()) { self.result_cache .entry(entry.entry_id().clone()) - .or_insert_with(BTreeMap::new); + .or_default(); } // Always recurse into tiles, because results can be fetched @@ -1222,7 +1222,7 @@ impl SearchState { .and_modify(|_| { result = false; }) - .or_insert_with(BTreeMap::new); + .or_default(); result } @@ -1258,13 +1258,8 @@ impl SearchState { let level1_index = entry_id.slot_index(1).unwrap(); let level2_index = entry_id.slot_index(2).unwrap(); - let level0_subtree = self - .entry_tree - .entry(level0_index) - .or_insert_with(BTreeMap::new); - let level1_subtree = level0_subtree - .entry(level1_index) - .or_insert_with(BTreeSet::new); + let level0_subtree = self.entry_tree.entry(level0_index).or_default(); + let level1_subtree = level0_subtree.entry(level1_index).or_default(); level1_subtree.insert(level2_index); } } @@ -1820,7 +1815,14 @@ impl ProfApp { cx.scale_factor = 1.0; } - fn keyboard(ctx: &egui::Context, cx: &mut Context) { + fn reset_ui(cx: &mut Context, windows: &mut [Window]) { + cx.show_controls = false; + for window in windows.iter_mut() { + window.config.items_selected.clear(); + } + } + + fn keyboard(ctx: &egui::Context, cx: &mut Context, windows: &mut [Window]) { // Focus is elsewhere, don't check any keys if ctx.memory(|m| m.focus().is_some()) { return; @@ -1837,6 +1839,7 @@ impl ProfApp { ShrinkVertical, ResetVertical, ToggleControls, + ResetUI, NoAction, } let action = ctx.input(|i| { @@ -1874,6 +1877,8 @@ impl ProfApp { } } else if i.key_pressed(egui::Key::H) { Actions::ToggleControls + } else if i.key_pressed(egui::Key::Escape) { + Actions::ResetUI } else if i.key_pressed(egui::Key::ArrowLeft) { Actions::Pan(Percentage::from(5), PanDirection::Left) } else if i.key_pressed(egui::Key::ArrowRight) { @@ -1893,6 +1898,7 @@ impl ProfApp { Actions::ShrinkVertical => ProfApp::multiply_scale_factor(cx, 0.5), Actions::ResetVertical => ProfApp::reset_scale_factor(cx), Actions::ToggleControls => cx.show_controls = !cx.show_controls, + Actions::ResetUI => ProfApp::reset_ui(cx, windows), Actions::NoAction => {} } } @@ -2416,7 +2422,7 @@ impl eframe::App for ProfApp { } } - Self::keyboard(ctx, cx); + Self::keyboard(ctx, cx, windows); // Keep repainting as long as we have outstanding requests. if !pending_data_sources.is_empty()