Skip to content

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

Merge pull request #1109 from eliasx45/upstream/azerty-graph-zoom

Brandon Thomas287c35dae7d7
diff --cc crates/ui-egui/src/panels/timeline.rs
index 53799a0ef,df680410d..535a8dc29
--- a/crates/ui-egui/src/panels/timeline.rs
+++ b/crates/ui-egui/src/panels/timeline.rs
@@@ -1409,11 -1305,11 +1412,16 @@@ pub fn show(app: &mut EffectcraftApp, u
let span = ((graph_x1 - graph_x0 - 6.0) as f64 / pps).max(0.0);
app.ui.timeline.start = page_to_cti(app.ui.timeline.start, span, comp.duration.seconds(), app.session.time().seconds());
}
+ let scroll_to = app.ui.timeline.scroll_to.take();
+ if scroll_to == Some(crate::state::ScrollTo::Time) && app.ui.timeline.pps.is_some() {
+ let span = ((graph_x1 - graph_x0 - 6.0) as f64 / pps).max(0.0);
+ app.ui.timeline.start = centered_on(span, comp.duration.seconds(), app.session.time().seconds());
+ }
+ // As in After Effects, the ruler never scrolls past the comp's end: zoomed in, the last
+ // visible time is at most the comp duration.
+ let visible_secs = ((graph_x1 - graph_x0 - 6.0).max(1.0) as f64 / pps.max(1e-6)).max(0.0);
+ let max_start = (comp.duration.seconds() - visible_secs).max(0.0);
+ app.ui.timeline.start = app.ui.timeline.start.clamp(0.0, max_start);
let tm = TMap { x0: graph_x0 + 6.0, start: app.ui.timeline.start, pps };
ctx.data_mut(|d| d.insert_temp(tl_map_id(), (tm.x0, tm.start, tm.pps)));
let top = rect.min.y;