Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Hue/Saturation: the Lightness track runs black, grey, white (#6539)

David Mannac8d0af24c15
diff --git a/crates/ui-egui/src/adjust_editors.rs b/crates/ui-egui/src/adjust_editors.rs
index 87a81b8c3..eb1f08464 100644
--- a/crates/ui-egui/src/adjust_editors.rs
+++ b/crates/ui-egui/src/adjust_editors.rs
@@ -858,9 +858,10 @@ 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]
+/// The Lightness slider's track: black, mid grey, white, whatever the hue, as in Photoshop
+/// (UI-217-16, #6539).
+fn lightness_track() -> [Color32; 3] {
+ [Color32::BLACK, Color32::from_gray(128), Color32::WHITE]
}
fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f32; 4] {
@@ -926,7 +927,8 @@ 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).
+ // The Saturation track follows the current hue; the Lightness track is a fixed
+ // black-grey-white ramp, 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, "%", track_stops(cx, &sat_track));
@@ -934,7 +936,7 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
v["saturation"] = json!(s.round());
}
e.add(Edit::of(&r));
- let light_track = lightness_track(h);
+ let light_track = lightness_track();
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, "%", track_stops(cx, &light_track));
if r.changed() {
@@ -1681,12 +1683,19 @@ mod tests {
use super::*;
#[test]
- fn saturation_and_lightness_tracks_follow_the_hue() {
- // The S/L slider tracks recolour with the hue (UI-217-16).
+ fn saturation_track_follows_the_hue() {
+ // The Saturation slider track recolours 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 lightness_track_is_black_grey_white_whatever_the_hue() {
+ // Photoshop's Lightness track does not take the hue's colour (#6539).
+ assert_eq!(lightness_track(), [Color32::BLACK, Color32::from_gray(128), Color32::WHITE]);
+ let [_, mid, _] = lightness_track();
+ assert!(mid.r() == mid.g() && mid.g() == mid.b(), "the middle stop is neutral grey");
}
/// Preferences ▸ Interface ▸ Dynamic Color Sliders: off, the colour sliders get plain tracks.
diff --git a/docs/scorecard.md b/docs/scorecard.md
index 377ce8583..8059611b8 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -200,7 +200,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w
| UI-217-13 | Numeric fields accept arithmetic and units; scrubby labels; double-click resets a slider | done | [#217](https://github.com/storytold/photocraft/issues/217) | widgets::value_field: arithmetic plus units (1in, 5mm, 72pt, 50%) converted at the document resolution (#3099); widgets::scrub_label makes options-bar, slider-row and Character labels scrubby (Shift x10, Alt fine); slider rows with a known default reset on double-click |
| UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | done | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102) |
| UI-217-15 | Curves: smoothing / pencil mode, black/grey/white eyedroppers, tooltips | done | [#217](https://github.com/storytold/photocraft/issues/217) | Curves editor (adjust_editors.rs, dialog and Properties): Edit points / Draw (pencil) buttons and Smooth, all with tooltips; pencil curves are 256-level maps (Adjustment::Curves pencil, params pencil/smooth, PSD curv map form and smart-filter Mpng; #3088). Set Black/Neutral Gray/White Point eyedroppers in the Image > Adjustments > Curves dialog (adjust_dialog.rs, #873) and in a Curves adjustment layer's Properties panel (layer_picker.rs: a click on the image is one layer.setAdjustment with the eyedropper param, sampling below the layer; Esc or another tool disarms; #3110) |
-| 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-16 | Hue/Saturation: Saturation slider gets a hue-following colour track, Lightness a black-grey-white track | done | [#217](https://github.com/storytold/photocraft/issues/217) | saturation_track/lightness_track (adjust_editors.rs): grey -> the hue, recolouring as the Hue slider moves, and a fixed black -> grey -> white (#6539); saturation_track_follows_the_hue, lightness_track_is_black_grey_white_whatever_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 | done | [#217](https://github.com/storytold/photocraft/issues/217) | hints and tooltips go through shortcuts::pretty (6266b7a9, #262; pretty_uses_the_platform_notation); menus::reveal_label names Reveal in Finder per OS (Show in Explorer / Show in Folder) in the Smart Objects menu and the tab menu; reveal_label_names_the_platform_file_manager + smart_objects_reveal_item_names_the_platform_file_manager |
diff --git a/scorecard/ui.toml b/scorecard/ui.toml
index 4ac0ce638..46730c3ea 100644
--- a/scorecard/ui.toml
+++ b/scorecard/ui.toml
@@ -112,10 +112,10 @@ note = "Curves editor (adjust_editors.rs, dialog and Properties): Edit points /
[[item]]
id = "UI-217-16"
-target = "Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks"
+target = "Hue/Saturation: Saturation slider gets a hue-following colour track, Lightness a black-grey-white track"
status = "done"
issue = 217
-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"
+note = "saturation_track/lightness_track (adjust_editors.rs): grey -> the hue, recolouring as the Hue slider moves, and a fixed black -> grey -> white (#6539); saturation_track_follows_the_hue, lightness_track_is_black_grey_white_whatever_the_hue"
[[item]]
id = "UI-217-17"