LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge origin/main into slideshow-playback (painted toast from batch 33, kept at the top during a slideshow; both Slot variants; tracker rows)
Jason Baldwin09ea6a3f773f
diff --cc crates/ui-egui/src/panels/mod.rsindex cb19353e8,a8d99aed2..a5f998b72--- a/crates/ui-egui/src/panels/mod.rs+++ b/crates/ui-egui/src/panels/mod.rs@@@ -83,30 -79,16 +80,18 @@@ pub fn toast(app: &mut LightcraftApp, clet Some(canvas) = app.canvas_rect else { return };let t = Tokens::get(ctx);let fade = ((until - now) / 0.25).clamp(0.0, 1.0) as f32;- let (background, foreground) = label.map(crate::theme::label_toast_colors).unwrap_or((egui::Color32::from_black_alpha(200), t.text));- let background = background.gamma_multiply(fade);- let foreground = foreground.gamma_multiply(fade);+ let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, egui::Id::new("toast")));// long messages (a save warning, the web build's notices) wrap within the canvaslet wrap = (canvas.width() - 80.0).clamp(200.0, 720.0);- egui::Area::new(egui::Id::new("toast"))- .order(egui::Order::Foreground)- .movable(false)- .pivot(Align2::CENTER_CENTER)- // the toast takes the pointer (its text can be selected), so it must not sit on buttons: a- // slideshow's playback controls and a dialog's buttons are at the bottom, so it goes to the top there- .fixed_pos(pos2(- canvas.center().x,- if app.ui.slideshow.is_some() || app.ui.dialog.is_some() { canvas.top() + 60.0 } else { canvas.bottom() - 60.0 },- ))- .show(ctx, |ui| {- ui.set_max_width(wrap);- egui::Frame::NONE.fill(background).corner_radius(egui::CornerRadius::same(6)).inner_margin(egui::Margin::symmetric(20, 11)).show(- ui,- |ui| {- ui.add(egui::Label::new(egui::RichText::new(text).font(t.font(14.0)).color(foreground)).wrap());- },- );- });+ let (background, foreground) = label.map(crate::theme::label_toast_colors).unwrap_or((egui::Color32::from_black_alpha(200), t.text));+ let foreground = foreground.gamma_multiply(fade);+ let galley = painter.layout(text, t.font(14.0), foreground, wrap);+ let size = vec2(galley.size().x + 40.0, (galley.size().y + 22.0).max(40.0));- let r = Rect::from_center_size(pos2(canvas.center().x, canvas.bottom() - 60.0), size);++ // a slideshow's playback controls sit at the bottom: the toast goes to the top there, clear of them++ let y = if app.ui.slideshow.is_some() { canvas.top() + 60.0 } else { canvas.bottom() - 60.0 };++ let r = Rect::from_center_size(pos2(canvas.center().x, y), size);+ painter.rect_filled(r, 6.0, background.gamma_multiply(fade));+ painter.galley(r.center() - galley.size() / 2.0, galley, foreground);ctx.request_repaint_after(std::time::Duration::from_millis(30));}diff --cc crates/ui-egui/src/render.rsindex ab5d77228,fd0f0e9bf..79377ab91--- a/crates/ui-egui/src/render.rs+++ b/crates/ui-egui/src/render.rs@@@ -55,9 -55,9 +55,12 @@@ pub enum SlotImport(u32),/// The second window's view of the active photo.Second,+ /// A slideshow slide (the one up, the one fading out, the next ones prepared in advance; see+ /// [`crate::panels::slideshow`]).+ Slide(PhotoId),+ /// A slider drag's live HDR histogram: a small full-quality render of an HDR edit, beside the+ /// drafts (which have no HDR histogram), with no texture ([`Renderer::live_hdr_histogram`]).+ HdrHistogram,}pub struct Tex {diff --cc crates/ui-egui/src/tests_masking.rsindex e071a7389,bf808b532..11c871b44--- a/crates/ui-egui/src/tests_masking.rs+++ b/crates/ui-egui/src/tests_masking.rs@@@ -896,6 -905,80 +905,48 @@@ fn local_folder_tree_expands_and_browseh.settle(SETTLE);}+ /// A folder listed twice in Local (Pictures as a place of its own and again inside Home) opens+ /// and closes on each row by itself: both copies of its triangle used to share one egui id, so+ /// the copy drawn later took the clicks of the one drawn first (issue #1093).+ #[test]+ fn local_folder_listed_twice_opens_and_closes_each_row() {+ let base = std::env::temp_dir().join(format!("lc-ui-twice-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&base);+ let inner = base.join("Inner");+ std::fs::create_dir_all(inner.join("Sub")).unwrap();+ let mut h = detail("panel.edit");+ exec(&mut h, "view.leftPanel", json!({"show": true}));+ h.hide_home_above(&base);+ let (base_s, inner_s) = (base.to_string_lossy().to_string(), inner.to_string_lossy().to_string());+ let sub = inner.join("Sub").to_string_lossy().to_string();+ exec(&mut h, "local.addRoot", json!({"path": base_s}));+ exec(&mut h, "local.addRoot", json!({"path": inner_s}));+ h.settle(SETTLE);+ let r = h.request("ui.clickWidget", json!({"id": format!("folderToggle:{base_s}")}), T);+ assert_eq!(r["ok"], true, "{r}");+ let toggle = format!("folderToggle:{inner_s}");+ h.step_until(SETTLE, |h| h.app.widgets.iter().filter(|(w, _)| *w == toggle).count() == 2);+ let rows = |h: &Headless, id: &str| h.app.widgets.iter().filter(|(w, _)| w == id).count();+ assert_eq!(rows(&h, &toggle), 2, "Inner is listed inside the base folder and as a place of its own");+ let sub_row = format!("source:local:{sub}");+ assert_eq!(rows(&h, &sub_row), 0);+ // each copy's triangle opens that copy only, and closes it again+ for copy in 0..2 {+ let at = h.app.widgets.iter().filter(|(w, _)| *w == toggle).nth(copy).map(|(_, r)| r.center()).unwrap();+ let r = h.request("ui.click", json!({"x": at.x, "y": at.y}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step_until(SETTLE, |h| h.app.widgets.iter().any(|(w, _)| *w == sub_row));+ assert_eq!(rows(&h, &sub_row), 1, "copy {copy} opens, the other stays closed");+ let at = h.app.widgets.iter().filter(|(w, _)| *w == toggle).nth(copy).map(|(_, r)| r.center()).unwrap();+ let r = h.request("ui.click", json!({"x": at.x, "y": at.y}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.settle(SETTLE);+ assert_eq!(rows(&h, &sub_row), 0, "copy {copy} closes again");+ }+ let _ = std::fs::remove_dir_all(&base);+ h.settle(SETTLE);+ }+-#[test]-fn slideshow_advances_pauses_and_ends() {- let mut h = detail("panel.edit");- let first = h.app.session.active();- exec(&mut h, "view.slideshow", json!({"interval": 0.5}));- assert!(h.app.ui.fullscreen && h.app.ui.slideshow.is_some());- // simulated time runs with the frames- let mut moved = false;- for _ in 0..200 {- h.step();- if h.app.session.active() != first {- moved = true;- break;- }- }- assert!(moved, "the next photo comes up");- // Space pauses: nothing moves- let r = h.request("ui.key", json!({"key": "space"}), T);- assert_eq!(r["ok"], true, "{r}");- assert!(h.app.ui.slideshow.is_some_and(|s| s.2), "paused");- let held = h.app.session.active();- for _ in 0..120 {- h.step();- }- assert_eq!(h.app.session.active(), held);- // Esc ends it- let r = h.request("ui.key", json!({"key": "escape"}), T);- assert_eq!(r["ok"], true, "{r}");- assert!(!h.app.ui.fullscreen && h.app.ui.slideshow.is_none());- h.settle(SETTLE);-}-#[test]fn geometry_slider_drag_marks_the_grid() {let mut h = detail("panel.crop");diff --cc docs/parity-checklist.mdindex 8480d039b,76d91ba3e..67937e846--- a/docs/parity-checklist.md+++ b/docs/parity-checklist.md@@@ -36,7 -36,7 +36,7 @@@ cited here still exists. Formerly docs/| H. Crop & rotate (CROP) | 9 | 0 | 0 | 1 | 6/6 (100%) | 3/3 (100%) || I. Remove / healing (REM) | 8 | 1 | 2 | 2 | 4/4 (100%) | 2/3 (67%) || J. Red eye (EYE) | 2 | 0 | 0 | 0 | — | 1/1 (100%) |--| K. Masking (MASK) | 13 | 5 | 5 | 0 | 7/8 (88%) | 5/5 (100%) |++| K. Masking (MASK) | 14 | 5 | 5 | 0 | 7/8 (88%) | 6/6 (100%) || L. Presets (PRE) | 6 | 0 | 1 | 1 | 2/2 (100%) | 2/2 (100%) || M. Versions & history (VER) | 5 | 0 | 0 | 0 | 1/1 (100%) | 3/3 (100%) || N. Copy / paste / sync (SYNC) | 5 | 0 | 0 | 0 | 3/3 (100%) | 1/1 (100%) |@@@ -52,10 -52,10 +52,10 @@@| X. Cross-cutting behaviours (BEHAV) | 23 | 6 | 1 | 1 | 8/8 (100%) | 7/10 (70%) || Y. Menus | 84 | 0 | 4 | 8 | 47/47 (100%) | 23/23 (100%) || Z. Keyboard shortcuts (desktop) | 76 | 3 | 3 | 1 | 49/52 (94%) | 23/24 (96%) |-| Lightroom Classic extras | 34 | 16 | 35 | 8 | — | 24/26 (92%) |-| **Total** | 408 | 52 | 72 | 35 | 193/201 (96%) | 145/157 (92%) |+| Lightroom Classic extras | 34 | 17 | 34 | 8 | — | 24/26 (92%) |- | **Total** | 408 | 52 | 71 | 35 | 193/201 (96%) | 145/157 (92%) |++| **Total** | 409 | 53 | 71 | 35 | 193/201 (96%) | 146/158 (92%) |- Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **81.7%** of 531 in-scope rows — P0 98.0% of 201 · P1 95.2% of 157 · P2 50.3% of 172.-Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **81.6%** of 532 in-scope rows — P0 98.0% of 201 · P1 95.2% of 157 · P2 50.0% of 173.++Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **81.7%** of 533 in-scope rows — P0 98.0% of 201 · P1 95.3% of 158 · P2 50.3% of 173.<!-- /parity:summary -->## Top gaps and shortcut notes@@@ -132,14 -132,14 +132,14 @@@ differences and missing bindings are i| LR-VIEW-ZOOM | Zoom & pan | P0 | 🟡 | `cmd:view.zoomFit`, `cmd:view.zoom100`, `cmd:view.zoomIn`, `cmd:view.zoomOut`, `cmd:view.zoomToggle`, `cmd:view.clickZoom`, `cmd:view.navigate`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/headless.rs` | continuous native pinch / modifier-wheel zoom (Fit–800%, anchored under the pointer), two-finger scroll / touch pan with edge limits; Detail (including tools, Before/After and full-screen preview), Compare and Reference; fractional percentages preserve small gestures; image, picker and targeted-adjustment cursors stay steady between gesture events; keyboard steps 25–800 % (not 6–1600 %); Fill in the bottom bar; click / Z / Space eases to the chosen ratio (1:1 default, 2:1, 3:1, 4:1, 8:1). The loupe's cost follows the canvas, not the zoom (issue #323): the whole frame is rendered at about canvas size (at most the 2560 px preview source level unless a larger Preview size is chosen, and never above the GPU's texture side), and once the view is zoomed well past that (more than 25 %) the window on screen is rendered too, cut from a frame of at most the photo's own pixels, so beyond 100 % the GPU magnifies it (`region::plan`, `RenderRequest::window`, `Session::region_job`, `crates/ui-egui/src/region.rs`); 1:1 and 2:1–8:1 are sharp at any photo size. A slider tick takes 7–12 ms on a 1400 × 900 canvas and 11–25 ms on a 2800 × 1700 one at 100 % and 400 % of a 24 MP photo (M1 Max, GPU, `profile_slider_drag`); about 20–25 ms at 100 % on the big canvas is over a 16 ms frame. A continuous pinch holds the render sizes (and the windows there are) until it is quiet. A fit view on a canvas up to about 3200 px (a Retina Mac) never decodes the original; larger displays get a window at fit, which does. Modes that draw another picture over the loupe (mask overlays, soft proofing) and photos whose spots or Auto Mask strokes read too far for one window (only photos longer than 8192 px) render the whole frame at the size it is drawn, as before windows; while a preset or profile is hovered, or over a picture that is not the frame (an unsupported raw's embedded JPEG), the whole frame stays canvas-sized. Before/After (side by side, stacked, `\\` and both wipes) gets the same windows on both sides, clipped to their pane or side of the line. Windows render on the GPU like whole frames (equivalence-tested against the CPU), in the browser build too (windows no wider than its GPU's texture side, at most 3072 px), and are not made while hovering a look, soft-proofing or showing an overlay, nor over a picture that is not the frame (an unsupported raw's embedded JPEG with another crop). No texture is larger than the GPU allows. Spots and Auto Mask brushes work while what a window reads fits one render (8192 px along an axis, 4096 in the browser): the window grows to hold the spot and its source patch, or the dabs near it, and if that would take more (a clone from far away at 8:1) the loupe keeps the whole-frame render instead, and spots with an automatic source pick it from a fixed-size render of the whole frame (so a window's choice can differ from a whole-frame render's, which picks at its own resolution). The wide stages (dehaze, clarity, highlights/shadows base) and Refine Edges on masks read a window margin capped at 768 px; measured on hard-edged blocks that costs at most a few levels at 8:1. the histogram and Navigator come from the whole-frame render. Compare and Reference get the same windows, one per pane (`Slot::CompareRegion`, `panels/compare.rs`), over each pane's whole-frame render (at most 2560 px); while either view is open two originals stay decoded (`MediaCache::set_full_capacity`), so one pane's window does not evict the other's source; a pinch, or a slider drag on the active photo in Reference, keeps the windows there are until it ends. Still 🟡: mask overlays and soft proofing have no window (a full-size whole-frame render at 1:1) || 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 |- | 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; 1:1 to 8:1 sharp on both sides (zoom windows, see LR-VIEW-ZOOM); no zoom-link toggle |+ | 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; 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:<pane>`) or “This photo can't be opened” (`compare:renderFailed:<pane>`) 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 act on the active photo, hover × removes || LR-VIEW-INFOOVERLAY | Info overlay on the photo | P1 | ✅ | `cmd:view.infoOverlay` | off / file + date + size / exposure + camera; ⌘I cycles (I in full screen; elsewhere I stays the Info panel) |-| LR-VIEW-SLIDESHOW | Slideshow | P2 | ✅ | `cmd:view.slideshow` | View ▸ Slideshow (⌥⌘↩): the photos in view full screen, every 4 s (`interval`), wrapping; Space pauses, ←/→ step, Esc ends |+| 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) || LR-VIEW-CLIPPING | Clipping indicators | P0 | ✅ | `cmd:view.clipping` | |- | LR-VIEW-HISTOGRAM | Histogram | P0 | ✅ | `cmd:view.histogram`, `crates/ui-egui/src/panels/edit.rs`, `crates/pipeline/src/lib.rs` (`hdr_histogram`) | HDR edits: SDR on the left half, the HDR range (0 to 5 stops above SDR white, a fixed scale) on the right with the headroom limit marked; colour bar (white, or Visualize HDR range's colours when that is on) and SDR / HDR labels; no drag-to-adjust on the histogram |- | LR-VIEW-HDR-DISPLAY | HDR display output | P2 | ⬜ | | |+ | LR-VIEW-HISTOGRAM | Histogram | P0 | ✅ | `cmd:view.histogram`, `crates/ui-egui/src/panels/edit.rs`, `crates/pipeline/src/lib.rs` (`hdr_histogram`) | HDR edits: SDR on the left half, the HDR range (0 to 5 stops above SDR white, a fixed scale) on the right with the headroom limit marked; colour bar (white, or Visualize HDR range's colours when that is on) and SDR / HDR labels; no drag-to-adjust on the histogram; it follows slider drags live (a small render beside the drafts, `Slot::HdrHistogram`) and never drops to the SDR layout mid-drag |+ | LR-VIEW-HDR-DISPLAY | HDR display output | P2 | ⬜ | |, `apps/lightcraft/src/hdr_display.rs` (`choose`, `preferred_hdr_format`) | SDR/HDR decision (platform, surface format, OS headroom, `LIGHTCRAFT_HDR_DISPLAY=0`) is unit-tested and logged at start; always SDR today because eframe configures an 8-bit surface; no OS headroom query yet; |## D. Search & filter (FILT)diff --cc docs/whats-new.mdindex db5455167,b5c2ac68c..923bc8e9d--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -45,17 -150,24 +150,34 @@@- Upgrading from a Windows installer older than 0.6 (such as 0.5.0) keeps LightCraft in the folder it was installedin, instead of moving it back to Program Files (issue #399). If that folder has been deleted since, the upgradeinstalls to Program Files.+ - A photo that runs into a bug in LightCraft while it renders (in a raw decoder or the editing pipeline) now fails+ like a photo that can't be opened, with the reason, instead of rendering forever; its thumbnail stops waiting too.+ Each such bug used to take one of the render threads with it, so after a few of them no photo rendered until+ LightCraft was restarted. The bug is still written to the log (Help ▸ Open Log Folder) for a report.++ ### Library sorting+ - Photos that tie on the sort key (equal ratings, one import batch, a burst shot within the same second) now sort by+ file name, then id, instead of import order. Recently Added keeps a batch in file name order, and Auto-Stack orders a+ burst by file name, so the first file is the cover.++ ### Large preset collections+ - A library holding thousands of presets (a Lightroom collection imported whole: 11 000 presets, a 42 MB+ presets.json) stays responsive. Every command used to re-serialize the whole list to see whether it had changed+ (~0.6 s per slider tick); now the list is saved only after it changes, and a slider tick takes ~2 ms.+ - The Presets panel builds only the rows in view (and their thumbnails) instead of every preset on every frame; the+ preset pickers in Import and Settings ▸ Import scroll the same way.+ - Importing a large collection and opening its library no longer compare every preset with every other.+### Slideshow playback+- View ▸ Slideshow (⌥⌘↩) now plays with Lightroom Classic's Playback settings: how long each slide stays up, a fade+ between slides (a crossfade, or through black, white or any colour; 0 cuts), random order (every photo once per+ pass, a new order each time round), repeat (off: the slideshow ends after the last photo) and preparing previews in+ advance (the next two slides render while the current one is up, so a fade never waits or flashes).+- Change them in Settings ▸ Slideshow (View ▸ Slideshow Options…); they are saved with the library. Agents use+ `slideshow.playback`; `view.slideshow` takes any of them for one run (`interval` still sets the slide duration).+- While it plays, moving the pointer shows a small control bar: previous, play / pause, next, the slide number and+ end. Space pauses, ← / → step (a cut), Esc ends. A slide's time starts once it is shown sharp.+## 2026-10-10### Dialogs fit the window