From bef4e28a4d713e9c47bde074b8c5180035aaa3e3 Mon Sep 17 00:00:00 2001 From: komo1iddin <45395275+komo1iddin@users.noreply.github.com> Date: Thu, 22 Oct 2026 06:52:56 +0800 Subject: [PATCH] M7: a dragged page image leaves no outline where it was Edit text & images outlines every picture from the page's inventory, which still has the dragged one where it was until the release; that outline trailed behind the picture and caught up after it was let go. Leave the dragged picture's own outline out while it moves. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/edit_text_ui.rs | 7 +++++-- crates/ui-egui/tests/editing.rs | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/edit_text_ui.rs b/crates/ui-egui/src/edit_text_ui.rs index adfbc675ae..d6ddab2a94 100644 --- a/crates/ui-egui/src/edit_text_ui.rs +++ b/crates/ui-egui/src/edit_text_ui.rs @@ -677,14 +677,17 @@ pub(crate) fn image_input( // hovered boxes, so a ~1000-image CAD page stays interactive in Edit text & images. // Fully clipped placements (empty visible frames) get no outline. let faint_all = boxes.len() <= MAX_OUTLINES; + // The picture being dragged has its frame at the pointer; its outline where it was would + // trail behind until the release. + let moving = selected.filter(|_| dragging); if faint_all { - for b in boxes.iter().filter(|b| b.is_positive()) { + for (_, b) in boxes.iter().enumerate().filter(|(i, b)| b.is_positive() && moving != Some(*i)) { painter.rect_stroke(*b, CornerRadius::ZERO, Stroke::new(0.75, ACCENT.gamma_multiply(0.35)), egui::StrokeKind::Outside); } } let hovered_box = hover_pos.and_then(|p| boxes.iter().enumerate().rposition(|(i, b)| b.is_positive() && b.contains(p) && image_contains(i, p))); if !faint_all { - for i in selected.into_iter().chain(hovered_box.filter(|h| Some(*h) != selected)) { + for i in selected.filter(|_| moving.is_none()).into_iter().chain(hovered_box.filter(|h| Some(*h) != selected)) { if let Some(b) = boxes.get(i).filter(|b| b.is_positive()) { painter.rect_stroke(*b, CornerRadius::ZERO, Stroke::new(0.75, ACCENT.gamma_multiply(0.35)), egui::StrokeKind::Outside); } diff --git a/crates/ui-egui/tests/editing.rs b/crates/ui-egui/tests/editing.rs index 67d22f77ae..e1f542bde5 100644 --- a/crates/ui-egui/tests/editing.rs +++ b/crates/ui-egui/tests/editing.rs @@ -4518,6 +4518,12 @@ fn a_resized_image_keeps_its_new_size_until_the_page_is_redrawn() { h.hover_at(grip + (to - grip) * (k as f32 / 4.0)); h.run_steps(1); } + // While dragged, no outline stays where the picture was. + let old = egui::Rect::from_two_pos(at(60.0, 40.0), at(140.0, 120.0)); + let trailing = h.output().shapes.iter().any(|shape| { + matches!(&shape.shape, egui::Shape::Rect(r) if r.stroke.width == 0.75 && (r.rect.min - old.min).length() < 2.0 && (r.rect.max - old.max).length() < 2.0) + }); + assert!(!trailing, "the dragged picture's outline trails behind it"); h.state_mut().views[0].hold_rasters = true; h.drop_at(to); for frame in 0..4 {