mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-28 20:17:18 -06:00
LR-PRE-PANEL: an active photo outside the selection isn't marked with the preset applied to the selection (#2392)
preset.apply changes the selection, else the active photo; the panel remembered the preset on the active photo too, so an active photo outside the selection showed a preset it never received.
This commit is contained in:
@@ -1823,6 +1823,33 @@ mod tests {
|
||||
assert_eq!(marked(&h), None, "an edit after the preset drops the mark");
|
||||
}
|
||||
|
||||
/// A preset applied while the active photo lies outside the selection changes only the
|
||||
/// selection, so the active photo isn't marked as having it.
|
||||
#[test]
|
||||
fn applied_preset_is_not_marked_on_an_active_photo_outside_the_selection() {
|
||||
let mut h = demo([1400.0, 900.0]);
|
||||
let t = Duration::from_secs(10);
|
||||
h.request("ui.set", json!({"view": "detail"}), t);
|
||||
h.request("engine.execute", json!({"command": "panel.presets"}), t);
|
||||
h.settle(SETTLE);
|
||||
let a = h.app.session.active().unwrap();
|
||||
let b = h.app.session.visible_cloned().into_iter().find(|id| *id != a).unwrap();
|
||||
h.app.session.selection.ids = vec![b];
|
||||
h.app.session.selection.active = Some(a);
|
||||
let before = h.app.session.develop_of(a).unwrap();
|
||||
let r = h.request("ui.clickWidget", json!({"id": "preset:lc.warm-glow"}), t);
|
||||
assert_eq!(r["ok"], true, "{r}");
|
||||
h.settle(SETTLE);
|
||||
h.step();
|
||||
assert_eq!(h.app.session.active(), Some(a));
|
||||
assert!(*h.app.session.develop_of(a).unwrap() == *before, "the active photo wasn't changed");
|
||||
assert!(!h.app.widgets.iter().any(|(id, _)| id == "presetApplied"), "nor marked");
|
||||
h.request("engine.execute", json!({"command": "library.select", "params": {"ids": [b.0]}}), t);
|
||||
h.settle(SETTLE);
|
||||
h.step();
|
||||
assert!(h.app.widgets.iter().any(|(id, _)| id == "presetApplied"), "the selected photo is");
|
||||
}
|
||||
|
||||
/// Presets column: resting on a preset previews it in the loupe without a history entry;
|
||||
/// thumbnails are variant renders; Create Preset includes only the checked groups.
|
||||
#[test]
|
||||
|
||||
@@ -59,11 +59,12 @@ struct AppliedByPhoto(std::collections::HashMap<lightcraft_catalog::PhotoId, (St
|
||||
impl AppliedByPhoto {
|
||||
const ID: &'static str = "preset-applied-by-photo";
|
||||
|
||||
/// Remember `preset` on the photos `preset.apply` just changed (the selection, else the active photo).
|
||||
/// Remember `preset` on the photos `preset.apply` just changed (the selection, else the active
|
||||
/// photo; an active photo outside the selection wasn't changed and isn't marked).
|
||||
fn remember(ctx: &egui::Context, session: &lightcraft_engine::Session, preset: &str) {
|
||||
let id = egui::Id::new(Self::ID);
|
||||
let mut map: Self = ctx.data(|d| d.get_temp(id)).unwrap_or_default();
|
||||
for photo in session.selection.ids.iter().copied().chain(session.active()) {
|
||||
for photo in session.selected() {
|
||||
if let Some(d) = session.develop_of(photo) {
|
||||
map.0.insert(photo, (preset.to_string(), d));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user