Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge PR #999: Alt/Option-drag previews for clipping and sharpening (#937)

aiongg1b32dab094e4
diff --cc crates/engine/src/media/render.rs
index a87a0792c,000000000..4c28e1214
mode 100644,000000..100644
--- a/crates/engine/src/media/render.rs
+++ b/crates/engine/src/media/render.rs
@@@ -1,379 -1,0 +1,392 @@@
+use super::quick::QuickSource;
+use super::source::{DecodedSource, SourceLevel, SourceRef};
+use super::{
+ Arc, DevelopSettings, Hash128, Histogram, PhotoId, PreviewCache, Quality, RenderRequest, Rendered, Rgb32f, Rgba8, Source, SourceInfo, StageCache,
+};
+
+/// Everything needed to render one photo, detached from the session.
+#[derive(Clone)]
+pub struct RenderJob {
+ /// Assigned by a frontend to distinguish late completions, even for an identical render key.
+ pub request_id: u64,
+ pub cache_generation: u64,
+ /// Content identity for validating a decoded source returned after a reload.
+ pub source_key: Option<Hash128>,
+ pub photo: PhotoId,
+ pub level: SourceLevel,
+ pub source: SourceRef,
+ /// Where the photo's pixels come from (for executors that can't share `source`, e.g. a web
+ /// worker).
+ pub origin: Source,
+ pub info: SourceInfo,
+ pub settings: Arc<DevelopSettings>,
+ pub request: RenderRequest,
+ /// Identifies the result for caching: hash of settings + request.
+ pub key: u64,
+ /// Rendered-thumbnail cache and this job's key in it.
+ pub cache: Option<(Arc<PreviewCache>, Hash128)>,
+ /// Intermediate results of this view's previous renders (set by the frontend for the loupe):
+ /// slider drags then only redo the stages the changed setting feeds.
+ pub stages: Option<Arc<StageCache>>,
+ /// Keep a full-quality result here as the photo's view preview ([`crate::Session::loupe_job`]).
+ pub view_cache: Option<(Arc<PreviewCache>, Hash128)>,
+ /// Render for this monitor profile ([`Self::with_display`]).
+ pub display: Option<Arc<crate::display::Display>>,
+ /// Compose the render into a slideshow slide ([`Self::with_slide`]).
+ pub slide: Option<Arc<crate::slide::SlideCompose>>,
+ /// A face tile that can be cut from the raw's embedded preview, tried before `source`
+ /// ([`crate::Session::face_job`]; `None` for every other job).
+ pub preview_cut: Option<crate::face_tiles::PreviewCut>,
+ /// Shrink a full-quality result to fit this size (physical pixels) with a Lanczos filter once
+ /// it is rendered. The loupe renders a little larger than it is drawn (its edge is rounded up
+ /// to a 64 px step) and the window would otherwise shrink the texture with 2-tap bilinear sampling, which blurs fine detail at
+ /// small ratios and aliases it at large ones. The caches keep the full render.
+ pub display_fit: Option<(usize, usize)>,
+}
+
+/// `img` shrunk to fit `max_w × max_h` with a Lanczos filter (see [`RenderJob::display_fit`]).
+pub fn fit_for_display(img: &Rgba8, max_w: usize, max_h: usize) -> Rgba8 {
+ use lightcraft_raster::resample::{Filter, fit};
+ let f = lightcraft_raster::Image {
+ width: img.width,
+ height: img.height,
+ data: img.data.iter().map(|p| [f32::from(p[0]), f32::from(p[1]), f32::from(p[2]), f32::from(p[3])]).collect(),
+ };
+ let small = fit(&f, max_w.max(1), max_h.max(1), Filter::Lanczos3);
+ let c = |v: f32| v.round().clamp(0.0, 255.0) as u8;
+ Rgba8 { width: small.width, height: small.height, data: small.data.iter().map(|p| [c(p[0]), c(p[1]), c(p[2]), c(p[3])]).collect() }
+}
+
+pub struct RenderResult {
+ pub request_id: u64,
+ pub source_key: Option<Hash128>,
+ pub photo: PhotoId,
+ pub level: SourceLevel,
+ pub key: u64,
+ pub rendered: Result<Rendered, String>,
+ /// Set when this job's render was tried on the GPU and fell back to the CPU: why
+ /// ([`lightcraft_gpu::Fallback::Failed`]). The result is the CPU render either way.
+ pub gpu_fallback: Option<String>,
+ /// A source that was loaded by this job (to be inserted into the cache).
+ pub loaded: Option<DecodedSource>,
+ /// Set for a [`QuickJob`]'s stand-in: where the image came from.
+ pub quick: Option<QuickSource>,
+ /// The display profile (id) the image is encoded for; `None`: sRGB (see
+ /// [`crate::display::present`]).
+ pub display: Option<u64>,
+}
+
+impl RenderJob {
+ /// Render at draft quality (interactive drags). Gets its own result key.
+ /// Shrink the full-quality result to fit `w × h` pixels with a Lanczos filter (see
+ /// [`Self::display_fit`]). Gets its own result key, so a change of drawn size renders again.
+ pub fn with_display_fit(mut self, w: usize, h: usize) -> Self {
+ self.display_fit = Some((w, h));
+ self.key ^= ((w as u64) << 32 | h as u64).wrapping_mul(0x9e37_79b9_7f4a_7c15);
+ self
+ }
+
+ pub fn draft(mut self) -> Self {
+ if self.request.quality != Quality::Draft {
+ self.request.quality = Quality::Draft;
+ self.key ^= 0x9e37_79b9_7f4a_7c15;
+ }
+ self
+ }
+
+ /// Draw a diagnostic overlay over the result (e.g. Point Color's visualized range). Gets its
+ /// own result key.
+ pub fn with_overlay(mut self, overlay: lightcraft_pipeline::Overlay) -> Self {
+ if self.request.overlay != overlay {
+ self.key ^= self.request.overlay.key().wrapping_mul(0x9e37_79b9_7f4a_7c15);
+ self.request.overlay = overlay;
+ self.key ^= overlay.key().wrapping_mul(0x9e37_79b9_7f4a_7c15);
+ }
+ // a diagnostic view (visualized range / spots) must never become the photo's cached preview
+ if overlay != lightcraft_pipeline::Overlay::None {
+ self.view_cache = None;
+ }
+ self
+ }
+
+ /// Soft-proof the result (see [`lightcraft_pipeline::Proof`]). Gets its own result key and is
+ /// never kept as the photo's cached preview.
+ pub fn with_proof(mut self, proof: Option<lightcraft_pipeline::Proof>) -> Self {
+ if self.request.proof != proof {
+ let k = |p: Option<lightcraft_pipeline::Proof>| p.map_or(0, |p| p.key()).wrapping_mul(0xc2b2_ae3d_27d4_eb4f);
+ self.key ^= k(self.request.proof) ^ k(proof);
+ self.request.proof = proof;
+ }
+ if proof.is_some() {
+ self.view_cache = None;
+ }
+ self
+ }
+
+ /// Render with some colour grading wheels (shadows, midtones, highlights) switched off for
+ /// viewing (the wheel eyes in the Edit panel). The photo's settings are untouched; the result
+ /// gets its own key and is never cached as the photo's preview or thumbnail.
+ pub fn with_hidden_grading(mut self, hidden: [bool; 3]) -> Self {
+ if !hidden.iter().any(|h| *h) {
+ return self;
+ }
+ let mut s = (*self.settings).clone();
+ let g = &mut s.grading;
+ for (off, wheel) in hidden.into_iter().zip([&mut g.shadows, &mut g.midtones, &mut g.highlights]) {
+ if off {
+ *wheel = lightcraft_develop::Wheel::default();
+ }
+ }
+ let bits = hidden.iter().enumerate().fold(0u64, |b, (i, h)| b | ((*h as u64) << i));
+ self.key ^= s.hash64() ^ self.settings.hash64() ^ bits.wrapping_mul(0xd6e8_feb8_6659_fd93);
+ self.settings = Arc::new(s);
+ self.cache = None;
+ self.view_cache = None;
+ self.preview_cut = None;
+ self
+ }
+
+ /// Reuse `stages` across this view's renders.
+ pub fn with_stages(mut self, stages: Arc<StageCache>) -> Self {
+ self.stages = Some(stages);
+ self
+ }
+
+ /// Render for a monitor profile: into the display's primaries (its gamut, not sRGB's), ready
+ /// to show ([`RenderResult::display`]). The histogram and the cached view preview stay sRGB.
+ /// Gets its own result key. Thumbnail jobs (rendered-thumbnail cache) are left as they are:
+ /// [`crate::display::present`] converts their sRGB results.
+ pub fn with_display(mut self, display: Option<Arc<crate::display::Display>>) -> Self {
+ // (a slide is composed in sRGB, backdrop colours included; the frontend presents it)
+ if self.cache.is_some() || self.slide.is_some() || self.request.depth != lightcraft_pipeline::OutputDepth::U8 {
+ return self;
+ }
+ let k = |d: &Option<Arc<crate::display::Display>>| d.as_ref().map_or(0, |d| d.id()).wrapping_mul(0xd6e8_feb8_6659_fd93);
+ self.key ^= k(&self.display) ^ k(&display);
+ self.request.display = display.as_ref().map(|d| d.space);
+ self.display = display;
+ self
+ }
+
+ /// Render. A panic inside (a decoder or pipeline bug) is this job's failure: the view waiting
+ /// for it is told, instead of waiting forever on a worker that died (the pool doesn't replace
+ /// it, so a few such panics used to stop every render).
+ pub fn run(self) -> RenderResult {
+ let failed = self.failed(String::new());
+ crate::guard::catch("the render", || self.run_unguarded()).unwrap_or_else(|e| RenderResult { rendered: Err(e), ..failed })
+ }
+
+ /// This job's result when it fails with `e`.
+ fn failed(&self, e: String) -> RenderResult {
+ RenderResult {
+ request_id: self.request_id,
+ source_key: self.source_key,
+ photo: self.photo,
+ level: self.level,
+ key: self.key,
+ rendered: Err(e),
+ gpu_fallback: None,
+ loaded: None,
+ quick: None,
+ display: None,
+ }
+ }
+
+ /// Compose the render into a slideshow slide (layout, options, backdrop): the result is the
+ /// slide, not the photo. Gets its own result key; the photo's cached view preview stays the
+ /// photo. The slide stays sRGB ([`Self::with_display`] leaves it alone).
+ pub fn with_slide(mut self, slide: Arc<crate::slide::SlideCompose>) -> Self {
+ let k = |s: &Option<Arc<crate::slide::SlideCompose>>| s.as_ref().map_or(0, |s| s.key()).wrapping_mul(0xa24b_aed4_963e_e407);
+ self.key ^= k(&self.slide);
+ self.key ^= k(&Some(slide.clone()));
+ self.slide = Some(slide);
+ self
+ }
+
+ /// [`Self::run_photo`], composed into its slide when this is a slide job (inside [`Self::run`]'s guard).
+ fn run_unguarded(self) -> RenderResult {
+ let slide = self.slide.clone();
+ let mut r = self.run_photo();
+ if let (Some(slide), Ok(rendered)) = (slide, r.rendered.as_mut()) {
+ rendered.image = slide.compose(&rendered.image);
+ rendered.deep = None;
+ }
+ r
+ }
+
+ /// The photo's render (without slide composition).
+ fn run_photo(self) -> RenderResult {
+ if let Some((cache, key)) = &self.cache
+ && let Some(img) = cache.get_at(self.cache_generation, *key)
+ {
+ let image = Arc::unwrap_or_clone(img);
+ let histogram = Histogram::of_srgb8(&image);
+ return RenderResult {
+ request_id: self.request_id,
+ source_key: self.source_key,
+ photo: self.photo,
+ level: self.level,
+ key: self.key,
+ rendered: Ok(Rendered { image, histogram, deep: None }),
+ gpu_fallback: None,
+ loaded: None,
+ quick: None,
+ display: None,
+ };
+ }
+ // a face tile of an unedited raw: cut from the camera's embedded preview when it is big enough
+ // (the sensor data is never read for it), else rendered from `source` below
+ if let Some(image) = self.preview_cut.as_ref().and_then(|c| c.cut()) {
+ if let Some((cache, key)) = &self.cache {
+ cache.put_at(self.cache_generation, *key, Arc::new(image.clone()));
+ }
+ let histogram = Histogram::of_srgb8(&image);
+ return RenderResult {
+ request_id: self.request_id,
+ source_key: self.source_key,
+ photo: self.photo,
+ level: self.level,
+ key: self.key,
+ rendered: Ok(Rendered { image, histogram, deep: None }),
+ gpu_fallback: None,
+ loaded: None,
+ quick: None,
+ display: None,
+ };
+ }
+ let was_loaded = matches!(self.source, SourceRef::Loaded(_));
+ // The app is closing (issue #620): nobody is left to show this, and quitting waits for the
+ // jobs that are running. Without this, one that lost the GPU mid-way would render on the CPU.
+ let closing = || lightcraft_gpu::shutting_down().then(|| "LightCraft is closing".to_string());
+ let source = match closing() {
+ Some(e) => Err(e),
+ None => self.source.load_source().and_then(|s| closing().map_or(Ok(s), Err)),
+ };
+ match source {
+ Ok(source) => {
+ // the plain picture, or (Denoise amount above 0 and a denoised picture cached) the mix the amount asks for
+ let src = &source.image_for(self.settings.denoise_amount());
+ let info = source.info_or(self.info);
+ // Thumbnails (many small jobs side by side) stay on the CPU; views and exports use
+ // the GPU when there is one.
+ let gpu = self.cache.is_none();
- let (mut rendered, gpu_fallback) = develop_reporting(src, &info, &self.settings, &self.request, self.stages.as_deref(), gpu);
++ // a clipping preview tests sRGB values, like the histogram: rendered in sRGB, then
++ // converted for the display below
++ let clip_view = self.request.overlay.is_clipping();
++ let request = if clip_view { RenderRequest { display: None, ..self.request } } else { self.request };
++ let (mut rendered, gpu_fallback) = develop_reporting(src, &info, &self.settings, &request, self.stages.as_deref(), gpu);
+ // for a display profile: the image goes to the display's values, the histogram
+ // and the cached view preview stay sRGB
+ let mut srgb = None;
+ let display = match (&self.display, self.request.display) {
++ // a diagnostic view: the histogram stays the photo's (taken before the overlay
++ // was drawn), and nothing goes to the view cache
++ (Some(d), Some(_)) if self.request.overlay != lightcraft_pipeline::Overlay::None => {
++ let converted = if clip_view { d.profile.from_srgb(&mut rendered.image) } else { d.profile.correct(&mut rendered.image) };
++ if let Err(e) = converted {
++ log::warn!("display profile: {e}");
++ }
++ Some(d.id())
++ }
+ (Some(d), Some(_)) => {
+ let keep = self.view_cache.is_some() && self.request.quality == Quality::Full;
+ let (s, h) = crate::display::finish_render(&mut rendered.image, d, keep);
+ // (an HDR edit's HDR histogram stays)
+ if let Some(h) = h.filter(|_| rendered.histogram.hdr.is_none()) {
+ rendered.histogram = h;
+ }
+ srgb = s;
+ Some(d.id())
+ }
+ _ => None,
+ };
+ if let Some((cache, key)) = &self.cache {
+ cache.put_at(self.cache_generation, *key, Arc::new(rendered.image.clone()));
+ }
+ if let Some((cache, key)) = &self.view_cache
+ && self.request.quality == Quality::Full
+ && (display.is_none() || srgb.is_some())
+ {
+ cache.put_deferred_at(self.cache_generation, *key, Arc::new(srgb.unwrap_or_else(|| rendered.image.clone())));
+ }
+ // the display fit, after the caches have the full render
+ if let Some((fw, fh)) = self.display_fit
+ && self.request.quality == Quality::Full
+ {
+ let (w, h) = (rendered.image.width, rendered.image.height);
+ if w > fw.max(1) || h > fh.max(1) {
+ rendered.image = fit_for_display(&rendered.image, fw, fh);
+ }
+ }
+ RenderResult {
+ request_id: self.request_id,
+ source_key: self.source_key,
+ photo: self.photo,
+ level: self.level,
+ key: self.key,
+ rendered: Ok(rendered),
+ gpu_fallback,
+ loaded: (!was_loaded).then_some(source),
+ quick: None,
+ display,
+ }
+ }
+ Err(e) => self.failed(e),
+ }
+ }
+}
+
+/// Render `src`: on the GPU when `gpu` is set and a GPU is available (`lightcraft_gpu`), else on
+/// the CPU, reusing `stages` either way. Both produce the same image within 1–3 LSB (see
+/// `docs/gpu-pipeline.md`); `LIGHTCRAFT_GPU=0` or [`lightcraft_gpu::set_enabled`] forces the CPU.
+pub fn develop(src: &Arc<Rgb32f>, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest, stages: Option<&StageCache>, gpu: bool) -> Rendered {
+ develop_reporting(src, info, s, req, stages, gpu).0
+}
+
+/// [`develop`], also saying why the render fell back from the GPU to the CPU when it did (`None`:
+/// it rendered on the GPU, or the GPU was not tried). The reason is this render's own, not the
+/// process-wide [`lightcraft_gpu::last_fallback`].
+pub fn develop_reporting(
+ src: &Arc<Rgb32f>,
+ info: &SourceInfo,
+ s: &DevelopSettings,
+ req: &RenderRequest,
+ stages: Option<&StageCache>,
+ gpu: bool,
+) -> (Rendered, Option<String>) {
+ let (mut rendered, fallback) = develop_image(src, info, s, req, stages, gpu);
+ // an HDR edit's preview is its SDR rendition: its histogram shows the HDR range instead
+ if let Some(h) = lightcraft_pipeline::hdr_histogram(src, info, s, req) {
+ rendered.histogram = h;
+ }
+ (rendered, fallback)
+}
+
+fn develop_image(
+ src: &Arc<Rgb32f>,
+ info: &SourceInfo,
+ s: &DevelopSettings,
+ req: &RenderRequest,
+ stages: Option<&StageCache>,
+ gpu: bool,
+) -> (Rendered, Option<String>) {
+ // LUT profiles have no GPU stage: they render on the CPU
+ let fallback = if gpu
+ && !lightcraft_pipeline::lut::is_lut_profile(&s.profile.id)
+ && !s.masks.iter().any(|m| m.visible && m.refine > 0.0)
+ && req.proof.is_none()
+ {
+ match lightcraft_gpu::try_render(src, info, s, req, stages) {
+ Ok(r) => return (r, None),
+ Err(lightcraft_gpu::Fallback::Failed(why)) => Some(why),
+ Err(lightcraft_gpu::Fallback::NotTried) => None,
+ }
+ } else {
+ None
+ };
+ let rendered = match stages {
+ Some(st) => lightcraft_pipeline::render_cached(src, info, s, req, st),
+ None => lightcraft_pipeline::render(src, info, s, req),
+ };
+ (rendered, fallback)
+}
diff --cc crates/pipeline/src/finish.rs
index 4fccd1134,99c83dc42..c1443a8b8
--- a/crates/pipeline/src/finish.rs
+++ b/crates/pipeline/src/finish.rs
@@@ -532,134 -678,6 +541,134 @@@ pub(crate) fn finish_with<T: Copy + Def
out
}
+struct PixelLocalTerms {
+ values: [f32; MASK_SUMS],
+ tint: Option<([f32; 3], f32)>,
+}
+
+fn pixel_local_terms(p: &Prepared, terms: &[[f32; MASK_TERMS]], index: usize) -> PixelLocalTerms {
+ let mut values = [0.0; MASK_SUMS];
+ let mut tint = None;
+ for (mask, terms) in p.masks.iter().zip(terms) {
+ let alpha = mask.alpha.data[index];
+ if alpha <= 0.0 {
+ continue;
+ }
+ for (sum, term) in values.iter_mut().zip(terms.iter().take(MASK_SUMS)) {
+ *sum += alpha * term;
+ }
+ if terms[MASK_SUMS] > 0.0 {
+ tint = Some(([terms[MASK_SUMS + 1], terms[MASK_SUMS + 2], 0.0], alpha * terms[MASK_SUMS + 3]));
+ }
+ }
+ PixelLocalTerms { values, tint }
+}
+
+fn adjust_scene_pixel(p: &Prepared, fp: &FinishParams, index: usize, raw: [f32; 3], local: &PixelLocalTerms) -> ([f32; 3], f32) {
+ let [l_exp, l_temp, l_tint, _, _, _, _, _, _, _, l_dehaze, _, _, _, l_noise, l_moire, l_defringe] = local.values;
+ let mut color = if fp.gain == 1.0 { raw } else { raw.map(|value| value * fp.gain) };
+
+ let moire = (l_moire + 0.5 * l_noise.max(0.0)).clamp(-1.0, 1.0);
+ if moire != 0.0
+ && let Some(blur) = &p.chroma_blur
+ {
+ let (luminance, original, blurred) = (luminance_2020(color), crate::masks::chromaticity(raw), blur.data[index]);
+ color = std::array::from_fn(|channel| ((original[channel] + (blurred[channel] - original[channel]) * moire) * luminance).max(0.0));
+ }
+ let defringe = l_defringe.clamp(0.0, 1.0);
+ if defringe > 0.0
+ && let Some(blur) = &p.texture_blur
+ {
+ let amount = defringe * defringe_weight(color, p.log_l.data[index] - blur.data[index]);
+ if amount > 0.0 {
+ let luminance = luminance_2020(color);
+ color = color.map(|value| value + (luminance - value) * amount);
+ }
+ }
+
+ let dehaze = fp.dehaze + l_dehaze;
+ if dehaze != 0.0
+ && let Some(dark) = &p.dark
+ {
+ // Limit the estimated veil to the pixel's own minimum channel. This avoids crushing bright
+ // neighbours when the dark-channel blur spans the edge of a local window.
+ let min_channel = color[0].min(color[1]).min(color[2]);
+ let veil = (if fp.air_pre > 0.0 { dark.data[index] / fp.air_pre } else { 0.0 })
+ .min(if fp.air > 0.0 { min_channel / fp.air } else { 0.0 })
+ .clamp(0.0, 1.0);
+ if dehaze > 0.0 {
+ let transmission = (1.0 - 0.95 * dehaze.min(1.0) * veil).max(0.12);
+ color = color.map(|value| ((value - fp.air * (1.0 - transmission)) / transmission).max(0.0));
+ } else {
+ let amount = (-dehaze).min(1.0) * 0.7 * (0.35 + 0.65 * veil);
+ color = color.map(|value| value + (fp.air * 0.9 - value) * amount);
+ }
+ }
+
+ if l_exp != 0.0 {
+ let gain = l_exp.exp2();
+ color = color.map(|value| value * gain);
+ }
+ if l_temp != 0.0 || l_tint != 0.0 {
+ let luminance_before = luminance_2020(color);
+ color = [color[0] * (1.0 + 0.3 * l_temp), color[1] * (1.0 - 0.22 * l_tint), color[2] * (1.0 - 0.3 * l_temp).max(0.0)];
+ let luminance_after = luminance_2020(color).max(1e-9);
+ color = color.map(|value| value * luminance_before / luminance_after);
+ }
+
+ let l0 = p.log_l.data[index] + fp.ev;
+ let log_luminance = if dehaze != 0.0 || l_exp != 0.0 { log_lum(color) } else { l0 };
+ (color, log_luminance)
+}
+
+fn local_tone_delta(p: &Prepared, fp: &FinishParams, index: usize, base: f32, l1: f32, local: &PixelLocalTerms) -> f32 {
+ let [_, _, _, l_con, l_hl, l_sh, l_wh, l_bl, l_tex, l_clar, _, _, _, l_sharp, l_noise, _, _] = local.values;
+ let mut delta = 0.0;
+ let (highlights, shadows) = (fp.hl + l_hl, fp.sh + l_sh);
+ if highlights != 0.0 || shadows != 0.0 {
+ let shadow_weight = 1.0 - smooth(-4.8, 0.3, base);
+ let highlight_weight = smooth(-1.0, 2.8, base);
+ delta += shadows * 1.7 * shadow_weight * shadow_weight.sqrt() + highlights * 1.7 * highlight_weight;
+ }
+ if l_wh != 0.0 {
+ delta += l_wh * 0.8 * smooth(0.5, 3.0, l1);
+ }
+ if l_bl != 0.0 {
+ delta += l_bl * 0.8 * (1.0 - smooth(-6.0, -1.5, l1));
+ }
+ if l_con != 0.0 {
+ delta += l_con * 0.14 * l1.clamp(-6.0, 4.0);
+ }
+ let clarity = fp.clar + l_clar;
+ if clarity != 0.0
+ && let Some(blur) = &p.clarity_blur
+ {
+ let detail = (p.log_l.data[index] - blur.data[index]).clamp(-2.5, 2.5);
+ let midtone = (-(base / 3.2).powi(2)).exp();
+ delta += clarity * 0.85 * detail * (0.35 + 0.65 * midtone);
+ }
+ let texture = fp.tex + l_tex;
+ let sharpen = l_sharp * 0.6 + fp.sharpen;
+ if (texture != 0.0 || sharpen != 0.0)
+ && let Some(blur) = &p.texture_blur
+ {
+ let detail = p.log_l.data[index] - blur.data[index];
+ let tame = 1.0 - 0.6 * smooth(0.4, 1.6, detail.abs());
+ delta += texture * 1.1 * detail.clamp(-1.0, 1.0) * tame;
+ if sharpen != 0.0 {
- let mask = if fp.sharpen_mask > 0.0 { smooth(fp.sharpen_mask * 0.25, fp.sharpen_mask * 0.25 + 0.15, detail.abs()) } else { 1.0 };
++ let mask = sharpen_mask_weight(fp.sharpen_mask, detail);
+ delta += sharpen * 1.3 * detail.clamp(-0.8, 0.8) * mask;
+ }
+ }
+ if l_noise != 0.0
+ && let Some(blur) = &p.texture_blur
+ {
+ let detail = p.log_l.data[index] - blur.data[index];
+ delta -= l_noise.clamp(-1.0, 1.0) * 0.9 * detail * (1.0 - smooth(0.1, 0.5, detail.abs()));
+ }
+ delta
+}
+
/// A colour needing more desaturation than this (scale < `GAMUT_WARN`) to fit is out of gamut for
/// the gamut warnings (tolerates rounding at the gamut boundary).
const GAMUT_WARN: f32 = 0.995;
diff --cc crates/pipeline/src/local.rs
index c91872d38,4ddd885cb..948ea12f6
--- a/crates/pipeline/src/local.rs
+++ b/crates/pipeline/src/local.rs
@@@ -557,15 -452,16 +557,20 @@@ pub struct PlaneSigmas
pub chroma: Option<f32>,
}
+ /// Gaussian sigma (pixels) of the texture / sharpening band at `px_per_long`.
+ pub fn texture_sigma(px_per_long: f64) -> f32 {
+ (0.0018 * px_per_long as f32).max(0.6)
+ }
+
pub fn plane_sigmas(s: &DevelopSettings, px_per_long: f64, q: Quality) -> PlaneSigmas {
let ppl = px_per_long as f32;
- let local_any = |f: fn(&lightcraft_develop::LocalAdjustments) -> f64| s.masks.iter().any(|m| f(&m.adjust) != 0.0);
- let tone_active =
- s.light.highlights != 0.0 || s.light.shadows != 0.0 || s.masks.iter().any(|m| m.adjust.highlights != 0.0 || m.adjust.shadows != 0.0);
+ // A hidden mask, or one with no components, does not change the picture. Its sliders must
+ // not pick the tone base Clarity reads (#1214).
+ let live = |m: &&lightcraft_develop::Mask| m.visible && !m.components.is_empty();
+ let local_any = |f: fn(&lightcraft_develop::LocalAdjustments) -> f64| s.masks.iter().filter(live).any(|m| f(&m.adjust) != 0.0);
+ let tone_active = s.light.highlights != 0.0
+ || s.light.shadows != 0.0
+ || s.masks.iter().filter(live).any(|m| m.adjust.highlights != 0.0 || m.adjust.shadows != 0.0);
// Edge-aware base at ~1.5% of the long edge (EV² epsilon: edges of > ~0.6 EV are preserved)
// From V2 it is taken of the median at 0.15%: lines and texture finer than that are detail,
// not tone (#632).
@@@ -580,10 -476,10 +585,10 @@@
|| local_any(|a| a.texture)
|| local_any(|a| a.sharpness)
|| local_any(|a| a.noise)
- || s.masks.iter().any(|m| m.adjust.defringe > 0.0))
+ || s.masks.iter().filter(live).any(|m| m.adjust.defringe > 0.0))
- .then(|| (0.0018 * ppl).max(0.6));
+ .then(|| texture_sigma(px_per_long));
let dark = (s.effects.dehaze != 0.0 || local_any(|a| a.dehaze)).then(|| (0.02 * ppl).max(1.0));
- let chroma = (local_any(|a| a.moire) || s.masks.iter().any(|m| m.adjust.noise > 0.0)).then(|| (CHROMA_SIGMA * ppl).max(1.0));
+ let chroma = (local_any(|a| a.moire) || s.masks.iter().filter(live).any(|m| m.adjust.noise > 0.0)).then(|| (CHROMA_SIGMA * ppl).max(1.0));
let base_detail = if base.is_some() { tone_base_detail(s, px_per_long) } else { 0 };
PlaneSigmas { base, base_detail, clarity, texture, dark, chroma }
}
diff --cc crates/pipeline/src/visualize.rs
index 8f3cf1884,64964de16..cda511baa
--- a/crates/pipeline/src/visualize.rs
+++ b/crates/pipeline/src/visualize.rs
@@@ -198,19 -296,31 +296,36 @@@ pub fn apply(img: &mut Rgba8, o: Overla
mask_view(img, a, view, color, opacity);
}
}
+ Overlay::ClipShadows => clipping(img, false),
+ Overlay::ClipHighlights => clipping(img, true),
+ Overlay::Grayscale => grayscale(img),
+ Overlay::SharpenDetail | Overlay::SharpenMask => {
+ if let Some(p) = plane.filter(|a| (a.width, a.height) == (img.width, img.height)) {
+ let detail = o == Overlay::SharpenDetail;
+ let w = img.width;
+ for_rows(&mut img.data, w, |y, row| {
+ for (x, px) in row.iter_mut().enumerate() {
+ let v = p.data[y * w + x];
+ let g = if detail { 128.0 + v * DETAIL_GAIN } else { 255.0 * v };
+ let g = g.round().clamp(0.0, 255.0) as u8;
+ *px = [g, g, g, 255];
+ }
+ });
+ }
+ }
Overlay::AllMasks { view, color, opacity } => {
- if let Some(planes) = masks {
- for a in planes {
- if (a.width, a.height) == (img.width, img.height) {
- mask_view(img, a, view, color, opacity);
- }
+ // one view of the union of the masks: painting the planes one after another
+ // overwrites (White on Black, Image on Black…) or compounds (Color) the earlier ones
+ let mut union: Option<Plane> = None;
+ for a in masks.unwrap_or_default().iter().filter(|a| (a.width, a.height) == (img.width, img.height)) {
+ match &mut union {
+ None => union = Some(a.clone()),
+ Some(u) => u.data.iter_mut().zip(&a.data).for_each(|(u, a)| *u = u.max(*a)),
}
}
+ if let Some(u) = &union {
+ mask_view(img, u, view, color, opacity);
+ }
}
}
}
diff --cc crates/ui-egui/src/app/frame.rs
index 6e92091c7,000000000..d5ff6f64b
mode 100644,000000..100644
--- a/crates/ui-egui/src/app/frame.rs
+++ b/crates/ui-egui/src/app/frame.rs
@@@ -1,457 -1,0 +1,459 @@@
+use super::{
+ LightcraftApp, docking, drop_overlay, export_task, focus_scan, import, lightroom_import, merge, model_setup, monotonic_ms, panels, pick, recheck,
+ shortcuts, slideshow_export, state, sync, tasks, theme, updates_ui, widgets,
+};
+
+impl LightcraftApp {
+ /// Install/refresh fonts once and watch the device and availability caches. Setup, not input.
+ pub(super) fn ensure_fonts(&mut self, ctx: &egui::Context) {
+ if !self.styled {
+ theme::install_fonts_with_chinese(ctx, self.chinese_font.as_ref());
+ theme::apply(ctx);
+ Self::drop_legacy_panel_state(ctx);
+ // File → Add from Device lists cards scanned in the background: show hot-plugs
+ let repaint = ctx.clone();
+ lightcraft_engine::devices::on_change(move || repaint.request_repaint());
+ // "is the original there?" (grid, Info panel, Missing Photos) answers from a cache a
+ // worker fills: a sleeping NAS or a dropped share never stalls a frame
+ let repaint = ctx.clone();
+ self.session.media.availability.run_in_background(std::sync::Arc::new(move || repaint.request_repaint()));
+ self.styled = true;
+ self.font_language = self.ui.language;
+ } else if self.font_language != self.ui.language {
+ // Shared Han characters take the active language's forms (Japanese faces for 日本語,
+ // the Simplified Chinese face for 简体中文): rebuild the fallback order.
+ theme::install_fonts_with_chinese(ctx, self.chinese_font.as_ref());
+ self.font_language = self.ui.language;
+ } else {
+ self.fonts_ready = true;
+ }
+ }
+
+ /// 0.36 stored each `PanelState` under the panel's exact `Id`; 0.37 stores it under
+ /// `parent_ui.scope_id().with_salt(id_salt)`, so the old entries are unreachable and the
+ /// panels reset once by simply not finding them. Remove the old keys anyway so egui memory
+ /// does not retain dead entries (no document, workspace JSON, catalog or XMP data is
+ /// migrated; nothing above a user's photo edits depends on them).
+ fn drop_legacy_panel_state(ctx: &egui::Context) {
+ for salt in ["top_bar", "bottom_bar", "tool_strip", "library-problem-banner"] {
+ ctx.data_mut(|d| d.remove::<egui::containers::panel::PanelState>(egui::Id::unique(salt)));
+ }
+ }
+
+ /// Queues and timers. Each consumed queue is drained once per call; time-gated work uses the
+ /// monotonic app clock, so a hidden `run_logic` keeps it advancing and a second layout pass is
+ /// a no-op rather than a duplicate.
+ pub(super) fn logic_background(&mut self, ctx: &egui::Context) {
+ panels::notices::logic(self);
+ // closing the window (or Quit) with changes only in memory: retry, else ask first
+ if ctx.input(|i| i.viewport().close_requested()) && !panels::notices::may_close(self) {
+ ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
+ }
+ let now = self.tick_now();
+ self.drain_control(ctx);
+ self.apply_settings(ctx);
+ if self.queued_input_needs_repaint() {
+ ctx.request_repaint();
+ }
+ self.renderer.poll(ctx, &mut self.session);
+ merge::poll(self, ctx);
+ import::poll_scan(self, ctx);
+ sync::poll(self, ctx);
+ sync::poll_run(self, ctx);
+ // Import commits batches and must not run twice in one host frame. The first layout pass
+ // and a hidden logic tick both report pass index 0; a second pass reports 1. A wall-clock
+ // gate cannot express that (a slow discarded first pass would re-run it).
+ if import_tick_allowed(ctx) {
+ import::tick(self, ctx);
+ }
+ lightroom_import::tick(self, ctx);
+ recheck::tick(self);
+ tasks::poll(self, ctx);
+ updates_ui::tick(self, ctx);
+ self.preview_build_status(ctx);
+ self.save_status(ctx);
+ self.ai_mask_detail(ctx, now);
+ self.place_names_outcome(ctx);
+ self.slideshow_tick(ctx, now);
+ panels::denoise::pump_background(self, ctx, now);
+ panels::faces::pump_background(self, ctx, now);
+ model_setup::pump(self, ctx, now);
+ focus_scan::pump(self, ctx, now);
+ // auto import: list the watched folder every few seconds (on a worker thread: it may be on
+ // a network share), then import what's new like any import (also on a worker thread)
+ #[cfg(not(target_arch = "wasm32"))]
+ if let Some(folder) = self.session.import_defaults.auto_folder.clone() {
+ const LABEL: &str = "Auto Import";
+ if now - self.ui.auto_import_at >= 3.0
+ && self.import.is_none()
+ && self.sync_run.is_none()
+ && self.lightroom.is_none()
+ && !self.tasks.is_running(LABEL)
+ {
+ self.ui.auto_import_at = now;
+ let work = move || lightcraft_engine::cmd::library::list_auto_import_folder(&folder);
+ let done = |app: &mut LightcraftApp, _ctx: &egui::Context, listing: Result<Vec<(String, u64)>, String>| {
+ let listing = match listing {
+ Ok(l) => l,
+ Err(e) => return log::debug!("auto import: {e}"),
+ };
+ let p = serde_json::json!({"listing": listing, "start": false});
+ let Ok(r) = app.session.execute("library.autoImportScan", &p) else { return };
+ let Some(mut params) = r.get("import").cloned().filter(|_| app.import.is_none()) else { return };
+ let paths: Vec<String> =
+ params["paths"].as_array().into_iter().flatten().filter_map(|v| v.as_str().map(str::to_string)).collect();
+ if let Some(o) = params.as_object_mut() {
+ o.remove("paths");
+ }
+ let undo0 = app.session.undo.len();
+ app.import = Some(import::ImportTask::new(paths, params, undo0, false).auto());
+ };
+ // listed every few seconds: quiet, no row in the activity stack
+ if let Err(e) = tasks::spawn(self, LABEL, None, work, done) {
+ log::warn!("{e}");
+ }
+ }
+ ctx.request_repaint_after(std::time::Duration::from_secs(3));
+ }
+ // automatic XMP writes that failed (a network share offline): tried again every few seconds once their files
+ // are reachable, and said once when they start waiting and once when they're written
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ if self.session.unsaved_sidecars() > 0 {
+ if now - self.ui.sidecar_retry_at >= 10.0 {
+ self.ui.sidecar_retry_at = now;
+ self.session.retry_unsaved_sidecars();
+ }
+ ctx.request_repaint_after(std::time::Duration::from_secs(10));
+ }
+ let waiting = self.session.unsaved_sidecars();
+ if waiting > 0 && self.ui.sidecars_waiting == 0 {
+ self.toast_for(
+ ctx,
+ crate::i18n::tr_format!(
+ "The XMP sidecars of {n} photos couldn't be written (is their folder offline?). LightCraft keeps trying.",
+ n = waiting
+ ),
+ 8.0,
+ );
+ } else if waiting == 0 && self.ui.sidecars_waiting > 0 {
+ self.toast(ctx, crate::i18n::tr("Wrote the XMP sidecars that were waiting"));
+ }
+ self.ui.sidecars_waiting = waiting;
+ }
+ // Settings → Import: open the import review when a camera or card is connected
+ #[cfg(not(target_arch = "wasm32"))]
+ if self.session.import_defaults.show_on_card {
+ if let Some(now) = lightcraft_engine::devices::devices_scanned() {
+ import::cards_seen(self, now);
+ }
+ ctx.request_repaint_after(lightcraft_engine::devices::MAX_AGE);
+ } else {
+ self.ui.known_cards = None;
+ }
+ self.session.persist_if_dirty();
+ self.expire_gestures();
+ self.collect_screenshots(ctx);
+ self.issue_screenshots(ctx);
+ self.request_paint_while_hidden(ctx);
+ }
+
+ /// While hidden, queued captures and an injected gesture step need a real UI pass; a pending
+ /// screenshot command paints by itself once issued.
+ fn request_paint_while_hidden(&self, ctx: &egui::Context) {
+ // `logic` runs per layout pass; one command per host frame is enough.
+ if ctx.current_pass_index() != 0 {
+ return;
+ }
+ // `ViewportInfo::visible()`: minimized or fully occluded is `Some(false)`; `None`
+ // (headless, `RawInput::default()`) is normal and must not be treated as hidden.
+ let hidden = ctx.input(|i| i.viewport().visible() == Some(false));
+ if hidden && self.needs_ui_pass_while_hidden() {
+ ctx.send_viewport_cmd(egui::ViewportCommand::RequestPaintWhileHidden);
+ }
+ }
+
+ /// A hidden window needs a real UI pass for queued/settling captures, for control gestures
+ /// that still have to resolve or deliver, and for an injected synthetic step. An already
+ /// issued screenshot has its own compositor-driven paint and must not request another
+ /// `RequestPaintWhileHidden`; its fallback and timeout keep running from `logic`.
+ pub(crate) fn needs_ui_pass_while_hidden(&self) -> bool {
+ !self.pending_gestures.is_empty()
+ || self.pointer_cleanup
+ || self.pending_screenshots.iter().any(|shot| shot.sent_at_ms.is_none())
+ || !self.synthetic.is_empty()
+ || self.synthetic_in_flight
+ }
+
+ /// Queued synthetic input, including a queued pointer cancellation that is not part of
+ /// `synthetic`, needs the next visible frame even when an earlier stall left the synthetic
+ /// queue empty.
+ pub(crate) fn queued_input_needs_repaint(&self) -> bool {
+ !self.synthetic.is_empty() || self.pointer_cleanup
+ }
+
+ /// Input, layout and setup for a known UI phase: at most once per host frame, and never from a
+ /// hidden logic tick. `current_pass_index() == 0` is the first pass of this `run_ui`; a second
+ /// pass has empty events.
+ pub(super) fn ui_pass(&mut self, ctx: &egui::Context) {
+ if ctx.current_pass_index() != 0 {
+ return;
+ }
+ // A prompt owns the keyboard and focus. A notice may have been added by this frame's logic
+ // after `raw_input_hook`; capture its Tab/Enter/Space/Escape and drop everything else
+ // before any panel, focused control or shortcut reads the input. A new prompt gets a
+ // shielding pass whose background is not drawn at all (see `draw_window`).
+ let batch_in_flight = self.synthetic_in_flight;
+ if panels::notices::prepare_ui_pass(self, ctx) {
+ self.cancel_gestures_for_barrier(batch_in_flight, "a modal prompt appeared");
+ }
+ panels::library_problem::prepare_ui_pass(self, ctx, batch_in_flight);
+ let now = self.tick_now();
+ // the last pass's time is fine here: this is a UI phase, not a hidden tick
+ let t = ctx.input(|i| i.time);
+ let dt = t - self.last_time;
+ if dt > 0.0 {
+ self.perf.fps = self.perf.fps * 0.9 + (1.0 / dt).min(240.0) * 0.1;
+ }
+ self.last_time = t;
+ panels::denoise::pump_ui_input(self, ctx, now);
+ panels::faces::pump_ui_input(self, ctx, now);
+ // A prompt or the blocking library window owns the library too: files dropped while either
+ // is up wait in the queue and are imported on the first UI pass after it goes away, never
+ // behind it. With no library open the window's `hold_dropped` path still takes the photos
+ // once its own dialog and asynchronous library picker are gone, so `blocks_file_drops`
+ // only holds them back until then. Mark those drops: once the barrier opens they may find
+ // a dialog, Lightroom import or import that the library's own open started still running.
+ if panels::notices::blocks_input(self) || panels::library_problem::blocks_file_drops(self) {
+ self.defer_dropped_files();
+ } else {
+ self.import_dropped_files(ctx);
+ }
+ self.check_external_editor(ctx);
++ // Alt (Option on macOS) while a slider is dragged shows its temporary preview
++ self.ui.alt_held = ctx.input(|i| i.modifiers.alt);
+ // Recent-library checks and launch-list keys read focus/time/keys: they belong to the UI
+ // phase, not the hidden-capable `logic` tick (plan §4.5 / migration input contract).
+ panels::library_problem::logic(self, ctx);
+ if self.fonts_ready && !updates_ui::blocks_input(self) {
+ shortcuts::handle(self, ctx);
+ }
+ }
+
+ /// Lights Out: veil everything but the photo (the loupe's image, or the grid / Compare /
+ /// Survey area) in black. Painted above the panels, below dialogs and notices.
+ fn lights_out(&self, ctx: &egui::Context) {
+ let a = self.ui.lights_out.veil();
+ if a <= 0.0 {
+ return;
+ }
+ let screen = ctx.content_rect();
+ let keep = if self.ui.view == state::ViewMode::Detail { self.image_rect.or(self.canvas_rect) } else { self.canvas_rect };
+ let veil = egui::Color32::from_black_alpha((a.clamp(0.0, 1.0) * 255.0).round() as u8);
+ let p = ctx.layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique("lights-out")));
+ let k = keep.unwrap_or(egui::Rect::NOTHING).intersect(screen);
+ if !k.is_positive() {
+ p.rect_filled(screen, 0.0, veil);
+ return;
+ }
+ // four bands around the photo
+ use egui::{Rect, pos2};
+ p.rect_filled(Rect::from_min_max(screen.min, pos2(screen.right(), k.top())), 0.0, veil);
+ p.rect_filled(Rect::from_min_max(pos2(screen.left(), k.bottom()), screen.max), 0.0, veil);
+ p.rect_filled(Rect::from_min_max(pos2(screen.left(), k.top()), pos2(k.left(), k.bottom())), 0.0, veil);
+ p.rect_filled(Rect::from_min_max(pos2(k.right(), k.top()), pos2(screen.right(), k.bottom())), 0.0, veil);
+ }
+
+ /// Once per library opened (at launch too): name it in the window title, so nobody edits in
+ /// the wrong one, and put it first in File ▸ Open Recent Library.
+ pub(crate) fn library_changed(&mut self, ctx: &egui::Context) {
+ let generation = self.session.library_generation();
+ if self.shown_library == Some(generation) {
+ return;
+ }
+ self.shown_library = Some(generation);
+ if let Some(l) = self.session.library.as_ref().filter(|l| l.on_disk) {
+ let path = l.dir.to_string_lossy().into_owned();
+ panels::settings::remember_library(&mut self.ui.settings.recent_libraries, &path);
+ // it is open: whatever an earlier check said about it is over
+ self.recent_checks.opened(&path);
+ // when, for the launch window (issue #1290); only the listed libraries keep a time
+ let settings = &mut self.ui.settings;
+ settings.recent_opened.insert(path, (self.session.clock)());
+ settings.recent_opened.retain(|p, _| settings.recent_libraries.contains(p));
+ }
+ ctx.send_viewport_cmd(egui::ViewportCommand::Title(self.window_title()));
+ }
+
+ /// "LightCraft — <library name>" (just "LightCraft" for a library that isn't saved).
+ pub fn window_title(&self) -> String {
+ match panels::settings::open_library_name(self) {
+ Some(name) => format!("LightCraft — {name}"),
+ None => "LightCraft".to_string(),
+ }
+ }
+
+ /// The browser page's title: "<file name>[ •] — LightCraft" for the active photo (• while
+ /// `unsaved`: changes not yet written to storage), else the window title. The web build has no
+ /// window for `ViewportCommand::Title`; a host embedding it reads this title to tell which
+ /// document a drop opened and whether it is saved (issue #2397).
+ pub fn page_title(&self, unsaved: bool) -> String {
+ let dot = if unsaved { " •" } else { "" };
+ match self.session.active().and_then(|id| self.session.catalog.photo(id)) {
+ Some(p) => format!("{}{dot} — LightCraft", p.file_name),
+ None => format!("{}{dot}", self.window_title()),
+ }
+ }
+
+ /// A completed, nondiscarded pass is a settled frame; a discarded pass threw its widgets away
+ /// and must not advance the geometry generation a capture binds to.
+ pub(crate) fn finish_ui_pass(&mut self, ctx: &egui::Context) {
+ // Any pass consumed the injected batch; a discarded pass still read its events and the
+ // next pass has none. Only a nondiscarded pass, however, is a settled frame a capture may
+ // bind to and a control gesture may resolve against.
+ self.synthetic_in_flight = false;
+ if ctx.will_discard() {
+ self.next_widgets.clear();
+ self.next_widget_hits.clear();
+ return;
+ }
+ self.widgets = std::mem::take(&mut self.next_widgets);
+ self.widget_hits = std::mem::take(&mut self.next_widget_hits);
+ panels::notices::finish_ui_pass(self, ctx);
+ panels::library_problem::finish_ui_pass(self, ctx);
+ self.ui_passes = self.ui_passes.wrapping_add(1);
+ self.layout_epoch = self.layout_epoch.wrapping_add(1);
+ self.resolve_pending_gestures(ctx);
+ self.reply_delivered_gestures();
+ if self.pointer_cleanup {
+ // A canceled press may be discovered by a timeout after the synthetic queue emptied;
+ // nothing else may ask for the frame that applies its cancellation.
+ ctx.request_repaint();
+ }
+ }
+
+ /// Presentation only: the window's panels, dialogs and overlays.
+ pub(super) fn draw_window(&mut self, ui: &mut egui::Ui) {
+ let ctx = ui.ctx().clone();
+ let t0 = monotonic_ms();
+ panels::library_problem::begin_draw(self);
+ // A command or shortcut drawn before this can create the window after `ui_pass`; catch it
+ // here before any panel draws with the still-focused background text field.
+ let batch_in_flight = self.synthetic_in_flight;
+ panels::library_problem::prepare_ui_pass(self, &ctx, batch_in_flight);
+ // A newly shown blocking library window gets the same barrier as a prompt: its first Area
+ // layout is non-interactable and hit testing still uses the previous pass, so background
+ // panels (and a focused text field) must not draw in that pass.
+ if panels::library_problem::shield_pass(self, &ctx) {
+ #[cfg(test)]
+ self.library_passes.push(panels::library_problem::LibraryPass::Shield);
+ panels::library_problem::show(self, &ctx, false);
+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);
+ ctx.request_discard("library problem: shield the window's creation frame");
+ self.end_frame(&ctx, t0);
+ return;
+ }
+ // A newly shown prompt gets one pass with no background. egui's first Area layout is
+ // non-interactable and its hit test uses the previous pass, so drawing panels here would
+ // let a pointer press/release in the prompt's creation frame act underneath it. `ui()` then
+ // reruns this pass with empty raw input, where the settled prompt and the full window draw
+ // together. This is a state/input-routing barrier, not a wholesale input disable: once
+ // settled, raw pointer input still reaches the prompt backdrop (a no-op) or its buttons.
+ if panels::notices::shield_pass(self, &ctx) {
+ panels::notices::show(self, &ctx);
+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);
+ ctx.request_discard("notice: shield the prompt's creation frame");
+ self.end_frame(&ctx, t0);
+ return;
+ }
+ #[cfg(test)]
+ self.library_passes.push(panels::library_problem::LibraryPass::Background);
+ panels::dialogs::prepare(self, ui);
+ // Freeze this frame's notice barrier before `notices::show` can dismiss a prompt: the same
+ // click or key must never be acted on again by the dialog drawn after it.
+ let notice_blocks = panels::notices::blocks_input(self);
+ if std::mem::take(&mut self.ui.quit) {
+ ctx.send_viewport_cmd(egui::ViewportCommand::Close);
+ }
+ self.library_changed(&ctx);
+ // panels set it again this frame while the pointer rests on a preset or profile
+ self.hover_preview = None;
+ if self.ui.fullscreen {
+ // full-screen preview: the photo alone on black
+ egui::CentralPanel::default()
+ .frame(egui::Frame::NONE.fill(egui::Color32::BLACK))
+ .show(ui, |ui| if self.ui.slideshow.is_some() { panels::slideshow::show(self, ui) } else { panels::detail::show(self, ui) });
+ panels::second::show(self, &ctx);
+ if notice_blocks {
+ panels::notices::restore_prompt_pointer(self, &ctx);
+ }
+ panels::notices::show(self, &ctx);
+ if notice_blocks {
+ panels::notices::hide_background_pointer(&ctx);
+ }
+ panels::dialogs::show(self, &ctx, notice_blocks);
+ updates_ui::show(self, &ctx);
+ panels::library_problem::show(self, &ctx, notice_blocks);
+ panels::toast(self, &ctx);
+ drop_overlay::show(self, &ctx);
+ if notice_blocks {
+ // Keep the real press/release state for the next pass: an ordinary click spans
+ // host frames, and resetting it above must only hide it from this pass's dialogs.
+ panels::notices::restore_prompt_pointer(self, &ctx);
+ }
+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);
+ self.end_frame(&ctx, t0);
+ return;
+ }
+ // Order matters: earlier panels take the full edge (top bar spans the window; the tool strip,
+ // right panels and left panel run to the bottom; the bottom bar sits between them).
+ panels::topbar::show(self, ui);
+ panels::library_problem::banner(self, ui);
+ panels::strip::show(self, ui);
+ // filled: the gaps the dock leaves between its panes show chrome, not the dark clear colour
+ let chrome = theme::Tokens::get(&ctx).chrome;
+ egui::CentralPanel::default().frame(egui::Frame::NONE.fill(chrome)).show(ui, |ui| docking::show(self, ui));
+ self.lights_out(&ctx);
+ panels::second::show(self, &ctx);
+ if notice_blocks {
+ panels::notices::restore_prompt_pointer(self, &ctx);
+ }
+ panels::notices::show(self, &ctx);
+ if notice_blocks {
+ panels::notices::hide_background_pointer(&ctx);
+ }
+ panels::dialogs::show(self, &ctx, notice_blocks);
+ updates_ui::show(self, &ctx);
+ panels::library_problem::show(self, &ctx, notice_blocks);
+ export_task::poll(self, &ctx);
+ slideshow_export::poll(self, &ctx);
+ panels::activity::show(self, &ctx);
+ export_task::poll_photos(self, &ctx);
+ pick::poll(self, &ctx);
+ panels::grid::drag_feedback(self, &ctx);
+ panels::left::album_drag_feedback(self, &ctx);
+ panels::left::section_drag_feedback(self, &ctx);
+ panels::keyword_list::drag_feedback(self, &ctx);
+ panels::toast(self, &ctx);
+ drop_overlay::show(self, &ctx);
+ // AppKit moves the window on a drag anywhere in the title-bar band unless the window isn't
+ // movable: it stops being movable while the pointer is on a bar control or a panel over it
+ #[cfg(target_os = "macos")]
+ craft_window::title_bar::sync_movable(&ctx, &mut self.window_movable);
+ if notice_blocks {
+ // Keep the real press/release state for the next pass: an ordinary click spans host
+ // frames, and resetting it above must only hide it from this pass's dialogs.
+ panels::notices::restore_prompt_pointer(self, &ctx);
+ }
+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);
+ self.text_focus = ctx.egui_wants_keyboard_input();
+ self.end_frame(&ctx, t0);
+ }
+}
+
+/// Import commits batches at most once per host frame. The first layout pass and a hidden
+/// `run_logic` tick both report pass index 0; a discarded frame's later passes report 1+. A
+/// wall-clock gate cannot express that (a slow first pass could re-run it within one frame).
+pub(crate) fn import_tick_allowed(ctx: &egui::Context) -> bool {
+ ctx.current_pass_index() == 0
+}
diff --cc crates/ui-egui/src/panels/detail.rs
index 6840afdf0,3dcab57ac..7ba2182fc
--- a/crates/ui-egui/src/panels/detail.rs
+++ b/crates/ui-egui/src/panels/detail.rs
@@@ -911,141 -2254,207 +911,148 @@@ fn targeted_drag(app: &mut LightcraftAp
}
}
- /// The diagnostic overlay the loupe shows (the selected mask, Point Color's visualized range,
- /// Visualize Spots).
-// ------------------------------------------------------------------------ filmstrip
++/// The diagnostic overlay the loupe shows (an Alt-drag preview, the selected mask, Point Color's
++/// visualized range, Visualize Spots).
+pub(crate) fn view_overlay(app: &LightcraftApp, d: &DevelopSettings) -> lightcraft_pipeline::Overlay {
+ use lightcraft_pipeline::{MaskView, Overlay};
+ if app.ui.fullscreen {
+ return Overlay::None;
+ }
++ // Lightroom's temporary previews: clipping, greyscale, sharpening detail / mask
++ if app.ui.right == RightPanel::Edit
++ && app.ui.alt_held
++ && let Some(o) = app.ui.dragging_control.as_deref().and_then(Overlay::for_control)
++ {
++ return o;
++ }
+ // Show every visible mask's region at once (Ctrl+Shift+O / Cmd+Shift+O), ahead of the selected-mask overlay
+ // so the shortcut is not shadowed by the always-on single-mask overlay.
+ if app.ui.right == RightPanel::Masking && app.ui.mask_overlay_all && d.masks.iter().any(|m| m.visible && !m.components.is_empty()) {
+ return Overlay::AllMasks {
+ view: MaskView::parse(&app.ui.mask_overlay_mode).unwrap_or_default(),
+ color: app.ui.mask_overlay_color,
+ opacity: app.ui.mask_overlay_opacity.clamp(0.0, 100.0).round() as u8,
+ };
+ }
+ if app.ui.right == RightPanel::Masking
+ && app.ui.mask_overlay
+ && let Some(m) = app.session.active_mask.and_then(|id| d.masks.iter().find(|m| m.id == id))
+ && !m.components.is_empty()
+ {
+ return Overlay::Mask {
+ id: m.id.min(u16::MAX as u32) as u16,
+ view: MaskView::parse(&app.ui.mask_overlay_mode).unwrap_or_default(),
+ color: app.ui.mask_overlay_color,
+ opacity: app.ui.mask_overlay_opacity.clamp(0.0, 100.0).round() as u8,
+ };
+ }
+ if app.ui.right == RightPanel::Remove && app.ui.visualize_spots {
+ return Overlay::Spots(app.ui.spots_threshold.clamp(0.0, 100.0).round() as u8);
+ }
+ let edit = app.ui.right == RightPanel::Edit;
+ if edit && app.ui.point_color_visualize && app.ui.flyout_open("pointColor") && app.ui.point_color < d.point_colors.len() {
+ return Overlay::PointColorRange(app.ui.point_color as u8);
+ }
+ if edit && app.ui.hdr_visualize && d.hdr.enabled {
+ return Overlay::HdrRange;
+ }
+ Overlay::None
+}
-/// A filmstrip cell's file-name label: names longer than 14 characters are cut to 13 and an
-/// ellipsis. Counts characters, not bytes, so a CJK name is never cut inside a character (#266).
-fn film_label(name: &str) -> String {
- if name.chars().nth(14).is_some() { format!("{}…", name.chars().take(13).collect::<String>()) } else { name.to_string() }
+fn clipping_overlay(app: &LightcraftApp, p: &egui::Painter, r: Rect) {
+ // Highlight clipped regions using the histogram's extremes isn't spatial; show a subtle frame hint.
+ if let Some(h) = app.renderer.textures.get(&Slot::Main).and_then(|t| t.histogram.as_ref()) {
+ let (lo, hi) = h.clipping();
+ if hi > 0.003 {
+ p.rect_stroke(r, 0.0, Stroke::new(2.0, Color32::from_rgb(255, 60, 60)), StrokeKind::Outside);
+ }
+ if lo > 0.003 {
+ p.rect_stroke(r.expand(3.0), 0.0, Stroke::new(2.0, Color32::from_rgb(60, 120, 255)), StrokeKind::Outside);
+ }
+ }
}
-pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) {
- let t = Tokens::get(ui.ctx());
- ui.painter().rect_filled(r, 0.0, t.canvas);
- ui.painter().rect_filled(Rect::from_min_size(r.min, vec2(r.width(), 4.0)), 0.0, Color32::from_gray(0x20));
- let ids = app.session.visible_cloned();
- let active = app.session.selection.active;
- let cell_w = 120.0;
- let ppp = ui.ctx().pixels_per_point();
- if ids.is_empty() {
- let why = if app.session.filter != Default::default() { "No photos match the filters (View → Clear Filters)" } else { "No photos" };
- ui.painter().text(r.center(), Align2::CENTER_CENTER, why, t.font(12.5), t.text_dim);
+fn general_cursor(app: &LightcraftApp, ui: &egui::Ui, resp: &egui::Response, img: Rect, canvas: Rect) {
+ // A panel or overlay under the pointer keeps its own cursor.
+ if !resp.dragged() && !resp.hovered() {
return;
}
- let mut child = ui.new_child(egui::UiBuilder::new().max_rect(r.shrink2(vec2(0.0, 4.0))));
- // a vertical mouse wheel scrolls the strip sideways (horizontal trackpad scrolls still work)
- child.style_mut().always_scroll_the_only_direction = true;
- // only a new active photo (or the strip appearing) scrolls it; see `grid::follow_active`
- let follow = super::grid::follow_active(child.ctx(), egui::Id::new("film-follow-active"), active, app.session.source);
- egui::ScrollArea::horizontal().id_salt("filmstrip").auto_shrink([false, false]).show_viewport(&mut child, |ui, vp| {
- let (area, _) = ui.allocate_exact_size(vec2(ids.len() as f32 * cell_w, r.height() - 16.0), Sense::hover());
- app.film_scroll = Some(vp.left());
- for (i, id) in ids.iter().enumerate() {
- let cr = Rect::from_min_size(pos2(area.left() + i as f32 * cell_w, area.top()), vec2(cell_w, area.height()));
- let local = Rect::from_min_size(pos2(i as f32 * cell_w, 0.0), cr.size());
- // centred when it is (partly) off screen; a click on a visible thumbnail leaves the strip alone
- if follow && Some(*id) == active && !(local.left() >= vp.left() && local.right() <= vp.right()) {
- ui.scroll_to_rect(cr, Some(egui::Align::Center));
- }
- if !local.intersects(vp.expand2(vec2(cell_w * 4.0, 0.0))) {
- continue;
- }
- let resp = ui.interact(cr, egui::Id::new(("film", id.0)), Sense::click());
- register(ui.ctx(), format!("film:{}", id.0), cr);
- let state = app.session.selection.state_of(*id);
- let sel = state == lightcraft_engine::SelectionState::Active;
- let p = ui.painter();
- let label = app.session.catalog.photo(*id).and_then(|ph| ph.label);
- let selected = state != lightcraft_engine::SelectionState::NotSelected;
- let base = if selected {
- t.cell_selected
- } else if resp.hovered() {
- t.cell_selected.gamma_multiply(0.6)
+ let cursor = match app.ui.tool.as_str() {
+ "wbPicker" | "colorRange" | "pointColor" => egui::CursorIcon::Crosshair,
+ tool if tool.starts_with("tat:") => egui::CursorIcon::ResizeVertical,
+ _ if img.width() > canvas.width() + 1.0 || img.height() > canvas.height() + 1.0 => {
+ if resp.dragged() {
+ egui::CursorIcon::Grabbing
} else {
- t.canvas
- };
- p.rect_filled(cr, 0.0, crate::theme::label_background(base, label, selected));
- let names = app.ui.settings.film_names;
- if let Some(ph) = app.session.catalog.photo(*id).filter(|_| names) {
- let name = ph.file_name.rsplit_once('.').map(|(n, _)| n).unwrap_or(&ph.file_name);
- p.text(pos2(cr.left() + 8.0, cr.top() + 10.0), Align2::LEFT_CENTER, film_label(name), t.font(10.0), t.text_dim);
- p.text(pos2(cr.right() - 8.0, cr.top() + 10.0), Align2::RIGHT_CENTER, &ph.format, t.semibold(8.5), t.text_dim);
- }
- let img_area = Rect::from_min_max(cr.min + vec2(10.0, 22.0), cr.max - vec2(10.0, 8.0));
- super::grid::request_thumb(app, *id, (256.0 * ppp.min(2.0) / 2.0) as usize * 2, 8);
- if let Some(tex) = app.renderer.thumb(*id) {
- let [tw, th] = tex.size;
- let s = (img_area.width() / tw as f32).min(img_area.height() / th as f32);
- let fr = Rect::from_center_size(img_area.center(), vec2(tw as f32 * s, th as f32 * s));
- p.image(tex.tex.id(), fr, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE);
- if sel {
- p.rect_stroke(fr, 0.0, Stroke::new(1.5, Color32::WHITE), StrokeKind::Outside);
- } else if state == lightcraft_engine::SelectionState::Selected {
- p.rect_stroke(fr, 0.0, Stroke::new(1.5, Color32::from_gray(170)), StrokeKind::Outside);
- }
- if app.ui.settings.film_badges
- && let Some(ph) = app.session.catalog.photo(*id)
- {
- film_badges(p, &t, fr, ph);
- }
- if let Some(st) = app.session.catalog.stack_of(*id) {
- let text =
- if st.collapsed { st.photos.len().to_string() } else { format!("{}/{}", st.position(*id).unwrap_or(0) + 1, st.photos.len()) };
- let g = p.layout_no_wrap(text, t.semibold(9.5), Color32::WHITE);
- let br = Rect::from_min_size(fr.min + vec2(3.0, 3.0), vec2(g.size().x + 22.0, 15.0));
- p.rect_filled(br, 7.5, Color32::from_black_alpha(170));
- crate::icons::paint(p, Rect::from_min_size(br.min + vec2(4.0, 2.0), vec2(11.0, 11.0)), crate::icons::Icon::Stack, Color32::WHITE);
- p.galley(pos2(br.min.x + 17.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE);
- }
- }
- if resp.clicked() && app.ui.view == crate::state::ViewMode::Compare {
- // Compare: the clicked photo replaces the active side (or swaps with the other one)
- if let Err(e) = app.run("compare.set", json!({"id": id.0})) {
- app.toast(ui.ctx(), e);
- }
- } else if resp.clicked() {
- let m = ui.input(|i| i.modifiers);
- let mode = if m.command {
- "toggle"
- } else if m.shift {
- "range"
- } else {
- "replace"
- };
- let _ = app.run("library.select", json!({"ids": [id.0], "mode": mode}));
+ egui::CursorIcon::Grab
}
- // the same photo actions as the grid and loupe (Restore / Delete Permanently in Recently Deleted)
- resp.context_menu(|ui| super::grid::context_menu(app, ui, *id));
}
- });
+ _ => return,
+ };
+ ui.ctx().set_cursor_icon(cursor);
}
-/// Rating, flag and edited badges along a filmstrip thumbnail's bottom edge (Settings → Interface).
-fn film_badges(p: &egui::Painter, t: &Tokens, fr: Rect, ph: &lightcraft_catalog::Photo) {
- use crate::icons::{Icon, paint};
- use lightcraft_catalog::Flag;
- let edited = ph.is_edited();
- if ph.rating == 0 && ph.flag == Flag::None && !edited {
- return;
- }
- let bar = Rect::from_min_max(pos2(fr.left(), fr.bottom() - 15.0), fr.right_bottom());
- p.rect_filled(bar, 0.0, Color32::from_black_alpha(130));
- let y = bar.center().y;
- let mut x = bar.left() + 3.0;
- for i in 0..ph.rating {
- paint(p, Rect::from_min_size(pos2(x + i as f32 * 9.0, y - 4.0), vec2(8.0, 8.0)), Icon::StarFilled, t.star);
- }
- x += ph.rating as f32 * 9.0 + 2.0;
- match ph.flag {
- Flag::Pick => paint(p, Rect::from_min_size(pos2(x, y - 5.0), vec2(10.0, 10.0)), Icon::FlagPick, t.pick),
- Flag::Reject => paint(p, Rect::from_min_size(pos2(x, y - 5.0), vec2(10.0, 10.0)), Icon::FlagReject, t.reject),
- Flag::None => {}
- }
- if edited {
- paint(p, Rect::from_min_size(pos2(bar.right() - 13.0, y - 5.0), vec2(10.0, 10.0)), Icon::Sliders, t.text_label);
- }
+/// Where the photo is on the canvas.
+struct PhotoPlacement {
+ /// the photo's rectangle
+ img: Rect,
+ /// the canvas it is shown on
+ canvas: Rect,
+ /// the photo's size in pixels
+ native: [usize; 2],
+ aspect: f32,
}
-#[cfg(test)]
-mod preview_geometry_tests {
- use super::{fit_rect, fit_texture_rect};
- use crate::state::Zoom;
- use egui::{Rect, pos2, vec2};
-
- #[test]
- fn portrait_preview_keeps_its_ratio_inside_a_landscape_frame() {
- let frame = Rect::from_min_size(pos2(0.0, 0.0), vec2(400.0, 200.0));
- let image = fit_texture_rect(frame, [100, 200]);
-
- assert!((image.width() / image.height() - 0.5).abs() < 1e-6);
- assert_eq!(image.center(), frame.center());
- assert!(frame.contains_rect(image));
+fn general_interaction(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, map: &CanvasMap, placement: &PhotoPlacement) {
+ let PhotoPlacement { img, canvas, native, aspect } = *placement;
+ if app.ui.tool == "wbPicker" {
+ if resp.clicked()
+ && let Some(q) = resp.interact_pointer_pos()
+ {
+ let n = map.norm(q);
+ let _ = app.run("develop.wbPick", json!({"x": n.x, "y": n.y}));
+ app.ui.tool.clear();
+ }
+ return;
}
-
- #[test]
- fn portrait_preview_aspect_fits_detail_area_without_stretching() {
- let area = Rect::from_min_size(pos2(0.0, 0.0), vec2(400.0, 200.0));
- let image = fit_rect(area, 0.5, Zoom::Fit, [4000, 6000], 1.0, (0.5, 0.5));
-
- assert!((image.width() / image.height() - 0.5).abs() < 1e-6);
- assert_eq!(image.size(), vec2(100.0, 200.0));
- assert_eq!(image.center(), area.center());
+ if let Some(target) = app.ui.tool.strip_prefix("tat:").map(str::to_string) {
+ targeted_drag(app, resp, map, &target);
+ return;
}
-}
-
-/// Straighten tool: drag along a horizon (or a vertical) to set the crop angle; double-click = Auto.
-/// The image is shown unrotated in the crop view, so the line's on-screen angle is its image angle.
-/// `held`: drawn with ⌘ held in the crop tool, which stays active afterwards.
-fn straighten_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, held: bool) {
- ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair);
- if !held && resp.double_clicked() {
- let _ = app.run("crop.autoStraighten", json!({}));
- app.ui.tool.clear();
- app.gesture = None;
+ if app.ui.tool == "colorRange" {
+ color_range_pick(app, ui, resp, map);
return;
}
- if resp.drag_started()
- && let Some(q) = ui.input(|i| i.pointer.press_origin()).or(resp.interact_pointer_pos())
- {
- app.gesture = Some(Gesture::StraightenLine { a: q });
- }
- let Some(Gesture::StraightenLine { a }) = app.gesture.clone() else { return };
- let Some(b) = resp.interact_pointer_pos().or(resp.hover_pos()) else { return };
- let p = ui.painter();
- p.line_segment([a, b], Stroke::new(3.0, Color32::from_black_alpha(140)));
- p.line_segment([a, b], Stroke::new(1.5, Color32::WHITE));
- if resp.drag_stopped() {
- app.gesture = None;
- let v = b - a;
- if v.length() > 8.0 {
- let mut deg = v.y.atan2(v.x).to_degrees() as f64;
- // fold to the nearest axis: a line closer to vertical straightens plumb lines
- while deg > 45.0 {
- deg -= 90.0;
- }
- while deg < -45.0 {
- deg += 90.0;
+ if app.ui.tool == "pointColor" {
+ if resp.clicked()
+ && let Some(q) = resp.interact_pointer_pos()
+ {
+ let n = map.norm(q);
+ if let Ok(r) = app.run("pointColor.pick", json!({"x": n.x, "y": n.y})) {
+ app.ui.point_color = r["index"].as_u64().unwrap_or(0) as usize;
}
- let _ = app.run("crop.straighten", json!({"angle": (-deg * 100.0).round() / 100.0}));
- }
- if !held {
app.ui.tool.clear();
}
+ return;
+ }
+ // click toggles Fit ↔ the chosen click-zoom ratio at the clicked point; drag pans when zoomed
+ let zoomed = img.width() > canvas.width() + 1.0 || img.height() > canvas.height() + 1.0;
+ if resp.double_clicked() || (resp.clicked() && !zoomed) {
+ if let Some(q) = resp.interact_pointer_pos() {
+ let u = ((q.x - img.left()) / img.width()).clamp(0.0, 1.0);
+ let v = ((q.y - img.top()) / img.height()).clamp(0.0, 1.0);
+ app.ui.pan = (u, v);
+ }
+ app.ui.zoom = if matches!(app.ui.zoom, Zoom::Fit) { Zoom::Percent(app.ui.click_zoom as f32) } else { Zoom::Fit };
+ app.ui.zoom_anim = true;
+ } else if resp.clicked() && zoomed {
+ app.ui.zoom = Zoom::Fit;
+ app.ui.zoom_anim = true;
}
+ if zoomed && resp.dragged() {
+ pan_image(app, canvas, img, resp.drag_delta());
+ }
+ let _ = (native, aspect);
}
#[cfg(test)]
diff --cc crates/ui-egui/src/panels/detail/window.rs
index f4ec89c5b,000000000..c9b78b542
mode 100644,000000..100644
--- a/crates/ui-egui/src/panels/detail/window.rs
+++ b/crates/ui-egui/src/panels/detail/window.rs
@@@ -1,119 -1,0 +1,122 @@@
+use super::{Color32, LightcraftApp, PhotoId, Rect, Slot, pos2, vec2};
+
+/// Whether an overlay can be rendered on a region tile without changing what the tile means. Mask (one or all)
+/// overlays are evaluated from the same mask alpha as the full render; Point Color range and Visualize
+/// HDR act pixel by pixel (the HDR rendition is rendered for the same window); Visualize Spots' high
+/// pass reads about 3σ = 1.8 % of the long edge, inside the window's margin
+/// ([`crate::region::margin_for`]: 4.5 %). Each is tested equal to the whole-frame render's pixels.
+pub(crate) fn overlay_supports_window(overlay: lightcraft_pipeline::Overlay) -> bool {
+ use lightcraft_pipeline::Overlay as O;
+ match overlay {
+ O::None | O::Mask { .. } | O::AllMasks { .. } | O::PointColorRange(_) | O::HdrRange | O::Spots(_) => true,
++ // clipping and greyscale previews act pixel by pixel on the finished image
++ o if o.per_pixel() => true,
++ _ => false,
+ }
+}
+
+/// What a window render of the loupe needs to know about the view it belongs to.
+pub(super) struct WindowCtx {
+ pub(super) id: PhotoId,
+ pub(super) overlay: lightcraft_pipeline::Overlay,
+ /// Long edge of the frame the windows are cut from (`None`: no windows).
+ pub(super) frame_edge: Option<usize>,
+ pub(super) drawn_long: f32,
+ pub(super) aspect: f32,
+ pub(super) ppp: f32,
+ pub(super) texture_side: usize,
+ pub(super) crop_tool: bool,
+ pub(super) interacting: bool,
+ /// Hash of the photo's develop settings.
+ pub(super) look: u64,
+ /// A pinch or two-finger scroll is running: keep the windows there are.
+ pub(super) holding: bool,
+}
+
+/// One side of the loupe that gets a window render.
+#[derive(Clone, Copy)]
+pub(super) struct WindowView {
+ pub(super) slot: Slot,
+ /// The Before side (the photo without its edits).
+ pub(super) before: bool,
+ /// The rect the photo is drawn in.
+ pub(super) img: Rect,
+ /// The rect it is requested for (the drawn rect without a click-zoom animation).
+ pub(super) target: Rect,
+ /// The area whose pixels are on screen.
+ pub(super) visible: Rect,
+}
+
+/// Ask for the window of `v` that holds what is on screen; remember it so its texture can be
+/// drawn where it belongs. `None`: no window is wanted (or possible) for this view.
+pub(super) fn request_window(app: &mut LightcraftApp, c: &WindowCtx, v: &WindowView) -> Option<crate::region::RegionView> {
+ let frame_edge = c.frame_edge?;
+ // while a pinch or scroll runs the windows there are keep being drawn, magnified: no new one
+ // per frame (zooming out would ask for ever wider ones)
+ if c.holding {
+ return if v.before { app.region_before_view } else { app.region_view }.filter(|w| w.photo == c.id);
+ }
+ let (fw, fh) =
+ if c.aspect >= 1.0 { (frame_edge as f32, frame_edge as f32 / c.aspect) } else { (frame_edge as f32 * c.aspect, frame_edge as f32) };
+ let (fw, fh) = (fw.round().max(1.0) as usize, fh.round().max(1.0) as usize);
+ // what is on screen, in pixels of the window's frame (the drawn frame, scaled)
+ let to_px = c.ppp * frame_edge as f32 / c.drawn_long.max(1.0);
+ let visible = (
+ to_px * (v.visible.left() - v.target.left()),
+ to_px * (v.visible.top() - v.target.top()),
+ to_px * (v.visible.right() - v.target.left()),
+ to_px * (v.visible.bottom() - v.target.top()),
+ );
+ let win = crate::region::window_for(fw, fh, visible, crate::region::max_span(c.texture_side))?;
+ // a window waits for the original another window job is decoding (see `defer_window`)
+ let original_held = app.session.media.has_source(c.id, lightcraft_engine::SourceLevel::for_size(fw.max(fh)));
+ let window_pending = app.renderer.is_pending(Slot::Region) || app.renderer.is_pending(Slot::RegionBefore);
+ if crate::region::defer_window(window_pending, original_held) {
+ return if v.before { app.region_before_view } else { app.region_view }.filter(|w| w.photo == c.id);
+ }
+ let job = if v.before {
+ app.session.region_job_before(c.id, fw, fh, win, !c.crop_tool)
+ } else {
+ app.session.region_job(c.id, fw, fh, win, !c.crop_tool)
+ };
+ // refused: what the window reads (a spot's source, an Auto Mask stroke) is too far for one
+ // render, so the whole frame is rendered at the drawn size instead (see `region::plan`)
+ let Some(job) = job else {
+ app.window_refused = Some((c.id, c.look, frame_edge));
+ return None;
+ };
+ // a drag renders drafts of the window, as it does of the whole frame. The Before tile stays
+ // plain; the After tile carries the same mask overlay as the whole-frame render.
+ let job = if c.interacting { job.draft() } else { job };
+ let overlay = if v.before { lightcraft_pipeline::Overlay::None } else { c.overlay };
+ let job = if v.before { job } else { job.with_hidden_grading(app.ui.grading_hidden_for(c.id)) };
+ // the After window is proofed like the whole-frame render under it; the Before side is
+ // never proofed (its whole-frame render isn't either)
+ let proof = app.ui.soft_proof.then_some(app.ui.proof);
+ let job = job.with_overlay(overlay).with_proof(if v.before { None } else { proof });
+ // keyed as the renderer keys the texture (a display profile changes the key)
+ let job = app.renderer.job_for(v.slot, job);
+ // The overlay and the proof are part of the tile's identity too, so changing mask view/colour
+ // or the proof never leaves a stale region tile on screen while its replacement renders.
+ let proof_key = if v.before { 0 } else { proof.map_or(0, |p| p.key()) };
+ let look = job.settings.hash64() ^ overlay.key().rotate_left(17) ^ proof_key.rotate_left(41);
+ let view = crate::region::RegionView { photo: c.id, before: v.before, key: job.key, full: (fw, fh), window: win, settings: look };
+ // windows of other photos, looks and zooms of this side can't be drawn any more
+ app.region_tiles.retain(|(before, _), t| *before != v.before || t.is_current(c.id, (fw, fh), look, c.interacting));
+ app.region_tiles.insert((v.before, job.key), view);
+ app.renderer.request(v.slot, job, 99);
+ Some(view)
+}
+
+/// Draw `v`'s window texture over the whole-frame render, if it is the one asked for (or, in a
+/// drag, an earlier draft of it).
+pub(super) fn draw_window(p: &egui::Painter, app: &LightcraftApp, c: &WindowCtx, v: &WindowView, wanted: &crate::region::RegionView) {
+ let Some(tex) = app.renderer.textures.get(&v.slot).filter(|t| t.photo == c.id) else { return };
+ let Some(tile) = app.region_tiles.get(&(v.before, tex.key)).filter(|t| t.is_current(c.id, wanted.full, wanted.settings, c.interacting)) else {
+ return;
+ };
+ let (fw, fh) = (tile.full.0 as f32, tile.full.1 as f32);
+ let at = v.img.min + vec2(tile.window.x as f32 / fw * v.img.width(), tile.window.y as f32 / fh * v.img.height());
+ let dst = Rect::from_min_size(at, vec2(tile.window.w as f32 / fw * v.img.width(), tile.window.h as f32 / fh * v.img.height()));
+ p.image(tex.tex.id(), dst, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE);
+}
diff --cc crates/ui-egui/src/tests.rs
index 3a102a29a,000000000..2b3d1807b
mode 100644,000000..100644
--- a/crates/ui-egui/src/tests.rs
+++ b/crates/ui-egui/src/tests.rs
@@@ -1,87 -1,0 +1,88 @@@
+mod activity;
+mod album_picker;
+mod album_remove;
++mod alt_preview;
+mod appearance;
+mod before_after;
+mod browse_active;
+mod button;
+mod canvas_keys;
+mod canvas_pan;
+mod capture_time;
+mod compare;
+mod copy_paste_dialogs;
+mod crop_rotate;
+mod crop_tool;
+mod curve;
+mod date_picker;
+mod dialog_fit;
+mod dialog_primary;
+mod dialog_settings;
+mod dialog_tab;
+mod dialogs;
+mod docking_acceptance;
+mod drop_import;
+mod edit_layout;
+mod empty_library;
+mod error_kinds;
+mod filmstrip;
+mod focus_point;
+mod folder_drop;
+mod grading;
+mod grid;
+mod guided_guides;
+mod histogram_drag;
+mod info_dialogs;
+mod keymap;
+mod keyword_files;
+mod keyword_list;
+mod keyword_set;
+mod keyword_sidebar;
+mod keywording;
+mod labels;
+mod launch_library;
+mod layout_image;
+mod library_problem;
+mod lifecycle_037;
+mod lightroom_destination;
+mod lights_out;
+mod mask_effects;
+mod masking;
+mod masking_layout;
+mod menubar;
+mod merge_preview;
+mod model_setup;
+mod offline;
+mod open_lightroom;
+pub(super) mod panels;
+mod preset_favorites;
+mod preset_import;
+mod preview_limit;
+mod print;
+mod profile_menu;
+mod profiles_layout;
+mod progress;
+mod quit_unsaved;
+mod rating;
+mod recheck;
+mod rename_person;
+mod rules_editor;
+mod sam_setup;
+mod scroll;
+mod slider_reset;
+mod slideshow;
+mod solo_sections;
+mod switch_library;
+mod sync;
+mod tallies;
+mod temp_slider;
+mod titlebar;
+mod tool_overlay;
+mod unsaved;
+mod view_cost;
+mod wb_selector;
+mod zoom;
+mod zoom_keys;
+
+pub(super) mod fixtures;
+pub(super) mod render_fixtures;
diff --cc crates/ui-egui/src/tests/alt_preview.rs
index 000000000,7a212869f..7a212869f
mode 000000,100644..100644
--- a/crates/ui-egui/src/tests/alt_preview.rs
+++ b/crates/ui-egui/src/tests/alt_preview.rs
diff --cc docs/parity-checklist.md
index 08dab300b,125b91de9..22bddaf82
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@@ -178,13 -177,13 +178,13 @@@ differences and missing bindings are i
| LR-EDIT-AUTO | Auto settings | P0 | ✅ | `cmd:develop.auto`, `crates/pipeline/src/auto.rs` | a Lightroom-like recipe calibrated black-box on Lightroom's Auto results for 24 Sony raws: Exposure from the scene's scene-linear log-average luminance (Lightroom's observed slope, -0.41 EV per EV), Highlights -66 and Shadows +52 (Lightroom's average Auto values), Contrast +68 and Vibrance +30 fitted on our scales. Held out one photo at a time: on the 16 photos whose start Sony's DRO doesn't brighten, a median dE76 of 6.4 from Lightroom's Auto results against 8.3 unedited; on all 24, 7.7 against 7.9 (issues #318, #209). Calibrated on Sony files only; Whites and Blacks stay 0 |
| LR-EDIT-BW | Black & white | P0 | ✅ | `cmd:develop.treatment` | |
| LR-EDIT-HDR-MODE | HDR editing | P2 | ✅ | `cmd:develop.hdr`, `ctl:hdr.maxEv`, `crates/ui-egui/src/panels/edit.rs` (`hdr_row`) | HDR button next to B&W in the Edit panel header, as Lightroom (Visualize HDR and the headroom limit in the Light panel while it's on); see Q. HDR |
- | LR-EDIT-LIGHT-EXPOSURE | Exposure | P0 | ✅ | `ctl:light.exposure` | |
+ | LR-EDIT-LIGHT-EXPOSURE | Exposure | P0 | ✅ | `ctl:light.exposure` | Alt/Option-drag shows highlight clipping (black, clipped channels in colour) |
| LR-EDIT-LIGHT-CONTRAST | Contrast | P0 | ✅ | `ctl:light.contrast` | |
- | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp |
- | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632) |
- | LR-EDIT-LIGHT-WHITES | Whites | P0 | ✅ | `ctl:light.whites` | |
- | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | ✅ | `ctl:light.blacks` | |
+ | LR-EDIT-LIGHT-HIGHLIGHTS | Highlights | P0 | ✅ | `ctl:light.highlights`, `crates/raw/src/highlight.rs` | sensor-clipped highlights stay neutral when Highlights (or Exposure, Whites) darkens them: fully clipped content is rebuilt to the neutral of the colour model applied after it, partly clipped content takes its colour from reliable unclipped content nearby (not from dark objects, lens fringes or another surface beside it) and white where there is none, and pale partly clipped content (a white sky) turns white on its way to clipping (#523); binned previews and thumbnails decide clipping per sample before averaging (`develop_binned_masked`, `highlight::reconstruct_masked`), so a block with one clipped specular sample keeps its mean instead of jumping to the clip level, which reconstruction turned into green speckles at 500 px (#548) From process V2 the Highlights/Shadows base is the edge-aware filter of the 0.15 %-of-long-edge median of log luminance: twigs and fine texture take their surroundings' shift, so bright areas keep their local contrast as with Exposure (V1's base kept ~0.6 of it at −100, #632); region edges stay sharp. Alt/Option-drag shows highlight clipping |
+ | LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) |
+ | LR-EDIT-LIGHT-WHITES | Whites | P0 | ✅ | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | Alt/Option-drag shows highlight clipping (black, clipped channels in colour) |
+ | LR-EDIT-LIGHT-BLACKS | Blacks | P0 | ✅ | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | Alt/Option-drag shows shadow clipping (white, clipped channels in colour) |
-| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*` | |
+| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step) |
| LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON |
| LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | |
| LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | |
@@@ -204,9 -203,9 +204,9 @@@
| LR-EDIT-EFFECTS-DEHAZE | Dehaze | P0 | ✅ | `ctl:effects.dehaze` | |
| LR-EDIT-EFFECTS-VIGNETTE | Post-crop vignette | P0 | ✅ | `ctl:vignette.*`, `crates/pipeline/src/finish.rs`, `crates/ui-egui/src/panels/edit.rs` | style picker (Highlight / Color / Paint) in the Effects section |
| LR-EDIT-EFFECTS-GRAIN | Grain | P1 | ✅ | `ctl:grain.*` | |
- | LR-EDIT-DETAIL-SHARPEN | Sharpening | P0 | ✅ | `ctl:detail.sharpenAmount`, `ctl:detail.sharpenRadius`, `ctl:detail.sharpenDetail`, `ctl:detail.sharpenMasking` | no Alt-drag mask preview |
- | LR-EDIT-DETAIL-NR | Luminance noise reduction | P0 | ✅ | `ctl:detail.nrLuminance`, `ctl:detail.nrDetail`, `ctl:detail.nrContrast` | radii in the original's pixels, so grid, loupe and smaller exports look like the full-size render scaled down (`local::nr_params`, `Plan::detail_scale`, #960) |
+ | LR-EDIT-DETAIL-SHARPEN | Sharpening | P0 | 🟡 | `ctl:detail.sharpenAmount`, `ctl:detail.sharpenRadius`, `ctl:detail.sharpenDetail`, `ctl:detail.sharpenMasking`, `crates/pipeline/src/visualize.rs` | Amount and Masking work; Radius and Detail are stored (XMP round trip) but do not change the render yet (the band is a fixed 0.18 % of the long edge). Alt/Option-drag previews: Amount greyscale, Radius / Detail the detail band sharpening amplifies, Masking the mask (white = sharpened) |
-| LR-EDIT-DETAIL-NR | Luminance noise reduction | P0 | ✅ | `ctl:detail.nrLuminance`, `ctl:detail.nrDetail`, `ctl:detail.nrContrast` | Alt/Option-drag on Luminance, Detail and Contrast shows the photo in greyscale |
-| LR-EDIT-DETAIL-CNR | Colour noise reduction | P0 | ✅ | `ctl:detail.nrColor`, `ctl:detail.nrColorDetail`, `ctl:detail.nrColorSmoothness` | |
++| LR-EDIT-DETAIL-NR | Luminance noise reduction | P0 | ✅ | `ctl:detail.nrLuminance`, `ctl:detail.nrDetail`, `ctl:detail.nrContrast` | radii in the original's pixels, so grid, loupe and smaller exports look like the full-size render scaled down (`local::nr_params`, `Plan::detail_scale`, #960). Alt/Option-drag on Luminance, Detail and Contrast shows the photo in greyscale |
+| LR-EDIT-DETAIL-CNR | Colour noise reduction | P0 | ✅ | `ctl:detail.nrColor`, `ctl:detail.nrColorDetail`, `ctl:detail.nrColorSmoothness` | preview-size independent like luminance NR (#960) |
| LR-EDIT-DETAIL-DENOISE | AI denoise | P2 | 🟡 | cmd:denoise.toggle, cmd:denoise.models.install, cmd:denoise.queue, ctl:enhance.denoise, `crates/denoise/`, `docs/denoise.md` | non-destructive Bayer RAW, opt-in weights, pure-Rust CPU/GPU; GPU convolution uses independently written shared scalars (Metal equivalence regression, issue #479); tiles can also run on another computer's graphics card (`lightcraft-cli denoise-serve`, `crates/denoise/src/remote.rs`); X-Trans/linear RGB, model policy and Lightroom fidelity remain; closing the model setup without installing turns the switch back off (#922) |
| LR-EDIT-DETAIL-RAWDETAILS | Improved demosaic toggle | P2 | ⬜ | | |
| LR-EDIT-DETAIL-SUPERRES | Super resolution | P2 | ⬜ | | |
@@@ -900,31 -806,7 +900,32 @@@ Latin stays upright. Advanced Japanese
| 2026-10-12 | minor | LR-IMP-FORMATS: the Hasselblad Lunar (a Sony NEX-7 ARW under Make HASSELBLAD) decodes from sensor data instead of opening as its preview; an uncompressed Leaf MOS imports as a preview-only raw instead of a greyscale image of its mosaic (#1275); status unchanged (🟡) |
| 2026-10-12 | minor | LR-HDR-EXPORT, LR-EXP-HDR: HLG AVIF export (`hdrTransfer`); LR-VIEW-HDR-DISPLAY: tested SDR/HDR display decision |
| 2026-10-12 | minor | LR-EXP-PSD, MENU-FILE-PHOTOSHOP: Photo ▸ Edit In ▸ Open Original in Other Editor (RAW, no copy) hands the original files (the raws themselves) to the other editor in one start; statuses unchanged |
+| 2026-10-12 | minor | LRC-PRINT-JOB: the Print dialog's Print Job panel sets the profile (Managed by Printer or a printer / paper profile picked from disk), intent, black point compensation, print adjustment, print sharpening and depth |
+| 2026-10-12 | minor | LRC-PRINT-JOB: print colour management (printer / paper ICC profiles or Managed by Printer, intent, black point compensation, print adjustment, print sharpening) and a 16-bit ICC-tagged PDF with an output intent; still 🟡 (no OS print dialog or JPEG output) |
+| 2026-10-12 | minor | LRC-PRINT-GUIDES, LRC-PRINT-CELLS, LRC-PRINT-LAYOUTSTYLE, LRC-PRINT-IMAGESETTINGS (✅), LRC-PRINT-LAYOUT, LRC-PRINT-PAGE, LRC-PRINT-TEMPLATES (🟡): File → Print… opens the Print dialog with a scaled page preview, rulers and guides, cells dragged and resized with snapping, image settings, page setup and templates, and prints to PDF in the background |
+| 2026-10-12 | minor | LRC-PRINT-LAYOUTSTYLE, LRC-PRINT-IMAGESETTINGS, LRC-PRINT-LAYOUT, LRC-PRINT-CELLS, LRC-PRINT-PAGE, LRC-PRINT-TEMPLATES: the Print module is reachable as 18 `print.*` commands (settings, cells, Auto Layout, PDF, templates saved in prefs.json) from the CLI, control channel and MCP; 🟡 until the Print UI lands, LRC-PRINT-GUIDES stays ⬜ |
+| 2026-10-12 | minor | LRC-PRINT-IMAGESETTINGS: `print/compose.rs` composes pages (Zoom to Fill, Rotate to Fit, Photo Border, Inner Stroke, background) from the layout model into 16-bit Rec. 2020 `PageRaster`s, with an interim sRGB PDF writer in `print/output.rs`; rows stay until commands and UI reach them |
+| 2026-10-12 | minor | LRC-PRINT-LAYOUT: the Print layout model (paper, margins, grid, package cells, Auto Layout packer, snapping) lands in `print/layout.rs`; no row changes status until commands and UI follow |
+| 2026-10-12 | minor | LR-MASK-BRUSH: pen pressure scales brush size and flow |
+| 2026-10-13 | patch | LR-BEHAV-AUTOSAVE: a damaged snapshot that still parses is repaired on open (ids, stacks, folder loops, id counters) instead of panicking or hanging; status unchanged |
+| 2026-10-13 | minor | LR-EDIT-OPTICS-PROFILE: Nikon Z 6II / Z 8 / Z f NEFs use the camera's in-file distortion correction (NikonNEFInfo); status unchanged (🟡) |
+| 2026-10-12 | minor | LR-IMP-FORMATS and LR-IMP-CAMERA-COVERAGE: 22 more CR3 bodies verified on one CC0 file each (all 110 CC0 CR3s decode); EOS R6 Mark III `ColorData` 66 white balance; status unchanged (🟡: CRX variants without public samples remain refused) |
+| 2026-10-11 | minor | Model setup folder action, opener error and retry (LR-MASK-OBJECTS). |
+| 2026-10-13 | minor | LR-PROF-CAMERACOLOR: the camera look follows the lens warp of lens-corrected camera JPEGs; status unchanged (🟡) |
+| 2026-10-13 | minor | LR-PROF-CAMERACOLOR: bundled Nikon Z 6II camera profile; status unchanged (🟡) |
+| 2026-10-13 | minor | LR-PROF-CAMERACOLOR: bundled Nikon Z 8 camera profile; status unchanged (🟡) |
+| 2026-10-13 | minor | LR-PROF-CAMERACOLOR: bundled Nikon D5300 camera profile; status unchanged (🟡) |
+| 2026-10-12 | minor | LR-VIEW-ZOOM: slider-drag drafts are timed with the frame that shows them, drop to 0.6 mid-drag when far over budget, stay 0.6 under a zoom window; workers convert texture pixels (issue #330); status unchanged |
+| 2026-10-11 | minor | LR-VIEW-ZOOM: a slider drag keeps the loupe's full resolution where the GPU draws the view and keeps up (0.6 drafts on the CPU, with soft proofing or the HDR range, or after over-budget drags; issue #330); status unchanged |
+| 2026-10-11 | minor | LR-EXP-LOCATION: Export to "Same folder as original photo" (`destinationMode`), issue #956; status unchanged (✅) |
+| 2026-10-12 | minor | LR-IMP-CAMERA-COVERAGE: 117 Nikon and Fujifilm Adobe models verified on one CC0 file each; COOLPIX 5700 / 8400 / 8800 found decoding wrongly; status unchanged (🟡) |
+| 2026-10-13 | patch | LR-EXP-QUALITY: JPEG exports use Huffman tables made for each image (same pixels, 12–14 % smaller files, issue #1373); status unchanged |
+| 2026-10-13 | patch | LR-BEHAV-GPU: a GPU lost while LightCraft runs (driver reset) is reported as a stop, not a failed start, and the next start renders on the CPU and says why (issue #1337); status unchanged |
+| 2026-10-13 | minor | LR-META-INFO: Nikon DSLR raws show their lens from the maker note; status unchanged (✅) |
+| 2026-10-13 | patch | LR-IMP-LOCAL: browsing a Local folder again forgets the untouched records of files deleted or moved by another app (issue #1392); status unchanged |
+| 2026-10-13 | minor | LR-MERGE-PANO: a panorama keeps its photos' resolution (up to 512 MP / 65,000 px) instead of a fixed 40 MP, held to what fits in memory (issue #1455); status unchanged |
+| 2026-10-21 | minor | LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; reference pins stay within their catalog, unavailable or malformed photo ids refused, deleted reference not drawn and its pane released, a switch leaves Reference view; statuses unchanged |
+ | 2026-10-11 | minor | Alt/Option-drag previews on Exposure, Highlights, Shadows, Whites, Blacks and Sharpening (issue #937); LR-EDIT-DETAIL-SHARPEN ✅ → 🟡: Radius and Detail don't change the render |
| 2026-10-11 | minor | KEY-SLIDER-TYPE: honor immediate Return/Escape and keep typed keys in the value editor; add regression references |
| 2026-10-11 | minor | LR-PROF-CAMERACOLOR: raws with a black-and-white camera JPEG take its tone curve (issue #577) |
| 2026-10-11 | minor | LR-VIEW-ZOOM and LR-VIEW-COMPARE: Compare and Reference are sharp at 1:1 (zoom windows per pane, two originals kept decoded while they are open); statuses unchanged |
diff --cc docs/ui-parity.md
index 24099eb63,207370912..b441e0e2a
--- a/docs/ui-parity.md
+++ b/docs/ui-parity.md
@@@ -66,19 -65,21 +66,28 @@@ under the UI command that wraps it (a n
| Create Version | ⌘⇧S (+ ⇧M) | ⇧M (Windows: Ctrl+⇧S) | — |
| Select None | ⌘⇧A (+ ⌘D) | ⌘D | — |
-**Library culling (KEYC-RATING):** `0–5`, `6–9` and `P/X/U` reach egui on macOS even when displayed in the native menu (adapted from PR #261; issue #283). `Shift+0–9` applies and advances once; `Shift+P` picks and advances in Photo Grid / Square Grid and retains Presets elsewhere. See [library shortcuts](library-shortcuts.md) for the verified Classic mapping and regression coverage. Remaining Classic gaps: rating `[` / `]`, flag cycling and filter-bar keys.
+**Library culling (KEYC-RATING):** `0–5`, `6–9` and `P/X/U` reach egui on macOS even when displayed in the native menu (adapted from PR #261; issue #283). `Shift+0–9` applies and advances once; `Shift+P` picks and advances in Photo Grid / Square Grid and retains Presets elsewhere. See [library shortcuts](library-shortcuts.md) for the verified Classic mapping and regression coverage. F6, F7 and F8 show / hide the filmstrip, the left panel and the right panel (F8 brings back the panel it hid; `view.rightPanel`). `` ` `` cycles the flag (unflagged → pick → reject → unflagged) and ⌘↑ / ⌘↓ raise / lower it; the native menu leaves ⌘↑ / ⌘↓ to egui so Compare/Survey act on the active photo. `\` shows / hides the Filter Bar in Photo Grid / Square Grid and keeps Show Original in Detail. ⌘L / Ctrl+L (Enable Filters) puts the filter aside and shows every photo, and the next press brings back the same filter, stars, flag and text together; setting or clearing a filter while it is off drops the one put aside (not documented by Adobe, our choice). ⌘⌥⇧C / ⌘⌥⇧V (Ctrl+Alt+Shift+C / V on Windows and Linux, KEYC-METADATA) copy the active photo's metadata and paste it on the selected photos.
+
+**Grid thumbnail size (KEYC-COMPARE):** Classic's `=` and `-` increase and decrease the Grid thumbnail size (same keys on macOS and Windows; `+` also works for the larger size here, as Shift+`=` or the keypad). They step the bottom-bar slider by 30 pt inside its 90–480 pt range, in Photo Grid, Square Grid and People only; Detail, Compare, Survey and Reference ignore them, and ⌘= / ⌘− stay Zoom In / Out. See [library shortcuts](library-shortcuts.md).
+
+**Add Keywords key (KEYC-METADATA):** `⌘K` (`Ctrl+K` on Windows and Linux) is Add Keywords (`panel.addKeywords`): it shows the Keywords panel, opens its Keywording section when that is folded shut, and puts the cursor in the Add keyword box; pressed again it leaves the panel open. With no photo selected the panel says "Select photos to give them keywords." and the key does not move the cursor. The shortcut list names the key only; what the key opens is LightCraft's choice. Covered by `crates/ui-egui/src/tests/keywording.rs`.
+
+**Library navigation keys (KEYC-COMPARE):** in Photo Grid and Square Grid, `Home` / `End` make the first / last photo of the view the active, selected one, and `Shift+Left` / `Shift+Right` add the previous / next photo of the view to the selection (the added photo becomes active; the keys never remove a photo from the selection, and do nothing at either end of the view). They wait in the other views, in the full-screen preview, while a text field or a dialog has the keyboard, and when you gave the key to a command; they are listed under Fixed keys in Help → Keyboard Shortcuts. `Cmd+O` (`Ctrl+O` on Windows and Linux) runs File → Open Library… ; View → Visualize HDR has no default key (`Shift+H` cycles the Tool Overlay, issue #224; `Cmd+Shift+H` stays the Histogram). Covered by `crates/ui-egui/src/tests/keymap.rs`; the macOS native menu path for `Cmd+O` is not exercised by the headless tests.
+
+**Keyword sets (KEYC-METADATA):** `⌥0` / `⌥⇧0` (`Alt+0` / `Alt+Shift+0` on Windows and Linux) make the next / previous keyword set current (`keyword.nextSet`, `keyword.previousSet`), in the Keyword Set menu's order: Recent Keywords, then the saved sets. After the last set comes Recent Keywords, and before Recent Keywords comes the last set (not documented by Adobe, our choice). `⌥1`–`⌥9` then apply the new set's keywords. Both keys can be reassigned in Help → Keyboard Shortcuts.
+ **Alt/Option-drag previews (issue #937):** hold Alt (Option on macOS) while dragging an Edit slider, before or during
+ the drag. Exposure, Highlights and Whites show highlight clipping (black, clipped channels in their colour, white where
+ all three clip); Shadows and Blacks show shadow clipping (white, black where all three clip). Sharpening Amount shows
+ greyscale, Radius and Detail the detail band sharpening amplifies, Masking the mask (white = sharpened); luminance Noise
+ Reduction (Luminance, Detail, Contrast) shows greyscale. Releasing the key or the slider brings the photo back; the
+ edit, its history and the histogram are unchanged (on a profiled display too). Not yet: mask range sliders and the
+ Masking panel's local sliders. On Linux desktops that move windows with Alt+drag (KDE Plasma's
+ default, also some GNOME / Xfce setups) the window manager takes the drag first: set its window-move modifier to Meta.
+
**Still missing / broken:**
-- No command yet: F1 help (verify the rest of the old list: full screen, settings, stacks,
- visualize spots and merges have commands now).
-- `H` opens Remove; Lightroom also uses it (Classic) to hide pins — pins toggle from View → Show Mask Pins.
+- Tab / ⇧Tab (hide the side panels / all panels): Tab moves the keyboard focus here (accessibility), so it is
+ not bound; F5 (hide the top panel) is not bound either.
- ⌘M / ⌘H / ⌘Q / ⌘W rely on the platform window defaults (unverified).
@@@ -152,21 -114,7 +161,22 @@@ establish OS keyboard delivery or cross
| Date | Change | Summary |
|---|---|---|
+| 2026-10-24 | patch | KEYC-METADATA: ⌘⌥⇧C / ⌘⌥⇧V (Ctrl+Alt+Shift+C / V on Windows and Linux) copy and paste metadata |
+| 2026-10-24 | minor | KEYC-METADATA: ⌥0 / ⌥⇧0 (Alt+0 / Alt+Shift+0) go to the next / previous keyword set, Recent Keywords first, wrapping around at either end |
+| 2026-10-24 | minor | KEYC-METADATA: ⌘K / Ctrl+K (Add Keywords) shows the Keywords panel with the cursor in its Add keyword box |
+| 2026-10-15 | patch | Context menus: a right-click elsewhere on the same widget while its menu is open moves the menu to the pointer; before it flashed at the new spot and closed (issue #1877); every site uses `widgets::context_menu`; 70% unchanged |
+| 2026-10-23 | patch | KEYC-RATING: ⌘L / Ctrl+L (Library ▸ Enable Filters) switches the filter off and on, restoring it as it was |
+| 2026-10-15 | patch | KEYC-RATING: `\` shows / hides the Filter Bar in Photo Grid and Square Grid (Show Original in Detail); ⌘L is the filter-bar key left |
+| 2026-10-14 | minor | Zoom row: diagnostic overlays render zoom windows too |
+| 2026-10-14 | patch | Shortcuts: Visualize HDR loses its default ⇧H, which cycles the Tool Overlay (issue #224); both PRs had claimed it |
+| 2026-10-12 | minor | Accessibility: crop handles, spots, gradient handles and mask pins operable by keyboard with AccessKit names and values; Tab order test for the right panels; hand-drawn icons and rows named; 55% → 75%; UI remaining 34–58 h → 32–54 h |
+| 2026-10-13 | minor | Shortcuts: Tool Overlay modes for spot and mask pins on ⇧H (H stays Remove; issue #224), listed with the deliberate differences; dropped from the missing list |
+| 2026-10-13 | minor | Library culling: backtick cycles the flag; ⌘↑ / ⌘↓ raise / lower flag status |
+| 2026-10-13 | minor | KEYC-COMPARE: `=` / `-` grid thumbnail size keys noted in the shortcuts section |
+| 2026-10-13 | minor | Shortcuts: Home / End and Shift+Left / Right in the two library grids, Cmd+O (Open Library…) and Shift+H (Visualize HDR) get bindings and keyboard tests; percentages and the dated counts above are unchanged |
+| 2026-10-14 | minor | Zoom row: soft proofing gets zoom windows; LR-VIEW-ZOOM gap closed |
| 2026-10-12 | minor | Accessibility: an AccessKit tree audit test over every view, Develop tool and 13 dialogs; unnamed fields, slider ranges and the Auto Stack slider fixed; 30% → 55%; UI remaining 40–70 h → 34–58 h |
+| 2026-10-21 | minor | Reference Escape exits to Detail; catalog-local pins and missing/deleted reference handling verified with regressions and native Windows smoke |
+ | 2026-10-11 | minor | Alt/Option-drag slider previews (clipping, sharpening) and the Linux window-manager note |
| 2026-10-11 | minor | Zoom row: Compare and Reference get zoom windows; what remains of LR-VIEW-ZOOM is overlays and soft proofing |
| 2026-10-10 | major | Created: measured command and shortcut counts, assessment by area, estimates; moved the shortcut conflicts section here from the checklist |
diff --cc docs/whats-new.md
index a0213da82,4d084e82d..bdbdeb1b4
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -893,16 -111,18 +893,28 @@@
- Lossy JPEG XL files in Display P3 or Rec. 2020 now open in their real colours; saturated colours used to come in
noticeably duller.
+### Export next to the originals
+- The Export dialog has Export to: Specific folder (as before) or Same folder as original photo, like Lightroom
+ Classic (issue #956). With the second, each photo is exported into the folder its original is in, plus the
+ Subfolder if you give one (say `Exports`), so a batch from several folders lands next to each set of originals.
+ "If file exists" works per folder as usual, and an original is never written over.
+- A photo that has no folder on disk (a demo photo, or one in the web version's browser storage) or whose folder
+ is missing (moved, drive unplugged) is not exported; it gets its own error naming it.
+- The choice is saved in export presets and Export with Previous. Agents pass
+ `destinationMode: "sameAsOriginal"` (or `"specificFolder"`) to `app.export`; `dir` is then not needed.
+
+ ### Alt/Option-drag previews
+ - Hold Alt (Option on macOS) while dragging Exposure, Highlights or Whites to see which areas clip to white: the
+ photo turns black, fully clipped areas show white and areas clipped in one or two channels show those channels'
+ colour. Shadows and Blacks do the same for clipping to black, on white (issue #937).
+ - In Detail ▸ Sharpening the same key shows Amount in greyscale, Radius and Detail as the fine detail being
+ sharpened, and Masking as the mask: white is sharpened, black is protected. Radius and Detail don't change the
+ render yet, so their preview stays the same while you drag them. Noise Reduction's Luminance, Detail and Contrast
+ show the photo in greyscale.
+ - The preview lasts while the key and the slider are held, and never changes the edit, its history or exports.
+ - Linux: KDE Plasma (and some other desktops) move windows with Alt+drag. If Alt+drag moves the window instead,
+ set the window manager's move modifier to Meta.
+
### Open Library knows a Lightroom catalog
- Choosing a Lightroom Classic catalog folder in File → Open Library… (or one of its `Previews.lrdata` /
`.lrcat-data` folders, or the `.lrcat`) no longer makes an empty LightCraft library inside it (issue #891). The