mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-16 15:22:43 +00:00
#2047: markers no expression reads don't drop the resolution
Compare the comp the way the frame cache does (#1083): markers count as pixels only when an expression reads them, so dragging a marker keeps Full. Tighten the click and Fast Previews Off tests so they prove the gesture reached the app.
This commit is contained in:
1 parent
724865e340
commit
9ed7954a97
2 files changed
+27
-8
No files matched your search
@@ -8,9 +8,9 @@ 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.
|
||||
/// The active comp and its current frame index when a panel starts its pass. [`DragWatch::end`]
|
||||
/// compares them with the comp and 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)>,
|
||||
}
|
||||
@@ -25,10 +25,11 @@ impl DragWatch {
|
||||
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.
|
||||
/// While the primary button drags (moved past a click, or held past one), 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,
|
||||
/// or a drag that draws the same pixels (scrolling, zooming, the work area, selecting, markers
|
||||
/// no expression reads, as for the frame cache) 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()) {
|
||||
@@ -39,7 +40,7 @@ impl DragWatch {
|
||||
}
|
||||
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)) {
|
||||
if moved || (!Arc::ptr_eq(&comp, &now) && !now.same_pixels_with(&comp, app.session.project.reads_markers(), &|_| false)) {
|
||||
app.ui.viewer.property_interacting = true;
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
@@ -158,24 +158,42 @@ fn work_area_drag_keeps_full_resolution() {
|
||||
release(&mut f.h, from);
|
||||
}
|
||||
|
||||
/// Markers are pixels only to the expressions that read them (#1083): moving one keeps Full.
|
||||
#[test]
|
||||
fn marker_drag_keeps_full_resolution() {
|
||||
let mut f = fixture("adaptive");
|
||||
f.h.state_mut().session.execute("comp.addMarker", json!({"time": 2.0})).unwrap();
|
||||
f.h.run_steps(3);
|
||||
let from = rect(&f.h, "timeline.marker.0").center();
|
||||
let before = f.h.state().session.active_comp().unwrap().markers[0].time;
|
||||
hold(&mut f.h, from, from + vec2(80.0, 0.0));
|
||||
assert_ne!(f.h.state().session.active_comp().unwrap().markers[0].time, before, "the marker moved");
|
||||
assert!(!draft(&f.h), "a marker no expression reads changes no pixels");
|
||||
release(&mut f.h, from);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timeline_click_keeps_full_resolution() {
|
||||
let mut f = fixture("adaptive");
|
||||
let point = rect(&f.h, "timeline.ruler").center();
|
||||
let before = f.h.state().session.time();
|
||||
f.h.input_mut().events.push(Event::PointerMoved(point));
|
||||
f.h.step();
|
||||
f.h.input_mut().events.push(Event::PointerButton { pos: point, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
f.h.run_steps(3);
|
||||
assert_ne!(f.h.state().session.time(), before, "the click moved the playhead");
|
||||
assert!(!draft(&f.h));
|
||||
release(&mut f.h, point);
|
||||
}
|
||||
|
||||
/// The drag is still noted, but Fast Previews Off never lowers the resolution.
|
||||
#[test]
|
||||
fn fast_previews_off_keeps_full_resolution() {
|
||||
let mut f = fixture("off");
|
||||
let ruler = rect(&f.h, "timeline.ruler");
|
||||
let from = pos2(ruler.min.x + 40.0, ruler.max.y - 3.0);
|
||||
hold(&mut f.h, from, from + vec2(200.0, 0.0));
|
||||
assert!(f.h.state().ui.viewer.property_interacting);
|
||||
assert!(!draft(&f.h));
|
||||
release(&mut f.h, from);
|
||||
}
|
||||
Reference in new issue
Block a user