Skip to content

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

LRC-LIB-KEYWORDS + LRC-LIB-VIEWS: keyword painter, square-grid captions

Brandon Thomas81f77d74dfc7
diff --git a/crates/ui-egui/src/menubar.rs b/crates/ui-egui/src/menubar.rs
index e089192f1..d2b08a26e 100644
--- a/crates/ui-egui/src/menubar.rs
+++ b/crates/ui-egui/src/menubar.rs
@@ -103,6 +103,7 @@ const LAYOUT: &[(&str, &[&str])] = &[
&[
"view.photoGrid",
"view.squareGrid",
+ "@Grid Info",
"view.detail",
"view.compare",
"view.survey",
@@ -390,6 +391,11 @@ fn expanded(app: &LightcraftApp, name: &str) -> Option<Vec<MenuNode>> {
v.push(item("dialog.labelNames", Value::Null, "Edit Label Names…", None, true, None));
v
}
+ "Grid Info" => ["filename", "exposure", "date"]
+ .into_iter()
+ .zip(["File Name", "Exposure (shutter · aperture · ISO)", "Capture Date"])
+ .map(|(k, label)| item("view.gridInfo", json!({"info": k}), label, None, true, Some(app.ui.grid_info == k)))
+ .collect(),
"Sort" => {
use lightcraft_catalog::SortKey::*;
let cur = app.session.sort;
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 89f60b80a..207eb7db6 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -84,6 +84,8 @@ pub const UI_COMMANDS: &[UiCommand] = &[
("view.photoCounts", "Show Photo Counts", None, "View"),
("view.slideshow", "Slideshow", Some("Cmd+Alt+Enter"), "View"),
("view.secondWindow", "Second Window", Some("Cmd+F11"), "Window"),
+ ("tool.keywordPainter", "Keyword Painter", None, ""),
+ ("view.gridInfo", "Grid Info", None, ""),
("dialog.allMetadata", "All Metadata…", None, "Photo"),
("dialog.newSmartAlbum", "New Smart Album from Filter…", Some("Cmd+Alt+N"), "File"),
("dialog.createPreset", "Create Preset…", Some("Cmd+Shift+P"), "Photo"),
@@ -196,6 +198,32 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
app.ui.view = ViewMode::SquareGrid;
Ok(Value::Null)
}
+ "view.gridInfo" => {
+ // {info?: filename | exposure | date} (cycles when omitted)
+ let next = match p.get("info").and_then(Value::as_str) {
+ Some(i @ ("filename" | "exposure" | "date")) => i.to_string(),
+ Some(other) => return Some(Err(format!("view.gridInfo: unknown `{other}` (filename|exposure|date)"))),
+ None => match app.ui.grid_info.as_str() {
+ "filename" => "exposure".into(),
+ "exposure" => "date".into(),
+ _ => "filename".into(),
+ },
+ };
+ app.ui.grid_info = next;
+ app.ui.show_filenames = true;
+ Ok(json!({"info": app.ui.grid_info}))
+ }
+ "tool.keywordPainter" => {
+ // {keyword?}: paint that keyword onto photos in the grid by clicking them; no keyword stops
+ app.ui.keyword_painter = p.get("keyword").and_then(Value::as_str).map(str::trim).filter(|k| !k.is_empty()).map(str::to_string);
+ if app.ui.keyword_painter.is_some() && !matches!(app.ui.view, ViewMode::PhotoGrid | ViewMode::SquareGrid) {
+ app.ui.view = ViewMode::PhotoGrid;
+ }
+ if let Some(k) = app.ui.keyword_painter.clone() {
+ app.toast(&ctx, format!("Painting “{k}”: click photos to add or remove it · Esc stops"));
+ }
+ Ok(json!({"keyword": app.ui.keyword_painter}))
+ }
"view.secondWindow" => {
app.ui.second_window = p.get("show").and_then(Value::as_bool).unwrap_or(!app.ui.second_window);
Ok(json!({"show": app.ui.second_window}))
@@ -227,6 +255,8 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
"view.back" => {
if app.ui.dialog.is_some() {
app.ui.dialog = None;
+ } else if app.ui.keyword_painter.is_some() {
+ app.ui.keyword_painter = None;
} else if app.ui.fullscreen {
app.ui.fullscreen = false;
app.ui.slideshow = None;
diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rs
index 21d6b116d..23a806500 100644
--- a/crates/ui-egui/src/panels/grid.rs
+++ b/crates/ui-egui/src/panels/grid.rs
@@ -344,7 +344,25 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, square
}
// labels and badges
if square && app.ui.show_filenames {
- let name = photo.file_name.rsplit_once('.').map(|(n, _)| n.to_string()).unwrap_or(photo.file_name.clone());
+ let m = &photo.meta;
+ let name = match app.ui.grid_info.as_str() {
+ "exposure" => {
+ let parts: Vec<String> = [
+ // whole seconds read "8 s"; fractions as written ("1/250")
+ (!m.shutter.is_empty())
+ .then(|| if m.shutter.contains('/') || m.shutter.ends_with('s') { m.shutter.clone() } else { format!("{} s", m.shutter) }),
+ m.aperture.map(|a| format!("f/{a:.1}").replace(".0", "")),
+ m.iso.map(|i| format!("ISO {i}")),
+ m.focal_mm.map(|f| format!("{f:.0} mm")),
+ ]
+ .into_iter()
+ .flatten()
+ .collect();
+ if parts.is_empty() { "—".to_string() } else { parts.join(" · ") }
+ }
+ "date" => photo.captured.as_deref().map(lightcraft_catalog::dates::display_time).unwrap_or_else(|| "No date".into()),
+ _ => photo.file_name.rsplit_once('.').map(|(n, _)| n.to_string()).unwrap_or(photo.file_name.clone()),
+ };
p.text(pos2(r.left() + 8.0, r.top() + 12.0), Align2::LEFT_CENTER, name, t.font(10.5), t.text_dim);
let fmt = photo.format.clone();
let g = p.layout_no_wrap(fmt, t.semibold(9.0), t.text_label);
@@ -402,6 +420,18 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, square
p.rect_filled(img_rect, 0.0, Color32::from_black_alpha(110));
}
// interaction
+ if let Some(k) = app.ui.keyword_painter.clone() {
+ // painting: a click toggles the keyword on this photo
+ if resp.hovered() {
+ ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair);
+ }
+ if resp.clicked() {
+ let has = photo.meta.keywords.iter().any(|x| x.eq_ignore_ascii_case(&k));
+ let key = if has { "removeKeywords" } else { "addKeywords" };
+ let _ = app.run("photo.setMeta", json!({"ids": [id.0], key: [k]}));
+ }
+ return;
+ }
if resp.clicked() {
let m = ui.input(|i| i.modifiers);
let mode = if m.shift {
diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs
index 94574dd81..f2ad1ac0a 100644
--- a/crates/ui-egui/src/panels/right.rs
+++ b/crates/ui-egui/src/panels/right.rs
@@ -627,6 +627,23 @@ fn keywords(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
});
ui.add_space(10.0);
keyword_set(app, ui, &p.meta.keywords);
+ ui.add_space(8.0);
+ // the painter: click photos in the grid to give them (or take away) a keyword
+ ui.horizontal(|ui| {
+ let pid = egui::Id::new("kw-painter");
+ let painting = app.ui.keyword_painter.clone();
+ let mut k: String = ui.data(|d| d.get_temp(pid)).unwrap_or_else(|| painting.clone().unwrap_or_default());
+ let r = ui.add_enabled(painting.is_none(), egui::TextEdit::singleline(&mut k).hint_text("Keyword to paint").desired_width(130.0));
+ register(ui.ctx(), "field:keywordPainter", r.rect);
+ ui.data_mut(|d| d.insert_temp(pid, k.clone()));
+ let label = if painting.is_some() { "Stop" } else { "Paint" };
+ if text_button(ui, "keywordPaint", label, painting.is_some())
+ .on_hover_text("Click photos in the grid to toggle the keyword; Esc stops")
+ .clicked()
+ {
+ let _ = app.run("tool.keywordPainter", json!({"keyword": if painting.is_some() { serde_json::Value::Null } else { json!(k) }}));
+ }
+ });
ui.add_space(10.0);
// suggestions: completions of the typed text, else keywords used together with this
// photo's keywords, else the most used ones
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index 7c5ae7011..daaa07432 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -211,6 +211,9 @@ pub struct UiState {
pub crop_overlay_orient: u8,
pub crop_overlay: CropOverlay,
pub show_filenames: bool,
+ /// What the square grid's caption shows: `filename`, `exposure` (shutter · aperture · ISO ·
+ /// focal length) or `date`.
+ pub grid_info: String,
/// Photo counts next to sources and albums in the left panel.
pub show_counts: bool,
/// Copies opened in an external editor this session (reloaded when the window is focused
@@ -274,6 +277,9 @@ pub struct UiState {
pub fullscreen: bool,
/// Window ▸ Second Window.
pub second_window: bool,
+ /// The keyword painter: clicking a photo in the grid toggles this keyword on it.
+ #[serde(skip)]
+ pub keyword_painter: Option<String>,
/// A running slideshow (full screen): seconds per photo, when the next one is due (egui
/// time), paused.
#[serde(skip)]
@@ -463,6 +469,7 @@ impl Default for UiState {
crop_overlay: CropOverlay::Thirds,
crop_overlay_orient: 0,
show_filenames: true,
+ grid_info: "filename".into(),
show_counts: true,
dragging_control: None,
external_edits: Vec::new(),
@@ -495,6 +502,7 @@ impl Default for UiState {
fullscreen: false,
slideshow: None,
second_window: false,
+ keyword_painter: None,
info_overlay: InfoOverlay::Off,
navigator: true,
settings: AppSettings::default(),
diff --git a/crates/ui-egui/src/tests_masking.rs b/crates/ui-egui/src/tests_masking.rs
index 5e25da0cb..3e992ca41 100644
--- a/crates/ui-egui/src/tests_masking.rs
+++ b/crates/ui-egui/src/tests_masking.rs
@@ -502,3 +502,47 @@ fn grid_frame_100k() {
let ms = t.elapsed().as_secs_f64() * 1e3 / n as f64;
eprintln!("grid frame at 100k photos: {ms:.1} ms (UI thread, renders excluded)");
}
+
+#[test]
+fn keyword_painter_toggles_on_click() {
+ let mut h = detail("panel.edit");
+ exec(&mut h, "tool.keywordPainter", json!({"keyword": "harbour"}));
+ assert_eq!(h.app.ui.view, crate::state::ViewMode::PhotoGrid);
+ h.settle(SETTLE);
+ let target = h.app.session.visible_cloned()[0];
+ let has = |h: &Headless| h.app.session.catalog.photo(target).unwrap().meta.keywords.iter().any(|k| k == "harbour");
+ let sel = h.app.session.selection.clone();
+ // a click: press and release on separate frames, no movement
+ let click = |h: &mut Headless| {
+ let w = h.request("ui.widgets", json!({}), T);
+ let r = w["result"]
+ .as_array()
+ .and_then(|a| a.iter().find(|x| x["id"] == format!("thumb:{}", target.0)))
+ .map(|x| x["rect"].clone())
+ .expect("thumb on screen");
+ let (x, y) = (r[0].as_f64().unwrap() + r[2].as_f64().unwrap() / 2.0, r[1].as_f64().unwrap() + r[3].as_f64().unwrap() / 2.0);
+ let r = h.request("ui.drag", json!({"x": x, "y": y, "toX": x, "toY": y, "steps": 2}), T);
+ assert_eq!(r["ok"], true, "{r}");
+ };
+ click(&mut h);
+ assert!(has(&h), "painted");
+ assert_eq!(h.app.session.selection, sel, "painting doesn't select");
+ click(&mut h);
+ assert!(!has(&h), "a second click takes it away");
+ h.request("ui.key", json!({"key": "escape"}), T);
+ assert!(h.app.ui.keyword_painter.is_none());
+ h.settle(SETTLE);
+}
+
+#[test]
+fn grid_info_cycles_caption() {
+ let mut h = detail("panel.edit");
+ assert_eq!(exec(&mut h, "view.gridInfo", json!({}))["info"], "exposure");
+ assert_eq!(exec(&mut h, "view.gridInfo", json!({}))["info"], "date");
+ assert_eq!(exec(&mut h, "view.gridInfo", json!({"info": "filename"}))["info"], "filename");
+ let r = h.request("engine.execute", json!({"command": "view.gridInfo", "params": {"info": "lens"}}), T);
+ assert_ne!(r["ok"], true);
+ exec(&mut h, "view.squareGrid", json!({}));
+ exec(&mut h, "view.gridInfo", json!({"info": "exposure"}));
+ h.settle(SETTLE);
+}
diff --git a/docs/parity.md b/docs/parity.md
index ad097f8f4..37d92f26b 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -47,10 +47,10 @@ and prints the summary; `cargo xtask parity --write` refreshes the summary table
| X. Cross-cutting behaviours (BEHAV) | 14 | 1 | 2 | 1 | 8/8 (100%) | 5/5 (100%) |
| Y. Menus | 79 | 2 | 4 | 8 | 46/47 (98%) | 22/23 (96%) |
| Z. Keyboard shortcuts (desktop) | 74 | 3 | 3 | 1 | 49/52 (94%) | 22/23 (96%) |
-| Lightroom Classic extras | 22 | 10 | 47 | 9 | — | 18/21 (86%) |
-| **Total** | 370 | 26 | 104 | 37 | 193/198 (97%) | 132/144 (92%) |
+| Lightroom Classic extras | 23 | 9 | 47 | 9 | — | 19/21 (90%) |
+| **Total** | 371 | 25 | 104 | 37 | 193/198 (97%) | 133/144 (92%) |
-Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **76.6%** of 500 in-scope rows — P0 98.7% of 198 · P1 94.4% of 144 · P2 32.6% of 158.
+Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **76.7%** of 500 in-scope rows — P0 98.7% of 198 · P1 94.8% of 144 · P2 32.6% of 158.
<!-- /parity:summary -->
## Top gaps
@@ -688,7 +688,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06-
| LRC-LIB-IMPORT | Full import dialog | P1 | ✅ | `cmd:library.import` (`mode`, `destination`, `organize`, `rename`, `metadataPreset`, `preset`, `keywords`, `album`), `crates/ui-egui/src/import.rs` | review grid with duplicates skipped; add in place or copy (library Originals or any folder; by day / by month / one folder; rename template with live example, numbered across the import); develop preset, metadata preset, keywords, album on import |
| LRC-LIB-AUTOIMPORT | Watched-folder import | P2 | ✅ | `cmd:library.autoImport` | see LR-IMP-AUTO |
| LRC-LIB-TETHER | Tethered capture | P2 | ⬜ | | |
-| LRC-LIB-VIEWS | Grid / loupe / compare / survey / people | P1 | 🟡 | `cmd:view.photoGrid`, `cmd:view.squareGrid`, `cmd:view.detail`, `cmd:view.compare`, `cmd:view.survey` | grid, square grid, loupe, compare, survey; no people view; grid cell styles: filenames only |
+| LRC-LIB-VIEWS | Grid / loupe / compare / survey / people | P1 | 🟡 | `cmd:view.photoGrid`, `cmd:view.squareGrid`, `cmd:view.detail`, `cmd:view.compare`, `cmd:view.survey`, `cmd:view.gridInfo` | grid, square grid, loupe, compare, survey, second window; square-grid captions: file name, exposure or capture date (View ▸ Grid Info); no people view |
| LRC-LIB-COMPARE | Compare view | P1 | ✅ | `cmd:view.compare` | ⇧C (C is Crop here); swap, make select; zoom always linked |
| LRC-LIB-SURVEY | Survey view | P2 | ✅ | `cmd:view.survey` | N |
| LRC-LIB-REFVIEW | Reference view | P2 | ⬜ | | |
@@ -701,7 +701,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06-
| LRC-LIB-STACKS | Stacks (full) | P1 | ✅ | `crates/catalog/src/stacks.rs`, `cmd:stack.group`, `cmd:stack.split`, `cmd:stack.moveUp`, `cmd:stack.moveDown` | group / ungroup / toggle / set top / remove / auto by time / split / move up and down |
| LRC-LIB-VC | Virtual copies | P1 | ✅ | `cmd:photo.virtualCopy` | ⌘' |
| LRC-LIB-LABELS | Colour-label sets | P1 | ✅ | `cmd:label.sets`, `cmd:label.applySet`, `cmd:label.saveSet`, `cmd:label.deleteSet`, `cmd:label.setNames`, `crates/engine/src/cmd/manage.rs` | built-in Colors / Review sets + user sets (Photo ▸ Set Color Label, Edit Label Names… dialog); names written to and read from `xmp:Label` |
-| LRC-LIB-KEYWORDS | Hierarchical keywords, sets, painter | P1 | 🟡 | `crates/catalog/src/keywords.rs`, `cmd:keyword.list`, `cmd:keyword.sets`, `cmd:keyword.toggleFromSet`, `cmd:keyword.saveSet` | hierarchical `a\|b\|c` keywords (tree, parent filters include children, rename moves children); keyword sets + Recent Keywords in the Keywords panel, ⌥1–⌥9 toggle; no keyword painter |
+| LRC-LIB-KEYWORDS | Hierarchical keywords, sets, painter | P1 | ✅ | `crates/catalog/src/keywords.rs`, `cmd:keyword.list`, `cmd:keyword.sets`, `cmd:keyword.toggleFromSet`, `cmd:keyword.saveSet`, `cmd:tool.keywordPainter` | hierarchical `a\|b\|c` keywords (tree, parent filters include children, rename moves children); keyword sets + Recent Keywords (⌥1–⌥9); keyword painter (Keywords panel ▸ Paint: click photos in the grid to toggle a keyword, Esc stops) |
| LRC-LIB-METADATA | Metadata panel & presets | P1 | ✅ | `cmd:photo.setMeta`, `cmd:metadata.savePreset`, `cmd:metadata.applyPreset`, `cmd:metadata.presets`, `cmd:metadata.deletePreset`, `cmd:dialog.captureTime` | IPTC core, accessibility, place, capture-time edit; metadata presets (Photo → Metadata Preset, Save Metadata Preset… from the active photo; applied on import from Settings); no copyright status field |
| LRC-LIB-QUICKDEV | Quick develop | P2 | ⬜ | | |
| LRC-LIB-PEOPLE | People view | P2 | ⬜ | | |