PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Title bar: dialogs no longer stop the window dragging on macOS (#5826) (#5860)
Michael Higgins3887d8f738d2
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 6f4346e06..9c75ec3a3 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1970,7 +1970,7 @@ impl eframe::App for PhotocraftApp {notices::show(self, &ctx);gpu_status::show_fallback(self, &ctx);kys_import::show_offer(self, &ctx);- if chrome && self.ui.panels.menu_bar && self.custom_titlebar && !self.ui.dialogs.is_empty() {+ if self.titlebar_modal_drag(chrome) {titlebar::modal_drag_overlay(&ctx);}if self.custom_titlebar {@@ -2041,6 +2041,14 @@ fn read_dropped(_f: &dyn egui::DroppedFile) -> Result<Vec<u8>, String> {}impl PhotocraftApp {+ /// Whether the title bar's free gap gets the drag overlay this frame: the app draws its title+ /// strip (`chrome`: not hidden by the screen mode) and a dialog's modal layer covers it. Not+ /// only with the custom title bar: on macOS the strip under the traffic lights is the window's+ /// title bar too, and an open dialog (Embedded Profile Mismatch…) left it undraggable (#5826).+ pub(crate) fn titlebar_modal_drag(&self, chrome: bool) -> bool {+ chrome && self.ui.panels.menu_bar && !self.ui.dialogs.is_empty()+ }+/// `params` aimed at the active layer's mask (`"target":"mask"`) when the Layers panel targets/// it and command `id` edits the target (adjustments, filters, fills) without naming one:/// ⌘I then inverts the mask, as in Photoshop (#780). A targeted alpha channel or Quick Maskdiff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rsindex de10ca30f..25b23ee0f 100644--- a/crates/ui-egui/src/titlebar.rs+++ b/crates/ui-egui/src/titlebar.rs@@ -538,6 +538,23 @@ mod tests {use egui::{Event, Pos2, RawInput, ViewportId};use photocraft_engine::Session;+ /// #5826: the drag overlay under a dialog doesn't depend on the custom title bar. On macOS+ /// (OS traffic lights over the app's own title strip) a dialog left the window undraggable.+ #[test]+ fn a_dialog_keeps_the_title_strip_draggable_with_either_title_bar() {+ for custom in [false, true] {+ let mut app = PhotocraftApp::new(Session::new(), crate::Services::default());+ app.custom_titlebar = custom;+ app.run("file.new", serde_json::json!({"width": 8, "height": 8})).unwrap();+ assert!(!app.titlebar_modal_drag(true), "no dialog, no overlay");+ crate::filter_dialog::open(&mut app, "filter.blur.gaussianBlur").unwrap();+ assert!(app.titlebar_modal_drag(true), "custom title bar: {custom}");+ assert!(!app.titlebar_modal_drag(false), "chrome hidden (full screen): no title strip");+ app.ui.panels.menu_bar = false;+ assert!(!app.titlebar_modal_drag(true), "no menu bar, no title strip");+ }+ }+/// A headless window `width` pt wide showing the title bar and the resize zones.struct Win {ctx: egui::Context,