mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-01 22:19:23 +00:00
M8: an ending glass sprite shows the backdrop of where it stopped (#2853)
Once the drag ends, the sprite keeps asking for and showing a backdrop render of its last place until the canvas render replaces it, so a render still on its way when the button goes up isn't left showing an older place's backdrop. A render test checks that a layer dragged together with the pane, under it, shows through the pane as it would where both are.
This commit is contained in:
@@ -24,3 +24,23 @@ fn a_pane_moved_back_shows_what_lies_under_it_where_it_is() {
|
||||
assert!(differ(&here, &there) > 1000, "the backdrop where it is differs from where it started");
|
||||
assert_eq!(differ(&sprite, &there), 0, "drawn where it started, it shows the pane as it looks where it is");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_layer_dragged_with_the_pane_shows_through_it() {
|
||||
// The white card under the pane, selected and dragged with it: the first of the layers drawn.
|
||||
let (d, p, pane, card) = scene();
|
||||
let layers = d.node(p).unwrap().children.clone();
|
||||
let at = Rect::new(300.0, 220.0, 900.0, 580.0);
|
||||
let by = (25.0, 5.0);
|
||||
let mut moved = d.clone();
|
||||
for (id, x, y) in [(card, 420.0, 300.0), (pane, 300.0, 220.0)] {
|
||||
moved.get_mut(id).unwrap().transform = Affine::translate((x + by.0, y + by.1));
|
||||
}
|
||||
let shifted = Rect::new(at.x0 + by.0, at.y0 + by.1, at.x1 + by.0, at.y1 + by.1);
|
||||
let there = render_area_over(&moved, &[card, pane], &layers, shifted, 1.0).unwrap();
|
||||
let sprite = render_area_moved(&d, &[card, pane], &layers, at, 1.0, by).unwrap();
|
||||
let pane_only = render_area_moved(&d, &[pane], &layers, at, 1.0, by).unwrap();
|
||||
let differ = |a: &tiny_skia::Pixmap, b: &tiny_skia::Pixmap| a.data().iter().zip(b.data()).filter(|(x, y)| x.abs_diff(**y) > 2).count();
|
||||
assert!(differ(&sprite, &pane_only) > 1000, "the card moving with the pane changes what it shows");
|
||||
assert_eq!(differ(&sprite, &there), 0, "and the pane shows it as it does where both are");
|
||||
}
|
||||
|
||||
@@ -200,6 +200,11 @@ pub(super) fn sync(app: &mut FigApp, ctx: &egui::Context, ppp: f32, max_side: u3
|
||||
None => app.canvas.sprite = None,
|
||||
}
|
||||
}
|
||||
// Ending, it still asks for and shows a backdrop render of where it stopped until the canvas
|
||||
// render takes over: one still on its way would leave it showing an older place's backdrop.
|
||||
if let Some(s) = app.canvas.sprite.as_mut().filter(|s| s.ending) {
|
||||
s.follow();
|
||||
}
|
||||
let (base, _) = moved?;
|
||||
if app.canvas.sprite_declined.as_ref().is_some_and(|d| Weak::ptr_eq(d, &Arc::downgrade(&base))) || !view_ok {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user