Compare commits

...
Author SHA1 Message Date
autocraft-bot[bot] 2c3a03018d Merge main (8413f81a) into the pull request
I resolved the merge. Main moved the transition drawing out of `show/ui.

I resolved the merge. Main moved the transition drawing out of `show/ui.rs` into `show/frames.rs` and removed the `old`, `morph` and `parts` fields from `Transition`. In `ui.rs` I took main's side, since the PR's edits there were only to the now-removed `draw_transition`. In `show.rs` I kept the PR's `clock` and `primed` fields and the `progress()` method, and the `Transition` constructors now carry `clock: None, primed: false` on top of main's slimmer struct. I carried the PR's `progress()` call over to main's new code: `prepare_transition` in `frames.rs` now takes `&mut show.trans` and gets `p` from `tr.progress(now)`. The hidden-show path still expires the transition from `start`, as in the PR. No conflict markers remain, `cargo fmt --check` is clean, and `cargo clippy --offline -p deckcraft-ui-egui --all-targets` gave no warnings. I couldn't run the `show::` tests. The test build was still compiling when I stopped it after about 14 minutes, so the PR's new test `a_slow_first_frame_does_not_use_up_the_transition` is compiled but not run.
2026-12-01 22:28:37 +00:00
SofiaAFigueredoandClaude Sonnet 5.5 6c068ffc30 Merge upstream/main into fix/transition-clock-1385
Keeps both the transition clock (clock, primed) and the reversed-transition
flag (#1531) on `Transition`, and both tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 22:07:59 -03:00
SofiaAFigueredoandClaude Sonnet 5.5 7a51671ebd Merge upstream/main into fix/transition-clock-1385
main split `draw_slide` into helpers; the transition's progress now comes
from `Transition::progress` inside `draw_transition`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 14:19:28 -03:00
Claude d5741616c1 Merge upstream/main into fix/transition-clock-1385
show.rs was split into show/{ui,tests,...}.rs; the transition clock change is reapplied in
show.rs (Transition::progress), show/ui.rs and show/tests.rs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0113uEh5SFtfDDpkv4PyLjCn
2026-10-28 10:23:35 +00:00
SofiaAFigueredoandClaude Sonnet 5.5 877e6db673 fix(show): a hidden show expires a transition from the key press (#1385)
Re-anchoring `start` for the drawn transition delayed the hidden show's
expiration by the time between the press and the second frame. The press time
stays in `start`; the drawn clock is its own field.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 19:05:43 -03:00
SofiaAFigueredoandClaude Sonnet 5.5 b697455ea7 docs(contributors): credit SofiaAFigueredo by real name (#1385)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 18:57:15 -03:00
SofiaAFigueredoandClaude Sonnet 5.5 5c179822d9 fix(show): start a slide transition's clock after its first frame is rendered (#1385)
The clock started at the key press, but the new slide (and, for Pan, Reveal
and similar transitions, four more pictures) is rendered on the UI thread
before the first transition frame. When that took longer than the
transition's duration, the first drawn frame was already past the end and the
next slide appeared with no transition. The first frame now renders the slide
and the pictures while showing the start of the transition, and the clock
starts on the frame after it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 18:53:05 -03:00
3 changed files with 50 additions and 4 deletions
+25 -2
View File
@@ -125,7 +125,16 @@ pub(crate) struct BackKey {
struct Transition {
/// The slide left behind, whose shapes Morph matches.
from: Option<usize>,
/// The time of the key press. A hidden show, which draws nothing, expires the transition
/// from it.
start: f64,
/// Where the drawn transition's clock starts: the frame after the first one (see `progress`),
/// because rendering the new slide and the transition's pictures can take longer than the
/// whole transition (#1385). `None` until then.
clock: Option<f64>,
/// The first frame of the transition has been drawn: the new slide and the pictures the
/// transition needs exist, so the time they took is not part of the transition.
primed: bool,
kind: String,
option: String,
dur: f64,
@@ -134,6 +143,20 @@ struct Transition {
reverse: bool,
}
impl Transition {
/// How far the transition has come at frame time `now`, from 0 to 1. The first frame is the
/// one that renders the new slide and the transition's pictures and the second one starts the
/// clock, so a slow render never eats the transition's duration (#1385).
fn progress(&mut self, now: f64) -> f64 {
if !self.primed {
self.primed = true;
return 0.0;
}
let clock = *self.clock.get_or_insert(now);
((now - clock) / self.dur.max(0.01)).clamp(0.0, 1.0)
}
}
/// A copy of the show's clock origins for regressions that must not depend on wall time.
#[cfg(test)]
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -230,7 +253,7 @@ impl Show {
.map(|t| (t.kind.clone(), t.option.clone(), t.duration_ms as f64 / 1000.0))
.unwrap_or(("none".into(), String::new(), 0.0));
self.trans = if kind != "none" && dur > 0.0 && !doc.show.without_animation {
Some(Transition { from, start: now, kind, option, dur, reverse: false })
Some(Transition { from, start: now, clock: None, primed: false, kind, option, dur, reverse: false })
} else {
None
};
@@ -443,7 +466,7 @@ impl Show {
// reversed Morph.
let reverse = back && kind != "morph";
self.trans = if kind != "none" && dur > 0.0 && !doc.show.without_animation {
Some(Transition { from, start: now, kind, option, dur, reverse })
Some(Transition { from, start: now, clock: None, primed: false, kind, option, dur, reverse })
} else {
None
};
+2 -2
View File
@@ -493,8 +493,8 @@ fn prepare_transition(
store: &TextureStore<FrameKey>,
frame: &mut PaintFrame,
) {
let Some(tr) = &show.trans else { return };
let p = ((now - tr.start) / tr.dur.max(0.01)).clamp(0.0, 1.0);
let Some(tr) = &mut show.trans else { return };
let p = tr.progress(now);
if p >= 1.0 {
return;
}
+23
View File
@@ -625,6 +625,29 @@ fn animations_start_after_the_slides_transition() {
assert_eq!(show.clock_snapshot().step_start, 10.0);
}
#[test]
fn a_slow_first_frame_does_not_use_up_the_transition() {
// #1385: the clock started at the key press, so rendering the new slide for longer than the
// transition's duration showed the next slide with no transition at all.
let mut s = deckcraft_engine::Session::with_new();
s.execute("slide.new", &json!({})).unwrap();
s.execute("transition.set", &json!({"kind": "fade", "index": 1, "duration": 500})).unwrap();
let doc = s.active().unwrap().doc.clone();
let mut show = Show::new(&doc, 0, false, false);
assert!(show.apply(ShowAction::Slide(1), &doc, 10.0));
let tr = show.trans.as_mut().expect("the fade plays");
assert!((tr.dur - 0.5).abs() < 1e-9);
// The first frame renders for two seconds; it still shows the start of the transition.
assert_eq!(tr.progress(10.0), 0.0);
// The frame after it starts the clock.
assert_eq!(tr.progress(12.0), 0.0);
assert!((tr.progress(12.25) - 0.5).abs() < 1e-9);
assert_eq!(tr.progress(12.5), 1.0);
assert_eq!(tr.progress(20.0), 1.0);
// A hidden show still expires it from the key press.
assert_eq!(tr.start, 10.0);
}
#[test]
fn going_back_plays_the_left_slides_transition_reversed() {
// #1531: Back plays the transition of the slide being left, in reverse.