mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-01 14:16:49 -06:00
#1311: floating windows stay below the macOS title-bar strip (craft-ui float_bounds)
This commit is contained in:
Generated
+1
-1
@@ -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",
|
||||
|
||||
+1
-1
@@ -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" }
|
||||
|
||||
@@ -572,6 +572,17 @@ fn shared_command(app: &mut DesignApp, id: &str, params: &Value) -> Result<Value
|
||||
Ok(txn.commit(app, closed, reveal))
|
||||
}
|
||||
|
||||
/// Where floating windows may go: the window, below the title-bar strip when DesignCraft draws
|
||||
/// its own title bar under macOS's transparent one. A floating window in that strip would take
|
||||
/// presses that move the whole app window.
|
||||
fn float_bounds(app: &DesignApp, ctx: &egui::Context) -> 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<Value
|
||||
/// same command, or headless) floats at that size too.
|
||||
fn float_space(app: &DesignApp) -> FloatSpace<String> {
|
||||
let space = match app.egui_ctx.as_ref() {
|
||||
Some(ctx) => craft_ui::docking::float_space::<String>(ctx, area_id()).unwrap_or_else(|| FloatSpace::new(ctx.content_rect())),
|
||||
Some(ctx) => craft_ui::docking::float_space::<String>(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);
|
||||
}
|
||||
|
||||
@@ -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:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user