Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
fa93d6f
LRC-SS-PLAYBACK: pan and zoom moves and zooms each photo during playback
dotCooCoo Oct 31, 2026
0f0ab77
LRC-SS-PLAYBACK: the pan and zoom amount is saved and an old slide re…
dotCooCoo Oct 31, 2026
41e2d54
LRC-SS-PLAYBACK: motion comments use American spelling
dotCooCoo Oct 31, 2026
3283631
LRC-SS-PLAYBACK: tests for pan and zoom across a slide, a pause, a fa…
dotCooCoo Nov 4, 2026
87dea3a
LRC-SS-PLAYBACK: the slideshow stops redrawing every frame once a pho…
dotCooCoo Nov 4, 2026
3e8e088
LRC-SS-PLAYBACK: a single repeating photo starts its next path where …
dotCooCoo Nov 4, 2026
3e9231e
LRC-SS-PLAYBACK: test pan and zoom on very narrow and very wide photo…
dotCooCoo Nov 4, 2026
eea0393
LRC-SS-PLAYBACK: a pan and zoom amount outside 0 to 1 is an error
dotCooCoo Nov 4, 2026
2a65e2e
Merge main into feat/slideshow-pan-and-zoom
dotCooCoo Nov 5, 2026
1289200
Merge main into feat/slideshow-pan-and-zoom
dotCooCoo Nov 11, 2026
19e10be
LRC-SS-PLAYBACK: test that the pan and zoom amount sets the playback …
dotCooCoo Nov 12, 2026
fe9266c
Slideshow: pan and zoom draws every frame only once its slide is ready
dotCooCoo Nov 18, 2026
5b201a9
Merge main into feat/slideshow-pan-and-zoom
dotCooCoo Nov 18, 2026
bd8409c
Slideshow: pan and zoom moves the strip an extreme crop is composed into
dotCooCoo Nov 18, 2026
cf895a6
Merge branch 'main' into feat/slideshow-pan-and-zoom
FredApps Nov 18, 2026
4af1602
Merge branch 'main' into feat/slideshow-pan-and-zoom
FredApps Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/engine/src/cmd/slideshow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Slideshow Playback Settings",
[],
None,
"{slideDuration?: seconds (0.5–120), fadeDuration?: seconds (0 = cut; at most 10 and the slide duration), fadeColor?: \"#rrggbb\"|[r,g,b]|null (fade through a colour instead of crossfading), randomOrder?: bool, repeat?: bool, preparePreviews?: bool (render the next slides before they are due), manual?: bool (manual slideshow: a slide stays up until ← or → changes it)} — omitted keys keep their value, {} reads them; saved with the library → {slideDuration, fadeDuration, fadeColor, randomOrder, repeat, preparePreviews, manual}",
"{slideDuration?: seconds (0.5–120), fadeDuration?: seconds (0 = cut; at most 10 and the slide duration), fadeColor?: \"#rrggbb\"|[r,g,b]|null (fade through a colour instead of crossfading), randomOrder?: bool, repeat?: bool, preparePreviews?: bool (render the next slides before they are due), manual?: bool (manual slideshow: a slide stays up until ← or → changes it), panAndZoom?: bool (each photo moves and zooms slowly over its slide, on its own path), panAndZoomAmount?: 0 (low) to 1 (high)} — omitted keys keep their value, {} reads them; saved with the library → {slideDuration, fadeDuration, fadeColor, randomOrder, repeat, preparePreviews, manual, panAndZoom, panAndZoomAmount}",
always,
playback
),
Expand Down
6 changes: 5 additions & 1 deletion crates/engine/src/slide_template/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ fn ids(s: &mut Session) -> Vec<String> {

/// A look different from the defaults in every section.
fn custom(s: &mut Session) {
run(s, "slideshow.playback", json!({"slideDuration": 7.5, "fadeDuration": 0.5, "fadeColor": "#102030", "randomOrder": true, "repeat": false}));
run(
s,
"slideshow.playback",
json!({"slideDuration": 7.5, "fadeDuration": 0.5, "fadeColor": "#102030", "randomOrder": true, "repeat": false, "panAndZoom": true, "panAndZoomAmount": 0.8}),
);
run(
s,
"slideshow.layout",
Expand Down
106 changes: 100 additions & 6 deletions crates/engine/src/slideshow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Slideshow playback: the settings of Lightroom Classic's Playback panel and the timeline that
//! plays the photos in view (durations, fades, random order, repeat, pause, stepping, manual
//! advance), between an optional intro and ending screen (the Titles panel,
//! advance, pan and zoom), between an optional intro and ending screen (the Titles panel,
//! [`crate::slide_title`]).
//!
//! No UI here: [`Playback`] is a pure state machine driven with injected times (seconds on any
Expand All @@ -14,6 +14,7 @@
//! with the `slideshow.playback` command.

use lightcraft_catalog::PhotoId;
use lightcraft_slideshow::{Motion, View};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};

Expand All @@ -23,7 +24,7 @@ pub const SLIDE_MAX: f64 = 120.0;
/// Longest fade (seconds); a fade is never longer than the slide duration.
pub const FADE_MAX: f64 = 10.0;

/// How playback runs (Lightroom Classic's Playback panel, without music and pan & zoom).
/// How playback runs (Lightroom Classic's Playback panel, without music).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct PlaybackSettings {
Expand All @@ -43,6 +44,10 @@ pub struct PlaybackSettings {
/// Manual slideshow: a slide stays up until ← / → (or the controls) change it; the slide
/// duration is not used for playback then.
pub manual: bool,
/// Pan and zoom: each photo moves and zooms slowly over its slide's time, on its own path.
pub pan_and_zoom: bool,
/// How much it moves: 0 (Low) to 1 (High).
pub pan_and_zoom_amount: f64,
}

impl Default for PlaybackSettings {
Expand All @@ -55,18 +60,22 @@ impl Default for PlaybackSettings {
repeat: true,
prepare_previews: true,
manual: false,
pan_and_zoom: false,
pan_and_zoom_amount: 0.5,
}
}
}

impl PlaybackSettings {
/// The settings with every value in range (a non-finite duration takes the default; the fade
/// is never longer than the slide).
/// The settings with every value in range (a non-finite duration or amount takes the default;
/// the fade is never longer than the slide).
pub fn sanitized(mut self) -> Self {
let d = PlaybackSettings::default();
self.slide_duration = if self.slide_duration.is_finite() { self.slide_duration.clamp(SLIDE_MIN, SLIDE_MAX) } else { d.slide_duration };
let fade = if self.fade_duration.is_finite() { self.fade_duration } else { d.fade_duration };
self.fade_duration = fade.clamp(0.0, FADE_MAX).min(self.slide_duration);
self.pan_and_zoom_amount =
if self.pan_and_zoom_amount.is_finite() { self.pan_and_zoom_amount.clamp(0.0, 1.0) } else { d.pan_and_zoom_amount };
self
}

Expand All @@ -79,6 +88,8 @@ impl PlaybackSettings {
"repeat": self.repeat,
"preparePreviews": self.prepare_previews,
"manual": self.manual,
"panAndZoom": self.pan_and_zoom,
"panAndZoomAmount": self.pan_and_zoom_amount,
})
}

