LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge remote-tracking branch 'upstream/main' into fix/1506-explicit-targets
Michael Andersone48d5d428da3
diff --cc crates/engine/src/cmd/library.rsindex 1908002cf,cc3e654c7..1cfaaefdc--- a/crates/engine/src/cmd/library.rs+++ b/crates/engine/src/cmd/library.rs@@@ -167,9 -167,22 +167,22 @@@ fn album_targets_or_err(s: &Session, coOk((kept, skipped))}+ /// Move to Recently Deleted and drop the photos from stacks so leftover members do not keep+ /// showing `i/n` (issue #1493).+ fn mark_deleted(s: &mut Session, ids: &[PhotoId], label: &str) -> Result<usize> {+ let mut ops: Vec<Op> = ids.iter().map(|id| Op::SetDeleted { id: *id, deleted: true }).collect();+ let n = ops.len();+ if n == 0 {+ return Ok(0);+ }+ ops.extend(s.catalog.remove_from_stacks_ops(ids));+ s.commit(label, Op::Batch { ops })?;+ Ok(n)+ }+/// Apply one op per target as a single undo step.fn for_targets(s: &mut Session, p: &Value, label: &str, f: impl Fn(PhotoId) -> Option<Op>) -> Result<Value> {- let targets = s.targets(p);+ let targets = s.targets(p)?;let ops: Vec<Op> = targets.iter().filter_map(|id| f(*id)).collect();let n = ops.len();if n > 0 {@@@ -196,6 -209,25 +209,25 @@@ fn change_rating(s: &mut Session, p: &VOk(json!({"changed": n}))}+ /// Move each target's own flag by `step`: cycling wraps unflagged -> pick -> reject -> unflagged,+ /// raising/lowering clamps on reject < unflagged < pick. Unchanged photos make no history step.+ fn change_flag(s: &mut Session, p: &Value, label: &str, step: impl Fn(Flag) -> Flag) -> Result<Value> {+ let mut ops = Vec::new();- for id in s.targets(p) {++ for id in s.targets(p)? {+ let old = s.catalog.photo(id).ok_or(lightcraft_catalog::CatalogError::NoPhoto(id))?.flag;+ let flag = step(old);+ if flag != old {+ ops.push(Op::SetFlag { id, flag });+ }+ }+ let n = ops.len();+ if n > 0 {+ s.commit(label, Op::Batch { ops })?;+ }+ advance_if(s, p);+ Ok(json!({"changed": n}))+ }+fn advance_if(s: &mut Session, p: &Value) {if bool_or(p, "advance", false) {let _ = step(s, 1);@@@ -779,9 -883,10 +883,10 @@@ pub fn specs() -> Vec<CommandSpec>// ---- delete / restorecmd!("photo.delete", "Delete Photo", ["Photo"], Some("Delete"), "{ids?} — moves to Recently Deleted", has_selection, |s, p| {let before = s.visible_cloned();- let v = for_targets(s, p, "Delete", |id| Some(Op::SetDeleted { id, deleted: true }))?;- let targets = s.targets(p);++ let targets = s.targets(p)?;+ let n = mark_deleted(s, &targets, "Delete")?;select_after_deletion(s, &before);- Ok(v)+ Ok(json!({"changed": n}))}),cmd!("photo.restore", "Restore", ["Photo"], None, "{ids?}", has_selection, |s, p| for_targets(s, p, "Restore", |id| Some(Op::SetDeleted {id,@@@ -1333,17 -1439,38 +1438,38 @@@Ok(result)}),- cmd!("album.removePhotos", "Remove from Album", [], None, "{id: albumId, ids?}", has_selection, |s, p| {- let id = album_param(p, "id", "album.removePhotos")?;- let targets = ids_param(p).unwrap_or_else(|| s.selected());- let al = s.catalog.album(id).ok_or_else(|| bad("album.removePhotos", "no such album"))?;- if al.is_smart() {- return Err(bad("album.removePhotos", "smart albums update automatically: change their rules"));+ cmd!(+ "album.removePhotos",+ "Remove from Album",+ ["Photo"],+ None,+ "{id?: albumId (default: the album on screen), ids?} — takes the photos out of the album only: they stay in the library and in their folders (issue #1805; photo.delete removes them from the library) → {removed, album: name}",+ has_selection,+ |s, p| {+ let id = match p.get("id") {+ Some(_) => album_param(p, "id", "album.removePhotos")?,+ None => match s.source {+ LibrarySource::Album(a) => a,+ _ => return Err(bad("album.removePhotos", "no album: pass `id` or show an album")),+ },+ };- let targets = ids_param(p).unwrap_or_else(|| s.targets(&Value::Null));++ let targets = ids_param(p).unwrap_or_else(|| s.selected());+ let al = s.catalog.album(id).ok_or_else(|| bad("album.removePhotos", "no such album"))?;+ if al.is_smart() {+ return Err(bad("album.removePhotos", "smart albums update automatically: change their rules"));+ }+ if al.folder {+ return Err(bad("album.removePhotos", "album folders don't hold photos"));+ }+ let name = al.name.clone();+ let photos: Vec<PhotoId> = al.photos.iter().copied().filter(|x| !targets.contains(x)).collect();+ let removed = al.photos.len().saturating_sub(photos.len());+ if removed > 0 {+ s.commit("Remove from Album", Op::SetAlbumPhotos { id, photos })?;+ }+ Ok(json!({"removed": removed, "album": name}))}- let photos: Vec<PhotoId> = al.photos.iter().copied().filter(|x| !targets.contains(x)).collect();- s.commit("Remove from Album", Op::SetAlbumPhotos { id, photos })?;- ok()- }),+ ),cmd!("album.setCover", "Set as Album Cover", [], None, "{id: albumId, photo?: photoId}", has_active, |s, p| {let id = album_param(p, "id", "album.setCover")?;let photo = p.get("photo").and_then(Value::as_u64).map(PhotoId).or(s.active());diff --cc crates/engine/src/cmd/merge.rsindex 6fcbad27f,708614453..c07065cde--- a/crates/engine/src/cmd/merge.rs+++ b/crates/engine/src/cmd/merge.rs@@@ -40,6 -40,26 +40,26 @@@ fn run(s: &mut Session, id: &str, p: &VOk(info)}+ /// `merge.hdrBatch`: an HDR merge of each bracket set among the photos ([`lightcraft_catalog::Catalog::bracket_sets`]),+ /// one after the other. A set that fails is reported and the others still run.+ fn run_batch(s: &mut Session, p: &Value) -> Result<Value> {+ const ID: &str = "merge.hdrBatch";+ let (kind, finish) = crate::merge::parse("merge.hdr", p)?;- let ids: Vec<PhotoId> = s.targets(p);++ let ids: Vec<PhotoId> = s.targets(p)?;+ let sets = s.catalog.bracket_sets(&ids);+ if sets.is_empty() {+ return Err(bad(ID, crate::merge::NO_BRACKET_SETS));+ }+ let (mut merged, mut failed) = (Vec::new(), Vec::new());+ for set in sets {+ match s.merge_now(kind.clone(), finish.clone(), &set) {+ Ok(v) => merged.push(v),+ Err(e) => failed.push(json!({"photos": set.iter().map(|p| p.0).collect::<Vec<_>>(), "error": e.to_string()})),+ }+ }+ Ok(json!({"merged": merged, "failed": failed}))+ }+pub fn specs() -> Vec<CommandSpec> {vec![cmd!(diff --cc crates/engine/src/tests.rsindex dc586be0f,05ac3ee05..b2d1f7445--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@@ -1487,34 -1563,23 +1563,55 @@@ fn oversized_spots_render()}}+/// A call that names its photos with a malformed `id` or `ids` (a string, a mixed list) is refused and changes+/// nothing; it used to act on the selection, or on the valid part of the list (issue #1506). Leaving the targets+/// out still means the selection.+#[test]+fn malformed_photo_targets_are_refused_not_widened() {+ use lightcraft_catalog::PhotoId;+ let mut s = Session::with_demo();+ let ids: Vec<u64> = s.catalog.photos().take(3).map(|p| p.id.0).collect();+ s.execute("library.select", &json!({"ids": [ids[0], ids[1]]})).unwrap();+ let rating = |s: &Session, i: u64| s.catalog.photo(PhotoId(i)).unwrap().rating;+ let before: Vec<u8> = ids.iter().map(|i| rating(&s, *i)).collect();+ for bad in [+ json!({"rating": 5, "id": "5"}),+ json!({"rating": 5, "ids": [ids[2], "x"]}),+ json!({"rating": 5, "ids": ids[2].to_string()}),+ json!({"rating": 5, "id": -1}),+ ] {+ let err = s.execute("photo.rate", &bad).unwrap_err();+ assert!(matches!(&err, crate::EngineError::BadParams { cmd, .. } if cmd == "photo.rate"), "{bad}: {err}");+ assert_eq!(ids.iter().map(|i| rating(&s, *i)).collect::<Vec<_>>(), before, "{bad} changed a rating");+ }+ let snapshot = s.catalog.to_snapshot();+ assert!(s.execute("photo.deletePermanently", &json!({"id": "5"})).is_err());+ assert_eq!(s.catalog.to_snapshot(), snapshot, "nothing deleted");+ // no targets, or a null one: the selection+ s.execute("photo.rate", &json!({"rating": 4, "id": null})).unwrap();+ assert_eq!((rating(&s, ids[0]), rating(&s, ids[1]), rating(&s, ids[2])), (4, 4, before[2]));+ // a preset's id is not a photo target+ let preset = s.presets.first().unwrap().id.clone();+ s.execute("preset.apply", &json!({"id": preset})).unwrap();+}+++ /// Rotate turns the crop with the image: a crop of the left half becomes the top half, and turning back restores it.+ #[test]+ fn rotate_carries_the_crop_with_the_image() {+ use lightcraft_geom::Rect;+ let mut s = demo();+ let id = s.active().unwrap();+ let mut d = active_dev(&s);+ let left_half = Rect { x0: 0.0, y0: 0.0, x1: 0.5, y1: 1.0 };+ d.crop.geometry.rect = left_half;+ d.crop.aspect = Some((2, 3));+ s.set_develop(id, d, "Crop").unwrap();+ s.execute("photo.rotateRight", &json!({})).unwrap();+ let c = active_dev(&s).crop;+ assert_eq!(c.geometry.rect, Rect { x0: 0.0, y0: 0.0, x1: 1.0, y1: 0.5 });+ assert_eq!(c.aspect, Some((3, 2)), "a locked aspect turns too");+ s.execute("photo.rotateLeft", &json!({})).unwrap();+ let c = active_dev(&s).crop;+ assert_eq!(c.geometry.rect, left_half);+ assert_eq!(c.aspect, Some((2, 3)));+ }diff --cc crates/ui-egui/src/menus.rsindex ba7607e05,960d2ad95..1e6f1dd4a--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@@ -1931,8 -2122,9 +2122,9 @@@ pub fn ui_enabled(app: &LightcraftApp,"file.restoreLibrary" => app.services.restore_library.is_some(),"app.clearRecentLibraries" => !app.ui.settings.recent_libraries.is_empty(),"compare.swap" | "compare.makeSelect" | "compare.set" => app.ui.view == ViewMode::Compare,+ "slideshow.togglePause" | "slideshow.next" | "slideshow.previous" | "slideshow.end" => app.ui.slideshow.is_some(),s if s.starts_with("dialog.merge") || (s.starts_with("merge.") && s.ends_with("Last")) => {- app.session.targets(&serde_json::json!({})).len() >= 2 && app.merge.final_task.is_none()+ app.session.selected().len() >= 2 && app.merge.final_task.is_none()}_ => true,}@@@ -1973,6 -2165,32 +2165,32 @@@ pub fn menu_entries(app: &LightcraftAppv}+ /// The Delete key in an album: a normal album loses the selected photos (`album.removePhotos`),+ /// which stay in the library and their folder; a smart album keeps them (its rules decide) and+ /// says so. True when the key was handled here, false outside albums (then it deletes the photos+ /// from the library). Photo ▸ Delete Photo still deletes from the library everywhere.+ pub fn delete_in_album(app: &mut LightcraftApp, ctx: &egui::Context) -> bool {+ let lightcraft_engine::LibrarySource::Album(aid) = app.session.source else { return false };+ let Some(album) = app.session.catalog.album(aid) else { return false };+ if album.is_smart() {+ app.toast(ctx, crate::i18n::tr("Smart albums update automatically: change their rules, or use Photo ▸ Delete Photo"));+ return true;+ }- if app.session.targets(&json!({})).is_empty() {++ if app.session.selected().is_empty() {+ return true;+ }+ match app.run("album.removePhotos", json!({"id": aid.0})) {+ Ok(r) => {+ let n = r["removed"].as_u64().unwrap_or(0);+ let name = r["album"].as_str().unwrap_or_default().to_string();+ let what = crate::i18n::tr_format!("{n} photo{}", if n == 1 { "" } else { "s" }, n = n);+ app.toast(ctx, crate::i18n::tr_format!("Removed {what} from {name}", what = what, name = name));+ }+ Err(e) => app.toast(ctx, e),+ }+ true+ }+/// With Settings → General → "Confirm before deleting" on, open the confirmation dialog instead/// of deleting; true when it did (the dialog's OK runs `photo.delete`).pub fn confirm_delete(app: &mut LightcraftApp) -> bool {diff --cc crates/ui-egui/src/merge.rsindex 05e7baa8e,02e4ddec2..d4c9a0bc6--- a/crates/ui-egui/src/merge.rs+++ b/crates/ui-egui/src/merge.rs@@@ -194,6 -196,31 +196,31 @@@ pub fn start_last(app: &mut LightcraftAstart_final(app, &opts)}+ /// HDR for Each Bracket Set (`merge.hdrBatch`): merge each bracket set among the photos in the background, one after+ /// the other, with the options last used for HDR (the defaults the first time).+ pub fn start_batch(app: &mut LightcraftApp, p: &Value) -> Result<Value, String> {+ if app.merge.final_task.is_some() {+ return Err("a merge is already running".into());+ }- let ids = app.session.targets(p);++ let ids = app.session.targets(p).map_err(|e| e.to_string())?;+ let sets = app.session.catalog.bracket_sets(&ids);+ if sets.is_empty() {+ return Err(lightcraft_engine::merge::NO_BRACKET_SETS.into());+ }+ let n = sets.len();+ app.merge.batch = sets.into();+ next_in_batch(app)?;+ Ok(json!({"started": true, "sets": n}))+ }++ /// Start the next bracket set of a batch, if any.+ fn next_in_batch(app: &mut LightcraftApp) -> Result<(), String> {+ let Some(ids) = app.merge.batch.pop_front() else { return Ok(()) };+ app.merge.ids = ids;+ let opts = app.merge.last.get("merge.hdr").cloned().unwrap_or_else(|| MergeDialog::for_command("merge.hdr"));+ start_final(app, &opts).map(|_| ())+ }+/// Per frame: keep the preview in sync with the dialog's options, collect finished jobs.pub fn poll(app: &mut LightcraftApp, ctx: &egui::Context) {// preview for the open dialogdiff --cc crates/ui-egui/src/panels/dialogs.rsindex 08b05e4bf,a7779fcd6..4702c507f--- a/crates/ui-egui/src/panels/dialogs.rs+++ b/crates/ui-egui/src/panels/dialogs.rs@@@ -643,10 -707,10 +707,10 @@@ pub fn show(app: &mut LightcraftApp, ctDialog::ContactSheet { options } => {options.columns = options.columns.clamp(1, 8);options.rows = options.rows.clamp(1, 10);- let n = app.session.targets(&json!({})).len();+ let n = app.session.selected().len();ui.label(format!("{n} selected photos · {} pages", n.div_ceil(options.columns * options.rows)));field(ui, "Paper", |ui| {- egui::ComboBox::from_id_salt("contactSheetPaper").selected_text(&options.paper).show_ui(ui, |ui| {+ crate::widgets::combo_box("contactSheetPaper").selected_text(&options.paper).show_ui(ui, |ui| {ui.selectable_value(&mut options.paper, "a4".into(), "A4");ui.selectable_value(&mut options.paper, "letter".into(), "Letter");});diff --cc crates/ui-egui/src/panels/grid.rsindex 76952b5ce,1aaddbeea..cc830d35e--- a/crates/ui-egui/src/panels/grid.rs+++ b/crates/ui-egui/src/panels/grid.rs@@@ -1039,8 -1089,8 +1089,8 @@@ pub fn context_menu(app: &mut Lightcraf}}});- ui.menu_button(crate::i18n::tr("Set Color Label"), |ui| label_menu(app, ui));+ crate::widgets::menu_button(ui, crate::i18n::tr("Set Color Label"), |ui| label_menu(app, ui));- if local_only(app, &app.session.targets(&serde_json::Value::Null)) {+ if local_only(app, &app.session.selected()) {// albums hold library photos (issue #684): nothing here to add until they join My Photoslet add = ui.add_enabled(false, egui::Button::new(crate::i18n::tr("Add to Album"))).on_disabled_hover_text(albums_hint());register(ui.ctx(), "button:contextAddToAlbum", add.rect);@@@ -1145,8 -1195,8 +1195,8 @@@if ui.button(crate::i18n::tr("Reset Edits")).clicked() {let _ = app.run("develop.reset", json!({}));}- ui.menu_button(crate::i18n::tr("Photo Merge"), |ui| {+ crate::widgets::menu_button(ui, crate::i18n::tr("Photo Merge"), |ui| {- let n = app.session.targets(&json!({})).len();+ let n = app.session.selected().len();for (id, label) in [("dialog.mergeHdr", "HDR…"), ("dialog.mergePanorama", "Panorama…"), ("dialog.mergeHdrPanorama", "HDR Panorama…")] {if ui.add_enabled(n >= 2, egui::Button::new(crate::i18n::tr(label))).clicked() {let _ = app.run(id, json!({}));diff --cc crates/ui-egui/src/panels/right.rsindex 60f1aa3cc,6a363278a..b8899a53c--- a/crates/ui-egui/src/panels/right.rs+++ b/crates/ui-egui/src/panels/right.rs@@@ -823,15 -889,113 +889,113 @@@ fn keywording(app: &mut LightcraftApp,padded(ui, |ui| {let kid = egui::Id::new("kw-input");let mut text = ui.data_mut(|d| d.get_temp::<String>(kid).unwrap_or_default());- let r =- crate::text_field::TextField::singleline("field:keyword", &mut text).hint(crate::i18n::tr("Add keyword")).width(f32::INFINITY).show(ui);+ // the keywords every selected photo has: those only some have are still offered and suggested- let selection = app.session.targets(&serde_json::Value::Null);++ let selection = app.session.selected();+ let have: Vec<String> =+ app.caches.keyword_chips(&app.session.catalog, &selection).iter().filter(|c| c.on_all()).map(|c| c.path.clone()).collect();+ // while the box has the cursor it offers the library's keywords for what is being typed,+ // right under itself; it stays for a click on one of them, which takes the cursor away+ let field = crate::text_field::id("field:keyword");+ let oid = egui::Id::new("kw-offers");+ let pass = ui.ctx().cumulative_pass_nr();+ // (remembered from the last frame: the text the highlight was for and the keyword it was+ // on, where the offers were drawn, and whether the box was in sight)+ let (typed_then, at_then, drawn, drawn_pass, hidden): (String, Option<String>, Rect, u64, bool) =+ ui.data(|d| d.get_temp(oid)).unwrap_or((String::new(), None, Rect::NOTHING, 0, false));+ let last_frame = drawn_pass.checked_add(1) == Some(pass);+ let clicking = last_frame+ && ui.input(|i| (i.pointer.any_down() || i.pointer.any_released()) && i.pointer.interact_pos().is_some_and(|p| drawn.contains(p)));+ let typed = super::keywording::typing(&text).to_string();+ // (none while the box is scrolled out of the panel: they would float over what is there)+ let offers = ((ui.memory(|m| m.has_focus(field)) || clicking) && !(last_frame && hidden))+ .then(|| app.caches.completions(&app.session.catalog, &have, &typed))+ .filter(|o| !o.keywords.is_empty() || o.create.is_some());+ // ↓ / ↑ move through the offers (none is highlighted at first, and ↑ from the first goes+ // back to none: Return then gives what was typed, as without offers); Return gives the+ // highlighted one. The highlight is on a keyword, not a line: it stays with it when the+ // library changes under it, and goes when the keyword does. With Shift or Alt the keys+ // are the text's own.+ let mut at = at_then.filter(|k| typed_then == typed && offers.as_ref().is_some_and(|o| o.keywords.contains(k)));+ let mut picked = None;+ if let Some(o) = offers.as_ref().filter(|o| !o.keywords.is_empty()) {+ let pressed = |ui: &mut egui::Ui, key: egui::Key| {+ ui.input_mut(|i| {+ let plain =+ |e: &egui::Event| matches!(e, egui::Event::Key { key: k, pressed: true, modifiers, .. } if *k == key && modifiers.is_none());+ let found = i.events.iter().any(plain);+ i.events.retain(|e| !plain(e));+ found+ })+ };+ let line = at.as_ref().and_then(|k| o.keywords.iter().position(|x| x == k));+ if pressed(ui, egui::Key::ArrowDown) {+ let next = line.map_or(0, |a| a.saturating_add(1)).min(o.keywords.len().saturating_sub(1));+ at = o.keywords.get(next).cloned();+ } else if pressed(ui, egui::Key::ArrowUp) {+ at = line.and_then(|a| a.checked_sub(1)).and_then(|a| o.keywords.get(a).cloned());+ }+ if let Some(k) = &at+ && pressed(ui, egui::Key::Enter)+ {+ picked = Some(super::keywording::Picked::Keyword(k.clone()));+ }+ }+ // (after an offer was taken the box starts a new edit, empty: Esc has nothing to bring back)+ // (asked for on the frame before this one only: a box that wasn't drawn then, its panel+ // switched away, doesn't claim the cursor whenever it is next drawn)+ let bid = egui::Id::new("kw-begin");+ let begin = ui.data_mut(|d| d.remove_temp::<u64>(bid)).is_some_and(|asked| asked.checked_add(1) == Some(pass));+ let r = crate::text_field::TextField::singleline("field:keyword", &mut text)+ .hint(crate::i18n::tr("Add keyword"))+ .width(f32::INFINITY)+ .begin_edit(begin)+ .show(ui);+ let in_sight = ui.clip_rect().contains(r.response.rect.center());+ let mut drawn = Rect::NOTHING;+ // (what isn't drawn can't be taken: Return on the frame the box scrolls out gives nothing)+ if !in_sight {+ picked = None;+ }+ if offers.is_none() {+ // (not over the offers)+ r.response.clone().on_hover_text(crate::i18n::tr("Separate several keywords with commas. Return gives them to the selected photos."));+ }+ if let Some(o) = offers.as_ref().filter(|_| in_sight) {+ let (clicked, rect) = super::keywording::offers_below(ui, r.response.rect, o, at.as_deref());+ drawn = rect;+ picked = picked.or(clicked);+ }+ ui.data_mut(|d| d.insert_temp(oid, (typed.clone(), at, drawn, pass, !in_sight)));// Return gives the keywords to the selected photos; Esc gives back what was there before// this edit (the shared field does)- if r.ending == Some(crate::text_field::Ending::Return) && !text.trim().is_empty() {- // a new name goes inside the default parent (Put New Keywords Inside This Keyword)- let kws: Vec<String> = text.split(',').map(|s| app.session.catalog.typed_keyword(s)).filter(|s| !s.is_empty()).collect();- let _ = app.run("photo.setMeta", json!({"addKeywords": kws}));- text.clear();+ let returned = r.ending == Some(crate::text_field::Ending::Return) && !text.trim().is_empty();+ // a new name goes inside the default parent (Put New Keywords Inside This Keyword)+ let as_typed = |app: &LightcraftApp, text: &str| -> Vec<String> {+ text.split(',').map(|s| app.session.catalog.typed_keyword(s)).filter(|s| !s.is_empty()).collect()+ };+ let adding: Option<Vec<String>> = match picked {+ // an offer: it, and the keywords typed before the last comma+ Some(super::keywording::Picked::Keyword(k)) => {+ let mut kws = super::keywording::typed_before(&app.session.catalog, &text);+ kws.push(k);+ Some(kws)+ }+ Some(super::keywording::Picked::Typed) => Some(as_typed(app, &text)),+ None if returned => Some(as_typed(app, &text)),+ None => None,+ };+ if let Some(kws) = adding {+ // (refused, the text stays to be put right, and the refusal is said)+ match app.run("photo.setMeta", json!({"addKeywords": kws})) {+ Ok(_) => {+ text.clear();+ // an offer taken leaves the cursor in the box, for the next keyword+ if !returned {+ ui.data_mut(|d| d.insert_temp(bid, pass));+ }+ }+ Err(e) => app.toast_error(ui.ctx(), e),+ }}ui.data_mut(|d| d.insert_temp(kid, text));ui.add_space(8.0);diff --cc docs/whats-new.mdindex 0ba1a14cb,3404dc978..fe2fd3cec--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -2,10 -2,121 +2,124 @@@## 2026-10-14+ ### Lightroom radial masks on the right side+ - Radial masks brought over from Lightroom Classic (catalog import, XMP sidecars, edits inside DNGs and presets) now+ apply their effect inside the circle, as Lightroom does, instead of outside it (issue #1815). A mask inverted in+ Lightroom stays inverted, and older Radial Filters keep their Effect Outside / Invert Mask setting. Photos imported+ before this keep the masks they got: Photo ▸ Read Metadata from File reads a sidecar's again.++ ### Delete in an album removes from the album only+ - In an album, the Delete key now takes the selected photos out of the album, as in Lightroom. It used to move them+ to Recently Deleted, so they also left their folder's view (issue #1805). They stay in the library and in their+ folder; Edit ▸ Undo puts them back in the album. Photo ▸ Remove from Album does the same and now shows the key.+ To delete photos from the library from an album, use Photo ▸ Delete Photo or right-click ▸ Delete Photo. In a smart+ album, Delete changes nothing: its rules decide what it shows.++ ### Local folders select a photo+ - Showing a Local folder now makes its first photo the active one, as albums and the other sources do (issue+ #1447), or keeps the photo you had when the folder holds it. Before, the photo from the previous view stayed active:+ Photo Grid marked nothing, and Detail, the histogram and the photo info showed a photo that isn't in the folder.++ ### HDR merges of moving lights, and many brackets at once+ - A star, the moon or a light that moves between the photos of a bracket (a night bracket on a tripod) no longer+ leaves a black hole where the middle photo had it clipped. With Deghost, the brightest photo's copy of it in a+ dark sky is now removed too.+ - Photo ▸ Photo Merge ▸ HDR for Each Bracket Set merges every bracket among the selected photos with the last HDR+ settings, one after the other: each stack, and photos taken less than a second apart at different exposures.+ From the command line: `lightcraft-cli merge hdr-batch FOLDER`.+ - Merging uses about a quarter less memory: three 67 MP raws need 3.8 GB instead of 4.8 GB.++ ### XMP sidecars catch up after a network share comes back+ - With automatic XMP writing on, an edit to a photo whose folder can't be written (a network share that dropped+ out, a folder that went read-only) used to be written only to the library, with a line in the log, so the sidecar+ stayed behind the edit. LightCraft now says once that the sidecars are waiting, tries again every few seconds once+ the files are reachable, and says when they're written. `library.retrySidecars` does it on request.++ ### Reliability+ - A damaged or crafted raw can no longer make LightCraft set aside gigabytes of memory before finding out the file is+ bad (issue #1512): a compressed PEF whose data is too short for the size it declares, an uncompressed TIFF-based+ raw whose tile claims far more samples than it holds, and an ARW6 with a broken tile are refused first. All 74+ files in the test corpus still decode.++ ### Reliability+ - Thumbnails and previews are written to the cache on disk by one background writer instead of a new thread for+ each image (issue #1522). When renders come in faster than the disk takes them, at most 128 MB of images wait;+ past that a write is skipped (the image stays in memory and is written by a later render), so a slow disk can't+ pile up threads and memory.++ ### Reliability+ - Saving the catalog and resuming a model download no longer write through a link left at the temporary file's+ name (`catalog.snap.tmp`, `model.onnx.part`): the link is removed and a new file made in its place, so the file it+ pointed to is never changed (issue #1502).+### Reliability+ - A photo whose file was replaced (Reload Changed Files after an outside edit) no longer keeps the faces recognition+ made from the old pixels: they are made again from the new file, and a scan still busy with the old file when it+ changed doesn't put its faces on the new one (issue #1524).++ ### Settings stays put when you change tabs+ - The Settings window keeps its top edge and width when you switch tabs, so the tab row no longer jumps around+ under the pointer. It used to be centred, so every tab of a different height moved it.++ ### Layout image over the loupe+ - View ▸ Loupe Overlay ▸ Choose Layout Image… draws a PNG with transparency over the photo in the loupe, such as+ a magazine cover's masthead and cover lines, so you can frame a shot for the page it is made for. It fits inside+ the photo, follows zoom and pan, and ⌥⌘O shows or hides it. The same menu sets its opacity and a matte that+ darkens the photo outside it. The layout stays chosen across launches.++ ### Smaller JPEG exports+ - JPEG exports are 12–14 % smaller at the same quality, with exactly the same pixels (issue #1373): each file now+ carries Huffman tables made for its own picture instead of the standard example tables. Every viewer opens them+ as before.++ ### Reliability+ - A photo whose Defringe amount was stored far past the sliders' 20 (in a damaged catalog or sidecar) no longer+ crashes LightCraft each time it renders: the amount acts as 20.++ ### Lens names for Nikon DSLR raws+ - Photos from Nikon DSLRs like the D700, D750, D80 or D5300 now show which lens they were taken with, for example+ "24.0-70.0 mm f/2.8". Those cameras don't write a lens name, so the lens field was empty and you couldn't filter or+ search by lens. LightCraft now reads the lens range Nikon keeps in its own maker note, the way Lightroom shows a+ lens it doesn't have a name for. Newly imported photos show it.++ ### Import when a card is connected+ - Settings → Import → Cameras and Cards has an option to open the import review as soon as a camera or memory card+ is connected, the same review File → Import from Device opens. It's off by default. A card that's already in when+ LightCraft starts doesn't ask, and if a dialog is open or an import is running it waits until that's done.++ ### Local folders+ - Photos deleted (or moved) by another app no longer stay in a Local folder, failing to load and logging an error+ each time you look (issue #1392): the next time you browse the folder, in a later session, they're left out. A photo you had rated, flagged or+ edited stays, marked missing, so its changes aren't lost; photos in My Photos are unchanged.++ ### Full-resolution panoramas+ - Panorama and HDR Panorama merges keep the resolution of their photos instead of stopping at 40 megapixels+ (issue #1455), up to 512 MP and 65,000 pixels on the long edge, as in Lightroom. When the full size needs more+ memory than the computer has, the panorama is made as large as fits (five 51 MP photos: up to 166 MP with+ 16 GB, 355 MP with 32 GB) and the message says so. The merge also frees each photo's pixels once they are+ projected, so it needs less memory than before at any size (an 81 MP stitch: 4.4 GB instead of 6.2 GB).++ ### Nikon D600, D610 and D5000+ - Raws from the Nikon D600, D610 and D5000 no longer show a bright line down the right edge (issue #1627). Their+ sensor data runs a few columns of filler past the picture, which stayed in the image; these bodies now develop+ at the camera JPEG's size (6016 × 4016 for the D600 and D610, 4288 × 2848 for the D5000, as the D90 already+ did). On the D600 and D610 the white level is also measured inside the picture, so the filler can't pass for+ clipped highlights.++ ### More Canon EOS R6 Mark II C-RAW files decode+ - Some EOS R6 Mark II C-RAW files (about 1 in 50 in one photographer's library) opened as their preview with+ "Canon CRX adaptive QP value 172" or "175". They now decode from the sensor data. Photos imported before this+ switch over with Photo ▸ Reload from Disk.++ ### Nikon raws without coloured edge bars+ - Raws from older Nikon bodies no longer show a thin coloured or dark bar along one edge (the right edge, or the top+ of a portrait photo): masked sensor columns were being developed as part of the picture (issues #976, #914,+ #1236). The D7000, D5100, D800, D800E, Df, D4, D3, D3S, D700, D300, D300S, D600, D610, D810, D4S, D5600,+ Coolpix A, D3000, D40X, D60, D80, D2Xs, D200, D3200, D3100, D5000, D40, D50, D70, D70s and Nikon 1 V1 now show+ the area the camera itself frames, a few pixels smaller than before.+- A command given photos it can't read as photo ids (`"id": "5"`, or a list with something else in it) from a+ script, the control channel or MCP is now refused (issue #1506). It used to act on the selected photos instead,+ or on the part of the list it could read, so a mistyped id could rate, move or delete the wrong photos.### Hard-edged Heal and Clone spots- A spot with Feather at 0 no longer draws black pixels exactly on its radius. This also fixes spots at 0% Opacity