Skip to content

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

KEYC-METADATA: Enable Painting unfolds a folded Keywords section

dotCooCoo5296a72176ed
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index abeefdb69..99c041715 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -502,6 +502,10 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
Ok(json!({"keyword": null}))
} else if k.is_empty() {
app.ui.right = RightPanel::Keywords;
+ // (a Keywords section folded shut would hide the painter's box)
+ if app.ui.section_folded("keywording") {
+ app.ui.toggle_folded("keywording");
+ }
app.toast(&ctx, crate::i18n::tr("Type a keyword to paint in the Keywords panel"));
Ok(json!({"keyword": null}))
} else {
diff --git a/crates/ui-egui/src/tests_keywording.rs b/crates/ui-egui/src/tests_keywording.rs
index ddc53add9..4c5f305e1 100644
--- a/crates/ui-egui/src/tests_keywording.rs
+++ b/crates/ui-egui/src/tests_keywording.rs
@@ -148,14 +148,17 @@ fn the_painters_field_pastes_and_return_paints() {
}
/// ⌘⌥K (Ctrl+Alt+K) is Enable Painting: with the painter's box empty it shows the Keywords panel to
-/// type a keyword in, with a keyword in the box it paints that keyword, and pressed again it stops.
+/// type a keyword in (unfolding the Keywords section when it was folded shut), with a keyword in the
+/// box it paints that keyword, and pressed again it stops.
#[test]
fn cmd_alt_k_paints_the_painters_keyword_and_stops() {
let (mut h, _) = two_selected();
let key = json!({"key": "K", "cmd": true, "alt": true});
ask(&mut h, "ui.set", json!({"right": "none"}));
+ h.app.ui.toggle_folded("keywording");
ask(&mut h, "ui.key", key.clone());
assert_eq!(h.app.ui.right, crate::state::RightPanel::Keywords, "an empty box: the Keywords panel");
+ assert!(!h.app.ui.section_folded("keywording") && has(&h, "field:keywordPainter"), "the painter's box shows");
assert!(h.app.ui.keyword_painter.is_none(), "nothing to paint yet");
h.view.clipboard = "Weddings".into();
ask(&mut h, "ui.clickWidget", json!({"id": "field:keywordPainter", "button": "right"}));