Expand All @@ -96,9 +107,14 @@ impl PlaybackSettings {
"repeat" => s.repeat = boolean(k, v)?,
"preparePreviews" => s.prepare_previews = boolean(k, v)?,
"manual" => s.manual = boolean(k, v)?,
"panAndZoom" => s.pan_and_zoom = boolean(k, v)?,
"panAndZoomAmount" => match v.as_f64() {
Some(x) if (0.0..=1.0).contains(&x) => s.pan_and_zoom_amount = x,
_ => return Err(format!("`{k}` must be a finite number from 0 (low) to 1 (high), not {v}")),
},
other => {
return Err(format!(
"unknown setting `{other}` (slideDuration, fadeDuration, fadeColor, randomOrder, repeat, preparePreviews, manual)"
"unknown setting `{other}` (slideDuration, fadeDuration, fadeColor, randomOrder, repeat, preparePreviews, manual, panAndZoom, panAndZoomAmount)"
));
}
}
Expand Down Expand Up @@ -229,6 +245,16 @@ pub struct Frame {
pub fade_color: Option<[u8; 3]>,
}

/// The pan and zoom views at a moment of playback (`None`: the slide shows its whole picture, as
/// a title screen always does, and every slide when pan and zoom is off).
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PanZoom {
/// The current slide's view.
pub current: Option<View>,
/// The view of the slide being faded out: where its motion ended.
pub from: Option<View>,
}

