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.
This commit is contained in:
dotCooCoo committed 2026-12-05 02:28:18 -08:00
1 parent 7aeb44ead9
commit e8862977f8
2 files changed
+13 -1

No files matched your search

+3 -1
View File
@@ -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);
}
+10
View File
@@ -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.