Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge pull request #443 from Aavirash/fix/shape-drag-preview

Claudeb7b47a0e100a
diff --cc crates/ui-egui/src/panels/viewer.rs
index eb6ab56a6,3fe377ed2..89f46d7e5
--- a/crates/ui-egui/src/panels/viewer.rs
+++ b/crates/ui-egui/src/panels/viewer.rs
@@@ -667,8 -668,14 +668,11 @@@ pub fn show(app: &mut EffectcraftApp, u
let frame = comp.frame_rate.frame_at(time);
let key = app.frame_key(cid, frame, scale);
app.request_frame_urgent(cid, frame, scale);
- if let Some((key, img)) = app.frames.get_for_viewer(&key, app.viewer_shown.as_ref().map(|(_, k)| k)) {
- let stale = app.viewer_shown.as_ref().is_none_or(|(_, k)| *k != key);
+ // The frame on screen. While a drag or a property scrub is rendering, the exact key changes
- // with every edit and its render is still in flight; showing the newest frame that is ready
- // keeps the picture following the pointer (a render behind), where waiting for the exact key
- // would freeze it until the pointer stops.
- let interacting = app.ui.viewer.interacting || app.ui.viewer.property_interacting;
- let shown = app.frames.get(&key).map(|img| (key, img)).or_else(|| interacting.then(|| app.frames.get_newest(&key)).flatten());
- if let Some((k, img)) = shown {
++ // with every edit and its render is still in flight; the newest completed revision of the
++ // same frame keeps the picture following the pointer instead of freezing until it stops.
++ if let Some((k, img)) = app.frames.get_for_viewer(&key, app.viewer_shown.as_ref().map(|(_, s)| s)) {
+ let stale = app.viewer_shown.as_ref().is_none_or(|(_, s)| *s != k);
// A CPU frame goes up again when the magnification calls for another factor.
let minify = minify_factor(app.session.prefs.viewer_zoom_smooth(), scale, (zoom * ppp) as f64);
let refit = !app.viewer_on_gpu() && app.viewer_tex.as_ref().is_some_and(|(_, _, m)| *m != minify);