PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge main into feat/6000-color-panel-modes
Khawar Zamman Wanicb56c99fbd17
diff --cc crates/ui-egui/src/color_panel_tests.rsindex 1152561d9,000000000..956d07ad4mode 100644,000000..100644--- a/crates/ui-egui/src/color_panel_tests.rs+++ b/crates/ui-egui/src/color_panel_tests.rs@@@ -1,337 -1,0 +1,337 @@@+//! The Color panel's modes, ramp and panel menu (#6000, #2569): every mode draws and edits the+//! colour in every theme, and the choice is the panel menu's, never the theme's.++use egui::{Modifiers, Pos2, Rect, pos2, vec2};+use egui_kittest::Harness;+use egui_kittest::kittest::Queryable;+use serde_json::json;++use crate::PhotocraftApp;+use crate::color_panel_ui::{Model, hex_code, html_color, ramp_color};+use crate::dock::Group;+use crate::state::{ColorPanelMode, ColorRamp};+use crate::theme::{ThemeKind, Tokens};++/// The Color tab of `kind` in `mode`, alone in a 300 x 400 pt panel that offers it 360 pt.+fn color_tab(kind: ThemeKind, mode: ColorPanelMode, fg: [f32; 4]) -> Harness<'static, PhotocraftApp> {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.tools.foreground = fg;+ app.ui.color_panel.mode = mode;+ let tab = Group::Color.tabs(Tokens::for_kind(kind).pro).iter().position(|name| *name == "Color").unwrap();+ let mut h = Harness::builder().with_size(vec2(300.0, 400.0)).with_step_dt(1.0 / 60.0).build_ui_state(+ move |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ ui.data_mut(|d| d.insert_temp(crate::panels::color_field_fill_id(), 360.0_f32));+ crate::panels::dock_body(app, ui, Group::Color, tab);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, kind);+ h.run_steps(3);+ h+}++/// Click at `p` with `modifiers` held.+fn press(h: &mut Harness<'_, PhotocraftApp>, p: Pos2, modifiers: Modifiers) {+ h.hover_at(p);+ h.event(egui::Event::ModifiersChanged(modifiers));+ h.run_steps(1);+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers });+ h.run_steps(1);+ }+ h.event(egui::Event::ModifiersChanged(Modifiers::NONE));+ h.run_steps(2);+}++fn bytes(c: [f32; 4]) -> [u8; 3] {+ [c[0], c[1], c[2]].map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)+}++fn type_into(h: &mut Harness<'_, PhotocraftApp>, role: egui::accesskit::Role, nth: usize, text: &str) {+ h.query_all_by_role(role).nth(nth).unwrap().click();+ h.run_steps(1);+ h.key_press_modifiers(Modifiers::COMMAND, egui::Key::A);+ h.run_steps(1);+ for ch in text.chars() {+ h.event(egui::Event::Text(ch.to_string()));+ h.run_steps(1);+ }+ h.key_press(egui::Key::Tab);+ h.run_steps(2);+}++#[test]+fn every_model_round_trips_its_colours() {+ let colours = [[0.2, 0.6, 0.8], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [0.5, 0.25, 0.75]];+ for model in [Model::Rgb, Model::Hsb, Model::Web, Model::Lab, Model::Cmyk] {+ for c in colours {+ // Pure red, for one, can't print: CMYK gives the nearest printable colour back.+ if model == Model::Cmyk && crate::color_picker_ui::out_of_gamut(c).is_some() {+ continue;+ }+ let back = model.to_rgb(model.values_of(c));+ let worst = (0..3).map(|i| (back[i] - c[i]).abs()).fold(0.0, f32::max);+ // Whole-number fields: RGB is exact, HSB within a step, CMYK and Lab within a few.+ let tolerance = match model {+ Model::Rgb | Model::Web => 0.6 / 255.0,+ Model::Hsb => 2.5 / 255.0,+ _ => 0.03,+ };+ assert!(worst <= tolerance, "{model:?} {c:?} -> {back:?}");+ }+ }+ for g in [0.0, 0.25, 0.5, 1.0] {+ let back = Model::Gray.to_rgb(Model::Gray.values_of([g; 3]));+ assert!((back[0] - g).abs() < 0.01, "gray {g} -> {back:?}");+ }+ // Hostile values give a valid colour.+ for model in [Model::Gray, Model::Rgb, Model::Hsb, Model::Cmyk, Model::Lab, Model::Web] {+ for v in [[f32::NAN; 4], [f32::INFINITY; 4], [-1e9; 4], [1e9; 4]] {+ assert!(model.to_rgb(v).iter().all(|x| (0.0..=1.0).contains(x)), "{model:?} {v:?}");+ }+ assert_eq!(+ model.channels().len(),+ match model {+ Model::Gray => 1,+ Model::Cmyk => 4,+ _ => 3,+ }+ );+ }+}++#[test]+fn ramps_match_photoshop() {+ let (fg, bg) = ([0.2, 0.4, 0.6], [1.0, 1.0, 0.0]);+ let near = |a: [f32; 3], b: [f32; 3]| (0..3).all(|i| (a[i] - b[i]).abs() < 0.02);+ // RGB Spectrum: hue across, white at the top, the full colour in the middle, black at the bottom.+ assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.0, 0.0), [1.0; 3]));+ assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.0, 0.5), [1.0, 0.0, 0.0]));+ assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 1.0 / 3.0, 0.5), [0.0, 1.0, 0.0]));+ assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.5, 1.0), [0.0; 3]));+ assert!(near(ramp_color(ColorRamp::GrayscaleRamp, false, fg, bg, 0.0, 0.3), [1.0; 3]));+ assert!(near(ramp_color(ColorRamp::GrayscaleRamp, false, fg, bg, 1.0, 0.3), [0.0; 3]));+ assert!(near(ramp_color(ColorRamp::CurrentColors, false, fg, bg, 0.0, 0.9), fg));+ assert!(near(ramp_color(ColorRamp::CurrentColors, false, fg, bg, 1.0, 0.1), bg));+ // CMYK Spectrum stays printable.+ let c = ramp_color(ColorRamp::CmykSpectrum, false, fg, bg, 0.6, 0.5);+ assert!(crate::color_picker_ui::out_of_gamut(c).is_none(), "{c:?}");+ // Make Ramp Web Safe: every colour is a web colour.+ for ramp in ColorRamp::ALL {+ for (x, y) in [(0.13, 0.37), (0.71, 0.66), (0.5, 0.5)] {+ let c = ramp_color(ramp, true, fg, bg, x, y);+ assert!(crate::color_picker_ui::not_web_safe(c).is_none(), "{ramp:?} {c:?}");+ }+ let c = ramp_color(ramp, false, fg, bg, f32::NAN, f32::INFINITY);+ assert!(c.iter().all(|v| (0.0..=1.0).contains(v)), "{ramp:?} {c:?}");+ }+ // Shift-click cycles the ramps in menu order and wraps.+ let mut r = ColorRamp::RgbSpectrum;+ let mut seen = vec![r];+ for _ in 0..3 {+ r = r.next();+ seen.push(r);+ }+ assert_eq!(seen, ColorRamp::ALL);+ assert_eq!(r.next(), ColorRamp::RgbSpectrum);+}++#[test]+fn copy_color_formats() {+ assert_eq!(html_color([0.2, 0.6, 0.8]), "color=\"#3399cc\"");+ assert_eq!(hex_code([0.2, 0.6, 0.8]), "3399cc");+}++/// Every mode draws in every theme, and a click in it sets the colour.+#[test]+fn every_mode_works_in_every_theme() {+ for kind in ThemeKind::ALL {+ for mode in ColorPanelMode::ALL {+ let mut h = color_tab(kind, mode, [1.0, 0.0, 0.0, 1.0]);+ match mode {+ ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => {+ assert!(h.query_by_label("#").is_some(), "{kind:?} {mode:?}: the readout");+ }+ ColorPanelMode::ColorWheel => {+ for label in ["H", "S", "B", "Add to Swatches"] {+ assert!(h.query_by_label(label).is_some(), "{kind:?} {mode:?}: {label}");+ }+ }+ _ => {+ for (label, ..) in Model::of(mode).channels() {+ assert!(h.query_by_label(label).is_some(), "{kind:?} {mode:?}: the {label} slider");+ }+ // The black box at the end of the ramp sets black.+ let black = h.get_by_label("Black").rect().center();+ press(&mut h, black, Modifiers::NONE);+ assert_eq!(bytes(h.state().session.tools.foreground), [0, 0, 0], "{kind:?} {mode:?}");+ }+ }+ assert!(h.query_by_label("Hue").is_none() && h.query_by_label("Saturation").is_none(), "{kind:?} {mode:?}: no old sliders");+ }+ }+}++#[test]+fn rgb_slider_track_sets_its_channel() {+ let mut h = color_tab(ThemeKind::AdwaitaDark, ColorPanelMode::RgbSliders, [0.0, 0.0, 0.0, 1.0]);+ let g = h.get_by_label("G").rect();+ press(&mut h, pos2(g.right() - 2.0, g.center().y), Modifiers::NONE);+ assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 0]);+ // The field takes a typed value too (the spin buttons are R, G, B).+ type_into(&mut h, egui::accesskit::Role::SpinButton, 2, "128");+ assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 128]);+}++/// Black has no hue or saturation of its own: typed H and S must stick while B is still 0.+#[test]+fn hsb_sliders_take_values_on_black() {+ let mut h = color_tab(ThemeKind::Studio, ColorPanelMode::HsbSliders, [0.0, 0.0, 0.0, 1.0]);+ for (field, typed) in [(0, "120"), (1, "100"), (2, "100")] {+ type_into(&mut h, egui::accesskit::Role::SpinButton, field, typed);+ }+ assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 0]);+}++#[test]+fn cmyk_sliders_keep_typed_values() {+ let mut h = color_tab(ThemeKind::Pro, ColorPanelMode::CmykSliders, [1.0, 1.0, 1.0, 1.0]);+ type_into(&mut h, egui::accesskit::Role::SpinButton, 0, "40");+ type_into(&mut h, egui::accesskit::Role::SpinButton, 3, "20");+ let shown: Vec<String> = h.query_all_by_role(egui::accesskit::Role::SpinButton).filter_map(|n| n.value()).collect();+ assert_eq!(shown.first().map(String::as_str), Some("40"), "C stays as typed: {shown:?}");+ assert_eq!(shown.get(3).map(String::as_str), Some("20"), "K stays as typed: {shown:?}");+}++#[test]+fn web_sliders_snap_and_take_hex() {+ let mut h = color_tab(ThemeKind::Classic, ColorPanelMode::WebColorSliders, [0.0, 0.0, 0.0, 1.0]);+ let r = h.get_by_label("R").rect();+ // 45% along the track snaps to 0x66 (102), the nearest web step.+ let x = r.left() + 4.0 + (r.width() - 8.0) * 0.45;+ press(&mut h, pos2(x, r.center().y), Modifiers::NONE);+ assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0, 0]);+ // Not a web colour: the cube alert snaps it.+ type_into(&mut h, egui::accesskit::Role::TextInput, 1, "C8");+ assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0xC8, 0]);+ let alert = h.get_by_label("Not a web colour: click for the nearest web colour").rect().center();+ press(&mut h, alert, Modifiers::NONE);+ assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0xCC, 0]);+}++#[test]+fn ramp_picks_and_shift_click_cycles_and_alt_picks_the_other_colour() {+ let mut h = color_tab(ThemeKind::BreezeDark, ColorPanelMode::RgbSliders, [0.0, 0.0, 0.0, 1.0]);+ let ramp: Rect = h.get_by_label("Color Ramp").rect();+ // The RGB Spectrum's top is white.+ press(&mut h, pos2(ramp.left() + 3.0, ramp.top() + 1.0), Modifiers::NONE);+ assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 240), "{:?}", h.state().session.tools.foreground);+ // Alt picks the background (the panel edits the foreground).+ press(&mut h, pos2(ramp.left() + 3.0, ramp.bottom() - 1.0), Modifiers::ALT);+ assert!(bytes(h.state().session.tools.background).iter().all(|v| *v < 16), "{:?}", h.state().session.tools.background);+ assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 240), "Alt leaves the foreground");+ // Shift-click cycles the ramp and picks nothing.+ let fg = h.state().session.tools.foreground;+ for expected in [ColorRamp::CmykSpectrum, ColorRamp::GrayscaleRamp, ColorRamp::CurrentColors, ColorRamp::RgbSpectrum] {+ press(&mut h, ramp.center(), Modifiers::SHIFT);+ assert_eq!(h.state().ui.color_panel.ramp, expected);+ }+ assert_eq!(h.state().session.tools.foreground, fg);+ // Grayscale Ramp: its left end is white.+ h.state_mut().ui.color_panel.ramp = ColorRamp::GrayscaleRamp;+ h.state_mut().session.tools.foreground = [0.0, 0.0, 0.0, 1.0];+ h.run_steps(2);+ press(&mut h, pos2(ramp.left() + 1.0, ramp.center().y), Modifiers::NONE);+ assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 245));+}++#[test]+fn color_wheel_ring_sets_hue_and_triangle_sets_saturation_and_brightness() {+ let mut h = color_tab(ThemeKind::Pro, ColorPanelMode::ColorWheel, [0.0, 0.0, 1.0, 1.0]);+ let area = h.get_by_label("Color Wheel").rect();+ let (center, inner, outer) = crate::color_panel_ui::wheel_geometry(area);+ let mid = (inner + outer) / 2.0;+ // Up on the ring: hue 90° (yellow-green). Blue is fully saturated and bright, so it keeps both.+ press(&mut h, pos2(center.x, center.y - mid), Modifiers::NONE);+ let [r, g, bl] = bytes(h.state().session.tools.foreground);+ assert!(r > 100 && g > 240 && bl < 10, "hue 90: {r} {g} {bl}");+ // The triangle's centre: some saturation, some brightness, same hue.+ press(&mut h, center, Modifiers::NONE);+ let after = bytes(h.state().session.tools.foreground);- let hsv = crate::color_picker_ui::rgb_to_hsv(after.map(|v| f32::from(v) / 255.0));++ let hsv = photocraft_color::convert::rgb_to_hsb(after.map(|v| f32::from(v) / 255.0));+ assert!((hsv[0] - 90.0).abs() < 4.0 && hsv[1] < 0.9 && hsv[2] < 0.95, "{after:?} {hsv:?}");+}++/// Picking a mode from the panel menu changes the panel; the theme never does.+#[test]+fn panel_menu_picks_the_mode_and_ramp() {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.tools.foreground = [0.2, 0.6, 0.8, 1.0];+ let mut h = Harness::builder().with_size(vec2(260.0, 700.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ crate::color_panel_ui::panel_menu(app, ui);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, ThemeKind::AdwaitaDark);+ h.run_steps(2);+ assert!(h.query_by_label("✔ Hue Cube").is_some(), "Hue Cube is the default");+ for mode in ColorPanelMode::ALL.into_iter().skip(1).chain([ColorPanelMode::HueCube, ColorPanelMode::WebColorSliders]) {+ h.get_by_label(&format!(" {}", mode.label())).click();+ h.run_steps(2);+ assert_eq!(h.state().ui.color_panel.mode, mode);+ assert!(h.query_by_label(&format!("✔ {}", mode.label())).is_some());+ }+ h.get_by_label(" Current Colors").click();+ h.run_steps(2);+ assert_eq!(h.state().ui.color_panel.ramp, ColorRamp::CurrentColors);+ h.get_by_label(" Make Ramp Web Safe").click();+ h.run_steps(2);+ assert!(h.state().ui.color_panel.web_safe_ramp);+ h.get_by_label("Copy Color's Hex Code").click();+ h.run_steps(1);+ let copied: Vec<_> =+ h.output().platform_output.commands.iter().filter_map(|c| if let egui::OutputCommand::CopyText(s) = c { Some(s.clone()) } else { None }).collect();+ assert_eq!(copied, ["3399cc"]);+ // Switching theme keeps the mode.+ let ctx = h.ctx.clone();+ h.state_mut().set_theme(&ctx, ThemeKind::Pro);+ h.run_steps(2);+ assert_eq!(h.state().ui.color_panel.mode, ColorPanelMode::WebColorSliders);+}++/// `ui.set colorPanel` merges, so setting the mode keeps the edited chip; bad values change nothing.+#[test]+fn control_sets_the_mode_ramp_and_web_safe_ramp() {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ let ctx = egui::Context::default();+ let call = |app: &mut PhotocraftApp, params: serde_json::Value| {+ let (req, _rx) = crate::control::ControlRequest::new("ui.set", params);+ match crate::control::handle(app, &ctx, &req) {+ crate::control::Outcome::Done(v) => v["ok"] == true,+ _ => panic!("expected an immediate reply"),+ }+ };+ assert!(call(&mut app, json!({"colorPanel": {"background": true}})));+ assert!(call(&mut app, json!({"colorPanel": {"mode": "labSliders", "ramp": "grayscaleRamp", "webSafeRamp": true}})));+ let cp = app.ui.color_panel;+ assert!(cp.background, "the chip is kept");+ assert_eq!((cp.mode, cp.ramp, cp.web_safe_ramp), (ColorPanelMode::LabSliders, ColorRamp::GrayscaleRamp, true));+ for bad in [json!({"colorPanel": {"mode": "hueWheel"}}), json!({"colorPanel": {"ramp": 3}}), json!({"colorPanel": {"webSafeRamp": "yes"}})] {+ assert!(!call(&mut app, bad.clone()), "{bad}");+ assert_eq!(app.ui.color_panel, cp, "{bad}: nothing changes");+ }+}++/// Only Web Colors is `webOnly` now that the state is camelCase; state saved before still loads.+#[test]+fn web_only_reads_its_old_snake_case_key() {+ let old: crate::state::ColorPanelState = serde_json::from_value(json!({"background": true, "web_only": true})).unwrap();+ assert!(old.background && old.web_only);+ let new = serde_json::to_value(old).unwrap();+ assert_eq!((new.get("webOnly"), new.get("web_only")), (Some(&json!(true)), None));+}diff --cc crates/ui-egui/src/color_panel_ui.rsindex 8f1acf67f,000000000..12f01ebf2mode 100644,000000..100644--- a/crates/ui-egui/src/color_panel_ui.rs+++ b/crates/ui-egui/src/color_panel_ui.rs@@@ -1,732 -1,0 +1,733 @@@+//! Photoshop's Color panel modes, picked from its panel menu and the same in every theme (#6000,+//! #2569): Hue Cube and Brightness Cube (drawn by [`crate::panels::color_field`]), Color Wheel (HSB+//! sliders over a hue ring around a saturation/brightness triangle), and the Grayscale, RGB, HSB,+//! CMYK, Lab and Web Color sliders over a colour ramp. The panel menu also has Copy Color as HTML,+//! Copy Color's Hex Code, the ramp choices (RGB Spectrum, CMYK Spectrum, Grayscale Ramp, Current+//! Colors) and Make Ramp Web Safe. Shift-click on the ramp cycles the ramps, Alt-click picks the+//! colour the panel isn't editing, and a right-click opens the ramp menu.++use std::f32::consts::TAU;+use std::sync::Arc;++use egui::{Color32, Mesh, Pos2, Rect, Sense, Stroke, StrokeKind, pos2, vec2};+use serde_json::json;++use crate::PhotocraftApp;- use crate::color_picker_ui::{hex, hsv_to_rgb, not_web_safe, out_of_gamut, rgb_to_hsv};++use crate::color_picker_ui::{hex, not_web_safe, out_of_gamut};++use photocraft_color::convert::{hsb_to_rgb, rgb_to_hsb};+use crate::panels::{color_field_fill_id, field_chips, field_hsva, srgb_hsva};+use crate::state::{ColorPanelMode, ColorRamp};+use crate::theme::Tokens;+use crate::widgets;+use photocraft_color::convert;++/// Width of the chips column, as the cube field's.+const CHIPS_W: f32 = 38.0;+/// Height of one slider row.+const ROW_H: f32 = 22.0;+/// Width of a slider row's value field.+const FIELD_W: f32 = 44.0;+/// Width of the unit after a field ("°", "%").+const UNIT_W: f32 = 14.0;+/// Width of the white and black boxes at the right end of the ramp.+const BOXES_W: f32 = 16.0;++/// The Color tab: whatever the panel menu picked.+pub(crate) fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ match app.ui.color_panel.mode {+ ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => crate::panels::color_field(app, ui),+ ColorPanelMode::ColorWheel => wheel(app, ui),+ mode => sliders(app, ui, mode),+ }+}++/// The colour model a slider mode edits.+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]+pub(crate) enum Model {+ Gray,+ Rgb,+ Hsb,+ Cmyk,+ Lab,+ Web,+}++impl Model {+ pub(crate) fn of(mode: ColorPanelMode) -> Model {+ match mode {+ ColorPanelMode::GrayscaleSlider => Model::Gray,+ ColorPanelMode::HsbSliders | ColorPanelMode::ColorWheel => Model::Hsb,+ ColorPanelMode::CmykSliders => Model::Cmyk,+ ColorPanelMode::LabSliders => Model::Lab,+ ColorPanelMode::WebColorSliders => Model::Web,+ ColorPanelMode::RgbSliders | ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => Model::Rgb,+ }+ }++ /// Each slider: label, range and unit, in Photoshop's order.+ pub(crate) fn channels(self) -> &'static [(&'static str, f32, f32, &'static str)] {+ match self {+ Model::Gray => &[("K", 0.0, 100.0, "%")],+ Model::Rgb | Model::Web => &[("R", 0.0, 255.0, ""), ("G", 0.0, 255.0, ""), ("B", 0.0, 255.0, "")],+ Model::Hsb => &[("H", 0.0, 360.0, "°"), ("S", 0.0, 100.0, "%"), ("B", 0.0, 100.0, "%")],+ Model::Cmyk => &[("C", 0.0, 100.0, "%"), ("M", 0.0, 100.0, "%"), ("Y", 0.0, 100.0, "%"), ("K", 0.0, 100.0, "%")],+ Model::Lab => &[("L", 0.0, 100.0, ""), ("a", -128.0, 127.0, ""), ("b", -128.0, 127.0, "")],+ }+ }++ /// The sRGB colour of slider values `v` (in the units the fields show).+ pub(crate) fn to_rgb(self, v: [f32; 4]) -> [f32; 3] {+ let [a, b, c, d] = v.map(|x| if x.is_finite() { x } else { 0.0 });+ let rgb = match self {+ Model::Gray => [1.0 - a / 100.0; 3],+ Model::Rgb | Model::Web => [a / 255.0, b / 255.0, c / 255.0],- Model::Hsb => hsv_to_rgb(a, b / 100.0, c / 100.0),++ Model::Hsb => hsb_to_rgb([a, b / 100.0, c / 100.0]),+ Model::Cmyk => convert::cmyk_to_rgb([a / 100.0, b / 100.0, c / 100.0, d / 100.0]),+ Model::Lab => convert::lab_to_srgb([a, b, c]),+ };+ rgb.map(|x| if x.is_finite() { x.clamp(0.0, 1.0) } else { 0.0 })+ }++ /// Slider values of `rgb`, rounded to whole numbers as Photoshop's fields show them.+ pub(crate) fn values_of(self, rgb: [f32; 3]) -> [f32; 4] {+ let v = match self {+ Model::Gray => [(1.0 - convert::rgb_to_gray(rgb)) * 100.0, 0.0, 0.0, 0.0],+ Model::Rgb | Model::Web => [rgb[0] * 255.0, rgb[1] * 255.0, rgb[2] * 255.0, 0.0],+ Model::Hsb => {- let [h, s, b] = rgb_to_hsv(rgb);++ let [h, s, b] = rgb_to_hsb(rgb);+ [h, s * 100.0, b * 100.0, 0.0]+ }+ Model::Cmyk => convert::rgb_to_cmyk(rgb).map(|x| x * 100.0),+ Model::Lab => {+ let [l, a, b] = convert::srgb_to_lab(rgb);+ [l, a, b, 0.0]+ }+ };+ v.map(|x| if x.is_finite() { x.round() } else { 0.0 })+ }+}++/// The colour the panel edits.+fn active(app: &PhotocraftApp) -> [f32; 3] {+ let c = if app.ui.color_panel.background { app.session.tools.background } else { app.session.tools.foreground };+ [c[0], c[1], c[2]].map(|x| x.clamp(0.0, 1.0))+}++/// Set the foreground (and recolour selected type) or the background colour.+pub(crate) fn set_color(app: &mut PhotocraftApp, background: bool, rgb: [f32; 3]) {+ let c = [rgb[0], rgb[1], rgb[2], 1.0];+ if background {+ app.session.tools.background = c;+ } else {+ app.session.tools.foreground = c;+ crate::type_tool::foreground_changed(app);+ }+}++/// The key of the slider values last shown for `model`, kept while they still give the colour:+/// a grey has no hue, and CMYK or Lab values don't survive an sRGB round trip (#3228).+fn values_key(model: Model, background: bool) -> egui::Id {+ egui::Id::new(("color-panel-values", model, background))+}++/// The key of the Hue Cube's remembered hue and saturation (see [`field_hsva`]).+fn field_key(background: bool) -> egui::Id {+ egui::Id::new(("color-field-hue", background))+}++/// Slider values for the colour the panel edits: the ones last shown while they still give it.+fn current_values(ui: &egui::Ui, model: Model, background: bool, rgb: [f32; 3]) -> [f32; 4] {+ let stored: Option<[f32; 4]> = ui.data(|d| d.get_temp(values_key(model, background)));+ if let Some(v) = stored.filter(|v| hex(model.to_rgb(*v)) == hex(rgb)) {+ return v;+ }+ if model == Model::Hsb {+ // Share the cube's hue and saturation, so a grey keeps its hue across modes.+ let c = [rgb[0], rgb[1], rgb[2], 1.0];+ let hsva = srgb_hsva(c);+ let remembered: (f32, f32) = ui.data(|d| d.get_temp(field_key(background))).unwrap_or((hsva.h, hsva.s));+ let h = field_hsva(hsva, remembered);+ return [h.h * 360.0, h.s * 100.0, h.v * 100.0, 0.0].map(f32::round);+ }+ model.values_of(rgb)+}++/// Apply edited slider values: the colour, and the values (and the cube's hue) remembered.+fn apply_values(app: &mut PhotocraftApp, ui: &egui::Ui, model: Model, v: [f32; 4]) {+ let background = app.ui.color_panel.background;+ let rgb = model.to_rgb(v);+ set_color(app, background, rgb);+ ui.data_mut(|d| d.insert_temp(values_key(model, background), v));+ if model == Model::Hsb && v[2] > 0.5 {+ ui.data_mut(|d| d.insert_temp(field_key(background), (v[0] / 360.0, v[1] / 100.0)));+ }+}++/// Track colours of slider `i` at `steps` + 1 points, the other sliders at `v`.+fn track_stops(model: Model, v: [f32; 4], i: usize, steps: usize) -> Vec<Color32> {+ let Some(&(_, lo, hi, _)) = model.channels().get(i) else { return Vec::new() };+ (0..=steps)+ .map(|k| {+ let mut w = v;+ if let Some(slot) = w.get_mut(i) {+ *slot = lo + (hi - lo) * k as f32 / steps as f32;+ }+ // HSB's hue track is the full spectrum, whatever the saturation and brightness.+ if model == Model::Hsb && i == 0 {+ w = [w[0], 100.0, 100.0, 0.0];+ }+ rgb32(model.to_rgb(w))+ })+ .collect()+}++pub(crate) fn rgb32(c: [f32; 3]) -> Color32 {+ let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8;+ Color32::from_rgb(q(c[0]), q(c[1]), q(c[2]))+}++/// The slider rows of `model`. Returns the edited values, if any.+fn slider_rows(ui: &mut egui::Ui, model: Model, v: [f32; 4], background: bool, dynamic: bool) -> Option<[f32; 4]> {+ let t = Tokens::get(ui.ctx());+ // Dynamic Color Sliders off: the tracks keep the colours they had when a drag began.+ let stops_key = egui::Id::new(("color-panel-stops", model, background));+ let dragging = ui.input(|i| i.pointer.any_down());+ let stops_from = if dynamic || !dragging { v } else { ui.data(|d| d.get_temp::<[f32; 4]>(stops_key)).unwrap_or(v) };+ if !dragging {+ ui.data_mut(|d| d.insert_temp(stops_key, v));+ }+ let mut out = None;+ let mut values = v;+ for (i, &(label, lo, hi, unit)) in model.channels().iter().enumerate() {+ let Some(¤t) = values.get(i) else { continue };+ let mut x = current;+ let mut changed = false;+ ui.horizontal(|ui| {+ ui.spacing_mut().item_spacing.x = 4.0;+ ui.set_height(ROW_H);+ let (lr, _) = ui.allocate_exact_size(vec2(12.0, ROW_H), Sense::hover());+ ui.painter().text(lr.left_center(), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(12.0), t.text_dim);+ let track_w = (ui.available_width() - FIELD_W - UNIT_W - 8.0).max(24.0);+ let (tr, resp) = ui.allocate_exact_size(vec2(track_w, ROW_H), Sense::click_and_drag());+ let stops = track_stops(model, stops_from, i, 24);+ changed |= track(ui, tr, &resp, &mut x, lo, hi, &stops, model == Model::Web);+ resp.widget_info(|| egui::WidgetInfo::slider(ui.is_enabled(), f64::from(x), label));+ if model == Model::Web {+ changed |= hex_pair(ui, ui.id().with(("web-field", i, background)), &mut x);+ } else if widgets::value_field(ui, &mut x, lo..=hi, "", FIELD_W).changed() {+ changed = true;+ }+ let (ur, _) = ui.allocate_exact_size(vec2(UNIT_W, ROW_H), Sense::hover());+ ui.painter().text(ur.left_center(), egui::Align2::LEFT_CENTER, unit, egui::FontId::proportional(12.0), t.text_faint);+ });+ if changed && let Some(slot) = values.get_mut(i) {+ *slot = x.clamp(lo, hi).round();+ out = Some(values);+ }+ }+ out+}++/// A slider track with Photoshop's triangle thumb under it. Returns true when dragged or clicked+/// to a new value; Web Color tracks snap to the web steps (00, 33, 66, 99, CC, FF).+#[allow(clippy::too_many_arguments)]+fn track(ui: &egui::Ui, r: Rect, resp: &egui::Response, value: &mut f32, lo: f32, hi: f32, stops: &[Color32], web: bool) -> bool {+ let t = Tokens::get(ui.ctx());+ let bar = Rect::from_min_max(pos2(r.left() + 4.0, r.center().y - 6.0), pos2(r.right() - 4.0, r.center().y + 1.0));+ let mut mesh = Mesh::default();+ let n = stops.len().saturating_sub(1).max(1);+ for (k, c) in stops.iter().enumerate() {+ let x = bar.left() + bar.width() * k as f32 / n as f32;+ mesh.colored_vertex(pos2(x, bar.top()), *c);+ mesh.colored_vertex(pos2(x, bar.bottom()), *c);+ }+ for k in 0..stops.len().saturating_sub(1) as u32 {+ let a = k * 2;+ mesh.add_triangle(a, a + 1, a + 3);+ mesh.add_triangle(a, a + 3, a + 2);+ }+ ui.painter().add(mesh);+ ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);+ if web {+ // Ticks at the web steps.+ for k in 0..=5 {+ let x = bar.left() + bar.width() * k as f32 / 5.0;+ ui.painter().line_segment([pos2(x, bar.bottom() + 1.0), pos2(x, bar.bottom() + 3.0)], Stroke::new(1.0, t.text_faint));+ }+ }+ let mut changed = false;+ if (resp.dragged() || resp.clicked())+ && let Some(p) = resp.interact_pointer_pos()+ && bar.width() > 0.0+ && hi > lo+ {+ let f = ((p.x - bar.left()) / bar.width()).clamp(0.0, 1.0);+ let mut v = lo + (hi - lo) * f;+ if web {+ v = (v / 51.0).round() * 51.0;+ }+ let v = v.round().clamp(lo, hi);+ if v != *value {+ *value = v;+ changed = true;+ }+ }+ let f = if hi > lo { ((*value - lo) / (hi - lo)).clamp(0.0, 1.0) } else { 0.0 };+ let x = bar.left() + bar.width() * f;+ let y = bar.bottom() + 1.0;+ let thumb = vec![pos2(x, y), pos2(x + 5.0, y + 7.0), pos2(x - 5.0, y + 7.0)];+ ui.painter().add(egui::Shape::convex_polygon(thumb, t.text, Stroke::new(1.0, t.field_border)));+ changed+}++/// A Web Color slider's field: the channel as two hex digits. Valid input sets `value` (0..255)+/// and returns true; while focused it shows what is typed, and an invalid entry snaps back.+fn hex_pair(ui: &mut egui::Ui, id: egui::Id, value: &mut f32) -> bool {+ let t = Tokens::get(ui.ctx());+ let (rect, _) = ui.allocate_exact_size(vec2(FIELD_W, ROW_H), Sense::hover());+ widgets::surface(ui, rect, t.field, false);+ if !t.bevel {+ ui.painter().rect_stroke(rect, t.radius_sm, Stroke::new(1.0, t.field_border), StrokeKind::Inside);+ }+ let byte = value.clamp(0.0, 255.0).round() as u8;+ let typing = if ui.memory(|m| m.has_focus(id)) { ui.data(|d| d.get_temp::<String>(id)) } else { None };+ let mut text = typing.unwrap_or_else(|| format!("{byte:02X}"));+ let inner = rect.shrink2(vec2(5.0, 2.0));+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center)));+ let resp = child+ .add(egui::TextEdit::singleline(&mut text).id(id).char_limit(2).desired_width(inner.width()).frame(egui::Frame::NONE).font(crate::theme::mono(12.0)));+ if resp.has_focus() {+ ui.data_mut(|d| d.insert_temp(id, text.clone()));+ } else {+ ui.data_mut(|d| d.remove::<String>(id));+ }+ if resp.changed()+ && text.len() == 2+ && let Ok(b) = u8::from_str_radix(&text, 16)+ {+ *value = f32::from(b);+ return true;+ }+ false+}++/// The slider modes: chips (with the out-of-gamut and web-colour alerts under them) beside the+/// sliders, over the colour ramp.+fn sliders(app: &mut PhotocraftApp, ui: &mut egui::Ui, mode: ColorPanelMode) {+ let model = Model::of(mode);+ let background = app.ui.color_panel.background;+ let rgb = active(app);+ let v = current_values(ui, model, background, rgb);+ let dynamic = app.session.prefs().interface.dynamic_color_sliders;+ let rows_h = model.channels().len() as f32 * (ROW_H + ui.spacing().item_spacing.y);+ let top_h = rows_h.max(CHIPS_W + 40.0);+ let mut edited = None;+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = 8.0;+ let (col, _) = ui.allocate_exact_size(vec2(CHIPS_W, top_h), Sense::hover());+ field_chips(app, ui, col);+ alerts(app, ui, col, rgb, model == Model::Web);+ ui.vertical(|ui| {+ edited = slider_rows(ui, model, v, background, dynamic);+ });+ });+ if let Some(v) = edited {+ apply_values(app, ui, model, v);+ }+ ui.add_space(6.0);+ let fill = ui.data(|d| d.get_temp::<f32>(color_field_fill_id()));+ let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0;+ let ramp_h = fill.filter(|f| f.is_finite()).map_or(36.0, |f| (f - top_h - gaps).clamp(28.0, 2000.0));+ ramp(app, ui, ramp_h);+}++/// Photoshop's alerts under the chips: ⚠ when the colour can't print (click: the nearest CMYK+/// colour) and, for Web Color sliders, the cube when it isn't a web colour (click: the nearest).+fn alerts(app: &mut PhotocraftApp, ui: &mut egui::Ui, col: Rect, rgb: [f32; 3], web: bool) {+ let t = Tokens::get(ui.ctx());+ let background = app.ui.color_panel.background;+ let mut y = col.top() + CHIPS_W + 2.0;+ let warnings = [+ (out_of_gamut(rgb), "Out of gamut for printing: click for the nearest printable colour", false),+ (if web { not_web_safe(rgb) } else { None }, "Not a web colour: click for the nearest web colour", true),+ ];+ for (slot, (near, tip, cube)) in warnings.into_iter().enumerate() {+ let Some(near) = near else { continue };+ let icon = Rect::from_min_size(pos2(col.left() + 1.0, y), vec2(14.0, 13.0));+ let chip = Rect::from_min_size(pos2(col.left() + 18.0, y), vec2(13.0, 13.0));+ if cube {+ crate::color_picker_ui::web_cube(ui.painter(), icon.shrink(0.5), t.text_dim);+ } else {+ crate::color_picker_ui::warning_triangle(ui.painter(), icon, t.text_dim, t.card);+ }+ ui.painter().rect_filled(chip, 0.0, rgb32(near));+ ui.painter().rect_stroke(chip, 0.0, Stroke::new(1.0, t.text_dim), StrokeKind::Outside);+ let resp = ui.interact(icon.union(chip), ui.id().with(("color-panel-alert", slot)), Sense::click());+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tip));+ if resp.on_hover_text(tl!(tip)).clicked() {+ set_color(app, background, near);+ }+ y += 18.0;+ }+}++/// The ramp's colour at (x, y) in 0..1 (y down). RGB Spectrum: hue across, white at the top+/// through the full colour to black at the bottom; CMYK Spectrum: the same in the CMYK gamut;+/// Grayscale Ramp: white to black; Current Colors: the foreground to the background.+pub(crate) fn ramp_color(ramp: ColorRamp, web_safe: bool, fg: [f32; 3], bg: [f32; 3], x: f32, y: f32) -> [f32; 3] {+ let (x, y) = (x.clamp(0.0, 1.0), y.clamp(0.0, 1.0));+ let spectrum = || {+ let (s, v) = if y < 0.5 { (y * 2.0, 1.0) } else { (1.0, 1.0 - (y - 0.5) * 2.0) };- hsv_to_rgb(x.min(0.9999) * 360.0, s, v)++ hsb_to_rgb([x.min(0.9999) * 360.0, s, v])+ };+ let c = match ramp {+ ColorRamp::RgbSpectrum => spectrum(),+ ColorRamp::CmykSpectrum => convert::cmyk_to_rgb(convert::rgb_to_cmyk(spectrum())),+ ColorRamp::GrayscaleRamp => [1.0 - x; 3],+ ColorRamp::CurrentColors => [0, 1, 2].map(|i| fg[i] + (bg[i] - fg[i]) * x),+ };+ let c = c.map(|v| if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 });+ if web_safe { c.map(|v| (v * 5.0).round() / 5.0) } else { c }+}++/// Cells across and down the ramp's mesh.+const RAMP_NX: usize = 48;+const RAMP_NY: usize = 8;++/// The ramp's colours, cached until the ramp, its inputs or the CMYK space change: the CMYK+/// Spectrum takes a CMYK round trip per vertex, too slow to redo every frame.+fn ramp_colors(ui: &egui::Ui, ramp: ColorRamp, web_safe: bool, fg: [f32; 3], bg: [f32; 3]) -> Arc<Vec<Color32>> {+ use std::hash::{Hash, Hasher};+ let mut h = std::collections::hash_map::DefaultHasher::new();+ (ramp as u8, web_safe).hash(&mut h);+ if ramp == ColorRamp::CurrentColors {+ (hex(fg), hex(bg)).hash(&mut h);+ }+ if ramp == ColorRamp::CmykSpectrum {+ convert::active_cmyk_space().map(|s| Arc::as_ptr(&s) as usize).hash(&mut h);+ }+ let sig = h.finish();+ let key = egui::Id::new("color-panel-ramp-cache");+ if let Some((s, colors)) = ui.data(|d| d.get_temp::<(u64, Arc<Vec<Color32>>)>(key))+ && s == sig+ {+ return colors;+ }+ // Web-safe ramps are flat cells (sampled at their centres), the others shaded vertices.+ let (nx, ny, half) = if web_safe { (RAMP_NX, RAMP_NY, 0.5) } else { (RAMP_NX + 1, RAMP_NY + 1, 0.0) };+ let mut colors = Vec::with_capacity(nx * ny);+ for j in 0..ny {+ for i in 0..nx {+ let (x, y) = ((i as f32 + half) / RAMP_NX as f32, (j as f32 + half) / RAMP_NY as f32);+ colors.push(rgb32(ramp_color(ramp, web_safe, fg, bg, x, y)));+ }+ }+ let colors = Arc::new(colors);+ ui.data_mut(|d| d.insert_temp(key, (sig, colors.clone())));+ colors+}++/// The ramp mesh over `r` from [`ramp_colors`].+fn ramp_mesh(r: Rect, colors: &[Color32], web_safe: bool) -> Mesh {+ let mut m = Mesh::default();+ let at = |i: usize, j: usize| pos2(r.left() + r.width() * i as f32 / RAMP_NX as f32, r.top() + r.height() * j as f32 / RAMP_NY as f32);+ if web_safe {+ for j in 0..RAMP_NY {+ for i in 0..RAMP_NX {+ let Some(&c) = colors.get(j * RAMP_NX + i) else { continue };+ let a = m.vertices.len() as u32;+ for p in [at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j + 1)] {+ m.colored_vertex(p, c);+ }+ m.add_triangle(a, a + 1, a + 2);+ m.add_triangle(a, a + 2, a + 3);+ }+ }+ return m;+ }+ for j in 0..=RAMP_NY {+ for i in 0..=RAMP_NX {+ m.colored_vertex(at(i, j), colors.get(j * (RAMP_NX + 1) + i).copied().unwrap_or(Color32::BLACK));+ }+ }+ let row = (RAMP_NX + 1) as u32;+ for j in 0..RAMP_NY as u32 {+ for i in 0..RAMP_NX as u32 {+ let a = j * row + i;+ m.add_triangle(a, a + 1, a + row + 1);+ m.add_triangle(a, a + row + 1, a + row);+ }+ }+ m+}++/// The colour ramp with the white and black boxes at its right end. A click or drag picks; with+/// Alt it picks the colour the panel isn't editing; Shift-click cycles the ramps; a right-click+/// opens the ramp menu.+fn ramp(app: &mut PhotocraftApp, ui: &mut egui::Ui, height: f32) {+ let t = Tokens::get(ui.ctx());+ let w = ui.available_width();+ let (all, _) = ui.allocate_exact_size(vec2(w, height), Sense::hover());+ let bar = Rect::from_min_max(all.min, pos2(all.right() - BOXES_W - 2.0, all.bottom()));+ let boxes = Rect::from_min_max(pos2(all.right() - BOXES_W, all.top()), all.max);+ let cp = app.ui.color_panel;+ let fg = rgb3(app.session.tools.foreground);+ let bg = rgb3(app.session.tools.background);+ let colors = ramp_colors(ui, cp.ramp, cp.web_safe_ramp, fg, bg);+ ui.painter().add(ramp_mesh(bar, &colors, cp.web_safe_ramp));+ ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);+ let (white, black) =+ (Rect::from_min_max(boxes.min, pos2(boxes.right(), boxes.center().y)), Rect::from_min_max(pos2(boxes.left(), boxes.center().y), boxes.max));+ ui.painter().rect_filled(white, 0.0, Color32::WHITE);+ ui.painter().rect_filled(black, 0.0, Color32::BLACK);+ ui.painter().rect_stroke(boxes, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);+ let resp = ui.interact(bar, ui.id().with("color-panel-ramp"), Sense::click_and_drag());+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Ramp"));+ let mods = ui.input(|i| i.modifiers);+ let target = cp.background != mods.alt;+ if resp.clicked() && mods.shift {+ app.ui.color_panel.ramp = cp.ramp.next();+ } else if (resp.dragged() || resp.clicked())+ && !mods.shift+ && let Some(p) = resp.interact_pointer_pos()+ && bar.width() > 0.0+ && bar.height() > 0.0+ {+ let c = ramp_color(cp.ramp, cp.web_safe_ramp, fg, bg, (p.x - bar.left()) / bar.width(), (p.y - bar.top()) / bar.height());+ set_color(app, target, c);+ }+ resp.context_menu(|ui| {+ widgets::style_spectrum_popup_menu(ui);+ ramp_menu(app, ui);+ });+ for (r, c, name) in [(white, [1.0; 3], "White"), (black, [0.0; 3], "Black")] {+ let b = ui.interact(r, ui.id().with(("color-panel-box", name)), Sense::click());+ b.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), name));+ if b.clicked() {+ set_color(app, target, c);+ }+ }+}++fn rgb3(c: [f32; 4]) -> [f32; 3] {+ [c[0], c[1], c[2]].map(|v| v.clamp(0.0, 1.0))+}++/// The Color Wheel: HSB sliders over a hue ring (red at the right, running counter-clockwise+/// through yellow and green) around a triangle whose tip is the hue, with white and black at its+/// other corners; the add-to-swatches button sits under it.+fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ let t = Tokens::get(ui.ctx());+ let background = app.ui.color_panel.background;+ let rgb = active(app);+ let v = current_values(ui, Model::Hsb, background, rgb);+ let dynamic = app.session.prefs().interface.dynamic_color_sliders;+ let rows_h = 3.0 * (ROW_H + ui.spacing().item_spacing.y);+ let top_h = rows_h.max(CHIPS_W);+ let mut edited = None;+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = 8.0;+ let (col, _) = ui.allocate_exact_size(vec2(CHIPS_W, top_h), Sense::hover());+ field_chips(app, ui, col);+ ui.vertical(|ui| {+ edited = slider_rows(ui, Model::Hsb, v, background, dynamic);+ });+ });+ let mut v = edited.unwrap_or(v);+ let mut changed = edited.is_some();+ ui.add_space(6.0);+ let fill = ui.data(|d| d.get_temp::<f32>(color_field_fill_id()));+ let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0;+ let w = ui.available_width();+ let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - top_h - gaps).min(w)).max(80.0);+ let (area, resp) = ui.allocate_exact_size(vec2(w, side), Sense::click_and_drag());+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Wheel"));+ let (center, inner, outer) = wheel_geometry(area);+ let ring_w = outer - inner;+ let (h, s, b) = (v[0] / 360.0, v[1] / 100.0, v[2] / 100.0);+ ui.painter().add(ring_mesh(center, inner, outer));+ let tri = triangle(center, inner - 1.0, h);+ ui.painter().add(triangle_mesh(tri, h));+ // Which part a drag began on: the ring sets the hue, the triangle saturation and brightness.+ // The ring or the triangle, from where the press began (kept for frames without a press+ // origin), so a drag that leaves the ring keeps turning the hue.+ let drag_key = ui.id().with("color-wheel-drag");+ if (resp.dragged() || resp.clicked())+ && let Some(p) = resp.interact_pointer_pos()+ {+ // A click is where it landed; a drag goes by where its press began.+ let origin = if resp.clicked() { Some(p) } else { ui.input(|i| i.pointer.press_origin()) };+ let on_ring = match origin {+ Some(origin) => {+ let on_ring = origin.distance(center) >= inner - 2.0;+ ui.data_mut(|d| d.insert_temp(drag_key, on_ring));+ on_ring+ }+ None => ui.data(|d| d.get_temp::<bool>(drag_key)).unwrap_or(false),+ };+ if on_ring {+ let a = (center.y - p.y).atan2(p.x - center.x).rem_euclid(TAU);+ v[0] = (a / TAU * 360.0).round().rem_euclid(360.0);+ } else if let Some((s2, b2)) = triangle_sv(tri, p) {+ v[1] = (s2 * 100.0).round();+ v[2] = (b2 * 100.0).round();+ }+ changed = true;+ }+ // Knobs: on the ring at the hue, in the triangle at the saturation and brightness.+ let a = h * TAU;+ let ring_knob = center + vec2(a.cos(), -a.sin()) * (inner + ring_w / 2.0);+ let tri_knob = triangle_point(tri, s, b);+ for k in [ring_knob, tri_knob] {+ ui.painter().circle_stroke(k, 5.0, Stroke::new(1.5, Color32::WHITE));+ ui.painter().circle_stroke(k, 6.5, Stroke::new(1.0, Color32::from_black_alpha(160)));+ }+ // Photoshop's add-to-swatches button under the wheel.+ let add = Rect::from_min_size(pos2(area.right() - 16.0, area.bottom() - 16.0), vec2(14.0, 14.0));+ ui.painter().rect_stroke(add, 1.0, Stroke::new(1.0, t.text_dim), StrokeKind::Inside);+ ui.painter().line_segment([pos2(add.center().x, add.top() + 3.5), pos2(add.center().x, add.bottom() - 3.5)], Stroke::new(1.0, t.text_dim));+ ui.painter().line_segment([pos2(add.left() + 3.5, add.center().y), pos2(add.right() - 3.5, add.center().y)], Stroke::new(1.0, t.text_dim));+ let add_resp = ui.interact(add, ui.id().with("color-wheel-add"), Sense::click());+ add_resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), "Add to Swatches"));+ if add_resp.on_hover_text(tl!("Create new swatch")).clicked()+ && let Err(e) = app.run("swatches.add", json!({"color": hex(rgb)}))+ {+ app.ui.status = e;+ app.ui.status_error = true;+ }+ if changed {+ apply_values(app, ui, Model::Hsb, v);+ }+}++/// The wheel in `area`: its centre and the hue ring's inner and outer radii.+pub(crate) fn wheel_geometry(area: Rect) -> (Pos2, f32, f32) {+ let outer = (area.width().min(area.height()) / 2.0 - 2.0).max(1.0);+ let ring_w = (outer * 0.09).clamp(6.0, 22.0).min(outer * 0.5);+ (area.center(), outer - ring_w, outer)+}++/// The wheel's hue ring between radii `inner` and `outer`.+fn ring_mesh(center: Pos2, inner: f32, outer: f32) -> Mesh {+ let mut m = Mesh::default();+ let steps = 96u32;+ for k in 0..=steps {+ let f = k as f32 / steps as f32;+ let a = f * TAU;- let c = rgb32(hsv_to_rgb(f * 360.0, 1.0, 1.0));++ let c = rgb32(hsb_to_rgb([f * 360.0, 1.0, 1.0]));+ let dir = vec2(a.cos(), -a.sin());+ m.colored_vertex(center + dir * inner, c);+ m.colored_vertex(center + dir * outer, c);+ }+ for k in 0..steps {+ let a = k * 2;+ m.add_triangle(a, a + 1, a + 3);+ m.add_triangle(a, a + 3, a + 2);+ }+ m+}++/// The triangle's corners for hue `h` (0..1): the pure hue at the hue's angle, white 120° on and+/// black 240° on, inside radius `r`.+fn triangle(center: Pos2, r: f32, h: f32) -> [Pos2; 3] {+ let at = |turns: f32| {+ let a = (h + turns) * TAU;+ center + vec2(a.cos(), -a.sin()) * r+ };+ [at(0.0), at(1.0 / 3.0), at(2.0 / 3.0)]+}++/// The point of saturation `s` and brightness `b` in the triangle: black + b·(white − black) ++/// b·s·(hue − white).+fn triangle_point([hue, white, black]: [Pos2; 3], s: f32, b: f32) -> Pos2 {+ black + (white - black) * b + (hue - white) * (b * s)+}++/// Saturation and brightness at `p`, clamped into the triangle; `None` for a degenerate one.+fn triangle_sv([hue, white, black]: [Pos2; 3], p: Pos2) -> Option<(f32, f32)> {+ let (a, c, d) = (white - black, hue - white, p - black);+ let det = a.x * c.y - a.y * c.x;+ if det.abs() < 1e-6 {+ return None;+ }+ let b = ((d.x * c.y - d.y * c.x) / det).clamp(0.0, 1.0);+ let bs = ((a.x * d.y - a.y * d.x) / det).clamp(0.0, b);+ Some((if b > 0.0 { bs / b } else { 0.0 }, b))+}++/// The triangle shaded through saturation and brightness at hue `h`.+fn triangle_mesh(tri: [Pos2; 3], h: f32) -> Mesh {+ let n = 16usize;+ let mut m = Mesh::default();+ for j in 0..=n {+ for i in 0..=n {+ let (s, b) = (i as f32 / n as f32, j as f32 / n as f32);- m.colored_vertex(triangle_point(tri, s, b), rgb32(hsv_to_rgb(h * 360.0, s, b)));++ m.colored_vertex(triangle_point(tri, s, b), rgb32(hsb_to_rgb([h * 360.0, s, b])));+ }+ }+ let row = (n + 1) as u32;+ for j in 0..n as u32 {+ for i in 0..n as u32 {+ let a = j * row + i;+ m.add_triangle(a, a + 1, a + row + 1);+ m.add_triangle(a, a + row + 1, a + row);+ }+ }+ m+}++/// `color="#rrggbb"`, what Copy Color as HTML puts on the clipboard.+pub(crate) fn html_color(rgb: [f32; 3]) -> String {+ format!("color=\"{}\"", hex(rgb))+}++/// `rrggbb`, what Copy Color's Hex Code puts on the clipboard.+pub(crate) fn hex_code(rgb: [f32; 3]) -> String {+ hex(rgb).trim_start_matches('#').to_string()+}++/// A panel menu row with Photoshop's check mark column.+fn check_item(ui: &mut egui::Ui, on: bool, label: &str) -> bool {+ ui.button(format!("{}{}", if on { "✔ " } else { " " }, tl!(label))).clicked()+}++/// The ramp choices and Make Ramp Web Safe (the panel menu's last section and the ramp's+/// right-click menu).+fn ramp_menu(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ for r in ColorRamp::ALL {+ if check_item(ui, app.ui.color_panel.ramp == r, r.label()) {+ app.ui.color_panel.ramp = r;+ ui.close();+ }+ }+ ui.separator();+ if check_item(ui, app.ui.color_panel.web_safe_ramp, "Make Ramp Web Safe") {+ app.ui.color_panel.web_safe_ramp = !app.ui.color_panel.web_safe_ramp;+ ui.close();+ }+}++/// The Color panel's panel menu, Photoshop's: the modes, the copy commands, the ramps.+pub(crate) fn panel_menu(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ for (i, mode) in ColorPanelMode::ALL.into_iter().enumerate() {+ if i == 3 {+ ui.separator();+ }+ if check_item(ui, app.ui.color_panel.mode == mode, mode.label()) {+ app.ui.color_panel.mode = mode;+ ui.close();+ }+ }+ ui.separator();+ let rgb = active(app);+ if ui.button(tl!("Copy Color as HTML")).clicked() {+ ui.ctx().copy_text(html_color(rgb));+ ui.close();+ }+ if ui.button(tl!("Copy Color's Hex Code")).clicked() {+ ui.ctx().copy_text(hex_code(rgb));+ ui.close();+ }+ ui.separator();+ ramp_menu(app, ui);+}diff --cc crates/ui-egui/src/control.rsindex 399f6d147,73a8911e5..878be8d06--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@@ -570,10 -586,10 +586,10 @@@ fn dispatch(app: &mut PhotocraftApp, ctlet dock_tabs = merged_object(&app.ui.dock_tabs, p.get("dockTabs"), "dockTabs")?;let dock = whole_object(&app.ui.dock, p.get("dock"), "dock")?;// Which chip the Color panel edits.- let color_panel = whole_object(&app.ui.color_panel, p.get("colorPanel"), "colorPanel")?;+ let color_panel = merged_object(&app.ui.color_panel, p.get("colorPanel"), "colorPanel")?;- let dock_width = num_field(p, "dockWidth")?;- let zoom = num_field(p, "zoom")?;- let rotation = num_field(p, "rotation")?;+ let dock_width = f32_field(p, "dockWidth")?;+ let zoom = f32_field(p, "zoom")?;+ let rotation = f32_field(p, "rotation")?;if rotation.is_some() && app.session.active_index().is_none() {return Err("no document open".into());}@@@ -2283,6 -2333,20 +2333,20 @@@ mod testsassert!(app.ui.color_panel.background, "a bad value changes nothing");}+ #[test]- fn ui_set_color_panel_slider_mode() {- use crate::state::ColorPanelSliderMode;++ fn ui_set_color_panel_mode() {++ use crate::state::ColorPanelMode;+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ let ctx = egui::Context::default();- assert_eq!(app.ui.color_panel.slider_mode, ColorPanelSliderMode::Hsb);- assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"slider_mode": "rgb"}}))["ok"], true);- assert_eq!(app.ui.color_panel.slider_mode, ColorPanelSliderMode::Rgb);- assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"slider_mode": "hsb"}}))["ok"], true);- assert_eq!(app.ui.color_panel.slider_mode, ColorPanelSliderMode::Hsb);- assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"slider_mode": "cmyk"}}))["ok"], false);- assert_eq!(app.ui.color_panel.slider_mode, ColorPanelSliderMode::Hsb);++ assert_eq!(app.ui.color_panel.mode, ColorPanelMode::HueCube);++ assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"mode": "rgbSliders"}}))["ok"], true);++ assert_eq!(app.ui.color_panel.mode, ColorPanelMode::RgbSliders);++ assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"mode": "hsbSliders"}}))["ok"], true);++ assert_eq!(app.ui.color_panel.mode, ColorPanelMode::HsbSliders);++ assert_eq!(call(&mut app, &ctx, "ui.set", json!({"colorPanel": {"mode": "nope"}}))["ok"], false);++ assert_eq!(app.ui.color_panel.mode, ColorPanelMode::HsbSliders);+ }+#[test]fn ui_set_unknown_theme_error_names_every_theme_and_each_name_works() {use crate::theme::ThemeKind;diff --cc crates/ui-egui/src/i18n/cs.tsvindex b3a430cbb,ab918f9b3..fdf788c06--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@@ -3862,23 -3904,9 +3904,27 @@@ navigator Zoom Zvětšen�DDS Options Možnosti DDSGenerate Mipmaps Generovat mipmapy+ # Color Table (.act) dialog+ There is no color table to save. Neexistuje žádná tabulka barev k uložení.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Uložena {n} barva do {file}|Uloženy {n} barvy do {file}|Uloženo {n} barev do {file}+# Graphics Adapter preference (#1885)GPU adapter Adaptér GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Krychle odstínu+ Brightness Cube Krychle jasu+ Color Wheel Barevné kolo+ Grayscale Slider Jezdec stupňů šedi+ RGB Sliders Jezdce RGB+ HSB Sliders Jezdce HSB+ CMYK Sliders Jezdce CMYK+ Lab Sliders Jezdce Lab+ Web Color Sliders Jezdce webových barev+ Copy Color as HTML Kopírovat barvu jako HTML+ Copy Color's Hex Code Kopírovat šestnáctkový kód barvy+ RGB Spectrum Spektrum RGB+ CMYK Spectrum Spektrum CMYK+ Grayscale Ramp Přechod stupňů šedi+ Current Colors Aktuální barvy+ Make Ramp Web Safe Omezit pruh na webové barvydiff --cc crates/ui-egui/src/i18n/de.tsvindex 37a16137a,2fae6d9de..36ebd46b5--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@@ -3257,23 -3302,9 +3302,27 @@@ curves Smooth GlätteCompression KomprimierungGenerate Mipmaps Mipmaps erzeugen+ # Color Table (.act) dialog+ There is no color table to save. Es gibt keine Farbtabelle zum Speichern.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} Farbe in {file} gespeichert|{n} Farben in {file} gespeichert+# Graphics Adapter preference (#1885)GPU adapter GPU-Adapter++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Farbtonwürfel+ Brightness Cube Helligkeitswürfel+ Color Wheel Farbkreis+ Grayscale Slider Graustufen-Regler+ RGB Sliders RGB-Regler+ HSB Sliders HSB-Regler+ CMYK Sliders CMYK-Regler+ Lab Sliders Lab-Regler+ Web Color Sliders Webfarben-Regler+ Copy Color as HTML Farbe als HTML kopieren+ Copy Color's Hex Code Hex-Code der Farbe kopieren+ RGB Spectrum RGB-Spektrum+ CMYK Spectrum CMYK-Spektrum+ Grayscale Ramp Graustufenbalken+ Current Colors Aktuelle Farben+ Make Ramp Web Safe Farbbalken auf Webfarben beschränkendiff --cc crates/ui-egui/src/i18n/el.tsvindex eb38f291c,588d9b909..791cb143e--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@@ -3954,22 -3993,9 +3993,26 @@@ curves Smooth Εξομάλυνσ�DDS Options Επιλογές DDSGenerate Mipmaps Δημιουργία mipmap+ # Color Table (.act) dialog+ There is no color table to save. Δεν υπάρχει πίνακας χρωμάτων για αποθήκευση.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Αποθηκεύτηκε {n} χρώμα στο {file}|Αποθηκεύτηκαν {n} χρώματα στο {file}+# Graphics Adapter preference (#1885)GPU adapter Προσαρμογέας GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Κύβος απόχρωσης+ Brightness Cube Κύβος φωτεινότητας+ Color Wheel Χρωματικός τροχός+ RGB Sliders Ρυθμιστικά RGB+ HSB Sliders Ρυθμιστικά HSB+ CMYK Sliders Ρυθμιστικά CMYK+ Lab Sliders Ρυθμιστικά Lab+ Web Color Sliders Ρυθμιστικά χρωμάτων ιστού+ Copy Color as HTML Αντιγραφή χρώματος ως HTML+ Copy Color's Hex Code Αντιγραφή δεκαεξαδικού κωδικού χρώματος+ RGB Spectrum Φάσμα RGB+ CMYK Spectrum Φάσμα CMYK+ Grayscale Ramp Διαβάθμιση του γκρι+ Current Colors Τρέχοντα χρώματα+ Make Ramp Web Safe Μόνο χρώματα ιστού στη διαβάθμισηdiff --cc crates/ui-egui/src/i18n/es.tsvindex e497472bb,5c51baa9f..3f1e900ac--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@@ -4216,22 -4255,9 +4255,26 @@@ navigator Zoom ZooDDS Options Opciones de DDSGenerate Mipmaps Generar mipmaps+ # Color Table (.act) dialog+ There is no color table to save. No hay ninguna tabla de colores para guardar.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Se guardó {n} color en {file}|Se guardaron {n} colores en {file}+# Graphics Adapter preference (#1885)GPU adapter Adaptador de GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Cubo de tono+ Brightness Cube Cubo de brillo+ Color Wheel Rueda de color+ RGB Sliders Reguladores RGB+ HSB Sliders Reguladores HSB+ CMYK Sliders Reguladores CMYK+ Lab Sliders Reguladores Lab+ Web Color Sliders Reguladores de colores web+ Copy Color as HTML Copiar color como HTML+ Copy Color's Hex Code Copiar código hexadecimal del color+ RGB Spectrum Espectro RGB+ CMYK Spectrum Espectro CMYK+ Grayscale Ramp Rampa de escala de grises+ Current Colors Colores actuales+ Make Ramp Web Safe Hacer rampa segura para webdiff --cc crates/ui-egui/src/i18n/fr.tsvindex 3b8ba6669,a8ffdcc6a..6891c8463--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@@ -3263,22 -3304,9 +3304,26 @@@ curves Smooth LisseCompression CompressionGenerate Mipmaps Générer les mipmaps+ # Color Table (.act) dialog+ There is no color table to save. Il n’y a aucune table de couleurs à enregistrer.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} couleur enregistrée dans {file}|{n} couleurs enregistrées dans {file}+# Graphics Adapter preference (#1885)GPU adapter Adaptateur GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Cube de teinte+ Brightness Cube Cube de luminosité+ Color Wheel Roue chromatique+ RGB Sliders Curseurs RVB+ HSB Sliders Curseurs TSL+ CMYK Sliders Curseurs CMJN+ Lab Sliders Curseurs Lab+ Web Color Sliders Curseurs de couleurs Web+ Copy Color as HTML Copier la couleur en HTML+ Copy Color's Hex Code Copier le code hexadécimal de la couleur+ RGB Spectrum Spectre RVB+ CMYK Spectrum Spectre CMJN+ Grayscale Ramp Barre de niveaux de gris+ Current Colors Couleurs actuelles+ Make Ramp Web Safe Limiter la barre aux couleurs Webdiff --cc crates/ui-egui/src/i18n/hu.tsvindex c0e1d11eb,a7ed13c5c..a57ec1de9--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@@ -4173,22 -4210,9 +4210,26 @@@ cameraRaw Yellow SárgDDS Options DDS-beállításokGenerate Mipmaps Mipmapek létrehozása+ # Color Table (.act) dialog+ There is no color table to save. Nincs menthető színtábla.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} szín mentve ide: {file}+# Graphics Adapter preference (#1885)GPU adapter GPU-adapter++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Színárnyalat-kocka+ Brightness Cube Fényerő-kocka+ Color Wheel Színkör+ RGB Sliders RGB-csúszkák+ HSB Sliders HSB-csúszkák+ CMYK Sliders CMYK-csúszkák+ Lab Sliders Lab-csúszkák+ Web Color Sliders Webes színek csúszkái+ Copy Color as HTML Szín másolása HTML-ként+ Copy Color's Hex Code Szín hexadecimális kódjának másolása+ RGB Spectrum RGB-spektrum+ CMYK Spectrum CMYK-spektrum+ Grayscale Ramp Szürkeárnyalatos sáv+ Current Colors Aktuális színek+ Make Ramp Web Safe Sáv korlátozása webes színekrediff --cc crates/ui-egui/src/i18n/id.tsvindex df209e84f,2e6239038..8a13a38ca--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@@ -3250,22 -3291,9 +3291,26 @@@ curves Smooth HaluskaCompression KompresiGenerate Mipmaps Buat mipmap+ # Color Table (.act) dialog+ There is no color table to save. Tidak ada tabel warna untuk disimpan.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} warna disimpan ke {file}+# Graphics Adapter preference (#1885)GPU adapter Adaptor GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Kubus Hue+ Brightness Cube Kubus Kecerahan+ Color Wheel Roda Warna+ RGB Sliders Slider RGB+ HSB Sliders Slider HSB+ CMYK Sliders Slider CMYK+ Lab Sliders Slider Lab+ Web Color Sliders Slider Warna Web+ Copy Color as HTML Salin Warna sebagai HTML+ Copy Color's Hex Code Salin Kode Hex Warna+ RGB Spectrum Spektrum RGB+ CMYK Spectrum Spektrum CMYK+ Grayscale Ramp Gradasi Grayscale+ Current Colors Warna Saat Ini+ Make Ramp Web Safe Jadikan Gradasi Aman untuk Webdiff --cc crates/ui-egui/src/i18n/it.tsvindex e1c0ea9cb,b029b6aea..ce86bfa95--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@@ -4371,22 -4410,9 +4410,26 @@@ shape Appearance AspettDDS Options Opzioni DDSGenerate Mipmaps Genera mipmap+ # Color Table (.act) dialog+ There is no color table to save. Non c'è alcuna tabella colori da salvare.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Salvato {n} colore in {file}|Salvati {n} colori in {file}+# Graphics Adapter preference (#1885)GPU adapter Adattatore GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Cubo tonalità+ Brightness Cube Cubo luminosità+ Color Wheel Ruota dei colori+ RGB Sliders Cursori RGB+ HSB Sliders Cursori HSB+ CMYK Sliders Cursori CMYK+ Lab Sliders Cursori Lab+ Web Color Sliders Cursori colori web+ Copy Color as HTML Copia colore come HTML+ Copy Color's Hex Code Copia codice esadecimale del colore+ RGB Spectrum Spettro RGB+ CMYK Spectrum Spettro CMYK+ Grayscale Ramp Barra scala di grigio+ Current Colors Colori correnti+ Make Ramp Web Safe Limita la barra ai colori webdiff --cc crates/ui-egui/src/i18n/ja.tsvindex 553f9cb6d,5602f7a91..836063ad7--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@@ -3932,22 -3971,9 +3971,26 @@@ curves Smooth スムー�Compression 圧縮Generate Mipmaps ミップマップを生成+ # Color Table (.act) dialog+ There is no color table to save. 保存するカラーテーブルがありません。+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {file} に {n} 色を保存しました+# Graphics Adapter preference (#1885)GPU adapter GPU アダプター++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube 色相キューブ+ Brightness Cube 明るさキューブ+ Color Wheel カラーホイール+ RGB Sliders RGB スライダー+ HSB Sliders HSB スライダー+ CMYK Sliders CMYK スライダー+ Lab Sliders Lab スライダー+ Web Color Sliders Web カラースライダー+ Copy Color as HTML カラーを HTML としてコピー+ Copy Color's Hex Code カラーの 16 進コードをコピー+ RGB Spectrum RGB スペクトル+ CMYK Spectrum CMYK スペクトル+ Grayscale Ramp グレースケールランプ+ Current Colors 現在のカラー+ Make Ramp Web Safe ランプを Web セーフにするdiff --cc crates/ui-egui/src/i18n/ko.tsvindex a816ba73b,4e355a66d..5dd4f84f2--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@@ -3438,23 -3483,9 +3483,27 @@@ curves Smooth 매끄럽�Compression 압축Generate Mipmaps 밉맵 생성+ # Color Table (.act) dialog+ There is no color table to save. 저장할 색상표가 없습니다.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {file}에 색상 {n}개 저장+# Graphics Adapter preference (#1885)GPU adapter GPU 어댑터++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube 색조 큐브+ Brightness Cube 밝기 큐브+ Color Wheel 색상환+ Grayscale Slider 회색 음영 슬라이더+ RGB Sliders RGB 슬라이더+ HSB Sliders HSB 슬라이더+ CMYK Sliders CMYK 슬라이더+ Lab Sliders Lab 슬라이더+ Web Color Sliders 웹 색상 슬라이더+ Copy Color as HTML 색상을 HTML로 복사+ Copy Color's Hex Code 색상의 16진수 코드 복사+ RGB Spectrum RGB 스펙트럼+ CMYK Spectrum CMYK 스펙트럼+ Grayscale Ramp 회색 음영 램프+ Current Colors 현재 색상+ Make Ramp Web Safe 램프를 웹 안전 색상으로 만들기diff --cc crates/ui-egui/src/i18n/nl.tsvindex 73582802d,dedcfa112..d7ed2070c--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@@ -4014,22 -4053,9 +4053,26 @@@ curves Smooth Vloeiend makeDDS Options DDS-optiesGenerate Mipmaps Mipmaps genereren+ # Color Table (.act) dialog+ There is no color table to save. Er is geen kleurtabel om op te slaan.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} kleur opgeslagen in {file}|{n} kleuren opgeslagen in {file}+# Graphics Adapter preference (#1885)GPU adapter GPU-adapter++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Kleurtoonkubus+ Brightness Cube Helderheidskubus+ Color Wheel Kleurenwiel+ RGB Sliders RGB-schuifregelaars+ HSB Sliders HSB-schuifregelaars+ CMYK Sliders CMYK-schuifregelaars+ Lab Sliders Lab-schuifregelaars+ Web Color Sliders Webkleurschuifregelaars+ Copy Color as HTML Kleur kopiëren als HTML+ Copy Color's Hex Code Hexadecimale code van kleur kopiëren+ RGB Spectrum RGB-spectrum+ CMYK Spectrum CMYK-spectrum+ Grayscale Ramp Grijswaardenbalk+ Current Colors Huidige kleuren+ Make Ramp Web Safe Balk beperken tot webkleurendiff --cc crates/ui-egui/src/i18n/pl.tsvindex 2955276ea,9790e2625..6ea307a74--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@@ -3854,22 -3893,9 +3893,26 @@@ curves Smooth Wygład�Compression KompresjaGenerate Mipmaps Generuj mipmapy+ # Color Table (.act) dialog+ There is no color table to save. Brak tabeli kolorów do zapisania.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Zapisano {n} kolor do {file}|Zapisano {n} kolory do {file}|Zapisano {n} kolorów do {file}+# Graphics Adapter preference (#1885)GPU adapter Karta GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Sześcian odcienia+ Brightness Cube Sześcian jasności+ Color Wheel Koło kolorów+ RGB Sliders Suwaki RGB+ HSB Sliders Suwaki HSB+ CMYK Sliders Suwaki CMYK+ Lab Sliders Suwaki Lab+ Web Color Sliders Suwaki kolorów internetowych+ Copy Color as HTML Kopiuj kolor jako HTML+ Copy Color's Hex Code Kopiuj kod szesnastkowy koloru+ RGB Spectrum Widmo RGB+ CMYK Spectrum Widmo CMYK+ Grayscale Ramp Pasek skali szarości+ Current Colors Bieżące kolory+ Make Ramp Web Safe Ogranicz pasek do kolorów internetowychdiff --cc crates/ui-egui/src/i18n/pt-br.tsvindex 863ae11a4,8d9db9079..e6c1aeb49--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@@ -4044,22 -4083,9 +4083,26 @@@ layerLabel No Color Sem coDDS Options Opções de DDSGenerate Mipmaps Gerar mipmaps+ # Color Table (.act) dialog+ There is no color table to save. Não há tabela de cores para salvar.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} cor salva em {file}|{n} cores salvas em {file}+# Graphics Adapter preference (#1885)GPU adapter Adaptador de GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Cubo de matiz+ Brightness Cube Cubo de brilho+ Color Wheel Roda de cores+ RGB Sliders Controles deslizantes RGB+ HSB Sliders Controles deslizantes HSB+ CMYK Sliders Controles deslizantes CMYK+ Lab Sliders Controles deslizantes Lab+ Web Color Sliders Controles deslizantes de cores da Web+ Copy Color as HTML Copiar cor como HTML+ Copy Color's Hex Code Copiar código hexadecimal da cor+ RGB Spectrum Espectro RGB+ CMYK Spectrum Espectro CMYK+ Grayscale Ramp Rampa de tons de cinza+ Current Colors Cores atuais+ Make Ramp Web Safe Tornar rampa segura para a Webdiff --cc crates/ui-egui/src/i18n/ru.tsvindex ab4de0922,2fcf5f5f1..f434f5ac0--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@@ -3229,22 -3271,9 +3271,26 @@@ curves Smooth Сгладит�Compression СжатиеGenerate Mipmaps Создать MIP-карты+ # Color Table (.act) dialog+ There is no color table to save. Нет таблицы цветов для сохранения.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Сохранён {n} цвет в {file}|Сохранены {n} цвета в {file}|Сохранено {n} цветов в {file}+# Graphics Adapter preference (#1885)GPU adapter Адаптер GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Куб цветового тона+ Brightness Cube Куб яркости+ Color Wheel Цветовой круг+ RGB Sliders Ползунки RGB+ HSB Sliders Ползунки HSB+ CMYK Sliders Ползунки CMYK+ Lab Sliders Ползунки Lab+ Web Color Sliders Ползунки web-цветов+ Copy Color as HTML Копировать цвет как HTML+ Copy Color's Hex Code Копировать шестнадцатеричный код цвета+ RGB Spectrum Спектр RGB+ CMYK Spectrum Спектр CMYK+ Grayscale Ramp Шкала градаций серого+ Current Colors Текущие цвета+ Make Ramp Web Safe Сделать шкалу безопасной для webdiff --cc crates/ui-egui/src/i18n/sr.tsvindex b4990bfde,43a05378e..a2e74385f--- a/crates/ui-egui/src/i18n/sr.tsv+++ b/crates/ui-egui/src/i18n/sr.tsv@@@ -4327,22 -4364,9 +4364,26 @@@ shape Appearance IzgleDDS Options DDS opcijeGenerate Mipmaps Generiši mipmape+ # Color Table (.act) dialog+ There is no color table to save. Нема табеле боја за чување.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Сачувана је {n} боја у {file}|Сачуване су {n} боје у {file}|Сачувано је {n} боја у {file}+# Graphics Adapter preference (#1885)GPU adapter GPU adapter++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Kocka nijanse+ Brightness Cube Kocka osvetljenosti+ Color Wheel Točak boja+ RGB Sliders RGB klizači+ HSB Sliders HSB klizači+ CMYK Sliders CMYK klizači+ Lab Sliders Lab klizači+ Web Color Sliders Klizači veb boja+ Copy Color as HTML Kopiraj boju kao HTML+ Copy Color's Hex Code Kopiraj heksadecimalni kod boje+ RGB Spectrum RGB spektar+ CMYK Spectrum CMYK spektar+ Grayscale Ramp Skala nijansi sive+ Current Colors Trenutne boje+ Make Ramp Web Safe Učini skalu bezbednom za vebdiff --cc crates/ui-egui/src/i18n/tr.tsvindex f5a3a2a2c,37667e447..f7ce2d0d4--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@@ -3984,22 -4021,9 +4021,26 @@@ cameraData Lens LenDDS Options DDS SeçenekleriGenerate Mipmaps Mipmap oluştur+ # Color Table (.act) dialog+ There is no color table to save. Kaydedilecek renk tablosu yok.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} renk {file} konumuna kaydedildi+# Graphics Adapter preference (#1885)GPU adapter GPU bağdaştırıcısı++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Renk Tonu Küpü+ Brightness Cube Parlaklık Küpü+ Color Wheel Renk Çarkı+ RGB Sliders RGB Kaydırıcıları+ HSB Sliders HSB Kaydırıcıları+ CMYK Sliders CMYK Kaydırıcıları+ Lab Sliders Lab Kaydırıcıları+ Web Color Sliders Web Rengi Kaydırıcıları+ Copy Color as HTML Rengi HTML Olarak Kopyala+ Copy Color's Hex Code Rengin Onaltılık Kodunu Kopyala+ RGB Spectrum RGB Spektrumu+ CMYK Spectrum CMYK Spektrumu+ Grayscale Ramp Gri Tonlama Şeridi+ Current Colors Geçerli Renkler+ Make Ramp Web Safe Şeridi Web Renkleriyle Sınırladiff --cc crates/ui-egui/src/i18n/uk.tsvindex 804188959,a57695407..4952864b1--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@@ -3963,22 -4002,9 +4002,26 @@@ curves Smooth Згладит�Compression СтисненняGenerate Mipmaps Створити MIP-карти+ # Color Table (.act) dialog+ There is no color table to save. Немає таблиці кольорів для збереження.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Збережено {n} колір у {file}|Збережено {n} кольори у {file}|Збережено {n} кольорів у {file}+# Graphics Adapter preference (#1885)GPU adapter Адаптер GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Куб тону+ Brightness Cube Куб яскравості+ Color Wheel Колірне коло+ RGB Sliders Повзунки RGB+ HSB Sliders Повзунки HSB+ CMYK Sliders Повзунки CMYK+ Lab Sliders Повзунки Lab+ Web Color Sliders Повзунки вебкольорів+ Copy Color as HTML Копіювати колір як HTML+ Copy Color's Hex Code Копіювати шістнадцятковий код кольору+ RGB Spectrum Спектр RGB+ CMYK Spectrum Спектр CMYK+ Grayscale Ramp Шкала градацій сірого+ Current Colors Поточні кольори+ Make Ramp Web Safe Зробити шкалу безпечною для вебуdiff --cc crates/ui-egui/src/i18n/vi.tsvindex b8385bee5,3a9585111..0eda1aaee--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@@ -3742,23 -3784,9 +3784,27 @@@ curves Smooth Làm mượCompression NénGenerate Mipmaps Tạo mipmap+ # Color Table (.act) dialog+ There is no color table to save. Không có bảng màu nào để lưu.+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Đã lưu {n} màu vào {file}+# Graphics Adapter preference (#1885)GPU adapter Bộ điều hợp GPU++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube Khối sắc màu+ Brightness Cube Khối độ sáng+ Color Wheel Bánh xe màu+ Grayscale Slider Thanh trượt thang xám+ RGB Sliders Thanh trượt RGB+ HSB Sliders Thanh trượt HSB+ CMYK Sliders Thanh trượt CMYK+ Lab Sliders Thanh trượt Lab+ Web Color Sliders Thanh trượt màu web+ Copy Color as HTML Sao chép màu dạng HTML+ Copy Color's Hex Code Sao chép mã hex của màu+ RGB Spectrum Phổ RGB+ CMYK Spectrum Phổ CMYK+ Grayscale Ramp Dải thang xám+ Current Colors Màu hiện tại+ Make Ramp Web Safe Giới hạn dải màu ở màu webdiff --cc crates/ui-egui/src/i18n/zh-hans.tsvindex 3f4f4b381,4c3611ba6..0255bd4ff--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@@ -2880,23 -2928,9 +2928,27 @@@ curves Smooth 平�Compression 压缩Generate Mipmaps 生成 Mipmap+ # Color Table (.act) dialog+ There is no color table to save. 没有可保存的色表。+ @plural Saved {n} color to {file}|Saved {n} colors to {file} 已将 {n} 种颜色保存到 {file}+# Graphics Adapter preference (#1885)GPU adapter GPU 适配器++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube 色相立方体+ Brightness Cube 亮度立方体+ Color Wheel 色轮+ Grayscale Slider 灰度滑块+ RGB Sliders RGB 滑块+ HSB Sliders HSB 滑块+ CMYK Sliders CMYK 滑块+ Lab Sliders Lab 滑块+ Web Color Sliders Web 颜色滑块+ Copy Color as HTML 将颜色复制为 HTML+ Copy Color's Hex Code 复制颜色的十六进制代码+ RGB Spectrum RGB 色谱+ CMYK Spectrum CMYK 色谱+ Grayscale Ramp 灰度色带+ Current Colors 当前颜色+ Make Ramp Web Safe 使色带成为 Web 安全色diff --cc crates/ui-egui/src/i18n/zh-hant.tsvindex 97a97d201,f19dd6e37..72d50a4f4--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@@ -2865,23 -2913,9 +2913,27 @@@ curves Smooth 平�Compression 壓縮Generate Mipmaps 產生 Mipmap+ # Color Table (.act) dialog+ There is no color table to save. 沒有可儲存的色表。+ @plural Saved {n} color to {file}|Saved {n} colors to {file} 已將 {n} 種顏色儲存至 {file}+# Graphics Adapter preference (#1885)GPU adapter GPU 介面卡++# Color panel menu: modes, copy commands and colour ramps (#6000)+ Hue Cube 色相立方體+ Brightness Cube 亮度立方體+ Color Wheel 色輪+ Grayscale Slider 灰階滑桿+ RGB Sliders RGB 滑桿+ HSB Sliders HSB 滑桿+ CMYK Sliders CMYK 滑桿+ Lab Sliders Lab 滑桿+ Web Color Sliders 網頁色彩滑桿+ Copy Color as HTML 將色彩複製為 HTML+ Copy Color's Hex Code 複製色彩的十六進位碼+ RGB Spectrum RGB 色譜+ CMYK Spectrum CMYK 色譜+ Grayscale Ramp 灰階色帶+ Current Colors 目前色彩+ Make Ramp Web Safe 讓色帶成為網頁安全色diff --cc crates/ui-egui/src/lib.rsindex 51bd4c890,6f54ed161..7d512eabc--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@@ -56,9 -57,9 +57,10 @@@ pub mod channels_panelpub mod chrome_ui;pub mod cjk_fonts;pub mod clip_line_ui;+pub mod color_panel_ui;pub mod color_picker_ui;pub mod color_range_ui;+ pub mod color_table_ui;pub mod comps_ui;pub mod control;pub mod corner_radius;diff --cc crates/ui-egui/src/panels.rsindex fd0be9e7c,78c4a65a4..c91634ef6--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@@ -3983,13 -4226,14 +4144,14 @@@ pub(crate) fn srgb_bytes(c: [f32; 4]) -/// The Color panel's HSB, as Photoshop's and the Color Picker's: on the sRGB-encoded values,/// so a 50% grey has Brightness 50%. egui's `Hsva` conversions work in linear light, which put/// that grey at 22% and drew the field's middle as 188 (#3323); `Hsva` only holds the numbers.-fn srgb_hsva(c: [f32; 4]) -> egui::ecolor::Hsva {+pub(crate) fn srgb_hsva(c: [f32; 4]) -> egui::ecolor::Hsva {- let [h, s, v] = crate::color_picker_ui::rgb_to_hsv([c[0], c[1], c[2]].map(|v| v.clamp(0.0, 1.0)));+ let [h, s, v] = photocraft_color::convert::rgb_to_hsb([c[0], c[1], c[2]].map(|v| v.clamp(0.0, 1.0)));egui::ecolor::Hsva::new(h / 360.0, s, v, 1.0)}+ /// The inverse of srgb_hsva: the Color panel's HSB back to sRGB-encoded values.-fn hsva_srgb(h: egui::ecolor::Hsva) -> [f32; 4] {+pub(crate) fn hsva_srgb(h: egui::ecolor::Hsva) -> [f32; 4] {- let [r, g, b] = crate::color_picker_ui::hsv_to_rgb(h.h * 360.0, h.s.clamp(0.0, 1.0), h.v.clamp(0.0, 1.0));+ let [r, g, b] = photocraft_color::convert::hsb_to_rgb([h.h * 360.0, h.s.clamp(0.0, 1.0), h.v.clamp(0.0, 1.0)]);[r, g, b, 1.0]}@@@ -4552,6 -4806,26 +4724,7 @@@ mod color_tests}}- #[test]- fn rgb_slider_mode_shows_red_green_blue_rows() {- use egui_kittest::kittest::Queryable;- let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());- app.ui.color_panel.slider_mode = ColorPanelSliderMode::Rgb;- let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 360.0)).build_ui_state(- |ui, app: &mut PhotocraftApp| {- if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {- color_picker(app, ui);- }- },- app,- );- PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::Studio);- h.run_steps(2);- for label in ["Red", "Green", "Blue"] {- h.get_by_label(label);- }- }+/// The Color panel's hex readout is editable, with or without the leading `#`.#[test]fn color_panel_hex_field_takes_a_typed_hex() {diff --cc docs/gaps.mdindex 5d6030c2a,9b281d678..9825e3c19--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -1,6 -1,6 +1,6 @@@# Where PhotoCraft falls short of Photoshop- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** minor (G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impacton the way to beta. This is the work list agents pick from: take the highest-ranked entry that@@@ -199,13 -204,14 +204,16 @@@ what an agent can't finish alone- **Estimate:** 60–110 h.### G9. Panels, preferences and workspace+ - **Progress (2026-10-15):** Preferences › General › Animated Zoom takes effect: a held Zoom+ tool press zooms continuously about the press point, ⌥ out (#6210, `ui-egui/src/zoom_hold.rs`).- **Progress (2026-10-12):** toolbar tool shortcuts can be reassigned, removed and reset (#4086),with saved bindings, matching toolbar hints and regression coverage (`ui-egui/src/tool_shortcuts.rs`).+- **Progress (2026-10-15):** the Color panel has Photoshop's panel-menu modes (Hue Cube, Brightness+ Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web Color sliders), its colour ramp and copy+ commands, the same in every theme (UI-217-17, #2569, #6000; `ui-egui/src/color_panel_ui.rs`).- - **Missing:** 27 of 156 preferences do nothing (scorecard prefs audit); panel groups can't+ - **Missing:** 24 of 171 preferences do nothing (scorecard prefs audit, 2026-10-15: Save in+ Background now takes effect, #6207); panel groups can't- float or tear off into OS windows (UI-217-5, #1828, #1213, #2305); Color panel lacks wheel and- slider modes (UI-217-17, #2569); more themes (UI-217-11, #2661); a single pixel layer+ float or tear off into OS windows (UI-217-5, #1828, #1213, #2305); more themes (UI-217-11, #2661); a single pixel layercopies without its mask and styles (UI-217-23; fill and adjustment layers copy whole, #2344); tool-specific context menus beyond brushes, selections and Pen([context-menu-parity.md](context-menu-parity.md)); Libraries, Comments, Contextual Task Barpanels.@@@ -276,9 -290,12 +292,13 @@@| Date | Change | Summary ||---|---|---|+| 2026-10-19 | minor | G9: Color panel modes, ramp and copy commands from its panel menu, the same in every theme (UI-217-17 done, #6000) || 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open || 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged |+ | 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms; local runs, baseline not re-run), the uncancelled job on a locked-transparency layer about 40% faster; #6205 |+ | 2026-10-15 | minor | G9: Animated Zoom preference takes effect (hold the Zoom tool to zoom continuously, #6210); prefs that do nothing 25 of 166; no estimate changed |+ | 2026-10-16 | minor | G7: Content-Aware Move's live preview covers every selection the command takes (over 256 × 256: a coarse result solved scaled down, then the exact one); TOOL-213-4 done (#6680) |+ | 2026-10-15 | minor | G9: Save in Background off saves in the foreground under a modal progress dialog (#6207); preferences that do nothing 25 → 24 of 169 || 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 || 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open || 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |diff --cc docs/scorecard.mdindex 477b68c81,9fd35b7e2..ed53773cf--- a/docs/scorecard.md+++ b/docs/scorecard.md@@@ -6,11 -6,11 +6,11 @@@ Generated by `cargo xtask scorecard` fr| Area | Done | Partial | Missing | Key numbers ||---|---:|---:|---:|---|- | [Performance](#performance) | 3 | 22 | 25 | 59 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 20 not run, 5 not measurable yet (baseline 2026-10-05) |- | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 |- | [Tools](#tools) | 33 | 11 | 0 | |- | [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 26 of 170 (target 0) |- | [Type](#type) | 4 | 3 | 2 | |+ | [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) |+ | [File compatibility](#file-compatibility) | 9 | 12 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 |+ | [Tools](#tools) | 36 | 8 | 0 | |-| [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 24 of 171 (target 0) |++| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 24 of 171 (target 0) |+ | [Type](#type) | 5 | 3 | 1 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present || [Distribution](#distribution) | 5 | 4 | 2 | |@@@ -201,9 -202,9 +202,9 @@@ Unread: `general.color_picker`, `genera| 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-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | done | [#217](https://github.com/storytold/photocraft/issues/217) | color_panel_ui.rs: Hue/Brightness Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web sliders, ramp; the same in every theme (#6000); color_panel_tests.rs |- | 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-18 | Alt+wheel zooms in gentle ~5 % steps; zoom controls uncramped | partial | [#217](https://github.com/storytold/photocraft/issues/217) | Alt+wheel zooms around the pointer, one step per notch applied the frame it arrives (wheel_nav.rs:94; input_tests.rs:443 alt_scroll_zooms_in_steps_around_the_pointer, wheel_nav.rs:448 alt_scroll_zooms_ten_percent_per_notch), but the step is x1.1 (10 %), not the ~5 % this row asks for: #1718 changed it from x1.05 after measuring Photoshop, so the row's target is in question. Status bar zoom field and Fit button fit inside the bar in every theme (status_bar_tests.rs:39 status_bar_controls_sit_inside_the_bar_with_even_margins, #2823); the Navigator zoom controls are not checked || 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 || UI-217-20 | 'Show rulers in new documents' preference; guides stored as f64 | done | [#217](https://github.com/storytold/photocraft/issues/217) | View › Rulers is remembered in unitsAndRulers.showRulers and applied at launch and on change (#2918; rulers_open_as_last_set_after_a_restart); doc Guides are Vec<f64> through New Guide, .pcraft and PSD 1032 (guides_keep_sub_pixel_positions_through_pcraft_and_psd) || UI-217-21 | One Preset Manager for every preset kind with folders, search, reorder, load/save sets | partial | [#217](https://github.com/storytold/photocraft/issues/217) | edit_menu_cmds.rs:714 covers brushes, custom shapes, patterns with reorder |diff --cc docs/ui-parity.mdindex 306fd662e,59d05d1e4..ad431018d--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@@ -1,6 -1,6 +1,6 @@@# UI parity: tools, handles, modifiers and feel- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (Pen Auto Add/Delete on the path being drawn, #6140; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,