PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Hue/Saturation: hue-following colour tracks on the Saturation and Lightness sliders (#1863)
Reynold Hua14e94617b92
diff --git a/crates/ui-egui/src/adjust_editors.rs b/crates/ui-egui/src/adjust_editors.rsindex e444c10ba..e202cef31 100644--- a/crates/ui-egui/src/adjust_editors.rs+++ b/crates/ui-egui/src/adjust_editors.rs@@ -695,6 +695,16 @@ fn hue_color(deg: f32) -> Color32 {Color32::from_rgb(rgb[0], rgb[1], rgb[2])}+/// The Saturation slider's track: grey to the hue at full saturation (UI-217-16).+fn saturation_track(hue_deg: f32) -> [Color32; 2] {+ [Color32::from_gray(128), hue_color(hue_deg)]+}++/// The Lightness slider's track: black, the hue, white (UI-217-16).+fn lightness_track(hue_deg: f32) -> [Color32; 3] {+ [Color32::BLACK, hue_color(hue_deg), Color32::WHITE]+}+fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f32; 4] {let mut b = HueRange::canonical_bounds(bounds);if k >= b.len() {@@ -758,13 +768,21 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {v["hue"] = json!(h.round());}e.add(Edit::of(&r));+ // The Saturation and Lightness tracks follow the current hue, as in Photoshop (UI-217-16).+ let sat_track = saturation_track(h);let mut s = num(v, "saturation", 0.0).clamp(slo, 100.0);- let r = widgets::slider_row(ui, tl!("Saturation"), &mut s, slo..=100.0, "%", None);+ let r = widgets::slider_row(ui, tl!("Saturation"), &mut s, slo..=100.0, "%", Some(&sat_track));if r.changed() {v["saturation"] = json!(s.round());}e.add(Edit::of(&r));- e.add(sliders(ui, v, &[("lightness", tl!("Lightness"), -100.0, 100.0, 0.0, "%")]));+ let light_track = lightness_track(h);+ let mut l = num(v, "lightness", 0.0).clamp(-100.0, 100.0);+ let r = widgets::slider_row(ui, tl!("Lightness"), &mut l, -100.0..=100.0, "%", Some(&light_track));+ if r.changed() {+ v["lightness"] = json!(l.round());+ }+ e.add(Edit::of(&r));} else {let key = HUE_RANGES[range - 1];if !v.get(key).is_some_and(Value::is_object) {@@ -1361,6 +1379,15 @@ pub fn layer_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: LayerId, adjmod tests {use super::*;+ #[test]+ fn saturation_and_lightness_tracks_follow_the_hue() {+ // The S/L slider tracks recolour with the hue (UI-217-16).+ assert_eq!(saturation_track(0.0), [Color32::from_gray(128), hue_color(0.0)]);+ assert_ne!(saturation_track(0.0)[1], saturation_track(120.0)[1]);+ assert_eq!(saturation_track(720.0)[1], saturation_track(0.0)[1], "hue wraps");+ assert_eq!(lightness_track(200.0), [Color32::BLACK, hue_color(200.0), Color32::WHITE]);+ }+#[test]fn hue_range_drag_canonicalizes_bounds_before_clamping() {let moved = move_hue_range_handle([0.0, 350.0, 100.0, 200.0], 2, 354.0);diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 50c95c23b..fad36ff96 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [Performance](#performance) | 3 | 22 | 13 | 47 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 6 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 12 | 14 | 8 | |-| [Workspace and UI](#workspace-and-ui) | 1 | 7 | 15 | settings that do nothing: 55 of 141 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 2 | 7 | 14 | settings that do nothing: 55 of 141 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) || [Reliability](#reliability) | 5 | 0 | 2 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -179,7 +179,7 @@ Unread: `general.color_picker`, `general.beep_when_done`, `general.export_clipbo| UI-217-13 | Numeric fields accept arithmetic and units; scrubby labels; double-click resets a slider | partial | [#217](https://github.com/storytold/photocraft/issues/217) | widgets.rs:132 DragValue scrubs and takes + - * / arithmetic; no units in expressions, label scrub or reset || UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | missing | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs:1108 plain dropdown; trash is click-only (panels.rs:1213) || UI-217-15 | Curves: smoothing / pencil mode, black/grey/white eyedroppers, tooltips | partial | [#217](https://github.com/storytold/photocraft/issues/217) | adjust_dialog.rs adds black/gray/white eyedroppers; smoothing and pencil modes remain missing |-| UI-217-16 | Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks | missing | [#217](https://github.com/storytold/photocraft/issues/217) | Only the Hue slider has a gradient |+| UI-217-16 | Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks | done | [#217](https://github.com/storytold/photocraft/issues/217) | saturation_track/lightness_track (adjust_editors.rs): grey -> the hue and black -> the hue -> white, recolouring as the Hue slider moves; saturation_and_lightness_tracks_follow_the_hue || UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | missing | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs:1837 single field + hex/RGB readout || UI-217-18 | Alt+wheel zooms in gentle ~5 % steps; zoom controls uncramped | missing | [#217](https://github.com/storytold/photocraft/issues/217) | canvas.rs:1107-1125 no Alt handling || UI-217-19 | Shortcut hints rendered per platform; Reveal label per OS | missing | [#217](https://github.com/storytold/photocraft/issues/217) | ~33 hard-coded modifier glyph strings in ui-egui; menu_catalog.rs:341 one label |diff --git a/scorecard/ui.toml b/scorecard/ui.tomlindex 0f2841d60..21006d200 100644--- a/scorecard/ui.toml+++ b/scorecard/ui.toml@@ -113,9 +113,9 @@ note = "adjust_dialog.rs adds black/gray/white eyedroppers; smoothing and pencil[[item]]id = "UI-217-16"target = "Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks"-status = "missing"+status = "done"issue = 217-note = "Only the Hue slider has a gradient"+note = "saturation_track/lightness_track (adjust_editors.rs): grey -> the hue and black -> the hue -> white, recolouring as the Hue slider moves; saturation_and_lightness_tracks_follow_the_hue"[[item]]id = "UI-217-17"