From 9484b116ab03e2d14ac98329c7728c87c92e8c11 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 15:31:04 -0800 Subject: [PATCH] Tests: screen-mode drags and popups start clear of the task bar In Full Screen Mode with Menu Bar and Full Screen Mode the canvas is about 390 pt wide, so the Contextual Task Bar under the selected rectangle now wraps onto a second row and covers the canvas's center. The middle-button pan, hand, zoom and context menu tests pressed there and reached the bar instead of the canvas. They now press low on the canvas, at a point the helper checks is clear of the bar. --- crates/ui-egui/src/tests/screenmode.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tests/screenmode.rs b/crates/ui-egui/src/tests/screenmode.rs index 3154ccb6d9..181212bd61 100644 --- a/crates/ui-egui/src/tests/screenmode.rs +++ b/crates/ui-egui/src/tests/screenmode.rs @@ -80,6 +80,14 @@ fn in_screen_mode(ctx: &egui::Context, mode: u8) -> VectorcraftApp { app } +/// A point on the empty canvas, low enough to miss the Contextual Task Bar under the selection +/// (on a narrow canvas its actions wrap onto more rows and can reach the canvas's center). +fn open_canvas_point(app: &VectorcraftApp, ctx: &egui::Context) -> egui::Pos2 { + let p = app.canvas_rect.unwrap().lerp_inside(egui::vec2(0.5, 0.85)); + assert!(crate::canvas::task_bar_rect(ctx).is_none_or(|bar| !bar.expand(40.0).contains(p)), "the task bar covers {p:?}"); + p +} + fn begin_tools_move(app: &mut VectorcraftApp, ctx: &egui::Context) -> (Option<[f32; 2]>, egui::Pos2) { app.run("window.panel.float", json!({"panel": "tools", "x": 120, "y": 140})).unwrap(); frame(app, ctx, vec![]); @@ -241,7 +249,7 @@ fn navigation_drag_keeps_screen_mode(kind: &str) { _ => panic!("unknown navigation drag"), }; frame(&mut app, &ctx, vec![]); - let start = app.canvas_rect.unwrap().center(); + let start = open_canvas_point(&app, &ctx); let end = start + egui::vec2(35.0, 20.0); let pointer = |pos, pressed| egui::Event::PointerButton { pos, button, pressed, modifiers: Default::default() }; frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start), pointer(start, true)]); @@ -551,7 +559,7 @@ fn held_escape_that_cancels_a_dialog_or_leaves_presentation_skips_a_command_boun fn a_popup_takes_escape_before_full_screen_exits() { let ctx = egui::Context::default(); let mut app = in_screen_mode(&ctx, 2); - let pos = app.canvas_rect.unwrap().center(); + let pos = open_canvas_point(&app, &ctx); let button = |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Secondary, pressed, modifiers: Default::default() }; frame(&mut app, &ctx, vec![egui::Event::PointerMoved(pos), button(true)]); frame(&mut app, &ctx, vec![button(false)]);