diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 74425972d80..6d9faaafc90 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -108,6 +108,7 @@ impl LightcraftApp { compare_windows: [None; 2], compare_tiles: Default::default(), compare_hold_until: f64::NEG_INFINITY, + survey_motion: Default::default(), merge: merge::MergeState::default(), import: None, scan: None, diff --git a/crates/ui-egui/src/dialogs/settings/libraries.rs b/crates/ui-egui/src/dialogs/settings/libraries.rs index 5e615bfbcbf..4e8d2a10d15 100644 --- a/crates/ui-egui/src/dialogs/settings/libraries.rs +++ b/crates/ui-egui/src/dialogs/settings/libraries.rs @@ -85,6 +85,9 @@ fn switch_library(app: &mut LightcraftApp, path: &str) -> Result app.ui.dialog = None; } app.renderer.forget_all(); + // photo ids are local to a catalog: a survey tile of the next library must not glide from a + // cell of this one, nor keep its render slot + app.survey_motion = Default::default(); if let Err(err) = opened { let Some(prev) = previous_dir else { return Err(err) }; return match app.session.open_library(&prev, false) { diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rs index d9a90d5464b..48a1161bfdc 100644 --- a/crates/ui-egui/src/headless.rs +++ b/crates/ui-egui/src/headless.rs @@ -400,6 +400,7 @@ impl Headless { || self.app.import.is_some() || self.app.export.is_some() || self.app.session.denoise_busy() + || self.app.survey_motion.moving(self.time) || !self.app.tasks.is_empty() || !self.app.synthetic.is_empty() || !self.app.pending_gestures.is_empty() diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index e1b34105562..c40d16b8e91 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -320,6 +320,8 @@ pub struct LightcraftApp { pub(crate) compare_tiles: std::collections::HashMap<(u8, u64), region::RegionView>, /// Until when (s) a pinch or scroll in Compare / Reference holds the windows there are. pub(crate) compare_hold_until: f64, + /// Survey tiles gliding to new cells, and the render slot each surveyed photo keeps. + pub(crate) survey_motion: panels::compare::survey::SurveyMotion, /// Photo Merge dialog previews and background merges. pub merge: merge::MergeState, /// An import in progress (the import review dialog's batches). diff --git a/crates/ui-egui/src/panels/compare.rs b/crates/ui-egui/src/panels/compare.rs index c6475a7017a..4fc9e495549 100644 --- a/crates/ui-egui/src/panels/compare.rs +++ b/crates/ui-egui/src/panels/compare.rs @@ -13,6 +13,8 @@ use crate::state::{ViewMode, Zoom}; use crate::theme::Tokens; use crate::widgets::register; +pub mod survey; + /// Most photos a survey shows. pub const SURVEY_MAX: usize = 48; @@ -203,11 +205,27 @@ fn request_tile_renders(app: &mut LightcraftApp, id: PhotoId, slot: Slot, want: if let Some(job) = app.session.render_job(id, rw.max(8), rh.max(8), false, true) { app.renderer.request(slot, job, 60); } + request_thumb(app, id); +} + +/// Ask for the thumbnail a tile shows until its render is there. +fn request_thumb(app: &mut LightcraftApp, id: PhotoId) { if let Some(job) = app.session.thumb_job(id, 256) { app.renderer.request(Slot::Thumb(id), job, 30); } } +/// The photo's frame as shown: cropped, rotated and lens-corrected. +fn frame_of(photo: &lightcraft_catalog::Photo) -> lightcraft_pipeline::geometry::Frame { + lightcraft_pipeline::geometry::Frame::with_lens( + photo.width.max(1) as usize, + photo.height.max(1) as usize, + &photo.develop, + true, + photo.embedded_lens.as_ref(), + ) +} + /// Draw one photo fitted into `area` (rendered at its display size into `slot`), with its caption /// strip below. Returns the image rect and the click/drag response. fn photo_tile( @@ -226,13 +244,7 @@ fn photo_tile( let Some(photo) = app.session.catalog.photo(id).cloned() else { return (area, area, resp) }; let caption_h = 26.0; let img_area = Rect::from_min_max(area.min, pos2(area.right(), area.bottom() - caption_h)); - let frame = lightcraft_pipeline::geometry::Frame::with_lens( - photo.width.max(1) as usize, - photo.height.max(1) as usize, - &photo.develop, - true, - photo.embedded_lens.as_ref(), - ); + let frame = frame_of(&photo); let aspect = frame.aspect() as f32; let native = super::detail::output_px(&frame); let mut img = super::detail::fit_rect(img_area, aspect, zoom, native, ppp, app.ui.pan); @@ -249,7 +261,13 @@ fn photo_tile( let texture_side = super::detail::texture_side(ui.ctx()); let want = (img.width().max(img.height()).min(img_area.width().max(img_area.height()) * 4.0) * ppp).min(2560.0_f32.min(texture_side as f32)) as usize; - request_tile_renders(app, id, slot, want, aspect); + // a gliding survey tile asks for its render once it has landed, not one per size it passes on + // the way, and for its thumbnail (one size) meanwhile; tiles that stay put render as usual + if app.ui.view == ViewMode::Survey && app.survey_motion.gliding(id, ui.input(|i| i.time)) { + request_thumb(app, id); + } else { + request_tile_renders(app, id, slot, want, aspect); + } // zoomed past what that render holds (1:1 to check focus): the part on screen as a window, as // in the loupe. Compare and Reference only; Survey tiles are fit views. let pane = match slot { @@ -546,21 +564,6 @@ pub fn show_compare(app: &mut LightcraftApp, ui: &mut egui::Ui) { ui.painter().line_segment([pos2(mid, area.top()), pos2(mid, area.bottom())], Stroke::new(1.0, Tokens::get(ui.ctx()).divider)); } -/// Columns for `n` tiles of aspect ~3:2 in `area`, maximizing the tile size. -pub fn survey_columns(n: usize, area: Rect) -> usize { - let mut best = (1, 0.0f32); - for cols in 1..=n.max(1) { - let rows = n.div_ceil(cols); - let w = area.width() / cols as f32; - let h = area.height() / rows as f32; - let s = w.min(h * 1.5); - if s > best.1 { - best = (cols, s); - } - } - best.0 -} - pub fn show_survey(app: &mut LightcraftApp, ui: &mut egui::Ui) { let t = Tokens::get(ui.ctx()); let canvas = area_and_filmstrip(app, ui); @@ -570,14 +573,20 @@ pub fn show_survey(app: &mut LightcraftApp, ui: &mut egui::Ui) { return; } let area = canvas.shrink(14.0); - let cols = survey_columns(photos.len(), area); - let rows = photos.len().div_ceil(cols); - let (cw, ch) = (area.width() / cols as f32, area.height() / rows as f32); - for (i, id) in photos.iter().enumerate() { - let (c, r) = (i % cols, i / cols); - let cell = Rect::from_min_size(pos2(area.left() + c as f32 * cw, area.top() + r as f32 * ch), vec2(cw, ch)).shrink(6.0); + let aspects: Vec = photos.iter().map(|id| app.session.catalog.photo(*id).map_or(1.5, |p| frame_of(p).aspect() as f32)).collect(); + let cells = survey::cells(&aspects, area); + let now = ui.input(|i| i.time); + let placed = app.survey_motion.place(&photos, &cells, area, ui.ctx().cumulative_frame_nr(), now); + let (slots, freed) = app.survey_motion.assign_slots(&photos); + for s in freed { + app.renderer.release(Slot::Compare(s)); + } + if app.survey_motion.moving(now) { + ui.ctx().request_repaint(); + } + for ((id, cell), slot) in photos.iter().zip(placed).zip(slots) { // (Survey tiles are fit views with no windows: what counts is the photo as painted) - let (_, img, resp) = photo_tile(app, ui, *id, Slot::Compare(i as u8), cell, "", Zoom::Fit); + let (_, img, resp) = photo_tile(app, ui, *id, Slot::Compare(slot), cell.shrink(survey::GAP), "", Zoom::Fit); if app.session.selection.active == Some(*id) { app.image_rect = Some(img); } diff --git a/crates/ui-egui/src/panels/compare/survey.rs b/crates/ui-egui/src/panels/compare/survey.rs new file mode 100644 index 00000000000..c4cb3eb9cf5 --- /dev/null +++ b/crates/ui-egui/src/panels/compare/survey.rs @@ -0,0 +1,261 @@ +//! Survey layout: the cells the photos are tiled in, fitted to their shapes, and the glide that +//! moves the tiles left to their new cells when a photo leaves or joins the survey, so it is +//! plain which photo went where. + +use std::collections::HashMap; + +use egui::{Rect, pos2, vec2}; +use lightcraft_catalog::PhotoId; + +/// Space a tile keeps below its photo for the caption (as `photo_tile` draws it). +pub const CAPTION_H: f32 = 26.0; +/// Margin around each tile inside its cell. +pub const GAP: f32 = 6.0; +/// Seconds a tile takes to glide to its new cell. +pub const GLIDE_SECS: f64 = 0.2; + +/// A width / height ratio that layout arithmetic can use: the photo's own, as it is drawn (a +/// 100:1 panorama counts as one), or a square for a size that is none. +fn usable_aspect(a: f32) -> f32 { + if a.is_finite() && a > 0.0 { a } else { 1.0 } +} + +/// Image area photos with `aspects` show in a grid of `cols` equal cells in `area`. +fn shown_area(aspects: &[f32], cols: usize, area: Rect) -> f32 { + let rows = aspects.len().div_ceil(cols.max(1)); + let iw = area.width() / cols.max(1) as f32 - 2.0 * GAP; + let ih = area.height() / rows.max(1) as f32 - 2.0 * GAP - CAPTION_H; + if iw <= 0.0 || ih <= 0.0 { + return 0.0; + } + aspects + .iter() + .map(|&a| { + let a = usable_aspect(a); + let w = iw.min(ih * a); + w * w / a + }) + .sum() +} + +/// The cell of each photo (width / height `aspects`, in survey order) in `area`: equal cells in +/// rows, with the column count that shows the most of the photos, so the survey fits their shapes +/// to the screen as Lightroom Classic's does (four portrait photos side by side on a wide screen, +/// not two by two). An incomplete last row is centred. +pub fn cells(aspects: &[f32], area: Rect) -> Vec { + let n = aspects.len(); + if n == 0 { + return Vec::new(); + } + let mut best = (1, f32::NEG_INFINITY); + for cols in 1..=n { + let shown = shown_area(aspects, cols, area); + if shown > best.1 { + best = (cols, shown); + } + } + let cols = best.0; + let rows = n.div_ceil(cols); + let (cw, ch) = (area.width() / cols as f32, area.height() / rows as f32); + let last_row = n - (rows - 1) * cols; + (0..n) + .map(|i| { + let (c, r) = (i % cols, i / cols); + let indent = if r == rows - 1 { (cols - last_row) as f32 * cw / 2.0 } else { 0.0 }; + Rect::from_min_size(pos2(area.left() + indent + c as f32 * cw, area.top() + r as f32 * ch), vec2(cw, ch)) + }) + .collect() +} + +/// One tile's way from where it was drawn to its cell. +#[derive(Clone, Copy, Debug)] +struct Glide { + from: Rect, + to: Rect, + start: f64, +} + +impl Glide { + fn at(&self, now: f64) -> Rect { + let t = ((now - self.start) / GLIDE_SECS).clamp(0.0, 1.0) as f32; + // ease out: quick to leave, gentle to land + let e = 1.0 - (1.0 - t).powi(3); + self.from.lerp_towards(&self.to, e) + } + + fn on_its_way(&self, now: f64) -> bool { + !self.done(now) && self.from != self.to + } + + fn done(&self, now: f64) -> bool { + // (a hair early: the clock's rounding must not keep a landed tile moving) + now - self.start >= GLIDE_SECS - 1e-9 + } +} + +/// Where the survey's tiles are drawn while they glide, and which render slot each photo keeps +/// (a photo keeps its slot while it is shown, so the tiles that move keep their renders). +#[derive(Default)] +pub struct SurveyMotion { + /// The survey area of the last frame drawn, and its frame number. + last: Option<(Rect, u64)>, + tiles: HashMap, + slots: HashMap, +} + +impl SurveyMotion { + /// Where to draw `photos` (in survey order) at `now`, given their `cells` in `area` this frame + /// (`frame`, egui's cumulative frame number). A tile whose cell changed since the last frame glides + /// there from where it was drawn; a photo that joined appears in its cell. A survey just opened + /// or a canvas that changed size is laid out at once. + pub fn place(&mut self, photos: &[PhotoId], cells: &[Rect], area: Rect, frame: u64, now: f64) -> Vec { + let continued = self.last.is_some_and(|(a, p)| a == area && frame <= p.saturating_add(1)); + self.last = Some((area, frame)); + let mut next = HashMap::with_capacity(photos.len()); + let placed = photos + .iter() + .zip(cells) + .map(|(id, &to)| { + let glide = match self.tiles.get(id) { + Some(g) if continued && g.to == to => *g, + Some(g) if continued => Glide { from: g.at(now), to, start: now }, + _ => Glide { from: to, to, start: now }, + }; + next.insert(*id, glide); + glide.at(now) + }) + .collect(); + self.tiles = next; + placed + } + + /// Whether a tile is still on its way. + pub fn moving(&self, now: f64) -> bool { + self.tiles.values().any(|g| g.on_its_way(now)) + } + + /// Whether the tile of `id` is still on its way (a tile that stays put, or a photo that just + /// joined, is not, while others glide). + pub fn gliding(&self, id: PhotoId, now: f64) -> bool { + self.tiles.get(&id).is_some_and(|g| g.on_its_way(now)) + } + + /// The render slot of each of `photos`: the one it had, else the lowest free one. Returns the + /// slots that photos no longer shown gave up, whose renders can be freed. + pub fn assign_slots(&mut self, photos: &[PhotoId]) -> (Vec, Vec) { + let freed: Vec = self.slots.iter().filter(|(id, _)| !photos.contains(id)).map(|(_, s)| *s).collect(); + self.slots.retain(|id, _| photos.contains(id)); + let used: Vec = self.slots.values().copied().collect(); + let mut free = (0..=u8::MAX).filter(move |s| !used.contains(s)); + let slots = photos.iter().map(|id| *self.slots.entry(*id).or_insert_with(|| free.next().unwrap_or(u8::MAX))).collect(); + (slots, freed) + } + + /// The render slot `id` keeps, if it has one. + #[cfg(test)] + pub fn slot(&self, id: PhotoId) -> Option { + self.slots.get(&id).copied() + } + + /// Whether `id` has a tile here (its place or its render slot). + #[cfg(test)] + pub fn tracks(&self, id: PhotoId) -> bool { + self.tiles.contains_key(&id) || self.slots.contains_key(&id) + } +} + +#[cfg(test)] +mod tests { + use super::{CAPTION_H, GAP, GLIDE_SECS, SurveyMotion, cells}; + use egui::{Rect, pos2, vec2}; + use lightcraft_catalog::PhotoId; + + const WIDE: Rect = Rect { min: pos2(0.0, 0.0), max: pos2(1600.0, 800.0) }; + + fn cols(cells: &[Rect]) -> usize { + cells.iter().filter(|c| c.top() == cells[0].top()).count() + } + + #[test] + fn four_portraits_stand_side_by_side_on_a_wide_screen() { + let c = cells(&[2.0 / 3.0; 4], WIDE); + assert_eq!(cols(&c), 4, "{c:?}"); + } + + #[test] + fn four_landscapes_on_a_wide_screen_take_two_rows() { + let c = cells(&[1.5; 4], WIDE); + assert_eq!(cols(&c), 2, "{c:?}"); + } + + /// Column choice follows the ratio drawn, also past 20:1: four 100:1 panoramas and four + /// portraits show most side by side in four columns, not one tall column. + #[test] + fn panoramas_count_at_their_own_ratio() { + let area = Rect::from_min_size(pos2(0.0, 0.0), vec2(2560.0, 1440.0)); + let aspects = [100.0, 100.0, 100.0, 100.0, 2.0 / 3.0, 2.0 / 3.0, 2.0 / 3.0, 2.0 / 3.0]; + assert_eq!(cols(&cells(&aspects, area)), 4); + } + + #[test] + fn the_last_row_is_centred() { + let c = cells(&[1.5; 5], WIDE); + assert_eq!(cols(&c), 3, "{c:?}"); + let (row, last) = (&c[..3], &c[3..]); + assert_eq!(last.len(), 2); + let mid = |r: &[Rect]| (r[0].left() + r[r.len() - 1].right()) / 2.0; + assert!((mid(row) - mid(last)).abs() < 0.01, "{c:?}"); + } + + #[test] + fn cells_stay_inside_the_area_and_survive_hostile_sizes() { + for aspects in [vec![f32::NAN, 0.0, -1.0, f32::INFINITY, 1e9, f32::MAX, f32::MIN_POSITIVE], vec![1.5; 48]] { + let c = cells(&aspects, WIDE); + assert_eq!(c.len(), aspects.len()); + assert!(c.iter().all(|r| WIDE.expand(0.01).contains_rect(*r)), "{c:?}"); + } + assert!(cells(&[], WIDE).is_empty()); + // a canvas too small for any tile still lays them out, one column + let tiny = Rect::from_min_size(pos2(0.0, 0.0), vec2(2.0 * GAP, CAPTION_H)); + assert_eq!(cells(&[1.0; 3], tiny).len(), 3); + } + + #[test] + fn a_tile_glides_to_its_new_cell_and_lands_there() { + let (a, b) = (PhotoId(1), PhotoId(2)); + let mut m = SurveyMotion::default(); + let first = cells(&[1.5; 2], WIDE); + assert_eq!(m.place(&[a, b], &first, WIDE, 1, 0.0), first, "a new survey is laid out at once"); + assert!(!m.moving(0.0)); + // a leaves: b moves to the single cell + let one = cells(&[1.5], WIDE); + let mid = m.place(&[b], &one, WIDE, 2, 1.0); + assert_eq!(mid[0], first[1], "it starts where it was drawn"); + assert!(m.moving(1.0)); + let half = m.place(&[b], &one, WIDE, 3, 1.0 + GLIDE_SECS / 2.0)[0]; + assert!(half != first[1] && half != one[0], "on its way: {half:?}"); + assert_eq!(m.place(&[b], &one, WIDE, 4, 1.0 + GLIDE_SECS)[0], one[0], "it lands in its cell"); + assert!(!m.moving(1.0 + GLIDE_SECS)); + } + + #[test] + fn a_reopened_survey_or_a_resized_canvas_does_not_glide() { + let (a, b) = (PhotoId(1), PhotoId(2)); + let mut m = SurveyMotion::default(); + m.place(&[a, b], &cells(&[1.5; 2], WIDE), WIDE, 1, 0.0); + let one = cells(&[1.5], WIDE); + assert_eq!(m.place(&[b], &one, WIDE, 9, 1.0), one, "frames skipped: the survey was not shown"); + let narrow = Rect::from_min_size(pos2(0.0, 0.0), vec2(900.0, 800.0)); + let c = cells(&[1.5], narrow); + assert_eq!(m.place(&[b], &c, narrow, 10, 2.0), c, "a new canvas size"); + } + + #[test] + fn photos_keep_their_slots_and_new_ones_take_freed_slots() { + let (a, b, c, d) = (PhotoId(1), PhotoId(2), PhotoId(3), PhotoId(4)); + let mut m = SurveyMotion::default(); + assert_eq!(m.assign_slots(&[a, b, c]), (vec![0, 1, 2], vec![])); + assert_eq!(m.assign_slots(&[a, c]), (vec![0, 2], vec![1]), "c keeps its render"); + assert_eq!(m.assign_slots(&[a, c, d]), (vec![0, 2, 1], vec![]), "d takes the freed slot"); + } +} diff --git a/crates/ui-egui/src/tests/compare.rs b/crates/ui-egui/src/tests/compare.rs index 4ce0341fb11..ee86f5322f4 100644 --- a/crates/ui-egui/src/tests/compare.rs +++ b/crates/ui-egui/src/tests/compare.rs @@ -485,6 +485,110 @@ fn survey_command_click_takes_the_photo_out() { assert_eq!((sel(&h), active(&h)), (vec![a], Some(a)), "the last photo stays in the survey"); } +/// A photo taken out of the survey leaves the others to glide to their new cells, so it shows +/// which photo went where: a frame later a tile is between its old and new place, then it lands. +#[test] +fn survey_tiles_glide_to_their_new_cells() { + let mut h = demo(); + let [a, _, c] = survey_of_three(&mut h); + let tile = |h: &Headless| h.app.widgets.iter().find(|(w, _)| *w == format!("cull:{c}")).map(|(_, r)| *r).expect("the tile is laid out"); + let before = tile(&h); + h.app.run("library.select", json!({"ids": [a], "mode": "toggle"})).unwrap(); + h.step(); + h.step(); + let moving = tile(&h); + assert!(h.app.survey_motion.moving(h.time()), "the tiles are on their way"); + h.settle(SETTLE); + let after = tile(&h); + assert!(!h.app.survey_motion.moving(h.time())); + assert_ne!(before, after, "the photo has a new cell"); + assert!(moving != before && moving != after, "between {before:?} and {after:?}: {moving:?}"); +} + +/// A photo that joins the survey makes room: the tiles already there glide to their new cells too. +#[test] +fn survey_tiles_glide_when_a_photo_joins() { + let mut h = demo(); + let ids = survey_of_three(&mut h); + let joining = h.app.session.visible_cloned().iter().map(|p| p.0).find(|p| !ids.contains(p)).expect("a fourth photo"); + let tile = |h: &Headless, id: u64| h.app.widgets.iter().find(|(w, _)| *w == format!("cull:{id}")).map(|(_, r)| *r).expect("the tile is laid out"); + let before = ids.map(|id| tile(&h, id)); + h.app.run("library.select", json!({"ids": [joining], "mode": "toggle"})).unwrap(); + h.step(); + h.step(); + let moving = ids.map(|id| tile(&h, id)); + assert!(h.app.survey_motion.moving(h.time()), "the tiles are on their way"); + h.settle(SETTLE); + let after = ids.map(|id| tile(&h, id)); + let moved: Vec = (0..3).filter(|&i| before[i] != after[i]).collect(); + assert!(!moved.is_empty(), "a photo joining changes the grid: {before:?} → {after:?}"); + for i in moved { + assert!(moving[i] != before[i] && moving[i] != after[i], "tile {i} between {:?} and {:?}: {:?}", before[i], after[i], moving[i]); + } +} + +/// A photo that joins takes its cell at once, so it asks for its own render while the others are +/// still gliding (it doesn't wait on the thumbnail until they land). +#[test] +fn a_photo_that_joins_renders_while_the_others_glide() { + let mut h = demo(); + let ids = survey_of_three(&mut h); + let joining = h.app.session.visible_cloned().into_iter().find(|p| !ids.contains(&p.0)).expect("a fourth photo"); + h.app.run("library.select", json!({"ids": [joining.0], "mode": "toggle"})).unwrap(); + h.step(); + h.step(); + let now = h.time(); + assert!(h.app.survey_motion.moving(now), "the others are on their way"); + assert!(!h.app.survey_motion.gliding(joining, now), "the photo that joined stays put"); + let slot = h.app.survey_motion.slot(joining).expect("the photo that joined has a slot"); + assert!(h.app.renderer.wanted(crate::render::Slot::Compare(slot)).is_some(), "its render is asked for"); +} + +/// Photo ids are local to a library: opening another one forgets the survey's tiles, so a photo +/// there with the same id doesn't glide from a cell of the library left. +#[test] +fn opening_another_library_forgets_the_survey_tiles() { + let dir = std::env::temp_dir().join(format!("lc-ui-survey-switch-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + let mut h = demo(); + let ids = survey_of_three(&mut h); + let tracked = |h: &Headless| ids.iter().filter(|id| h.app.survey_motion.tracks(lightcraft_catalog::PhotoId(**id))).count(); + assert_eq!(tracked(&h), 3); + let r = h.app.run("app.openLibrary", json!({"path": dir.join("second").to_string_lossy()})); + assert!(r.is_ok(), "{r:?}"); + assert_eq!(tracked(&h), 0, "nothing of the library left is remembered"); + drop(h); + let _ = std::fs::remove_dir_all(&dir); +} + +/// Every surveyed photo gets its own render, and keeps it when another photo leaves the survey +/// (each photo keeps its render slot, so the tiles that move don't fall back to thumbnails). +#[test] +fn survey_tiles_keep_their_renders_when_a_photo_leaves() { + let mut h = demo(); + let [a, b, c] = survey_of_three(&mut h); + let rendered = |h: &Headless, ids: &[u64]| { + ids.iter().all(|id| h.app.renderer.textures.iter().any(|(s, t)| matches!(s, crate::render::Slot::Compare(_)) && t.photo.0 == *id)) + }; + assert!(h.step_until(SETTLE, |h| rendered(h, &[a, b, c])), "each tile shows its render"); + let slot_of = |h: &Headless, id: u64| { + h.app.renderer.textures.iter().find(|(s, t)| matches!(s, crate::render::Slot::Compare(_)) && t.photo.0 == id).map(|(s, _)| *s) + }; + let c_slot = slot_of(&h, c).expect("c is rendered"); + let c_tex = h.app.renderer.textures.get(&c_slot).map(|t| t.tex.id()).expect("c's texture"); + h.app.run("library.select", json!({"ids": [a], "mode": "toggle"})).unwrap(); + h.step(); + h.step(); + assert!(h.app.survey_motion.moving(h.time())); + let drawn = h.view.painted_shapes().iter().any(|s| match s { + egui::epaint::Shape::Rect(r) => r.fill_texture_id() == c_tex, + egui::epaint::Shape::Mesh(m) => m.texture_id == c_tex, + _ => false, + }); + assert!(drawn, "c's render is drawn while it moves, not its thumbnail"); + assert!(h.step_until(SETTLE, |h| rendered(h, &[b, c]))); +} + /// Hover photo `id`'s survey tile, as a person does, so its × appears; then click the × in its corner. fn click_x(h: &mut Headless, id: u64) { let name = format!("cull:{id}"); diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 471263c055b..7d1ec1a01a9 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -135,7 +135,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-VIEW-NAVIGATOR | Navigator mini map | P1 | ✅ | `cmd:view.navigator`, `crates/ui-egui/src/panels/detail.rs` | shown while zoomed (bottom right); click/drag pans | | LR-VIEW-BEFOREAFTER | Before / after | P0 | ✅ | `cmd:view.showOriginal`, `cmd:view.beforeAfter`, `cmd:view.beforeAfterSplit`, `cmd:view.beforeAfterTopBottom`, `cmd:view.beforeAfterSplitTopBottom`, `cmd:beforeAfter.setBefore`, `cmd:beforeAfter.copyAfterToBefore`, `cmd:beforeAfter.copyBeforeToAfter`, `cmd:beforeAfter.swap`, `cmd:beforeAfter.resetBefore` | all four layouts; before = the import state (defaults + import preset) or a chosen history step / version / the current settings; copy and swap (View → Before/After Settings, History row menu). The chosen before lasts for the session; in side by side and top / bottom, clicks with the white-balance selector, colour samplers and targeted adjustment work in the Before view too (`crates/ui-egui/src/tests/before_after.rs`). Zoomed in, the side by side and stacked views each stay in their pane, with their labels under it. Click zoom animates both panes together, including cached window tiles; input follows the displayed image and render requests use the final size (#1821) | | LR-VIEW-COMPARE | Compare two photos | P1 | ✅ | `cmd:view.compare`, `cmd:compare.swap`, `cmd:compare.makeSelect`, `cmd:compare.set`, `crates/ui-egui/src/panels/compare.rs`, `crates/ui-egui/src/tests/compare.rs` | select / candidate, synced zoom + pan, arrows move the candidate; a filmstrip click puts the photo into the active side (a photo on the other side swaps), so the active photo is always one of the two shown; a ⌘/Ctrl- or Shift-click on the filmstrip changes the selection as in the grid while the two photos shown stay selected and the active photo is unchanged (#187); the active pane is framed in the active photo's two-tone selection ring (theme tokens, 3 pt), as in the grids; 1:1 to 8:1 sharp on both sides (zoom windows, see LR-VIEW-ZOOM); no zoom-link toggle; each pane says “Rendering…” (widget `compare:rendering:`) or “This photo can't be opened” (`compare:renderFailed:`) as the loupe does | -| LR-VIEW-SURVEY | Survey view [Classic] | P2 | ✅ | `cmd:view.survey`, `crates/ui-egui/src/panels/compare.rs` | selection tiled (≤ 48), keys, the bottom bar and the Info panel's stars and colour labels act on the active photo (ringed as in the grid), each tile's caption shows its colour label, hover × or ⌘/Ctrl-click removes a photo | +| LR-VIEW-SURVEY | Survey view [Classic] | P2 | ✅ | `cmd:view.survey`, `crates/ui-egui/src/panels/compare.rs` | selection tiled (≤ 48), keys, the bottom bar and the Info panel's stars and colour labels act on the active photo (ringed as in the grid), each tile's caption shows its colour label, hover × or ⌘/Ctrl-click removes a photo; the tiles fit the photos' shapes (the column count that shows the most of them, so four portrait photos stand side by side; an incomplete last row is centred) and glide to their new places when a photo leaves or joins, each keeping its render (`crates/ui-egui/src/panels/compare/survey.rs`) | | LR-VIEW-INFOOVERLAY | Info overlay on the photo | P1 | ✅ | `cmd:view.infoOverlay`, `cmd:view.viewOptions`, `crates/ui-egui/src/panels/detail.rs` (`info_overlay`) | off / Info 1 (by default file name, capture date, size) / Info 2 (file name, exposure, camera + lens), each three lines chosen in View Options; ⌘I cycles (I in full screen; elsewhere I stays the Info panel); the star rating and flag show under the lines when the photo has them, and in the full-screen preview on macOS the overlay starts below the window controls (issue #2460) | | LR-VIEW-SLIDESHOW | Slideshow | P2 | ✅ | `cmd:view.slideshow` | View ▸ Slideshow (⌥⌘↩): the photos in view full screen from the selected one, played with the library's playback settings (see LRC-SS-PLAYBACK: fades, random order, repeat, previews prepared ahead; `interval` / any setting overrides one run); Space pauses, ←/→ step (a cut), Esc ends; playback controls on pointer movement | | LR-VIEW-SECONDWINDOW | Second display window [Classic] | P2 | ✅ | `cmd:view.secondWindow`, `crates/ui-egui/src/panels/second.rs` | Window ▸ Second Window (⌘F11): the active photo fitted in its own native window with its own render (a floating panel where there are no native windows); loupe view only (no grid / compare / survey there) | @@ -809,6 +809,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 2026-11-06 | minor | LR-EDIT-DETAIL-CNR, LRC-DEV-PROCESS: process V6 takes colour noise reduction to the joint method on linear R−Y / B−Y (issue #815); status unchanged | | 2026-11-05 | minor | LR-BEHAV-RENDER-FIDELITY, LRC-DEV-PROCESS: process V5 rolls a raw's tone curve off into white in stops, past a camera curve's last knot and from half a stop below the generic curve's white point, so raising Exposure no longer turns recorded highlights white (#1632); statuses and counts unchanged | | 2026-11-05 | minor | LR-LIB-PEOPLE: face boxes another app drew on the photo as stored land on the upright photo (#2674) | +| 2026-11-02 | patch | LR-VIEW-SURVEY: the survey picks the column count that shows the most of its photos at their own shapes (four portrait photos side by side on a wide screen, not two by two) and centres an incomplete last row; when a photo leaves or joins, the others glide to their new places in 0.2 s and keep their renders (each photo keeps its render slot); status unchanged | | 2026-11-02 | minor | LRC-DEV-AUTOSYNC (N-A3, note 18): Auto Sync carries white balance as a mode or on each photo's own scale: As Shot and Auto per photo (were the active photo's numbers), a Temp move keeps each photo's tint, the same number on photos of the same scale, a photo of another scale (a JPEG beside a raw) moves by as much; Sync Settings unchanged; status unchanged | | 2026-10-29 | minor | LR-PREF-LOCALSTORAGE, LRC-LIB-PREVIEWS: the preview cache stays uncapped and warns once per session when its drive has under 10 % or 20 GB free, with a button to Settings → Performance; statuses unchanged | | 2026-10-27 | minor | LRC-LIB-PREVIEWS: the loupe shows built and prepared previews instead of rendering again, builds skip what is there and Build Previews with one photo open builds the view; LRC-PERF-PREP new (🟡): preparing photos in the background per mode |