diff --git a/Cargo.lock b/Cargo.lock index 8f06d3e91..93363ed56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -849,7 +849,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=352a8308c5cc53c2ae31326fa38a4a6bcb0ff9eb#352a8308c5cc53c2ae31326fa38a4a6bcb0ff9eb" +source = "git+https://github.com/aiongg/craft-libs?rev=2fa4ad79d7dcde5e6ad671d36083dee367a1b788#2fa4ad79d7dcde5e6ad671d36083dee367a1b788" dependencies = [ "egui", "serde", diff --git a/Cargo.toml b/Cargo.toml index 550e1f21f..d696e54fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,4 +126,4 @@ hayro-jbig2 = { git = "https://github.com/storytold/pdfcraft", rev = "b5467d93a0 # Docking trial: craft-ui from the craft-libs `docking` branch. [patch."https://github.com/storytold/craft-libs"] -craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "352a8308c5cc53c2ae31326fa38a4a6bcb0ff9eb" } +craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "2fa4ad79d7dcde5e6ad671d36083dee367a1b788" } diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index e3492f7a8..42dddf5f1 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -572,6 +572,17 @@ fn shared_command(app: &mut DesignApp, id: &str, params: &Value) -> Result egui::Rect { + let mut r = ctx.content_rect(); + if app.integrated_titlebar { + r.min.y = (r.min.y + crate::chrome::MAC_APP_BAR).min(r.max.y); + } + r +} + /// Where a command floats a panel, group or column it gives no rect: inside the dock area as /// last drawn, else inside the window, else (headless, before any frame) inside /// [`HEADLESS_AREA`]. @@ -579,7 +590,7 @@ fn shared_command(app: &mut DesignApp, id: &str, params: &Value) -> Result FloatSpace { let space = match app.egui_ctx.as_ref() { - Some(ctx) => craft_ui::docking::float_space::(ctx, area_id()).unwrap_or_else(|| FloatSpace::new(ctx.content_rect())), + Some(ctx) => craft_ui::docking::float_space::(ctx, area_id()).unwrap_or_else(|| FloatSpace::new(float_bounds(app, ctx))), None => FloatSpace::new(HEADLESS_AREA), }; crate::dock::DOCK_TABS @@ -877,7 +888,7 @@ pub(crate) fn show(app: &mut DesignApp, ui: &mut egui::Ui) { blocked.push(rect); } let style = dock_style(ui, &app.ui.language); - let mut dock = craft_ui::docking::DockArea::new(area).blocked_rects(&blocked).auto_collapse_iconic(app.ui.dock_auto_collapse); + let mut dock = craft_ui::docking::DockArea::new(area).float_bounds(float_bounds(app, ui.ctx())).blocked_rects(&blocked).auto_collapse_iconic(app.ui.dock_auto_collapse); if let Some(panel) = raise { dock = dock.raise_panel(panel); } diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rs index 9d272eb3c..e10eeb899 100644 --- a/crates/ui-egui/src/panel_docking_tests.rs +++ b/crates/ui-egui/src/panel_docking_tests.rs @@ -1143,3 +1143,17 @@ fn docking_labels_are_translated() { } } } + +/// With DesignCraft's title bar under macOS's transparent one, a floating window saved in the +/// title-bar strip is drawn below it, where its title bar can't move the app window. +#[test] +fn a_floating_window_saved_in_the_title_bar_strip_is_drawn_below_it() { + let mut app = app(); + app.integrated_titlebar = true; + app.run("window.panel.float", json!({"panel":"properties"})).unwrap(); + let window = app.ui.docking.as_mut().unwrap().floating.iter_mut().find(|w| w.panels().any(|p| p == "properties")).unwrap(); + window.rect = [200.0, 0.0, 280.0, 360.0]; + let h = harness(app, egui::vec2(1400.0, 900.0)); + let drawn = h.ctx.memory(|m| m.area_rect(crate::panel_docking::floating_layer("properties").id)).unwrap(); + assert!(drawn.min.y >= crate::chrome::MAC_APP_BAR - 0.5, "{drawn:?}"); +}