/// Where the timeline is: the intro, the photos, or the ending.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Phase {
Expand Down Expand Up @@ -261,6 +287,13 @@ pub struct Playback {
started: f64,
/// The slide fading out (until the transition ends).
from: Option<Item>,
/// The pan and zoom key of the slide fading out.
from_key: Option<u64>,
/// Times a single photo repeating has started over (each time on a new path).
reps: u64,
/// Where a single repeating photo's last path ended: its new path starts there, so the
/// picture does not jump when it starts over.
rep_start: Option<View>,
/// Paused at this time.
paused_at: Option<f64>,
ended: bool,
Expand Down Expand Up @@ -319,6 +352,9 @@ impl Playback {
ending: None,
started: now,
from: None,
from_key: None,
reps: 0,
rep_start: None,
paused_at: None,
ended: false,
held: None,
Expand Down Expand Up @@ -516,8 +552,11 @@ impl Playback {
}
let Some(next) = self.upcoming(1).first().copied() else {
if self.settings.repeat {
// a single photo repeating: nothing to change to
// a single photo repeating: nothing to change to (its pan and zoom starts again,
// on a new path from where the last one ended)
self.rep_start = self.motion(self.current()).map(|m| m.end);
self.started = now;
self.reps = self.reps.wrapping_add(1);
return Tick::Idle;
}
self.ended = true;
Expand All @@ -529,14 +568,67 @@ impl Playback {
}
self.held = None;
let old = self.current();
let old_key = self.motion_key(old);
let t = self.advance();
if let Tick::Advanced(new) = t {
self.started = now;
self.from = (self.fade_to(new) > 0.0).then_some(old);
self.from_key = self.from.and(old_key);
self.rep_start = None;
}
t
}

/// The pan and zoom path of `item` up now (`None` for a title screen): from its key, starting
/// where the last path ended when a single photo repeats.
fn motion(&self, item: Item) -> Option<Motion> {
let m = Motion::new(self.motion_key(item)?, self.settings.pan_and_zoom_amount);
Some(Motion { start: self.rep_start.unwrap_or(m.start), ..m })
}

/// The pan and zoom key of `item` up in the current pass (`None` for a title screen): the
/// seed, the pass, the photo and the repeats of a single photo, so every photo has its own
/// path, a new one in each pass, and the same seed plays the same paths.
fn motion_key(&self, item: Item) -> Option<u64> {
let photo = item.photo()?;
let mut st = self.seed ^ 0x7061_6e7a_6f6f_6d00;
for v in [self.pass, photo.0, self.reps] {
st = splitmix(&mut st) ^ v;
}
Some(splitmix(&mut st))
}

/// Where each slide's picture is at `now` with pan and zoom on: the current photo moves from
/// its start view (as it comes up, its fade in included) to its end view over its duration,
/// frozen while paused and held at the start in a manual slideshow (no slide is ever due
/// there); a photo fading out stays at its end view. Both are `None` with pan and zoom off.
pub fn pan_zoom(&self, now: f64) -> PanZoom {
if !self.settings.pan_and_zoom {
return PanZoom { current: None, from: None };
}
let amount = self.settings.pan_and_zoom_amount;
let current = self.current();
let t = if self.settings.manual {
0.0
} else {
let d = self.duration(current);
if d > 0.0 { (self.clock(now) - self.started) / d } else { 1.0 }
};
let from = self.frame(now).from.and(self.from_key).map(|k| Motion::new(k, amount).at(1.0));
PanZoom { current: self.motion(current).map(|m| m.at(t)), from }
}

/// Whether pan and zoom moves the current photo at `now`: on, playing (not paused, not a
/// manual slideshow), a photo up and its time not over. A slide whose time is over while the
/// next one is not ready yet stays at its end view.
pub fn pan_zoom_moving(&self, now: f64) -> bool {
self.settings.pan_and_zoom
&& self.paused_at.is_none()
&& !self.settings.manual
&& self.current().photo().is_some()
&& self.remaining(now) > 0.0
}

/// What to draw at `now`.
pub fn frame(&self, now: f64) -> Frame {
let now = self.clock(now);
Expand Down Expand Up @@ -597,6 +689,8 @@ impl Playback {
t = Tick::Advanced(self.current());
}
self.from = None;
self.from_key = None;
self.rep_start = None;
self.held = None;
self.started = now;
if self.paused_at.is_some() {
Expand Down
Loading
Loading