From e8862977f8b79bebe5eb2a2d9558a55ff90638b5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 02:28:18 -0800 Subject: [PATCH] Place: the place cursor's file label hides when a drag leaves the canvas A press that begins on the canvas keeps the document hover point while the pointer is dragged off it, so the thumbnail and count stayed drawn at the canvas edge. The overlay now also needs the pointer over the canvas. The test drags a press across the canvas, where the thumbnail stays, and then off it, where nothing shows. --- crates/ui-egui/src/canvas/tool_adapter.rs | 4 +++- crates/ui-egui/src/tests/place.rs | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 40fe212dec..4edaa65945 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -894,12 +894,14 @@ fn show_overlays(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass, view_in } super::overlays::show(app, ui, &space, &list, &extra); // The loaded place cursor shows its current file and the files left beside the pointer, while the canvas has the - // pointer and no view tool is held. + // pointer and no view tool is held. A press that began on the canvas keeps `hover_doc` while it is dragged off it, + // so the pointer must also be over the canvas. if app.session.tool_id() == "place" && app.ui.screen_mode < 3 && app.hover_doc.is_some() && !view_tool_held(app) && let Some(at) = ui.input(|i| i.pointer.hover_pos()) + && space.view.rect.contains(at) { crate::place::cursor_overlay(app, ui, at, space.view.rect, super::overlays::BADGE_OFFSET); } diff --git a/crates/ui-egui/src/tests/place.rs b/crates/ui-egui/src/tests/place.rs index a9929312ca..45bb099d8d 100644 --- a/crates/ui-egui/src/tests/place.rs +++ b/crates/ui-egui/src/tests/place.rs @@ -493,6 +493,16 @@ fn the_loaded_place_cursor_shows_its_file_and_the_files_left_beside_the_pointer( load(&mut app, &["only.png"]); let (thumbs, counts) = shown(&mut app, Some(pointer), "only.png"); beside(&thumbs, &counts, None); + + // A press on the canvas dragged across it keeps the thumbnail, and dragged off the canvas shows nothing. + let press = egui::Event::PointerButton { pos: pointer, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() }; + crate::testing::app_frame(&mut app, &ctx, raw_input(vec![egui::Event::PointerMoved(pointer), press], vec![], vec![])); + let (thumbs, _) = shown(&mut app, Some(pointer + vec2(10.0, 10.0)), "only.png"); + assert_eq!(thumbs.len(), 1, "dragged on the canvas: {thumbs:?}"); + let outside = egui::pos2(pointer.x, canvas.min.y - 4.0); + assert!(outside.y > 0.0, "{canvas:?} leaves room above it"); + let (thumbs, counts) = shown(&mut app, Some(outside), "only.png"); + assert!(thumbs.is_empty() && counts.is_empty(), "dragged off the canvas: {thumbs:?} {counts:?}"); } /// A tiny SVG document.