#2047: Fast Previews: any frame-changing Timeline drag draws a draft

One rule instead of a flag per gesture: DragWatch snapshots the active
comp and its current frame when the Timeline (and the Properties panel)
starts its pass, and after the pass, while the primary button drags
past a click, a new frame or a comp that no longer draws the same
pixels sets property_interacting until release. This covers the
playhead and timecode, layer moves and trims, slips, key drags and
alt-scale, Quick Offset, the In/Out/Duration cells, property scrubs and
the Graph Editor, and any gesture added later. Clicks, scrolling,
zooming, the work area and selection keep Full. It replaces the
prop.set-only check in apply_actions.
This commit is contained in:
arnav-hiwarkar committed 2026-11-12 19:00:04 +05:30
1 parent 550aeb0ac9
commit 724865e340
5 files changed
+57 -7

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ pub mod crypto_pick;
pub mod delete_items;
pub mod dialogs;
pub mod dialogs_3d;
pub(crate) mod drag_preview;
pub mod effect_controls;
pub mod effects_presets;
pub mod essential;
+47
View File
@@ -0,0 +1,47 @@
//! Fast Previews ▸ Adaptive Resolution for drags outside the viewer: as in After Effects, a drag
//! that changes the frame on screen (scrubbing the time, moving or trimming layers, slipping,
//! dragging keys, scrubbing values) draws a draft until the button is released.
use std::sync::Arc;
use effectcraft_engine::project::{Comp, ItemId};
use crate::EffectcraftApp;
/// The frame on screen when a panel starts its pass: the active comp and its current frame.
/// [`DragWatch::end`] compares it with the frame after the panel ran its gestures, so every drag
/// the panel handles is covered without a flag per gesture.
pub(crate) struct DragWatch {
before: Option<(ItemId, Arc<Comp>, i64)>,
}
impl DragWatch {
pub(crate) fn begin(app: &EffectcraftApp) -> Self {
let before = app.session.active_comp_id().and_then(|id| {
let comp = app.session.project.comp_arc(id)?;
let frame = comp.frame_rate.frame_at(app.session.time());
Some((id, comp, frame))
});
Self { before }
}
/// While the primary button drags (moved past a click), a change of the current frame or of
/// the active comp's pixels since [`Self::begin`] sets `property_interacting`, which stays
/// set until the button is up (`App::frame`). A click, a held button, or a drag that draws
/// the same pixels (scrolling, zooming, the work area, selecting) keeps Full.
pub(crate) fn end(self, app: &mut EffectcraftApp, ctx: &egui::Context) {
let Some((id, comp, frame)) = self.before else { return };
if app.ui.viewer.property_interacting || !ctx.input(|i| i.pointer.primary_down() && i.pointer.is_decidedly_dragging()) {
return;
}
if app.session.active_comp_id() != Some(id) {
return;
}
let Some(now) = app.session.project.comp_arc(id) else { return };
let moved = comp.frame_rate.frame_at(app.session.time()) != frame;
if moved || (!Arc::ptr_eq(&comp, &now) && !now.same_pixels(&comp)) {
app.ui.viewer.property_interacting = true;
ctx.request_repaint();
}
}
}
+2
View File
@@ -67,6 +67,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
p.text(rect.center(), Align2::CENTER_CENTER, crate::i18n::tr("Select a layer to see its properties"), Tokens::ui(12.0), t.text_faint);
return;
};
let watch = super::drag_preview::DragWatch::begin(app);
let project = app.session.project.clone();
let expr = app.session.expr.clone();
let now = app.session.time();
@@ -190,6 +191,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
app.ui.status = e;
}
}
watch.end(app, &ctx);
}
fn section_header(app: &mut EffectcraftApp, p: &egui::Painter, x0: f32, w: f32, y: f32, title: &str, auto: &str) {
+4 -6
View File
@@ -1963,6 +1963,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
return;
};
let Some(comp) = app.session.project.comp_arc(cid) else { return };
let watch = super::drag_preview::DragWatch::begin(app);
let mut tl = layout(app, ui, rect, cid, &comp);
let g = &mut tl;
if !ui.input(|i| i.pointer.primary_down()) {
@@ -2022,7 +2023,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
drop_targets(app, ui, g);
let Rw { tl, ui_actions, .. } = rw;
apply_ui_acts(app, &tl.comp, ui_actions);
apply_actions(app, ui, &tl.ctx, tl.actions);
apply_actions(app, &tl.ctx, tl.actions);
watch.end(app, &tl.ctx);
}
/// Applies the UI-only changes the frame collected (twirls, time, ending an undo merge).
@@ -2081,11 +2083,7 @@ fn apply_ui_acts(app: &mut EffectcraftApp, comp: &Comp, ui_actions: Vec<UiAct>)
}
/// Runs the commands the frame collected through [`crate::menus::invoke`].
fn apply_actions(app: &mut EffectcraftApp, ui: &mut egui::Ui, ctx: &egui::Context, actions: Vec<(String, serde_json::Value)>) {
if ui.input(|i| i.pointer.primary_down()) && actions.iter().any(|(id, _)| id == "prop.set") {
app.ui.viewer.property_interacting = true;
ctx.request_repaint();
}
fn apply_actions(app: &mut EffectcraftApp, ctx: &egui::Context, actions: Vec<(String, serde_json::Value)>) {
for (id, params) in actions {
if id == "__endMerge" {
app.session.history.merge_key = None;
+3 -1
View File
@@ -265,7 +265,9 @@ pub struct ViewerState {
/// The pointer is dragging in the viewer this frame (Adaptive Resolution).
#[serde(skip)]
pub interacting: bool,
/// A property scrub (Effect Controls, Timeline) or a Timeline drag of the playhead, keys or layer bars is in progress (Adaptive Resolution); cleared once the primary button is up.
/// A drag outside the viewer changed the frame on screen: a property scrub in Effect Controls,
/// or any Timeline or Properties drag ([`crate::panels::drag_preview`]). Adaptive Resolution
/// draws a draft until the primary button is up, which clears it.
#[serde(skip)]
pub property_interacting: bool,
/// Extended Viewer: the comp-space region the viewer renders this frame (comp frame plus