PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Tab in Full Screen Mode shows the menu bar and panels; leaving Full Screen restores them as before (#6760)
MarekSpodBiedryff5b1228c6d9
diff --git a/crates/ui-egui/src/dock_tests.rs b/crates/ui-egui/src/dock_tests.rsindex f0a64562c..a7162dc37 100644--- a/crates/ui-egui/src/dock_tests.rs+++ b/crates/ui-egui/src/dock_tests.rs@@ -943,6 +943,53 @@ fn tab_hides_all_panels_and_shift_tab_only_the_dock() {assert!(serde_json::from_value::<crate::state::Panels>(v).unwrap().dock);}+#[test]+fn tab_in_full_screen_shows_and_hides_the_chrome_and_leaving_restores_the_panels() {+ // #6760: Full Screen Mode starts with the chrome hidden; Tab shows the menu bar and panels over+ // the canvas, Tab again hides them. Tab there never touches the panels' own state, so leaving+ // Full Screen brings them back exactly as they were, however many Tabs were pressed.+ let (mut app, _, _) = app_with_layers();+ let ctx = egui::Context::default();+ let run = |app: &mut PhotocraftApp, id: &str| crate::menus::invoke(app, &ctx, id, json!({})).unwrap();+ let state = |app: &PhotocraftApp| {+ let p = &app.ui.panels;+ (p.toolbar, p.options_bar, p.dock, p.hidden_by_tab)+ };+ // Before entering: the options bar hidden by hand, then everything hidden by Tab (outside Full Screen).+ for (hide_by_hand, tab_first) in [(false, false), (true, false), (false, true)] {+ app.ui.panels = crate::state::Panels::default();+ app.ui.panels.options_bar = !hide_by_hand;+ if tab_first {+ run(&mut app, "window.togglePanels");+ }+ let before = state(&app);+ run(&mut app, "view.screenMode.fullScreen");+ assert!(!app.ui.panels.full_screen_chrome, "hidden on entry");+ run(&mut app, "window.togglePanels");+ assert!(app.ui.panels.full_screen_chrome, "Tab shows the chrome");+ assert_eq!(state(&app), before, "Tab in Full Screen leaves the panels alone");+ run(&mut app, "view.screenMode.standard");+ assert!(!app.ui.panels.full_screen_chrome);+ assert_eq!(state(&app), before, "one Tab: restored as before entering");+ run(&mut app, "view.screenMode.fullScreen");+ run(&mut app, "window.togglePanels");+ run(&mut app, "window.togglePanels");+ assert!(!app.ui.panels.full_screen_chrome, "Tab twice hides the chrome again");+ assert_eq!(state(&app), before);+ run(&mut app, "view.screenMode.standard");+ assert_eq!(state(&app), before, "two Tabs: restored as before entering");+ }+ // Entering again starts hidden, even when the last visit left the chrome shown.+ run(&mut app, "view.screenMode.fullScreen");+ run(&mut app, "window.togglePanels");+ run(&mut app, "view.screenMode.standard");+ run(&mut app, "view.screenMode.fullScreen");+ assert!(!app.ui.panels.full_screen_chrome);+ // The flag is not saved.+ let v = serde_json::to_value(&app.ui.panels).unwrap();+ assert!(v.get("full_screen_chrome").is_none());+}+/// #2726: the Navigator sizes its own preview to the group (no outer scroll area, so no scroll/// fade over the thumbnail), keeping the document's aspect, with the zoom controls below it.#[test]diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex e6685b9b7..be23de94d 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -2032,19 +2032,24 @@ impl eframe::App for PhotocraftApp {// system title bar this is where the document name lives, as the in-app title is hidden.panels::sync_window_title(self, &ctx);let chrome = !self.ui.view.hides_chrome();- if chrome && self.ui.panels.menu_bar {+ if chrome {+ self.ui.panels.full_screen_chrome = false;+ }+ // In Full Screen Mode, Tab shows the menu bar, options bar, toolbar and dock (#6760).+ let tabbed_in = !chrome && self.ui.panels.full_screen_chrome;+ if (chrome || tabbed_in) && self.ui.panels.menu_bar {panels::title_bar(self, ui);}- if chrome && self.ui.panels.options_bar {+ if (chrome && self.ui.panels.options_bar) || tabbed_in {panels::options_bar(self, ui);}if chrome && self.ui.panels.status_bar {panels::status_bar(self, ui);}- if chrome && self.ui.panels.toolbar {+ if (chrome && self.ui.panels.toolbar) || tabbed_in {panels::toolbar(self, ui);}- if chrome && self.ui.panels.dock {+ if (chrome && self.ui.panels.dock) || tabbed_in {panels::right_dock(self, ui);}let t = theme::Tokens::get(&ctx);diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex bbaf6fa6a..f6fefae46 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -580,6 +580,12 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id:}"window.togglePanels" => {// Tab hides the Tools panel, the options bar and the dock; Tab again shows what it hid.+ if app.ui.view.hides_chrome() {+ // Full Screen Mode: Tab only shows or hides the chrome for now (#6760); the panels'+ // own state, `hidden_by_tab` included, stays as it was before entering.+ app.ui.panels.full_screen_chrome = !app.ui.panels.full_screen_chrome;+ return Ok(Value::Null);+ }let p = &mut app.ui.panels;match p.hidden_by_tab.take() {Some([toolbar, options, dock]) if !(p.toolbar || p.options_bar || p.dock) => {diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex d464cb3cc..3dbfb13aa 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -404,6 +404,10 @@ pub struct Panels {/// What Tab hid (toolbar, options bar, dock), so a second Tab brings back just those.#[serde(default, skip_serializing_if = "Option::is_none")]pub hidden_by_tab: Option<[bool; 3]>,+ /// Tab in Full Screen Mode shows the menu bar, toolbar, options bar and dock over the canvas+ /// (#6760). Only a view of the moment: not saved, and the panels' own flags stay untouched.+ #[serde(skip)]+ pub full_screen_chrome: bool,/// The right dock's icon rail. An app that embeds PhotoCraft's UI can hide it for a simpler view.#[serde(default = "yes")]pub rail: bool,@@ -435,6 +439,7 @@ impl Default for Panels {toolbar_double: false,dock: true,hidden_by_tab: None,+ full_screen_chrome: false,rail: true,menu_bar: true,gradient_editor: false,diff --git a/crates/ui-egui/src/view_cmds.rs b/crates/ui-egui/src/view_cmds.rsindex 1da1f918d..ffee2ef96 100644--- a/crates/ui-egui/src/view_cmds.rs+++ b/crates/ui-egui/src/view_cmds.rs@@ -704,6 +704,8 @@ fn run(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, p: &Value) -> Resk};o.screen_mode = next.to_string();+ // Tab's view of the chrome (#6760) lasts only while in Full Screen Mode.+ app.ui.panels.full_screen_chrome = false;// Both full-screen modes take the whole display; the menu bar stays in the first.let (full_screen, maximized) = ctx.input(|i| (i.viewport().fullscreen.unwrap_or(false), i.viewport().maximized.unwrap_or(false)));let was_maximized = ctx.data(|d| d.get_temp::<bool>(was_maximized_id())).unwrap_or(false);