Skip to content

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

Edit: add Select Only Active Photo (Cmd+Shift+D)

eliets26f5e1f876e8e
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 141d6d782..248682b4a 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -58,6 +58,7 @@ pub const UI_COMMANDS: &[UiCommand] = &[
("view.squareGrid", "Square Grid", None, "View"),
// G: Photo Grid ↔ Square Grid (from other views: the photo grid)
("view.gridToggle", "Grid", Some("G"), ""),
+ ("library.selectOnlyActive", "Select Only Active Photo", Some("Cmd+Shift+D"), "Edit"),
("tool.guidedUpright", "Guided Upright", Some("Shift+G"), "Window>Tools"),
("view.detail", "Detail", Some("D"), "View"),
("view.compare", "Compare", Some("Shift+C"), "View"),
@@ -477,6 +478,10 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
}
"view.appearance" => appearance_command(app, p),
"view.theme" => theme_command(app, p),
+ "library.selectOnlyActive" => {
+ let Some(active) = app.session.active() else { return Some(Err("no active photo".into())) };
+ app.run("library.select", json!({"ids": [active.0], "active": active.0}))
+ }
"view.gridToggle" => {
app.ui.view = if app.ui.view == ViewMode::PhotoGrid { ViewMode::SquareGrid } else { ViewMode::PhotoGrid };
Ok(Value::Null)
@@ -1847,6 +1852,7 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
pub fn ui_enabled(app: &LightcraftApp, id: &str) -> bool {
match id {
+ "library.selectOnlyActive" => app.session.active().is_some(),
"dialog.contactSheet" | "app.contactSheet" => !cfg!(target_arch = "wasm32") && app.session.active().is_some() && app.export.is_none(),
s if s.starts_with("panel.") || s.starts_with("tool.") || s.starts_with("section.") => app.session.active().is_some() || s == "panel.close",
"app.export" | "dialog.export" | "dialog.createPreset" | "dialog.rename" | "dialog.captureTime" | "dialog.copySettings" => {