From e8273b364e74bc73bc608cd9be4351079f98245c Mon Sep 17 00:00:00 2001 From: Mollusk Date: Fri, 29 May 2026 05:10:16 -0400 Subject: [PATCH] feat(gui): Esc backs out one level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pressing Esc on the Host/View screens stops the session and returns to the menu (mirroring the '← Menu' button); on Settings it returns to the menu, or closes the theme editor back to the picker if one is open. Suppressed while a popup (colour picker, dropdown) is open so Esc just dismisses the popup there. Co-Authored-By: Claude Opus 4.8 --- src/gui/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 932644f..6e6dcd6 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -942,6 +942,28 @@ impl PixelPassApp { /// Render the current screen. Called from inside the egui frame. fn draw(&mut self, ui: &mut egui::Ui) { + // Esc backs out one level, mirroring each screen's "← Menu" button: stop + // any session and return to the menu, or (in the theme editor) close the + // editor back to the picker first so a live preview isn't left applied. + // Suppressed while a popup (colour picker, dropdown) is open, so there + // Esc just dismisses the popup rather than also navigating. + let esc = ui.input(|i| i.key_pressed(egui::Key::Escape)); + if esc && !ui.ctx().any_popup_open() { + match self.screen { + Screen::Host => { + self.stop_host(); + self.screen = Screen::Menu; + } + Screen::Viewer => { + self.stop_viewer(); + self.screen = Screen::Menu; + } + Screen::Settings if self.theme.editing => self.cancel_theme_edit(), + Screen::Settings => self.screen = Screen::Menu, + Screen::Menu => {} + } + } + // Apply whichever theme should be visible this frame. While the editor // is open its draft is previewed live; otherwise the active theme is // applied once (when dirty) and then sticks — the egui context persists