diff --git a/crates/engine/src/cmd/color.rs b/crates/engine/src/cmd/color.rs index 111159e7a2..3fef87a274 100644 --- a/crates/engine/src/cmd/color.rs +++ b/crates/engine/src/cmd/color.rs @@ -129,16 +129,26 @@ fn targeted(s: &mut Session, p: &Value) -> Result { } } "hue" | "sat" | "lum" => { - // the hue the colour mixer sees there (the mixer and everything after it neutralized) + // (a B&W profile, as the Color Mixer panel shows it: its B&W mix) + let bw = d.treatment == Treatment::Bw || d.profile.id == "lc.mono" || d.profile.id.starts_with("lc.bw."); + // the hue the colour mixer sees there (the mixer and everything after it neutralized); the B&W mix + // comes after the mixer, so for it the mixer's own adjustments stay let e = probe(s, c, x, y, |d| { - d.mixer = Default::default(); + if !bw { + d.mixer = Default::default(); + } + // (a B&W profile turns the render grey again: sample the source colour, with the profile's own + // adjustments before the mixer, its contrast say, and its other options kept) + if d.profile.id == "lc.mono" || d.profile.id.starts_with("lc.bw.") { + *d = lightcraft_pipeline::profiles::effective(d).into_owned(); + d.profile.id = "lc.color".into(); + } d.bw_mix = Default::default(); after_mixer_neutral(d); })?; let [_, _, h] = encoded_to_oklch(e); let w = lightcraft_pipeline::colorops::band_weights(h); let top = w.iter().cloned().fold(0.0f32, f32::max).max(1e-6); - let bw = d.treatment == Treatment::Bw || d.profile.id == "lc.mono"; label = if bw { "B&W Mix" } else { "Color Mixer" }; for (i, band) in MIXER_BANDS.iter().enumerate() { let k = (w[i] / top) as f64; diff --git a/crates/engine/src/tests/color.rs b/crates/engine/src/tests/color.rs index b9acb42a00..5727ebb2ce 100644 --- a/crates/engine/src/tests/color.rs +++ b/crates/engine/src/tests/color.rs @@ -125,7 +125,31 @@ fn targeted_adjustment_on_curve_and_mixer() { assert!(!o.is_empty() && o.keys().all(|k| k.starts_with("mixer.") && k.ends_with(".sat")), "{r}"); assert!(o.values().any(|v| v.as_f64() == Some(-30.0)), "{r}"); assert!(o.values().all(|v| v.as_f64().unwrap() < 0.0)); + let top_band = |o: &serde_json::Map| { + let (k, _) = o.iter().max_by(|a, b| a.1.as_f64().unwrap().abs().total_cmp(&b.1.as_f64().unwrap().abs())).unwrap(); + k.split('.').nth(1).unwrap().to_string() + }; + let sky_band = top_band(o); assert!(s.execute("develop.targeted", &json!({"target": "nope", "x": 0.5, "y": 0.5, "delta": 1})).is_err()); + // a B&W profile's photo: the Luminance targeted adjustment moves its B&W mix, as the panel shows + s.execute("develop.profile", &json!({"id": "lc.bw.mono-rich"})).unwrap(); + let r = s.execute("develop.targeted", &json!({"target": "lum", "x": 0.5, "y": 0.1, "delta": 10})).unwrap(); + let o = r.as_object().unwrap(); + assert!(!o.is_empty() && o.keys().all(|k| k.starts_with("bw.")), "{r}"); + // ... the band of the sky's own colour, not of the grey the profile renders + assert_eq!(top_band(o), sky_band, "{r}"); + // the B&W mix comes after the colour mixer: a mixer hue shift moves the colour the B&W mix sees there, so the + // same drag shares itself out over the bands differently + let neutral = o.clone(); + let zero: serde_json::Map = neutral.keys().map(|k| (k.clone(), json!(0))).collect(); + s.execute("develop.set", &json!({ "values": zero })).unwrap(); + let shift: serde_json::Map = + lightcraft_develop::MIXER_BANDS.iter().map(|b| (format!("mixer.{b}.hue"), json!(100))).collect(); + s.execute("develop.set", &json!({ "values": shift })).unwrap(); + let r = s.execute("develop.targeted", &json!({"target": "lum", "x": 0.5, "y": 0.1, "delta": 10})).unwrap(); + let shifted = r.as_object().unwrap(); + assert!(shifted.keys().all(|k| k.starts_with("bw.")), "{r}"); + assert_ne!(shifted, &neutral, "the mixer's hue shift is part of what the B&W mix sees"); } /// Issue #730: on a raw whose camera has measured colour matrices the white-balance commands write Kelvin, mark diff --git a/crates/ui-egui/locales/cs.json b/crates/ui-egui/locales/cs.json index 6f892b1e87..dd6addacae 100644 --- a/crates/ui-egui/locales/cs.json +++ b/crates/ui-egui/locales/cs.json @@ -2458,6 +2458,10 @@ "The photos are imported once it ends": "Fotky se naimportují potom", "An import is running. Drop photos when it has finished": "Import už běží. Fotky přetáhněte, až skončí", "Finish Lightroom catalog import before adding photos": "Dokončete import katalogu Lightroom, než přidáte fotky", + "Mixer": "Směšovač", + "HSL": "HSL", + "Adjust": "Upravit", + "Color Mixer Layout": "Rozvržení směšovače barev", "Loupe Overlay": "Překrytí lupy", "View Options…": "Možnosti zobrazení…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Zobrazení → Překrytí lupy → Možnosti zobrazení určuje, které řádky zobrazují Info 1 a Info 2.", diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json index 2445a40261..859a89422c 100644 --- a/crates/ui-egui/locales/de.json +++ b/crates/ui-egui/locales/de.json @@ -3514,6 +3514,10 @@ "The photos are imported once it ends": "Die Fotos werden danach importiert", "An import is running. Drop photos when it has finished": "Ein Import läuft. Lege die Fotos ab, wenn er fertig ist", "Finish Lightroom catalog import before adding photos": "Schließe den Import des Lightroom-Katalogs ab, bevor du Fotos hinzufügst", + "Mixer": "Mischer", + "HSL": "HSL", + "Adjust": "Anpassen", + "Color Mixer Layout": "Farbmischer-Ansicht", "View Options…": "Ansichtsoptionen…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Ansicht → Lupenüberlagerung → Ansichtsoptionen legt fest, welche Zeilen Info 1 und Info 2 zeigen.", "Camera preview": "Kameravorschau", diff --git a/crates/ui-egui/locales/es.json b/crates/ui-egui/locales/es.json index 9c651a693e..790f01e496 100644 --- a/crates/ui-egui/locales/es.json +++ b/crates/ui-egui/locales/es.json @@ -2409,6 +2409,10 @@ "The photos are imported once it ends": "Las fotos se importarán después", "An import is running. Drop photos when it has finished": "Hay una importación en curso. Suelta las fotos cuando termine", "Finish Lightroom catalog import before adding photos": "Termina la importación del catálogo de Lightroom antes de añadir fotos", + "Mixer": "Mezclador", + "HSL": "HSL", + "Adjust": "Ajustar", + "Color Mixer Layout": "Disposición del mezclador de color", "Loupe Overlay": "Superposición de la lupa", "View Options…": "Opciones de vista…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Vista → Superposición de la lupa → Opciones de vista elige las líneas que muestran Info 1 e Info 2.", diff --git a/crates/ui-egui/locales/fr.json b/crates/ui-egui/locales/fr.json index 6f7e1897a2..d95f56b654 100644 --- a/crates/ui-egui/locales/fr.json +++ b/crates/ui-egui/locales/fr.json @@ -2440,6 +2440,10 @@ "The photos are imported once a library is open": "Les photos seront importées dès qu'une bibliothèque sera ouverte", "Open a library first, then drop the presets again": "Ouvrez d'abord une bibliothèque, puis déposez à nouveau les préréglages", "This library couldn't be checked:": "Impossible de vérifier cette bibliothèque :", + "Mixer": "Mélangeur", + "HSL": "TSL", + "Adjust": "Régler", + "Color Mixer Layout": "Disposition du mélangeur de couleurs", "Camera preview": "Aperçu de l'appareil", "The camera's own JPEG, shown until LightCraft has rendered the raw. Judge colour and tone on the rendered photo.": "Le JPEG de l'appareil photo, affiché jusqu'à ce que LightCraft ait rendu le fichier RAW. Jugez la couleur et les tons sur la photo rendue.", "Profile: from the file (the camera's own correction)": "Profil : du fichier (correction de l'appareil)", diff --git a/crates/ui-egui/locales/it.json b/crates/ui-egui/locales/it.json index 38a2727488..077913039e 100644 --- a/crates/ui-egui/locales/it.json +++ b/crates/ui-egui/locales/it.json @@ -2451,6 +2451,10 @@ "The photos are imported once it ends": "Le foto verranno importate dopo", "An import is running. Drop photos when it has finished": "Un'importazione è in corso. Trascina le foto quando è finita", "Finish Lightroom catalog import before adding photos": "Termina l'importazione del catalogo Lightroom prima di aggiungere foto", + "Mixer": "Miscelatore", + "HSL": "HSL", + "Adjust": "Regola", + "Color Mixer Layout": "Disposizione del miscelatore colore", "Profile: from the file (the camera's own correction)": "Profilo: dal file (correzione della fotocamera)", "Downloading the lens database…": "Download del database degli obiettivi…", "This file names no lens.": "Questo file non indica alcun obiettivo.", diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.json index 1bcc8704cf..28a24b314e 100644 --- a/crates/ui-egui/locales/ja.json +++ b/crates/ui-egui/locales/ja.json @@ -2407,6 +2407,10 @@ "The photos are imported once it ends": "終わりしだい写真を読み込みます", "An import is running. Drop photos when it has finished": "読み込み中です。完了してから写真をドロップしてください", "Finish Lightroom catalog import before adding photos": "写真を追加する前に Lightroom カタログの読み込みを完了してください", + "Mixer": "ミキサー", + "HSL": "HSL", + "Adjust": "調整", + "Color Mixer Layout": "カラーミキサーの表示", "Loupe Overlay": "ルーペのオーバーレイ", "View Options…": "表示オプション…", "View Options": "表示オプション", diff --git a/crates/ui-egui/locales/pl.json b/crates/ui-egui/locales/pl.json index 5731fa59fb..2e2947c7f6 100644 --- a/crates/ui-egui/locales/pl.json +++ b/crates/ui-egui/locales/pl.json @@ -2333,6 +2333,10 @@ "The photos are imported once it ends": "Zdjęcia zostaną zaimportowane potem", "An import is running. Drop photos when it has finished": "Import jest w toku. Upuść zdjęcia, gdy się zakończy", "Finish Lightroom catalog import before adding photos": "Zakończ import katalogu Lightrooma, zanim dodasz zdjęcia", + "Mixer": "Mikser", + "HSL": "HSL", + "Adjust": "Dostosuj", + "Color Mixer Layout": "Układ miksera kolorów", "Loupe Overlay": "Nakładka lupy", "View Options…": "Opcje widoku…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Widok → Nakładka lupy → Opcje widoku wybiera wiersze, które pokazują Info 1 i Info 2.", diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.json index 4c02b5079b..ac54c73d5c 100644 --- a/crates/ui-egui/locales/pt-br.json +++ b/crates/ui-egui/locales/pt-br.json @@ -2253,6 +2253,10 @@ "The photos are imported once it ends": "As fotos serão importadas depois", "An import is running. Drop photos when it has finished": "Uma importação está em andamento. Solte as fotos quando ela terminar", "Finish Lightroom catalog import before adding photos": "Conclua a importação do catálogo do Lightroom antes de adicionar fotos", + "Mixer": "Misturador", + "HSL": "HSL", + "Adjust": "Ajustar", + "Color Mixer Layout": "Disposição do misturador de cores", "Loupe Overlay": "Sobreposição da lupa", "View Options…": "Opções de exibição…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Exibir → Sobreposição da lupa → Opções de exibição escolhe as linhas que Info 1 e Info 2 mostram.", diff --git a/crates/ui-egui/locales/ru.json b/crates/ui-egui/locales/ru.json index 1c38c8a668..d6078bf55d 100644 --- a/crates/ui-egui/locales/ru.json +++ b/crates/ui-egui/locales/ru.json @@ -2615,6 +2615,10 @@ "The photos are imported once it ends": "Фото будут импортированы после этого", "An import is running. Drop photos when it has finished": "Импорт уже выполняется. Перетащите фото, когда он закончится", "Finish Lightroom catalog import before adding photos": "Завершите импорт каталога Lightroom, прежде чем добавлять фото", + "Mixer": "Микшер", + "HSL": "HSL", + "Adjust": "Настройка", + "Color Mixer Layout": "Вид цветового микшера", "Loupe Overlay": "Накладка лупы", "View Options…": "Параметры вида…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Вид → Накладка лупы → Параметры вида выбирает строки, которые показывают Info 1 и Info 2.", diff --git a/crates/ui-egui/locales/uk.json b/crates/ui-egui/locales/uk.json index 0c978eeda4..c1aa856d87 100644 --- a/crates/ui-egui/locales/uk.json +++ b/crates/ui-egui/locales/uk.json @@ -2405,6 +2405,10 @@ "The photos are imported once it ends": "Фото буде імпортовано після цього", "An import is running. Drop photos when it has finished": "Імпорт уже виконується. Перетягніть фото, коли він завершиться", "Finish Lightroom catalog import before adding photos": "Завершіть імпорт каталогу Lightroom, перш ніж додавати фото", + "Mixer": "Змішувач", + "HSL": "HSL", + "Adjust": "Налаштування", + "Color Mixer Layout": "Вигляд змішувача кольорів", "Loupe Overlay": "Накладання лупи", "View Options…": "Параметри перегляду…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "Вигляд → Накладання лупи → Параметри перегляду вибирає рядки, які показують Info 1 та Info 2.", diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.json index 338995b1e4..84dd45bf5f 100644 --- a/crates/ui-egui/locales/zh-hans.json +++ b/crates/ui-egui/locales/zh-hans.json @@ -2252,6 +2252,10 @@ "The photos are imported once it ends": "结束后即导入这些照片", "An import is running. Drop photos when it has finished": "正在导入。导入完成后再拖放照片", "Finish Lightroom catalog import before adding photos": "添加照片前,请先完成 Lightroom 目录的导入", + "Mixer": "混合器", + "HSL": "HSL", + "Adjust": "调整", + "Color Mixer Layout": "颜色混合器布局", "Loupe Overlay": "放大镜叠加", "View Options…": "视图选项…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "视图 → 放大镜叠加 → 视图选项 用于选择“信息 1”和“信息 2”显示的行。", diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.json index 39f14df718..0d58778c89 100644 --- a/crates/ui-egui/locales/zh-hant.json +++ b/crates/ui-egui/locales/zh-hant.json @@ -2209,6 +2209,10 @@ "The photos are imported once it ends": "結束後即匯入這些照片", "An import is running. Drop photos when it has finished": "正在匯入。匯入完成後再拖放照片", "Finish Lightroom catalog import before adding photos": "新增照片前,請先完成 Lightroom 目錄的匯入", + "Mixer": "混合器", + "HSL": "HSL", + "Adjust": "調整", + "Color Mixer Layout": "混色器版面", "Loupe Overlay": "放大鏡疊加", "View Options…": "檢視選項…", "View → Loupe Overlay → View Options chooses the lines Info 1 and Info 2 show.": "檢視 → 放大鏡疊加 → 檢視選項 可選擇「資訊 1」和「資訊 2」顯示的行。", diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 67d972a750..6ad752e6a0 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -280,6 +280,7 @@ pub(crate) fn reveal_command(app: &mut crate::LightcraftApp, id: &str) -> Result Some(Panel::Library) } else if (id.starts_with("panel.") && id != "panel.close" && id != "panel.presets" || id == "view.rightPanel" + || id == "view.colorMixer" || id.starts_with("section.") || id.starts_with("tool.") && id != "tool.none") && app.ui.right != crate::state::RightPanel::None diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index 09b7118aa7..45200b7249 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -25,6 +25,70 @@ fn panel(app: &mut LightcraftApp, ctx: &egui::Context, p: RightPanel, name: &str let _ = app.session.end_interaction(); } +/// `view.colorMixer`: the Color Mixer's tab, Adjust mode, HSL group and Color-mode band, each +/// optional; the Edit panel opens on it. Returns the layout now shown. +fn color_mixer_layout(app: &mut LightcraftApp, p: &Value) -> Result { + use crate::panels::edit::{MIXER_ADJUST, MIXER_GROUPS, MIXER_TABS}; + let choose = |key: &str, items: &[(&str, &str)]| -> Result, String> { + match p.get(key) { + None | Some(Value::Null) => Ok(None), + Some(Value::String(v)) if items.iter().any(|(_, k)| k == v) => Ok(Some(v.clone())), + Some(other) => { + let keys: Vec<&str> = items.iter().map(|(_, k)| *k).collect(); + Err(format!("view.colorMixer: `{key}` must be one of {}, not {other}", keys.join(", "))) + } + } + }; + let bands: Vec<(&str, &str)> = lightcraft_develop::MIXER_BANDS.iter().map(|b| (*b, *b)).collect(); + let (tab, adjust, group, band) = + (choose("tab", &MIXER_TABS)?, choose("adjust", &MIXER_ADJUST)?, choose("group", &MIXER_GROUPS)?, choose("band", &bands)?); + if let Some(v) = tab { + app.ui.mixer_tab = v; + } + if let Some(v) = adjust { + app.ui.mixer_adjust = v; + } + if let Some(v) = group { + app.ui.mixer_group = v; + } + if let Some(v) = band { + app.ui.mixer_mode = v; + } + // coming from another panel puts its tool down (Masking's colour picker would keep taking the photo's clicks), + // as the panel switch does; the White Balance picker and the mixer's own tools stay + let mixer_tool = matches!(app.ui.tool.as_str(), "pointColor" | "tat:hue" | "tat:sat" | "tat:lum"); + if app.ui.right != RightPanel::Edit && app.ui.tool != "wbPicker" && !mixer_tool { + app.ui.tool.clear(); + } + crate::panels::edit::drop_hidden_mixer_tool(app); + // (a drag in Remove or Masking is finished first, so later edits aren't previews of it) + let _ = app.session.end_interaction(); + app.ui.right = RightPanel::Edit; + app.ui.view = ViewMode::Detail; + // (full-screen preview and a slideshow show only the photo: the mixer would not appear) + if app.ui.slideshow.is_some() { + crate::panels::slideshow::end(app); + } + app.ui.fullscreen = false; + if !app.ui.section_open("color") { + app.ui.toggle_section("color"); + } + // (Solo Mode closes the Light section that holds the Curve: its targeted adjustment would go on adjusting a + // curve no longer shown) + if app.ui.single_panel && app.ui.tool == "tat:curve" { + app.ui.tool.clear(); + } + if !app.ui.flyout_open("mixer") { + app.ui.toggle_flyout("mixer"); + } + // (a B&W photo shows its B&W mix, never the Point Color tab; the choice is kept for colour photos) + let bw = app.session.active().and_then(|id| app.session.develop_of(id)).is_some_and(|d| crate::is_bw(&d)); + let tab = if bw { "mixer" } else { app.ui.mixer_tab.as_str() }; + // (the band the panel shows: a value from before the bands, such as "hue", shows the first) + let band = lightcraft_develop::MIXER_BANDS.iter().copied().find(|b| *b == app.ui.mixer_mode).unwrap_or("red"); + Ok(json!({"tab": tab, "adjust": app.ui.mixer_adjust, "group": app.ui.mixer_group, "band": band})) +} + /// With the Remove panel open, choose the Remove brush unless one already is, so painting works /// straight away; another tool still on (the White Balance eyedropper) gives way. Mode ▸ None is /// for choosing in the panel itself. @@ -1092,6 +1156,7 @@ fn ui_commands_7(app: &mut LightcraftApp, ctx: &egui::Context, id: &str, p: &Val } Ok(Value::Null) } + "view.colorMixer" => color_mixer_layout(app, p), "panel.close" => { app.ui.right = RightPanel::None; app.ui.presets = false; diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 82d709b1d6..d240c41a27 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -159,6 +159,9 @@ pub const UI_COMMANDS: &[UiCommand] = &[ ("panel.activity", "History", None, "Window"), ("panel.bursts", "Bursts", None, "Window"), ("panel.close", "Close Panel", None, ""), + // the Color Mixer's layout {tab?: mixer|point, adjust?: hsl|color, group?: hue|sat|lum|all, + // band?: red…magenta}: opens it in the Edit panel (the sliders are the mixer.* controls) + ("view.colorMixer", "Color Mixer Layout", None, ""), // {solo?}: true opens just that section (⌥-click on its header); otherwise opens or closes it ("section.light", "Light", Some("Cmd+1"), "Window>Edit Sections"), ("section.color", "Color", Some("Cmd+2"), "Window>Edit Sections"), diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs index 860d916e7b..2538cdfdcf 100644 --- a/crates/ui-egui/src/panels/detail.rs +++ b/crates/ui-egui/src/panels/detail.rs @@ -1287,7 +1287,14 @@ pub(crate) fn view_overlay(app: &LightcraftApp, d: &DevelopSettings) -> lightcra return Overlay::Spots(app.ui.spots_threshold.clamp(0.0, 100.0).round() as u8); } let edit = app.ui.right == RightPanel::Edit; - if edit && app.ui.point_color_visualize && app.ui.flyout_open("pointColor") && app.ui.point_color < d.point_colors.len() { + // (a B&W photo's mixer shows its B&W mix, not Point Color) + if edit + && app.ui.point_color_visualize + && app.ui.flyout_open("mixer") + && app.ui.mixer_tab == "point" + && !crate::is_bw(d) + && app.ui.point_color < d.point_colors.len() + { return Overlay::PointColorRange(app.ui.point_color as u8); } if edit && app.ui.hdr_visualize && d.hdr.enabled { diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index 4d4dd2d1cc..c9f74d8121 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -33,7 +33,8 @@ pub(crate) use grading::{WheelGrab, WheelLock, WheelMods, wheel_pick}; pub(crate) use histogram::histogram; use histogram::soft_proofing; use lens_blur::lens_blur; -use mixer::{mixer, point_color}; +use mixer::mixer; +pub(crate) use mixer::{MIXER_ADJUST, MIXER_GROUPS, MIXER_TABS, drop_hidden_mixer_tool}; use sliders::{REL_TEMP, REL_TINT, hdr_row, header_buttons, k_to_rel, profile_menu, quick_develop, rel_to_k, reset_tip, section}; pub use sliders::{apply_slider_out, sub_title}; pub(crate) use sliders::{control, reload_preview_only}; @@ -257,15 +258,6 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { if open { mixer(app, ui, d); } - if !crate::is_bw(d) { - let open = app.ui.flyout_open("pointColor"); - if flyout_row(ui, "pointColor", crate::i18n::tr("Point Color"), Icon::Picker, open).clicked() { - app.ui.toggle_flyout("pointColor"); - } - if open { - point_color(app, ui, d); - } - } let open = app.ui.flyout_open("grading"); if flyout_row(ui, "grading", crate::i18n::tr("Color Grading"), Icon::Presets, open).clicked() { app.ui.toggle_flyout("grading"); diff --git a/crates/ui-egui/src/panels/edit/mixer.rs b/crates/ui-egui/src/panels/edit/mixer.rs index 0bddba375d..006f2dbd9b 100644 --- a/crates/ui-egui/src/panels/edit/mixer.rs +++ b/crates/ui-egui/src/panels/edit/mixer.rs @@ -1,10 +1,170 @@ use super::curve::set_tat; use super::sliders::{control, sub_title}; -use super::{BAND_COLORS, Color32, DevelopSettings, Icon, LightcraftApp, Sense, Stroke, Tokens, hex, json, paint, register, text_button, vec2}; +use super::{ + BAND_COLORS, Color32, DevelopSettings, Icon, LightcraftApp, Sense, Stroke, Tokens, apply_slider_out, controls, hex, json, paint, register, + text_button, vec2, +}; +use egui::{Align2, pos2}; // ------------------------------------------------------------------------------ colour mixer +/// The Color Mixer's tabs (Mixer | Point Color), the Mixer's Adjust choice (HSL | Color) and the +/// HSL groups (Hue | Saturation | Luminance | All), as (label, key). +pub(crate) const MIXER_TABS: [(&str, &str); 2] = [("Mixer", "mixer"), ("Point Color", "point")]; +pub(crate) const MIXER_ADJUST: [(&str, &str); 2] = [("HSL", "hsl"), ("Color", "color")]; +pub(crate) const MIXER_GROUPS: [(&str, &str); 4] = [("Hue", "hue"), ("Saturation", "sat"), ("Luminance", "lum"), ("All", "all")]; +/// The mixer bands' names, as the HSL sliders are labelled (parallel to `MIXER_BANDS`). +const BAND_NAMES: [&str; 8] = ["Red", "Orange", "Yellow", "Green", "Aqua", "Blue", "Purple", "Magenta"]; + +/// A Color Mixer targeted adjustment (`tat:hue|sat|lum`) whose button the mixer's layout no +/// longer shows is put down: a B&W photo shows Luminance's only, Point Color none, HSL only the chosen group's (all three in +/// All), Color mode all three. Dragging on the photo would otherwise change a hidden group. +pub(crate) fn drop_hidden_mixer_tool(app: &mut LightcraftApp) { + // a B&W photo's mixer is its B&W mix, with only the Luminance targeted adjustment + let bw = app.session.active().and_then(|id| app.session.develop_of(id)).is_some_and(|d| crate::is_bw(&d)); + // Point Color's picker lives on its own tab, which a B&W photo doesn't have + if app.ui.tool == "pointColor" { + if bw || app.ui.mixer_tab != "point" { + app.ui.tool.clear(); + } + return; + } + let Some(key) = app.ui.tool.strip_prefix("tat:") else { return }; + if !matches!(key, "hue" | "sat" | "lum") { + return; + } + let shown = if bw { + key == "lum" + } else { + app.ui.mixer_tab != "point" && (app.ui.mixer_adjust == "color" || app.ui.mixer_group == "all" || app.ui.mixer_group == key) + }; + if !shown { + app.ui.tool.clear(); + } +} + +/// The Color Mixer, laid out as in Lightroom Classic: "Mixer | Point Color" tabs; the Mixer +/// adjusts by HSL (Hue | Saturation | Luminance | All: eight colour sliders per group, each group +/// with its targeted adjustment) or by Color (one colour at a time). The same develop controls +/// (`mixer..`) either way; a B&W photo shows its B&W mix. pub(super) fn mixer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) { + // (the B&W mix keeps its own Luminance targeted adjustment; a picker it doesn't show is put down first) + if crate::is_bw(d) { + drop_hidden_mixer_tool(app); + mixer_by_color(app, ui, d); + return; + } + let pick = |ui: &mut egui::Ui, id: &str, items: &[(&str, &str)], current: &str| { + let at = items.iter().position(|(_, k)| *k == current).unwrap_or(0); + egui::Frame::NONE + .inner_margin(egui::Margin { left: 24, right: 22, top: 6, bottom: 2 }) + .show(ui, |ui| crate::widgets::segmented(ui, id, items, Some(at), items.len())) + .inner + .and_then(|i| items.get(i).map(|(_, k)| k.to_string())) + }; + if let Some(k) = pick(ui, "mixerTab", &MIXER_TABS, &app.ui.mixer_tab) { + app.ui.mixer_tab = k; + } + drop_hidden_mixer_tool(app); + if app.ui.mixer_tab == "point" { + point_color(app, ui, d); + return; + } + let t = Tokens::get(ui.ctx()); + egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 4, bottom: 0 }).show(ui, |ui| { + ui.label(egui::RichText::new(crate::i18n::tr("Adjust")).color(t.text_dim).size(11.5)); + }); + if let Some(k) = pick(ui, "mixerAdjust", &MIXER_ADJUST, &app.ui.mixer_adjust) { + app.ui.mixer_adjust = k; + drop_hidden_mixer_tool(app); + } + if app.ui.mixer_adjust == "color" { + mixer_by_color(app, ui, d); + return; + } + // HSL: Hue | Saturation | Luminance | All + egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 6, bottom: 2 }).show(ui, |ui| { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 14.0; + for (label, key) in MIXER_GROUPS { + if group_tab(ui, &format!("mixerGroup-{key}"), crate::i18n::tr(label), app.ui.mixer_group == key).clicked() { + app.ui.mixer_group = key.to_string(); + drop_hidden_mixer_tool(app); + } + } + }); + }); + let groups: &[(&str, &str)] = match app.ui.mixer_group.as_str() { + "sat" => &MIXER_GROUPS[1..2], + "lum" => &MIXER_GROUPS[2..3], + "all" => &MIXER_GROUPS[..3], + _ => &MIXER_GROUPS[..1], + }; + let all = groups.len() > 1; + for (label, key) in groups { + // the group's targeted adjustment (and, in All, its heading) + egui::Frame::NONE.inner_margin(egui::Margin { left: 20, right: 22, top: if all { 8 } else { 2 }, bottom: 0 }).show(ui, |ui| { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 6.0; + let tool = format!("tat:{key}"); + let active = app.ui.tool == tool; + let button = crate::widgets::icon_button( + ui, + &format!("tatMixer-{key}"), + Icon::Target, + vec2(24.0, 24.0), + active, + true, + "Targeted adjustment: drag up/down on the photo to adjust the colours there", + ); + // (named by its group for a screen reader: All shows three of them) + crate::widgets::announce_selected( + &button, + format!("{} ({})", crate::i18n::tr("Targeted Adjustment"), crate::i18n::tr(label)), + active, + ); + if button.clicked() { + set_tat(app, ui.ctx(), &tool, active); + } + if all { + let r = ui.label(egui::RichText::new(crate::i18n::tr(label)).color(t.text).strong().size(12.0)); + register(ui, format!("mixerHeading:{key}"), r.rect); + } + }); + }); + for (band, name) in lightcraft_develop::MIXER_BANDS.iter().zip(BAND_NAMES) { + let id = format!("mixer.{band}.{key}"); + let Some(spec) = controls::find(&id) else { continue }; + // labelled by the colour alone: the group says what it adjusts (a screen reader hears both) + let v = controls::get(d, &id).unwrap_or(spec.default); + // (both parts translated; the brackets read the same in every language the app has) + let spoken = format!("{} ({})", crate::i18n::tr(name), crate::i18n::tr(label)); + let out = crate::widgets::slider_named(ui, spec, v, true, Some(name), Some(&spoken)); + apply_slider_out(app, spec, out, |app, v| app.run("develop.set", json!({"control": id, "value": v}))); + } + } +} + +/// A word tab (Hue, Saturation…): bright and underlined when it is the one shown. +fn group_tab(ui: &mut egui::Ui, id: &str, label: &str, active: bool) -> egui::Response { + let t = Tokens::get(ui.ctx()); + let font = t.semibold(11.5); + let (r, resp) = { + let galley = ui.painter().layout_no_wrap(label.to_string(), font.clone(), t.text); + ui.allocate_exact_size(vec2(galley.size().x, 20.0), Sense::click()) + }; + crate::widgets::announce_selected(&resp, label.to_string(), active); + register(ui, format!("button:{id}"), r); + let colour = if active || resp.hovered() { t.text } else { t.text_dim }; + ui.painter().text(pos2(r.left(), r.center().y), Align2::LEFT_CENTER, label, font, colour); + if active { + ui.painter().line_segment([pos2(r.left(), r.bottom() - 1.0), pos2(r.right(), r.bottom() - 1.0)], Stroke::new(1.5, t.text)); + } + resp +} + +/// The Mixer by colour (and a B&W photo's mix): a dot per colour, then that colour's sliders. +fn mixer_by_color(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) { let t = Tokens::get(ui.ctx()); let bands = lightcraft_develop::MIXER_BANDS; let sel = bands.iter().position(|b| *b == app.ui.mixer_mode).unwrap_or(0); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 41ad3fc6c2..adb13e2d64 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -272,8 +272,15 @@ pub struct UiState { pub dragging_section: Option, /// Selected curve channel in the Curve flyout. pub curve_channel: String, - /// Selected mixer mode: "hue" | "saturation" | "luminance" | "all". + /// The colour band shown in the Color Mixer's Color mode (one of `MIXER_BANDS`). pub mixer_mode: String, + /// The Color Mixer's tab: "mixer" | "point" (Point Color). Remembered. + pub mixer_tab: String, + /// What the Mixer adjusts by: "hsl" (eight sliders per Hue / Saturation / Luminance) | + /// "color" (one colour at a time). Remembered; HSL by default. + pub mixer_adjust: String, + /// The HSL group shown: "hue" | "sat" | "lum" | "all". Remembered. + pub mixer_group: String, /// Selected colour grading tab: "3way" | "shadows" | "midtones" | "highlights". pub grading_mode: String, /// Colour grading wheels (shadows, midtones, highlights) hidden for viewing by their eye, and @@ -624,7 +631,10 @@ impl Default for UiState { dragging_album: None, dragging_section: None, curve_channel: "parametric".into(), - mixer_mode: "hue".into(), + mixer_mode: "red".into(), + mixer_tab: "mixer".into(), + mixer_adjust: "hsl".into(), + mixer_group: "hue".into(), grading_mode: "3way".into(), grading_hidden: None, tool: String::new(), diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 6988c7f437..67d8283b88 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -26,6 +26,7 @@ mod canvas_pan; mod capture_time; mod carried_right_click; mod carried_text_field_menu; +mod color_mixer; mod compare; mod copy_paste_dialogs; mod crop_rotate; diff --git a/crates/ui-egui/src/tests/color_mixer.rs b/crates/ui-egui/src/tests/color_mixer.rs new file mode 100644 index 0000000000..132745ccc8 --- /dev/null +++ b/crates/ui-egui/src/tests/color_mixer.rs @@ -0,0 +1,293 @@ +//! The Color Mixer laid out as in Lightroom Classic (item 13 of the evening retest): "Mixer | +//! Point Color" tabs, Adjust HSL / Color, and in HSL the Hue | Saturation | Luminance | All groups +//! of eight colour sliders, each with its targeted adjustment. HSL is the default and the choice +//! is remembered; the sliders are the same `mixer.*` controls. + +use std::time::Duration; + +use serde_json::json; + +use crate::headless::Headless; +use crate::{LightcraftApp, Services}; + +const T: Duration = Duration::from_secs(20); +const SETTLE: Duration = Duration::from_secs(120); +const BANDS: [&str; 8] = ["red", "orange", "yellow", "green", "aqua", "blue", "purple", "magenta"]; + +fn mixer() -> Headless { + let services = Services { png: None, ..Default::default() }; + let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), services); + let mut h = Headless::new(app, [1300.0, 2600.0], 1.0); + let r = h.request("ui.set", json!({"view": "detail", "right": "edit"}), T); + assert_eq!(r["ok"], true, "{r}"); + run(&mut h, "view.colorMixer", json!({})); + h.settle(SETTLE); + h +} + +fn run(h: &mut Headless, command: &str, params: serde_json::Value) -> serde_json::Value { + let r = h.request("engine.execute", json!({"command": command, "params": params}), T); + assert_eq!(r["ok"], true, "{command}: {r}"); + h.step(); + h.step(); + r["result"].clone() +} + +fn click(h: &mut Headless, id: &str) { + let r = h.request("ui.clickWidget", json!({"id": id}), T); + assert_eq!(r["ok"], true, "{id}: {r}"); + h.step(); + h.step(); +} + +fn has(h: &Headless, id: &str) -> bool { + h.app.widgets.iter().any(|(w, _)| w == id) +} + +fn sliders(h: &Headless, part: &str) -> usize { + BANDS.iter().filter(|b| has(h, &format!("slider:mixer.{b}.{part}"))).count() +} + +#[test] +fn hsl_is_the_default_with_eight_sliders_per_group() { + let mut h = mixer(); + for id in ["button:mixerTab-mixer", "button:mixerTab-point", "button:mixerAdjust-hsl", "button:mixerAdjust-color"] { + assert!(has(&h, id), "{id}"); + } + for g in ["hue", "sat", "lum", "all"] { + assert!(has(&h, &format!("button:mixerGroup-{g}")), "{g}"); + } + assert_eq!((h.app.ui.mixer_adjust.as_str(), h.app.ui.mixer_group.as_str()), ("hsl", "hue"), "HSL, Hue first"); + assert_eq!((sliders(&h, "hue"), sliders(&h, "sat"), sliders(&h, "lum")), (8, 0, 0), "eight Hue sliders"); + assert!(has(&h, "icon:tatMixer-hue"), "with its targeted adjustment"); + click(&mut h, "button:mixerGroup-sat"); + assert_eq!((sliders(&h, "hue"), sliders(&h, "sat"), sliders(&h, "lum")), (0, 8, 0)); + assert!(has(&h, "icon:tatMixer-sat")); + click(&mut h, "button:mixerGroup-lum"); + assert_eq!((sliders(&h, "hue"), sliders(&h, "sat"), sliders(&h, "lum")), (0, 0, 8)); + // All: the three groups stacked, each with a heading and its targeted adjustment + click(&mut h, "button:mixerGroup-all"); + assert_eq!((sliders(&h, "hue"), sliders(&h, "sat"), sliders(&h, "lum")), (8, 8, 8)); + let at = |h: &Headless, id: &str| h.app.widgets.iter().find(|(w, _)| w == id).map(|(_, r)| r.top()).unwrap_or_else(|| panic!("no {id}")); + for g in ["hue", "sat", "lum"] { + assert!(has(&h, &format!("mixerHeading:{g}")) && has(&h, &format!("icon:tatMixer-{g}")), "{g}"); + } + assert!(at(&h, "mixerHeading:hue") < at(&h, "slider:mixer.red.hue")); + assert!(at(&h, "slider:mixer.magenta.hue") < at(&h, "mixerHeading:sat")); + assert!(at(&h, "slider:mixer.magenta.sat") < at(&h, "mixerHeading:lum")); + // a group's targeted adjustment arms its tool + click(&mut h, "icon:tatMixer-sat"); + assert_eq!(h.app.ui.tool, "tat:sat"); +} + +#[test] +fn the_sliders_are_the_mixer_controls() { + let mut h = mixer(); + run(&mut h, "develop.set", json!({"control": "mixer.orange.hue", "value": -30})); + let id = h.app.session.active().expect("a photo"); + assert_eq!(h.app.session.develop_of(id).expect("settings").mixer.orange.hue, -30.0); + // the same value in Color mode, Orange + run(&mut h, "view.colorMixer", json!({"adjust": "color", "band": "orange"})); + h.settle(SETTLE); + assert!(has(&h, "mixerBand:orange"), "the colour dots"); + assert_eq!((sliders(&h, "hue"), sliders(&h, "sat"), sliders(&h, "lum")), (1, 1, 1), "one colour's three sliders"); + assert!(has(&h, "slider:mixer.orange.hue")); +} + +#[test] +fn the_choice_is_remembered_and_point_color_is_a_tab() { + let mut h = mixer(); + click(&mut h, "button:mixerAdjust-color"); + assert_eq!(h.app.ui.mixer_adjust, "color"); + assert!(has(&h, "mixerBand:red")); + // kept with the UI settings (a restart) + let saved = serde_json::to_value(&h.app.ui).expect("ui state"); + let back: crate::UiState = serde_json::from_value(saved).expect("reads back"); + assert_eq!(back.mixer_adjust, "color"); + // older settings without it start in HSL + let old: crate::UiState = serde_json::from_value(json!({})).expect("defaults"); + assert_eq!((old.mixer_tab.as_str(), old.mixer_adjust.as_str(), old.mixer_group.as_str()), ("mixer", "hsl", "hue")); + // Point Color is the second tab + click(&mut h, "button:mixerTab-point"); + assert!(has(&h, "icon:pointColorPicker"), "Point Color's eyedropper"); + assert_eq!(sliders(&h, "hue") + sliders(&h, "sat") + sliders(&h, "lum"), 0); + // the command checks what it is given + let r = h.request("engine.execute", json!({"command": "view.colorMixer", "params": {"group": "chroma"}}), T); + assert_eq!(r["ok"], false, "{r}"); +} + +/// A Color Mixer targeted adjustment whose button the layout no longer shows is put down (it would +/// change a hidden group); the command leaves full-screen preview, where the mixer can't be seen. +#[test] +fn a_hidden_groups_targeted_adjustment_is_put_down_and_the_command_shows_the_mixer() { + let mut h = mixer(); + click(&mut h, "icon:tatMixer-hue"); + assert_eq!(h.app.ui.tool, "tat:hue"); + click(&mut h, "button:mixerGroup-all"); + assert_eq!(h.app.ui.tool, "tat:hue", "All shows the Hue group's button too"); + click(&mut h, "button:mixerGroup-sat"); + assert_eq!(h.app.ui.tool, "", "Saturation hides Hue's"); + click(&mut h, "icon:tatMixer-sat"); + run(&mut h, "view.colorMixer", json!({"adjust": "color"})); + assert_eq!(h.app.ui.tool, "tat:sat", "Color mode shows all three"); + run(&mut h, "view.colorMixer", json!({"tab": "point"})); + assert_eq!(h.app.ui.tool, "", "Point Color shows none"); + h.app.ui.fullscreen = true; + run(&mut h, "view.colorMixer", json!({"tab": "mixer"})); + assert!(!h.app.ui.fullscreen); +} + +/// A B&W photo's mixer shows its B&W mix: Point Color's range view can't stay on the photo. +#[test] +fn point_colors_range_view_is_off_for_a_bw_photo() { + let mut h = mixer(); + run(&mut h, "view.colorMixer", json!({"tab": "point"})); + h.app.ui.point_color_visualize = true; + h.app.ui.point_color = 0; + let id = h.app.session.active().expect("a photo"); + let mut d = (*h.app.session.develop_of(id).expect("settings")).clone(); + d.point_colors.push(Default::default()); + assert!(matches!(crate::panels::detail::view_overlay(&h.app, &d), lightcraft_pipeline::Overlay::PointColorRange(0))); + d.treatment = lightcraft_develop::Treatment::Bw; + assert!(!matches!(crate::panels::detail::view_overlay(&h.app, &d), lightcraft_pipeline::Overlay::PointColorRange(_))); +} + +/// A B&W photo's mixer always shows its Luminance targeted adjustment: the command keeps it. +#[test] +fn a_bw_photos_luminance_targeted_adjustment_stays() { + let mut h = mixer(); + run(&mut h, "develop.treatment", json!({"bw": true})); + h.app.ui.tool = "tat:lum".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, "tat:lum"); + h.app.ui.tool = "tat:hue".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, "", "no Hue on a B&W photo"); +} + +/// Point Color's picker is put down when its tab is left, so a click on the photo picks no colour. +#[test] +fn point_colors_picker_is_put_down_when_its_tab_is_left() { + let mut h = mixer(); + run(&mut h, "view.colorMixer", json!({"tab": "point"})); + h.app.ui.tool = "pointColor".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, "pointColor", "still on its tab"); + run(&mut h, "view.colorMixer", json!({"tab": "mixer"})); + assert_eq!(h.app.ui.tool, "", "the Mixer tab puts it down"); +} + +/// On a B&W photo the command says the layout shown, its B&W mix, not Point Color: the choice of +/// tab is kept for colour photos. +#[test] +fn a_bw_photo_reports_the_mixer_it_shows() { + let mut h = mixer(); + run(&mut h, "develop.treatment", json!({"bw": true})); + let r = run(&mut h, "view.colorMixer", json!({"tab": "point"})); + assert_eq!(r["tab"], "mixer", "{r}"); + assert_eq!(h.app.ui.mixer_tab, "point", "kept for colour photos"); +} + +/// Opening the Color Mixer from Masking puts the Masking colour picker down, so a click on the photo is the Edit +/// panel's again, not a colour sample for a mask. +#[test] +fn the_color_mixer_command_puts_down_the_masking_picker() { + let mut h = mixer(); + let r = h.request("ui.set", json!({"right": "masking"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.app.ui.tool = "colorRange".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, "", "the Masking picker is put down"); + // the White Balance picker is the Edit panel's own, and stays + let r = h.request("ui.set", json!({"right": "masking"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.app.ui.tool = "wbPicker".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, "wbPicker"); +} + +/// A photo turned B&W while Point Color's picker is out puts the picker down when the panel next shows its B&W +/// mix, so a click on the photo picks no colour. +#[test] +fn point_colors_picker_is_put_down_when_the_photo_turns_bw() { + let mut h = mixer(); + run(&mut h, "view.colorMixer", json!({"tab": "point"})); + h.app.ui.tool = "pointColor".into(); + run(&mut h, "develop.treatment", json!({"bw": true})); + h.settle(SETTLE); + assert_eq!(h.app.ui.tool, "", "no Point Color on a B&W photo"); +} + +/// Another panel's targeted adjustment (Curve's) is put down too when the Color Mixer opens from Masking: only the +/// mixer's own tools stay. +#[test] +fn the_color_mixer_command_puts_down_the_curves_targeted_adjustment() { + let mut h = mixer(); + let r = h.request("ui.set", json!({"right": "masking"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.app.ui.tool = "tat:curve".into(); + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.tool, ""); +} + +/// The band the command reports is the one the panel shows: a remembered value from before the bands ("hue") +/// shows Red, and the reply can be fed back. +#[test] +fn the_color_mixer_reports_the_band_it_shows() { + let mut h = mixer(); + h.app.ui.mixer_mode = "hue".into(); + let r = run(&mut h, "view.colorMixer", json!({})); + assert_eq!(r["band"], "red", "{r}"); + run(&mut h, "view.colorMixer", json!({"band": r["band"]})); +} + +/// Each HSL slider sets its own band's own adjustment: a drag on a representative band of each group moves that +/// control and no other. +#[test] +fn an_hsl_slider_drag_sets_its_bands_control() { + let mut h = mixer(); + run(&mut h, "view.colorMixer", json!({"adjust": "hsl", "group": "all"})); + h.settle(SETTLE); + let mut moved: Vec = Vec::new(); + for (band, part) in [("red", "hue"), ("blue", "sat"), ("green", "lum")] { + let ctl = format!("mixer.{band}.{part}"); + let r = h.request("ui.dragWidget", json!({"id": format!("slider:{ctl}"), "fx": 0.5, "fy": 0.5, "dx": 40.0, "dy": 0.0, "steps": 8}), T); + assert_eq!(r["ok"], true, "{ctl}: {r}"); + h.settle(SETTLE); + moved.push(ctl.clone()); + let id = h.app.session.active().expect("a photo"); + let d = h.app.session.develop_of(id).expect("settings"); + for b in BANDS { + for p in ["hue", "sat", "lum"] { + let other = format!("mixer.{b}.{p}"); + let v = lightcraft_develop::controls::get(&d, &other).unwrap_or(0.0); + if moved.contains(&other) { + assert!(v > 0.0, "{other} moves with its own slider: {v}"); + } else { + assert_eq!(v, 0.0, "{other} stays when {ctl} is dragged"); + } + } + } + } +} + +/// In Solo Mode the Color Mixer command closes the Light section and its Curve, so the Curve's targeted adjustment +/// is put down; without Solo Mode the Curve stays on screen and keeps it. +#[test] +fn solo_mode_puts_down_the_curves_targeted_adjustment() { + let mut h = mixer(); + // (the Curve on screen: Light open with its Curve flyout, its targeted adjustment picked up) + if !h.app.ui.flyout_open("curve") { + h.app.ui.toggle_flyout("curve"); + } + h.app.ui.tool = "tat:curve".into(); + run(&mut h, "view.colorMixer", json!({})); + assert!(h.app.ui.section_open("light") && h.app.ui.flyout_open("curve"), "the Curve is still shown"); + assert_eq!(h.app.ui.tool, "tat:curve", "and keeps its targeted adjustment"); + // Solo Mode from Light alone: the command opens Color and closes Light + h.app.ui.single_panel = true; + h.app.ui.open_sections = vec!["light".into()]; + run(&mut h, "view.colorMixer", json!({})); + assert_eq!(h.app.ui.open_sections, ["color"], "Solo Mode closes Light"); + assert_eq!(h.app.ui.tool, "", "Solo Mode hides the Curve"); +} diff --git a/crates/ui-egui/src/tests/docking_acceptance.rs b/crates/ui-egui/src/tests/docking_acceptance.rs index 266bd75bfd..bac894b96b 100644 --- a/crates/ui-egui/src/tests/docking_acceptance.rs +++ b/crates/ui-egui/src/tests/docking_acceptance.rs @@ -68,6 +68,16 @@ fn window_menu_reopens_closed_panels_in_their_dock_columns() { assert_eq!(crate::docking::columns(h.app.ui.docking.as_ref().unwrap(), Side::Start), [(width, vec![vec![Panel::Library]])]); } +#[test] +fn the_color_mixer_command_brings_tools_forward() { + let mut h = app(); + dock(&mut h, json!({"operation":"move","panel":"tools","target":"library","zone":"center"})); + dock(&mut h, json!({"operation":"activate","panel":"library"})); + assert!(!crate::docking::exposed_in(h.app.ui.docking.as_ref().unwrap(), Panel::Tools)); + h.app.run("view.colorMixer", json!({})).unwrap(); + assert!(crate::docking::exposed_in(h.app.ui.docking.as_ref().unwrap(), Panel::Tools), "the mixer is shown, not left behind Library"); +} + #[test] fn inactive_same_mode_commands_reveal_without_closing_or_editing() { let mut h = app(); diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index 1a6b022915..d785211d34 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -419,6 +419,12 @@ const THUMB_RING: f32 = 7.0; /// Esc keeps the old one. Drag the value sideways to scrub it, as if dragging the thumb (Shift: a tenth /// as far). pub fn slider(ui: &mut Ui, spec: &ControlSpec, value: f64, enabled: bool, label_override: Option<&str>) -> SliderOut { + slider_named(ui, spec, value, enabled, label_override, None) +} + +/// [`slider`] that a screen reader calls `spoken` (already translated) rather than by its short drawn label: the +/// Color Mixer's All view draws "Red" three times, once per group, and says "Red (Hue)", "Red (Saturation)"… +pub fn slider_named(ui: &mut Ui, spec: &ControlSpec, value: f64, enabled: bool, label_override: Option<&str>, spoken: Option<&str>) -> SliderOut { let t = Tokens::get(ui.ctx()); let w = ui.available_width(); let (row, _) = ui.allocate_exact_size(vec2(w, t.slider_row_h), Sense::hover()); @@ -432,7 +438,7 @@ pub fn slider(ui: &mut Ui, spec: &ControlSpec, value: f64, enabled: bool, label_ let resp = ui.interact(track_rect.expand2(vec2(8.0, 2.0)), id, if enabled { Sense::click_and_drag() } else { Sense::hover() }); let (wheel_armed, pointer_in_row) = update_wheel_arming(ui, id, &resp, row, enabled); // screen readers: a slider named after its control, with its value - let label_text = crate::i18n::tr(label_override.unwrap_or(spec.label)).to_string(); + let label_text = spoken.map_or_else(|| crate::i18n::tr(label_override.unwrap_or(spec.label)).to_string(), str::to_string); resp.widget_info(|| egui::WidgetInfo::slider(enabled, value, label_text.clone())); describe_slider(ui, &g, &resp); // the name: double-click it to reset, as the thumb (a disabled slider's name is only text) diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 2fca3c23a1..b48837b6c0 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -201,7 +201,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-EDIT-COLOR-TINT | Tint | P0 | ✅ | `ctl:wb.tint`, `docs/tint-direction.md` | DNG / Lightroom sign: negative (left) adds green, positive (right) magenta; XMP `crs:Tint` values render as in Lightroom (issue #188); CPU/GPU regression tests | | LR-EDIT-COLOR-VIBRANCE | Vibrance | P0 | ✅ | `ctl:color.vibrance` | | | LR-EDIT-COLOR-SATURATION | Saturation | P0 | ✅ | `ctl:color.saturation` | | -| LR-EDIT-COLOR-MIXER-HSL | 8-band colour mixer | P0 | ✅ | `ctl:mixer.*` | no targeted (drag-on-image) mode | +| LR-EDIT-COLOR-MIXER-HSL | 8-band colour mixer | P0 | ✅ | `ctl:mixer.*`, `cmd:view.colorMixer`, `crates/ui-egui/src/panels/edit/mixer.rs` (`mixer`), `crates/ui-egui/src/tests/color_mixer.rs` | Lightroom Classic's layout: Mixer \| Point Color tabs, then Adjust HSL / Color; HSL shows Hue \| Saturation \| Luminance \| All (the three stacked with headings), eight sliders per group with coloured tracks and a targeted adjustment per group; Color shows one colour at a time; HSL by default, remembered | | LR-EDIT-COLOR-MIXER-BW | B&W mix | P1 | ✅ | `ctl:bw.*`, `cmd:develop.autoBwMix` | eight bands; Auto pushes each hue band's colourful pixels away from the mean lightness (own rule) | | LR-EDIT-COLOR-POINTCOLOR | Point colour | P1 | ✅ | `cmd:pointColor.pick`, `cmd:pointColor.delete` | | | LR-EDIT-COLOR-GRADING | Colour grading wheels | P0 | ✅ | `ctl:grading.*`, `crates/ui-egui/src/panels/edit.rs` (`grading`) | 3-Way / Shadows / Midtones / Highlights tabs; a range tab shows one large wheel with Hue, Saturation and Luminance sliders; Blending and Balance in every tab; 3-Way shows the hovered wheel's hue and saturation; every wheel marks its neutral centre; wheel modifiers as in Lightroom: Shift-drag keeps the puck's hue and changes saturation only (the spoke is the guide; a puck at the centre has no hue, so it takes the angle where the pointer pressed), Cmd/Ctrl-drag keeps the saturation and changes hue only (the circle is the guide), Alt/Option-drag fine-adjusts at 0.1x and combines with either lock, and a hover tooltip lists them (issues #559, #1160; tests `shift_dragging_across_the_tangent_keeps_the_hue_and_moves_saturation`, `shift_drag_keeps_the_pucks_hue_wherever_the_pointer_grabs`, `cmd_drag_keeps_the_saturation_and_changes_only_the_hue`, `alt_drag_fine_adjusts_to_a_tenth_of_the_pointers_travel`, `alt_works_with_shift_and_cmd_constraints` in `crates/ui-egui/src/tests/grading.rs`); a wheel drag holds the pointer as in Lightroom: hidden while dragging (the puck follows the mouse's travel; on macOS the pointer is locked in place), back where the button went down on release, and given back at once on Esc, a lost window focus or a wheel that goes away mid-drag; the browser can't move the pointer, so there it only shows again where the drag ended (issue #1899; tests `a_held_wheel_follows_the_mouses_motion_not_where_the_pointer_sits`, `a_wheel_drag_hides_the_pointer_and_releasing_puts_it_back_where_it_was_pressed`, `escape_or_losing_focus_gives_the_pointer_back_mid_drag`, `a_wheel_that_goes_away_mid_drag_gives_the_pointer_back`); the large wheel adds 25/50/75 % saturation rings (issue #559); each wheel's eye hides its effect for viewing only (`RenderJob::with_hidden_grading`, not saved, export unaffected) (issue #737). No Global wheel tab yet; from process V13 the Global wheel tints at 0.45 of the other wheels at the same saturation, measured against Lightroom exports (`colorops::global_wheel`) | @@ -834,6 +834,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 2026-10-25 | minor | LR-BEHAV-WINDOW (new row, 🟡): on Windows a window remembered maximized is built at its size and maximized once it shows (built maximized it could cover half the screen while Windows took it for maximized), and restored and maximized again once if it only says so; a window remembered larger than the screen it opens on is fitted to it, on every platform | | 2026-10-31 | patch | LR-MASK-OVERLAY: the pointer on a mask's own row (name, eye, menu) shows no overlay, so its eye judges the effect; a component row under it shows the whole mask's overlay; status unchanged (✅) | | 2026-10-25 | minor | LR-MASK-OVERLAY: one overlay rule (O / the eye, or the pointer on the mask's row or pin while nothing is adjusted, or a mask without settings yet); a mask with settings never shows by itself, so picking, creating, duplicating or adding to one no longer shows the overlay (#1800's re-show replaced, its test changed to the rule); sliders, mask drags and brush strokes hide it and the mask's lines and pins while at work; no stand-in overlay while an AI selection is computed; status unchanged (✅) | +| 2026-10-25 | minor | LR-EDIT-COLOR-MIXER-HSL: Lightroom Classic's layout (Mixer \| Point Color tabs, Adjust HSL / Color, Hue \| Saturation \| Luminance \| All with a targeted adjustment per group), `view.colorMixer`; status unchanged (✅) | | 2026-10-30 | patch | LR-BEHAV-ACCESS: the Flatpak manifests grant `--talk-name=org.a11y.Bus`, so AccessKit can find out whether a screen reader is running and publish the window inside the sandbox; packaging lint requires it in both manifests; status unchanged (🟡), not tried with Orca | | 2026-10-27 | patch | LR-LIB-LABEL, MENU-PHOTO-LABEL, KEY-LABELS: Clear Color Label (`photo.clearLabel`) is a command of its own, so Help → Keyboard Shortcuts can give it a key (#2980); the Photo ▸ Set Color Label ▸ None row runs it; status unchanged | | 2026-10-25 | minor | KEYC-METADATA, LRC-LIB-KEYWORDS: ⌘⌥⇧K / Ctrl+Alt+Shift+K (`dialog.keywordShortcut`, Set Keyword Shortcut) and ⇧K (`keyword.toggleShortcut`) add and remove the keyword shortcut's keywords; Keyword Shortcut leaves LRC-LIB-KEYWORDS' Not yet list; status counts unchanged (KEYC-METADATA stays 🟡) | diff --git a/docs/whats-new.md b/docs/whats-new.md index 44f9b4f1cc..214a42d52e 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -477,6 +477,12 @@ During a mask drag or a brush stroke, hovering shows no overlay; an overlay switched on with O, or a mask without settings, keeps showing what it selects. While an Object click or a description is still being computed, no stand-in overlay shows. +### Color Mixer: HSL +- **Color Mixer: HSL**, laid out as in Lightroom Classic: **Mixer | Point Color** tabs, then + **Adjust: HSL / Color**. HSL shows **Hue, Saturation, Luminance** or **All** (the three stacked, + each with its heading): eight colour sliders each, with coloured tracks, and a targeted + adjustment per group. HSL is the default and your choice is remembered. Point Color is now the + Color Mixer's second tab. ### Import rename numbering stops safely at its limit - Copy and Move imports can use the last representable rename number once. If more renamed files remain, each is reported as failed with guidance to lower `renameStart` or leave `rename` blank; completed transfers stay