PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Layer Mask Display Options: set the layer mask rubylith's colour and opacity
Trade-Mottoes8c9c5fccf880
diff --git a/crates/engine/src/channel_cmds.rs b/crates/engine/src/channel_cmds.rsindex 468db2698..f54ae8175 100644--- a/crates/engine/src/channel_cmds.rs+++ b/crates/engine/src/channel_cmds.rs@@ -1425,6 +1425,7 @@ fn options(s: &mut Session, p: &Value) -> Result<Value> {let opacity = p.get("opacity").and_then(Value::as_f64).map(|v| (v as f32 / 100.0).clamp(0.0, 1.0));let solidity = p.get("solidity").and_then(Value::as_f64).map(|v| (v as f32 / 100.0).clamp(0.0, 1.0));let kind = p.get("indicates").and_then(Value::as_str).map(str::to_string);+ let display_only = name.is_none() && kind.is_none() && solidity.is_none();let apply = move |ch: &mut AlphaChannel| -> Result<()> {if let Some(n) = &name {ch.name = n.clone();@@ -1493,7 +1494,31 @@ fn options(s: &mut Session, p: &Value) -> Result<Value> {})?;}}- _ => return Err(bad(cmd, "`channel` must be an alpha/spot channel or \"quickMask\"")),+ ChanRef::LayerMask => {+ // Layer Mask Display Options: only the rubylith's colour and opacity, for every mask.+ if !display_only {+ return Err(bad(cmd, "a layer mask's options are only `color` and `opacity`"));+ }+ // A preference, kept across restarts; not an undo step.+ if color.is_some() || opacity.is_some() {+ s.edit_prefs(|prefs| {+ let o = &mut prefs.layer_mask_overlay;+ if let Some(c) = color {+ o.color = crate::adjust_params::hex(c.to_rgb());+ }+ if let Some(a) = opacity {+ o.opacity = (a * 100.0).round();+ }+ });+ }+ let o = serde_json::to_value(&s.prefs().layer_mask_overlay).unwrap_or(Value::Null);+ let mut out = list(s);+ if let Some(m) = out.as_object_mut() {+ m.insert("layerMaskOverlay".into(), o);+ }+ return Ok(out);+ }+ _ => return Err(bad(cmd, "`channel` must be an alpha/spot channel, \"quickMask\" or \"mask\"")),}Ok(list(s))}@@ -1890,7 +1915,7 @@ pub fn specs() -> Vec<CommandSpec> {"Channel Options…",[],None,- r##"{"channel":index|name|"quickMask","name":str?,"indicates":"masked|selected|spot"?,"color":"#rrggbb"?,"opacity":0..100?,"solidity":0..100?}"##,+ r##"{"channel":index|name|"quickMask"|"mask","name":str?,"indicates":"masked|selected|spot"?,"color":"#rrggbb"?,"opacity":0..100?,"solidity":0..100?} ("mask": Layer Mask Display Options, the rubylith's color and opacity for every layer mask, kept in the preferences as layerMaskOverlay; not an undo step; returns them as layerMaskOverlay)"##,has_doc,options),diff --git a/crates/engine/src/channel_cmds/tests.rs b/crates/engine/src/channel_cmds/tests.rsindex d63dc5fd0..9cb541656 100644--- a/crates/engine/src/channel_cmds/tests.rs+++ b/crates/engine/src/channel_cmds/tests.rs@@ -401,6 +401,41 @@ fn quick_mask_without_selection_and_options() {assert!(sel_at(&s, 10, 10) < 0.05 && sel_at(&s, 30, 10) > 0.99, "{} {}", sel_at(&s, 10, 10), sel_at(&s, 30, 10));}+/// Layer Mask Display Options: `channel.options` on `"mask"` sets the rubylith's colour and+/// opacity for every mask. They're a preference (kept across restarts, as in Photoshop), not an+/// undo step, and come back in the result.+#[test]+fn layer_mask_display_options() {+ let mut s = session();+ let o = || crate::prefs::LayerMaskOverlay::default();+ assert_eq!(s.prefs().layer_mask_overlay, o());+ assert_eq!((o().rgb(), o().alpha()), ([1.0, 0.0, 0.0], 0.5));+ let hist = s.active().unwrap().history.entries().len();+ let r = s.execute("channel.options", json!({"channel": "mask", "color": "#00ff00", "opacity": 30})).unwrap();+ assert_eq!(r["layerMaskOverlay"], json!({"color": "#00ff00", "opacity": 30.0}));+ assert_eq!(s.execute("prefs.get", json!({"path": "layerMaskOverlay"})).unwrap(), json!({"color": "#00ff00", "opacity": 30.0}));+ assert_eq!(s.active().unwrap().history.entries().len(), hist, "not an undo step");+ // Just one of them leaves the other; no fields reads them back; out of range clamps.+ s.execute("channel.options", json!({"channel": "mask", "opacity": 250})).unwrap();+ let r = s.execute("channel.options", json!({"channel": "layerMask"})).unwrap();+ assert_eq!(r["layerMaskOverlay"], json!({"color": "#00ff00", "opacity": 100.0}));+ // A layer mask has no name, Color Indicates or solidity here.+ for bad in [json!({"name": "x"}), json!({"indicates": "selected"}), json!({"indicates": "spot"}), json!({"solidity": 20})] {+ let mut p = bad.clone();+ p["channel"] = json!("mask");+ assert!(s.execute("channel.options", p).is_err(), "{bad}");+ }+ assert_eq!(s.prefs().layer_mask_overlay.opacity, 100.0, "a refused call changes nothing");+ // prefs.set validates them like other preferences; prefs.reset restores red at 50 %.+ assert!(s.execute("prefs.set", json!({"path": "layerMaskOverlay.color", "value": "green"})).is_err());+ assert!(s.execute("prefs.set", json!({"path": "layerMaskOverlay.opacity", "value": 101})).is_err());+ s.execute("prefs.reset", json!({"path": "layerMaskOverlay"})).unwrap();+ assert_eq!(s.prefs().layer_mask_overlay, o());+ // A hand-edited settings file can't break the view.+ let odd = crate::prefs::LayerMaskOverlay { color: "nope".into(), opacity: f32::NAN };+ assert_eq!((odd.rgb(), odd.alpha()), ([1.0, 0.0, 0.0], 0.5));+}+/// Overlay coverage of the live Quick Mask at (x, y): how much colour the canvas shows there.fn qm_overlay(s: &Session, x: i32, y: i32) -> f32 {let q = doc(s).quick_mask.as_ref().unwrap();diff --git a/crates/engine/src/mask_view_cmds.rs b/crates/engine/src/mask_view_cmds.rsindex d7cfc338c..403a6a0a4 100644--- a/crates/engine/src/mask_view_cmds.rs+++ b/crates/engine/src/mask_view_cmds.rs@@ -160,7 +160,7 @@ pub fn specs() -> Vec<CommandSpec> {label: "Toggle Layer Mask Overlay",menu: &[],shortcut: Some("\\"),- params: r##"{"layer":id?} (shows or hides the active layer's mask as a 50% red rubylith over the composite, the `\` key; view state, not an undo step; painting while shown paints the mask)"##,+ params: r##"{"layer":id?} (shows or hides the active layer's mask as a rubylith over the composite, the `\` key; red at 50% unless Layer Mask Display Options, channel.options {"channel":"mask"}, set it; view state, not an undo step; painting while shown paints the mask)"##,enabled: active_has_mask,run: toggle_overlay,journal: false,diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex 2c2507226..da3dcd6a8 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -920,6 +920,37 @@ pub struct ToolbarCustomization {pub order: Vec<String>,}+/// Layer Mask Display Options (double-click the layer mask's row in the Channels panel, or Mask+/// Options… on its Layers thumbnail): the colour and opacity of the layer mask rubylith (`\`,+/// ⇧⌥-click the thumbnail). As in Photoshop, one setting for every mask, kept across restarts.+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]+#[serde(default, rename_all = "camelCase")]+pub struct LayerMaskOverlay {+ /// `#rrggbb`.+ pub color: String,+ /// Percent, 0..=100.+ pub opacity: f32,+}++impl Default for LayerMaskOverlay {+ /// Photoshop's: red at 50 %.+ fn default() -> Self {+ Self { color: "#ff0000".into(), opacity: 50.0 }+ }+}++impl LayerMaskOverlay {+ /// The colour as 0..1 RGB; red if the stored value isn't a colour.+ pub fn rgb(&self) -> [f32; 3] {+ parse_hex(&self.color).unwrap_or([255, 0, 0]).map(|v| f32::from(v) / 255.0)+ }++ /// The opacity as a fraction (0..1); 50 % if the stored value isn't a number.+ pub fn alpha(&self) -> f32 {+ if self.opacity.is_finite() { self.opacity.clamp(0.0, 100.0) / 100.0 } else { 0.5 }+ }+}+/// All preferences. JSON keys are the `edit.preferences.<section>` ids.#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]#[serde(default, rename_all = "camelCase")]@@ -991,6 +1022,8 @@ pub struct Preferences {pub view_extras: Value,/// File › Scripts › Script Events Manager: event → script bindings.pub script_events: crate::automate_cmds::ScriptEvents,+ /// Layer Mask Display Options: the layer mask rubylith's colour and opacity.+ pub layer_mask_overlay: LayerMaskOverlay,}/// Preferences dialog sections in Photoshop's order: (id, title).@@ -1122,6 +1155,7 @@ pub fn range(path: &str) -> Option<(f64, f64)> {"unitsAndRulers.printResolution" | "unitsAndRulers.screenResolution" | "rawDefaults.resolution" => (1.0, 10_000.0),"guidesGridAndSlices.gridlineEvery" => (0.001, 10_000.0),"guidesGridAndSlices.subdivisions" => (1.0, 100.0),+ "layerMaskOverlay.opacity" => (0.0, 100.0),"type.recentFonts" => (0.0, 50.0),"integrations.controlPort" => (0.0, 65535.0),_ => return None,@@ -1133,6 +1167,9 @@ pub fn is_color(path: &str) -> bool {if choices(path).is_some() || path.starts_with("shortcuts.") || path.starts_with("alternateShortcuts.") || path.starts_with("menus.") {return false;}+ if path == "layerMaskOverlay.color" {+ return true;+ }let leaf = path.rsplit('.').next().unwrap_or(path);matches!(leaf,diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 57d357511..43dabb960 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -7369,7 +7369,7 @@ mod tests {&app.session.documents()[0].channel_view,r,factor,- false,+ crate::channel_view::Look::default(),app.session.documents()[0].active_layer,).unwrap();@@ -7400,7 +7400,8 @@ mod tests {let st = &app.session.documents()[0];assert_eq!(image.pixels,- crate::channel_view::render(&st.doc, &st.channel_view, st.doc.bounds(), factor, false, st.active_layer).unwrap(),+ crate::channel_view::render(&st.doc, &st.channel_view, st.doc.bounds(), factor, crate::channel_view::Look::default(), st.active_layer)+ .unwrap(),"undo restores the shown mask");delta.clear();@@ -7445,12 +7446,28 @@ mod tests {let r = DRect::new(pos[0] as i32, pos[1] as i32, (pos[0] + image.size[0]) as i32, (pos[1] + image.size[1]) as i32);assert_eq!(image.pixels,- crate::channel_view::render(&shown, &app.session.documents()[0].channel_view, r, 1, false, app.session.documents()[0].active_layer).unwrap(),+ crate::channel_view::render(+ &shown,+ &app.session.documents()[0].channel_view,+ r,+ 1,+ crate::channel_view::Look::default(),+ app.session.documents()[0].active_layer+ )+ .unwrap(),"{target}");assert_ne!(image.pixels,- crate::channel_view::render(&original, &app.session.documents()[0].channel_view, r, 1, false, app.session.documents()[0].active_layer).unwrap(),+ crate::channel_view::render(+ &original,+ &app.session.documents()[0].channel_view,+ r,+ 1,+ crate::channel_view::Look::default(),+ app.session.documents()[0].active_layer+ )+ .unwrap(),"target was painted");delta.clear();@@ -7472,7 +7489,7 @@ mod tests {&app.session.documents()[0].channel_view,original.bounds(),1,- false,+ crate::channel_view::Look::default(),app.session.documents()[0].active_layer).unwrap()@@ -8420,7 +8437,8 @@ mod rotation_preview_isolation_tests {let mut delta = ctx.tex_manager().write().take_delta();let egui::ImageData::Color(image) = &delta.set.get(&texture).expect("filter preview must update channel overlay")[0].image;let st = app.session.active().unwrap();- let original = crate::channel_view::render(&before, &st.channel_view, before.bounds(), 1, false, st.active_layer).unwrap();+ let original =+ crate::channel_view::render(&before, &st.channel_view, before.bounds(), 1, crate::channel_view::Look::default(), st.active_layer).unwrap();assert_ne!(image.pixels, original, "a nontrivial filter must be visible before OK");delta.clear();assert!(std::sync::Arc::ptr_eq(&before, &app.session.active().unwrap().doc));@@ -8581,7 +8599,8 @@ mod rotation_preview_isolation_tests {let egui::ImageData::Color(image) = &delta.set.get(&texture).expect("preview must refresh overlay")[0].image;crate::dialogs::confirm(&mut app, dialog).unwrap();let st = app.session.active().unwrap();- let expected = crate::channel_view::render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let expected =+ crate::channel_view::render(&st.doc, &st.channel_view, st.doc.bounds(), 1, crate::channel_view::Look::default(), st.active_layer).unwrap();assert_eq!(image.pixels, expected, "quick_mask={quick_mask}");delta.clear();}diff --git a/crates/ui-egui/src/channel_options_ui.rs b/crates/ui-egui/src/channel_options_ui.rsindex c50244447..7ff77d114 100644--- a/crates/ui-egui/src/channel_options_ui.rs+++ b/crates/ui-egui/src/channel_options_ui.rs@@ -2,6 +2,9 @@//! Quick Mask row): name, Color Indicates Masked Areas / Selected Areas / Spot Color, the overlay//! or ink colour, and opacity (solidity for spot channels). OK runs the engine's//! `channel.options`, which agents can also call directly with params (#3761).+//!+//! On the layer mask (double-click its Channels row, or Mask Options… on its Layers thumbnail)+//! it is Photoshop's Layer Mask Display Options: just the rubylith's colour and opacity.use egui::{Align2, Sense, pos2, vec2};use photocraft_doc::ColorIndicates;@@ -21,11 +24,27 @@ fn hex(rgb: [f32; 3]) -> String {crate::color_picker_ui::hex(rgb)}-/// The dialog's fields for `channel` (an alpha/spot channel index, or `"quickMask"`), or `None`-/// when there's no document or no such channel.+/// Whether `f` is Layer Mask Display Options rather than a channel's options.+fn layer_mask(f: &Map<String, Value>) -> bool {+ f.get("channel").and_then(Value::as_str) == Some("mask")+}++/// The dialog's fields for `channel` (an alpha/spot channel index, `"quickMask"`, or `"mask"` for+/// Layer Mask Display Options), or `None` when there's no document or no such channel.pub fn fields(app: &PhotocraftApp, channel: &Value) -> Option<Map<String, Value>> {let doc = &app.session.active()?.doc;let kind = |i: ColorIndicates| if i == ColorIndicates::SelectedAreas { "selected" } else { "masked" };+ if channel.as_str() == Some("mask") {+ let o = &app.session.prefs().layer_mask_overlay;+ let mut f = Map::new();+ f.insert(MARK.into(), json!(true));+ f.insert("__command".into(), json!(COMMAND));+ f.insert("__label".into(), json!("Layer Mask Display Options…"));+ f.insert("channel".into(), json!("mask"));+ f.insert("color".into(), json!(hex(o.rgb())));+ f.insert("opacity".into(), json!((o.alpha() * 100.0).round()));+ return Some(f);+ }let (name, indicates, color, percent) = if channel.as_str() == Some("quickMask") {let o = app.session.quick_mask_options;(None, kind(o.indicates), o.color, o.opacity)@@ -84,6 +103,9 @@ fn label(ui: &mut egui::Ui, text: &str) {pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {ui.spacing_mut().item_spacing.y = 6.0;+ if layer_mask(f) {+ return mask_body(ui, f);+ }let quick = f.get("channel").and_then(Value::as_str) == Some("quickMask");if let Some(mut name) = f.get("name").and_then(Value::as_str).map(str::to_string) {ui.horizontal(|ui| {@@ -129,6 +151,24 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {});}+/// Layer Mask Display Options: Color and Opacity, as Photoshop's dialog has them.+fn mask_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {+ ui.horizontal(|ui| {+ label(ui, tl!("Color:"));+ let current = f.get("color").and_then(Value::as_str).and_then(crate::color_picker_ui::parse_hex).unwrap_or([1.0, 0.0, 0.0]);+ let c = current.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8);+ if crate::widgets::color_swatch_button(ui, egui::Color32::from_rgb(c[0], c[1], c[2]), tl!("Overlay Color")).clicked() {+ crate::color_picker_ui::request(f, &crate::color_picker_ui::title_for(tl!("Overlay Color")));+ }+ ui.add_space(12.0);+ ui.label(tl!("Opacity:"));+ let mut pct = f.get("opacity").and_then(Value::as_f64).unwrap_or(50.0) as f32;+ if crate::widgets::value_field(ui, &mut pct, 0.0..=100.0, "%", 64.0).changed() {+ f.insert("opacity".into(), json!(pct.round()));+ }+ });+}+// ---------------------------------------------------------------------------------------------// New Spot Channel…: Name and Ink Characteristics (Color, Solidity). OK runs `channel.newSpot`// (from the selection, as Photoshop does) and remembers the ink and solidity for next time.diff --git a/crates/ui-egui/src/channel_options_ui_tests.rs b/crates/ui-egui/src/channel_options_ui_tests.rsindex 9a4a3d4c3..210a4ff0e 100644--- a/crates/ui-egui/src/channel_options_ui_tests.rs+++ b/crates/ui-egui/src/channel_options_ui_tests.rs@@ -103,13 +103,42 @@ fn quick_mask_options_have_no_name_or_spot_and_bad_channels_open_nothing() {assert!(app.ui.dialogs.is_empty());}+/// Layer Mask Display Options: just the colour and opacity, from and to the+/// `layer_mask_overlay` preference; Channel Options… opens it on a targeted layer mask.+#[test]+fn layer_mask_display_options_set_the_rubylith() {+ let mut app = app();+ let f = fields(&app, &json!("mask")).unwrap();+ assert_eq!(f["__label"], json!("Layer Mask Display Options…"));+ assert!(!f.contains_key("name") && !f.contains_key("indicates"));+ assert_eq!((f["color"].clone(), f["opacity"].clone()), (json!("#ff0000"), json!(50.0)));+ assert_eq!(params(&f), json!({"channel": "mask", "color": "#ff0000", "opacity": 50.0}));+ let id = open(&mut app, &json!("mask")).unwrap();+ app.ui.dialog_mut(id).unwrap().fields.insert("color".into(), json!("#00ff00"));+ crate::dialogs::confirm(&mut app, id).unwrap();+ assert_eq!(app.session.prefs().layer_mask_overlay.color, "#00ff00");+ // Channels › Channel Options… with the layer mask targeted.+ app.run("layer.layerMask.revealAll", json!({})).unwrap();+ app.run("channel.target", json!({"channel": "mask"})).unwrap();+ let ctx = egui::Context::default();+ crate::menus::invoke(&mut app, &ctx, COMMAND, json!({})).unwrap();+ assert_eq!(app.ui.dialogs.last().unwrap().fields["channel"], json!("mask"));+ // Or with it targeted by `\` (the rubylith), which leaves the Channels target alone.+ app.run("channel.target", json!({"channel": "composite"})).unwrap();+ app.ui.dialogs.clear();+ app.run(photocraft_engine::mask_view_cmds::OVERLAY_ID, json!({})).unwrap();+ app.sync_mask_targets();+ crate::menus::invoke(&mut app, &ctx, COMMAND, json!({})).unwrap();+ assert_eq!(app.ui.dialogs.last().unwrap().fields["channel"], json!("mask"));+}+#[test]fn dialog_body_renders_for_alpha_spot_and_quick_mask() {let mut app = app();app.run("channel.options", json!({"channel": 0, "indicates": "spot"})).unwrap();let ctx = egui::Context::default();crate::theme::install_fonts(&ctx);- for channel in [json!(0), json!("quickMask")] {+ for channel in [json!(0), json!("quickMask"), json!("mask")] {let mut f = fields(&app, &channel).unwrap();ctx.run_ui(Default::default(), |ui| body(ui, &mut f)).textures_delta.clear();assert!(owns(&f));diff --git a/crates/ui-egui/src/channel_view.rs b/crates/ui-egui/src/channel_view.rsindex 5cbc960b8..0a5e1958a 100644--- a/crates/ui-egui/src/channel_view.rs+++ b/crates/ui-egui/src/channel_view.rs@@ -65,6 +65,31 @@ fn sample(s: &Surface, r: Rect, factor: u32) -> Vec<f32> {out}+/// How the view draws what it shows.+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct Look {+ /// Single colour channels tinted instead of grayscale (Photoshop's "Show Channels in Color").+ pub in_color: bool,+ /// The layer mask rubylith's colour and opacity (0..1): Layer Mask Display Options.+ pub mask_rgb: [f32; 3],+ pub mask_opacity: f32,+}++impl Default for Look {+ /// Photoshop's: grayscale channels, a red rubylith at 50 %.+ fn default() -> Self {+ Self { in_color: false, mask_rgb: AlphaChannel::DEFAULT_COLOR.to_rgb(), mask_opacity: 0.5 }+ }+}++impl Look {+ /// The current preferences of `s`.+ pub fn of(s: &photocraft_engine::Session) -> Self {+ let p = s.prefs();+ Self { in_color: p.interface.show_channels_in_color, mask_rgb: p.layer_mask_overlay.rgb(), mask_opacity: p.layer_mask_overlay.alpha() }+ }+}+/// Composite RGBA (over white, like Photoshop's channel views) at `factor` stride./// Render in bands instead of allocating a full-resolution float composite to sample a preview.fn composite(doc: &Document, r: Rect, factor: u32) -> Vec<[f32; 4]> {@@ -86,11 +111,10 @@ fn composite(doc: &Document, r: Rect, factor: u32) -> Vec<[f32; 4]> {}/// The channel view of `r` (document pixels, sampled every `factor` px) as premultiplied pixels,-/// or `None` when the plain composite is all there is to show. `in_color` shows single colour-/// channels tinted instead of grayscale (Photoshop's "Show Channels in Color").-pub fn render(doc: &Document, v: &ChannelView, r: Rect, factor: u32, in_color: bool, active: Option<photocraft_doc::LayerId>) -> Option<Vec<Color32>> {+/// or `None` when the plain composite is all there is to show.+pub fn render(doc: &Document, v: &ChannelView, r: Rect, factor: u32, look: Look, active: Option<photocraft_doc::LayerId>) -> Option<Vec<Color32>> {let mut unused = None;- render_with_source(doc, v, r, factor, in_color, active, CompositeSource { cached: None, fresh: &mut unused })+ render_with_source(doc, v, r, factor, look, active, CompositeSource { cached: None, fresh: &mut unused })}fn render_with_source(@@ -98,13 +122,15 @@ fn render_with_source(v: &ChannelView,r: Rect,factor: u32,- in_color: bool,+ look: Look,active: Option<photocraft_doc::LayerId>,source: CompositeSource<'_>,) -> Option<Vec<Color32>> {if v.is_plain(doc) || r.is_empty() {return None;}+ let in_color = look.in_color;+ let (mask_rgb, mask_opacity) = (look.mask_rgb, look.mask_opacity.clamp(0.0, 1.0));let layer_mask = v.shown_layer_mask(doc);// ⌥-click mask view (#196): the pixel mask alone, in grayscale (white reveals); ⇧⌥ with// nothing else shown: just the rubylith. Use the compositor's cached feather for the pixel@@ -123,9 +149,9 @@ fn render_with_source(match shown_mask {Some((m, MaskViewMode::Gray)) => return Some(mask_px(m, r, factor, |g| Color32::from_gray(q(g)))),Some((m, MaskViewMode::Overlay)) if only_mask => {- let c = AlphaChannel::DEFAULT_COLOR.to_rgb();+ let c = mask_rgb;return Some(mask_px(m, r, factor, |g| {- let a = 0.5 * (1.0 - g.clamp(0.0, 1.0));+ let a = mask_opacity * (1.0 - g.clamp(0.0, 1.0));Color32::from_rgba_premultiplied(q(c[0] * a), q(c[1] * a), q(c[2] * a), q(a))}));}@@ -212,10 +238,11 @@ fn render_with_source(};tint(sample(&ch.surface, r, factor), color, opacity, &|x| ch.overlay_coverage(x));}- // ⇧⌥-click mask view (#196): the layer mask as Quick Mask's red over the hidden areas- // (Photoshop's Layer Mask Display Options default).+ // ⇧⌥-click mask view (#196): the layer mask tinted over the hidden areas in the Layer Mask+ // Display Options colour and opacity (red at 50 % unless set).if !solo_mask && let Some((m, MaskViewMode::Overlay)) = shown_mask {- tint(sample(m, r, factor), AlphaChannel::DEFAULT_COLOR, 0.5, &|x| 1.0 - x);+ let [cr, cg, cb] = mask_rgb;+ tint(sample(m, r, factor), photocraft_color::Color::rgb(cr, cg, cb), mask_opacity, &|x| 1.0 - x);}Some(out.into_iter().map(|p| Color32::from_rgba_premultiplied(q(p[0]), q(p[1]), q(p[2]), q(p[3]))).collect())}@@ -252,9 +279,9 @@ fn q(x: f32) -> u8 {(x.clamp(0.0, 1.0) * 255.0 + 0.5) as u8}-fn view_key(v: &ChannelView, in_color: bool) -> u64 {- let s = serde_json::to_string(v).unwrap_or_default();- s.bytes().fold(in_color as u64 + 1, |h, b| h.wrapping_mul(1_099_511_628_211).wrapping_add(b as u64))+fn view_key(v: &ChannelView, look: Look) -> u64 {+ let s = serde_json::to_string(&(v, look.mask_rgb, look.mask_opacity)).unwrap_or_default();+ s.bytes().fold(look.in_color as u64 + 1, |h, b| h.wrapping_mul(1_099_511_628_211).wrapping_add(b as u64))}/// Make the channel-view texture of document `idx` current; `None` = nothing to draw.@@ -276,10 +303,10 @@ pub fn ensure(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize) -> Optio// The plain-composite path above needs no preview work.let (doc, preview_key) = crate::canvas::filter_channel_preview(app, idx, ctx).unwrap_or_else(|| crate::canvas::display_doc(app, idx));// Interface ▸ Show Channels in Color tints single colour channel views on the canvas too,- // not just the panel thumbnails (#2385). The view key carries the flag, so toggling it- // rebuilds the texture.- let in_color = app.session.prefs().interface.show_channels_in_color;- let key = view_key(&view, in_color);+ // not just the panel thumbnails (#2385). The view key carries the flag and the Layer Mask+ // Display Options, so changing them rebuilds the texture.+ let look = Look::of(&app.session);+ let key = view_key(&view, look);// Never exceed what the GPU accepts (egui panics on oversized textures).let max_side = (ctx.input(|i| i.max_texture_side) as u32).clamp(256, MAX_SIDE);let factor = doc.size.width.max(doc.size.height).div_ceil(max_side).max(1);@@ -315,7 +342,7 @@ pub fn ensure(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize) -> Optiolet d = d.intersect(&doc.bounds());let r = Rect::new(d.x0.div_euclid(f) * f, d.y0.div_euclid(f) * f, d.x1, d.y1).intersect(&doc.bounds());if !r.is_empty()- && let Some(px) = render(&doc, &view, r, factor, in_color, active)+ && let Some(px) = render(&doc, &view, r, factor, look, active){let img = egui::ColorImage::new([r.width().div_ceil(factor) as usize, r.height().div_ceil(factor) as usize], px);c.tex.set_partial([(r.x0 / f) as usize, (r.y0 / f) as usize], img, TextureOptions::LINEAR);@@ -327,7 +354,7 @@ pub fn ensure(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize) -> Optiolet b = doc.bounds();let cached = app.channel_views.get(&id).and_then(|c| c.source.as_ref()).map(|s| s.pixels.as_slice());let mut fresh = None;- let px = render_with_source(&doc, &view, b, factor, in_color, active, CompositeSource { cached, fresh: &mut fresh })?;+ let px = render_with_source(&doc, &view, b, factor, look, active, CompositeSource { cached, fresh: &mut fresh })?;let new_source = fresh.is_some();let size = [b.width().div_ceil(factor) as usize, b.height().div_ceil(factor) as usize];let img = egui::ColorImage::new(size, px);@@ -429,14 +456,14 @@ mod tests {let st = app.session.active().unwrap();assert_eq!(refreshed.revision, st.revision);assert_ne!(refreshed.pixels[0], original_sample, "new pixels must be recomposited");- let expected = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let expected = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();let mut unused = None;let actual = render_with_source(&st.doc,&st.channel_view,st.doc.bounds(),1,- false,+ Look::default(),st.active_layer,CompositeSource { cached: Some(&refreshed.pixels), fresh: &mut unused },)@@ -449,7 +476,7 @@ mod tests {fn plain_composite_draws_nothing() {let s = session();let st = s.active().unwrap();- assert!(render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).is_none());+ assert!(render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).is_none());}#[test]@@ -458,7 +485,7 @@ mod tests {s.execute("select.rect", json!({"x": 0, "y": 0, "width": 4, "height": 4})).unwrap();s.execute("select.editInQuickMaskMode", json!({})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!(px[0], Color32::TRANSPARENT, "selected: no overlay");assert_eq!(px[6], Color32::from_rgba_premultiplied(128, 0, 0, 128), "masked: 50% red");}@@ -473,12 +500,12 @@ mod tests {}s.execute("select.editInQuickMaskMode", json!({})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert!(px.iter().all(|p| *p == Color32::TRANSPARENT), "{before:?}");if let Some(i) = after {s.execute("channel.options", json!({"channel": "quickMask", "indicates": i})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert!(px.iter().all(|p| *p == Color32::TRANSPARENT), "{before:?} → {i}");}}@@ -488,7 +515,7 @@ mod tests {s.execute("select.all", json!({})).unwrap();s.execute("select.editInQuickMaskMode", json!({})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert!(px.iter().all(|p| *p == Color32::from_rgba_premultiplied(128, 0, 0, 128)));}@@ -503,14 +530,14 @@ mod tests {s.execute("view.layerMask", json!({"mode": "gray"})).unwrap();let st = s.active().unwrap();let b = st.doc.bounds();- let full = render(&st.doc, &st.channel_view, b, 1, false, st.active_layer).unwrap();+ let full = render(&st.doc, &st.channel_view, b, 1, Look::default(), st.active_layer).unwrap();assert!(full[0].r() < 10 && full[36].r() > 245 && full[0].a() == 255, "opaque grayscale ramp");// A sub-rect starting on the factor grid matches the same pixels of the full render.for f in [1u32, 2, 3] {- let all = render(&st.doc, &st.channel_view, b, f, false, st.active_layer).unwrap();+ let all = render(&st.doc, &st.channel_view, b, f, Look::default(), st.active_layer).unwrap();let w = b.width().div_ceil(f) as usize;let r = Rect::new(3 * f as i32, 2 * f as i32, 30, 19);- let part = render(&st.doc, &st.channel_view, r, f, false, st.active_layer).unwrap();+ let part = render(&st.doc, &st.channel_view, r, f, Look::default(), st.active_layer).unwrap();let pw = r.width().div_ceil(f) as usize;for (i, p) in part.iter().enumerate() {assert_eq!(*p, all[(i / pw + 2) * w + i % pw + 3], "factor {f}, pixel {i}");@@ -518,7 +545,7 @@ mod tests {}s.execute("view.layerMask", json!({"mode": "overlay"})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, b, 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, b, 1, Look::default(), st.active_layer).unwrap();assert!(px[0].r() >= 124 && px[0].g() == 0 && px[0].a() >= 124, "about 50% red over the hidden end: {:?}", px[0]);assert!(px[36].a() <= 4, "next to nothing over the revealed end: {:?}", px[36]);}@@ -541,17 +568,37 @@ mod tests {let softened = effective.sample_channel(0, 0, 0);assert!((softened - raw).abs() > 0.01, "the fixture has a visible feather at its edge");- let gray = render(&st.doc, &st.channel_view, bounds, 1, false, st.active_layer).unwrap();+ let gray = render(&st.doc, &st.channel_view, bounds, 1, Look::default(), st.active_layer).unwrap();assert_eq!(gray[0], Color32::from_gray(q(softened)), "gray view uses the compositor's feathered mask");s.execute("view.layerMask", json!({"mode": "overlay"})).unwrap();let st = s.active().unwrap();- let overlay = render(&st.doc, &st.channel_view, bounds, 1, false, st.active_layer).unwrap();+ let overlay = render(&st.doc, &st.channel_view, bounds, 1, Look::default(), st.active_layer).unwrap();let alpha = 0.5 * (1.0 - softened);let red = AlphaChannel::DEFAULT_COLOR.to_rgb();assert_eq!(overlay[0], Color32::from_rgba_premultiplied(q(red[0] * alpha), q(red[1] * alpha), q(red[2] * alpha), q(alpha)));}+ /// Layer Mask Display Options: the rubylith takes their colour and opacity, alone over the+ /// composite and with a colour channel hidden.+ #[test]+ fn layer_mask_overlay_takes_its_display_options() {+ let mut s = session();+ s.execute("layer.new.layer", json!({})).unwrap();+ s.execute("edit.fill", json!({"color": "#0000ff"})).unwrap();+ s.execute("layer.layerMask.hideAll", json!({})).unwrap();+ s.execute("view.layerMask", json!({"mode": "overlay"})).unwrap();+ let green = Look { mask_rgb: [0.0, 1.0, 0.0], mask_opacity: 0.25, ..Look::default() };+ let st = s.active().unwrap();+ let b = st.doc.bounds();+ assert_eq!(render(&st.doc, &st.channel_view, b, 1, Look::default(), st.active_layer).unwrap()[0], Color32::from_rgba_premultiplied(128, 0, 0, 128));+ assert_eq!(render(&st.doc, &st.channel_view, b, 1, green, st.active_layer).unwrap()[0], Color32::from_rgba_premultiplied(0, 64, 0, 64));+ // Red hidden: the white picture shows cyan, then green at 25 % over it.+ s.execute("channel.setVisible", json!({"channel": "red", "visible": false})).unwrap();+ let st = s.active().unwrap();+ assert_eq!(render(&st.doc, &st.channel_view, b, 1, green, st.active_layer).unwrap()[0], Color32::from_rgb(0, 255, 191));+ }+/// `cargo test --release -p photocraft-ui-egui --lib mask_view_switch_24mp -- --ignored --nocapture`#[test]#[ignore = "benchmark"]@@ -569,7 +616,7 @@ mod tests {let mut best = f64::MAX;for _ in 0..8 {let t = std::time::Instant::now();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), factor, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), factor, Look::default(), st.active_layer).unwrap();let img = egui::ColorImage::new([3000, 2000], px);std::hint::black_box(img);best = best.min(t.elapsed().as_secs_f64() * 1000.0);@@ -588,17 +635,20 @@ mod tests {s.execute("channel.target", json!({"channel": "green"})).unwrap();let st = s.active().unwrap();let b = st.doc.bounds();- assert_eq!(render(&st.doc, &st.channel_view, b, 1, false, st.active_layer).unwrap()[0], Color32::from_gray(128));- assert_eq!(render(&st.doc, &st.channel_view, b, 1, true, st.active_layer).unwrap()[0], Color32::from_rgb(0, 128, 0));+ assert_eq!(render(&st.doc, &st.channel_view, b, 1, Look::default(), st.active_layer).unwrap()[0], Color32::from_gray(128));+ assert_eq!(+ render(&st.doc, &st.channel_view, b, 1, Look { in_color: true, ..Look::default() }, st.active_layer).unwrap()[0],+ Color32::from_rgb(0, 128, 0)+ );let mut s = Session::new();s.execute("file.new", json!({"width": 4, "height": 4, "mode": "cmyk"})).unwrap();s.execute("edit.fill", json!({"color": "#4080c0"})).unwrap();s.execute("channel.target", json!({"channel": "cyan"})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, true, st.active_layer).unwrap()[0];+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look { in_color: true, ..Look::default() }, st.active_layer).unwrap()[0];assert!(px.r() < 100 && px.g() > 150 && px.b() > 150, "cyan ink, not gray: {px:?}");- let gray = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap()[0];+ let gray = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap()[0];assert_eq!(gray.r(), gray.g(), "off stays grayscale");}@@ -611,12 +661,12 @@ mod tests {let b = s.active().unwrap().doc.bounds();s.execute("channel.target", json!({"channel": {"color": 0}})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, b, 1, true, st.active_layer).unwrap()[0];+ let px = render(&st.doc, &st.channel_view, b, 1, Look { in_color: true, ..Look::default() }, st.active_layer).unwrap()[0];let spread = px.r().max(px.g().max(px.b())) as i32 - px.r().min(px.g().min(px.b())) as i32;assert!(spread <= 3, "Lightness stays gray: {px:?}");s.execute("channel.target", json!({"channel": {"color": 1}})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, b, 1, true, st.active_layer).unwrap()[0];+ let px = render(&st.doc, &st.channel_view, b, 1, Look { in_color: true, ..Look::default() }, st.active_layer).unwrap()[0];assert!(px.r() != px.g() || px.g() != px.b(), "a channel is tinted, not gray: {px:?}");}@@ -634,6 +684,10 @@ mod tests {assert!(ensure(&mut app, &ctx, 0).is_some());let key_on = app.channel_views.values().next().unwrap().key;assert_ne!(key_off, key_on, "the preference changes the cached view key");+ // So do the Layer Mask Display Options.+ app.session.execute("channel.options", json!({"channel": "mask", "color": "#00ff00", "opacity": 70})).unwrap();+ assert!(ensure(&mut app, &ctx, 0).is_some());+ assert_ne!(app.channel_views.values().next().unwrap().key, key_on, "the overlay options change the cached view key");}#[test]@@ -644,17 +698,17 @@ mod tests {s.execute("channel.new", json!({"fill": "selection"})).unwrap();let st = s.active().unwrap();assert_eq!(st.channel_view.target, ChannelTarget::Alpha(0));- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!((px[0], px[5]), (Color32::WHITE, Color32::BLACK));// Green alone: grayscale of the green channel; with blue hidden only.s.execute("channel.target", json!({"channel": "green"})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!(px[0], Color32::from_gray(128));s.execute("channel.target", json!({"channel": "composite"})).unwrap();s.execute("channel.setVisible", json!({"channel": "red", "visible": false})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 2, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 2, Look::default(), st.active_layer).unwrap();assert_eq!(px.len(), 4 * 2);assert_eq!(px[0], Color32::from_rgb(0, 128, 0));}@@ -667,7 +721,7 @@ mod tests {s.execute("channel.setVisible", json!({"channel": "composite", "visible": true})).unwrap();s.execute("channel.setVisible", json!({"channel": "composite", "visible": false})).unwrap();let st = s.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!(px[0], Color32::WHITE, "Alpha alone is the channel, not the red image");let mut q = session();@@ -675,7 +729,7 @@ mod tests {q.execute("select.editInQuickMaskMode", json!({})).unwrap();q.execute("channel.setVisible", json!({"channel": "composite", "visible": false})).unwrap();let st = q.active().unwrap();- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!(px[0], Color32::WHITE, "Quick Mask alone is grayscale, not the red composite");let mut m = session();@@ -685,7 +739,7 @@ mod tests {m.execute("channel.setVisible", json!({"channel": "composite", "visible": false})).unwrap();let st = m.active().unwrap();assert_eq!(st.channel_view.visible_colors(3), 0);- let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, false, st.active_layer).unwrap();+ let px = render(&st.doc, &st.channel_view, st.doc.bounds(), 1, Look::default(), st.active_layer).unwrap();assert_eq!(px[0], Color32::BLACK, "the hidden mask reads black, not the red layer");}}diff --git a/crates/ui-egui/src/channels_panel.rs b/crates/ui-egui/src/channels_panel.rsindex 7f175b620..0b233633a 100644--- a/crates/ui-egui/src/channels_panel.rs+++ b/crates/ui-egui/src/channels_panel.rs@@ -223,6 +223,10 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {if row == Row::QuickMask && resp.double_clicked() {actions.push(("ui.channelOptions".into(), json!("quickMask")));}+ // The layer mask's row: Layer Mask Display Options (the rubylith's colour, opacity).+ if row == Row::LayerMask && resp.double_clicked() {+ actions.push(("ui.channelOptions".into(), json!("mask")));+ }if let Row::Alpha(i) = row {if resp.double_clicked() && on_thumb {actions.push(("ui.channelOptions".into(), json!(i)));@@ -281,6 +285,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {let enabled = masked.as_ref().and_then(|l| l.mask.as_ref()).is_none_or(|m| m.enabled);item(ui, a, crate::layer_menu_ui::mask_toggle_label(enabled), "layer.layerMask.enabled", json!({}));item(ui, a, "Delete Layer Mask", "layer.layerMask.delete", json!({}));+ item(ui, a, "Layer Mask Display Options…", "ui.channelOptions", json!("mask"));}}ui.separator();@@ -541,7 +546,8 @@ mod tests {let masked = s.execute("layer.new.layer", json!({"name": "Masked"})).unwrap()["layer"].as_u64().unwrap();s.execute("layer.layerMask.revealAll", json!({"layer": masked})).unwrap();s.execute("channel.new", json!({})).unwrap();- let mut h = egui_kittest::Harness::builder().with_size(vec2(1440.0, 1000.0)).with_max_steps(64).build_eframe(move |cc| {+ // 60 fps steps, so two clicks a frame apart count as a double-click.+ let mut h = egui_kittest::Harness::builder().with_size(vec2(1440.0, 1000.0)).with_step_dt(1.0 / 60.0).with_max_steps(64).build_eframe(move |cc| {PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());PhotocraftApp::new(s, crate::Services::default())});@@ -703,6 +709,33 @@ mod tests {assert!(h.ctx.data(|d| d.get_temp::<(Row, String)>(drag_id())).is_none(), "the drag ended");}+ /// Double-clicking the layer mask's row opens Layer Mask Display Options, as in Photoshop; OK+ /// sets the rubylith's colour and opacity, a view setting rather than an undo step.+ #[test]+ fn double_clicking_the_layer_mask_row_opens_its_display_options() {+ let (mut h, _) = channels_harness();+ let steps = h.state().session.active().unwrap().history.past_len();+ let p = at(&h, "Masked Mask");+ h.hover_at(p);+ h.run_steps(30);+ for pressed in [true, false, true, false] {+ h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });+ h.step();+ }+ h.run_steps(3);+ let d = h.state().ui.dialogs.last().expect("a dialog opens");+ assert!(crate::channel_options_ui::owns(&d.fields), "{:?}", d.fields);+ assert_eq!((d.fields["channel"].clone(), d.fields["color"].clone(), d.fields["opacity"].clone()), (json!("mask"), json!("#ff0000"), json!(50.0)));+ let id = d.id;+ let d = h.state_mut().ui.dialog_mut(id).unwrap();+ d.fields.insert("color".into(), json!("#0000ff"));+ d.fields.insert("opacity".into(), json!(80.0));+ crate::dialogs::confirm(h.state_mut(), id).unwrap();+ let o = &h.state().session.prefs().layer_mask_overlay;+ assert_eq!((o.color.as_str(), o.opacity), ("#0000ff", 80.0));+ assert_eq!(h.state().session.active().unwrap().history.past_len(), steps, "no history step");+ }+/// The layer mask's row asks "Apply mask to layer before removing?", like its Layers thumbnail.#[test]fn the_layer_mask_row_on_the_trash_asks_first() {diff --git a/crates/ui-egui/src/filter_preview_ui.rs b/crates/ui-egui/src/filter_preview_ui.rsindex 90eaf4f6f..436e28e24 100644--- a/crates/ui-egui/src/filter_preview_ui.rs+++ b/crates/ui-egui/src/filter_preview_ui.rs@@ -225,7 +225,7 @@ fn upload(ctx: &egui::Context, app: &PhotocraftApp, name: &str, doc: &Document)let (width, height) = (doc.size.width.div_ceil(factor), doc.size.height.div_ceil(factor));if let Some(st) = app.session.active()&& let Some(pixels) =- crate::channel_view::render(doc, &st.channel_view, doc.bounds(), factor, app.session.prefs().interface.show_channels_in_color, st.active_layer)+ crate::channel_view::render(doc, &st.channel_view, doc.bounds(), factor, crate::channel_view::Look::of(&app.session), st.active_layer){let image = egui::ColorImage::new([width as usize, height as usize], pixels);return ctx.load_texture(name, image, egui::TextureOptions::LINEAR);@@ -332,7 +332,9 @@ mod tests {let egui::ImageData::Color(image) = &delta.set.get(&texture.id()).unwrap()[0].image;let pixels = image.pixels.clone();delta.clear();- let expected = crate::channel_view::render(&preview, &st.channel_view, preview.bounds(), 1, false, st.active_layer).unwrap();+ let expected =+ crate::channel_view::render(&preview, &st.channel_view, preview.bounds(), 1, crate::channel_view::Look::default(), st.active_layer)+ .unwrap();assert_eq!(pixels, expected, "depth {depth}, factor {k}");assert_ne!(pixels[0], pixels[pixels.len() - 1], "the alpha edge is visible, not the white RGB layer");assert!(pixels.iter().any(|p| p.r() > 0 && p.r() < 255), "the blurred edge is visible");diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex f3fb8c8c4..69807056d 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -19,6 +19,10 @@# (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin letters; the trailing "…" of# dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Možnosti masky…+ Layer Mask Display Options… Možnosti zobrazení masky vrstvy…+# Channel Options and New Spot Channel (#3761)Channel Color Barva kanáluColor Indicates: Barva označuje:diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 48ebfba67..bb643f9bf 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -15,6 +15,10 @@# way. Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin# letters; the trailing "…" of dialog commands is kept. Plural rule: one|other (n != 1 -> other).+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Maskenoptionen…+ Layer Mask Display Options… Anzeigeoptionen für Ebenenmasken…+# Channel Options and New Spot Channel (#3761)Channel Color KanalfarbeColor Indicates: Farbe kennzeichnet:diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex f2c67c2c4..cd9c5ec59 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -3,6 +3,10 @@# Original translations based on general Greek graphics/computing terminology.# Covers every source label the i18n coverage check lists.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Επιλογές μάσκας…+ Layer Mask Display Options… Επιλογές εμφάνισης μάσκας επιπέδου…+# Channel Options and New Spot Channel (#3761)Channel Color Χρώμα καναλιούColor Indicates: Το χρώμα υποδεικνύει:diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 45804fa2a..c489b2d6f 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -12,6 +12,10 @@# Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin# letters; the trailing "…" of dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opciones de máscara…+ Layer Mask Display Options… Opciones de visualización de máscara de capa…+# Channel Options and New Spot Channel (#3761)Channel Color Color del canalColor Indicates: El color indica:diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 3e3451e09..5f9af4b4f 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -19,6 +19,10 @@# ArtCraft, OpenType, Lab ...) stay as they are; RGB/CMYK read RVB/CMJN; the trailing "…" of# dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Options de masque…+ Layer Mask Display Options… Options d'affichage du masque de calque…+# Channel Options and New Spot Channel (#3761)Channel Color Couleur de la coucheColor Indicates: La couleur indique :diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsvindex 9dc9a47fb..f93821f8c 100644--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@ -4067,6 +4067,10 @@ cameraRaw Yellow Sárgaset in Print Settings… a nyomtatási beállításokban adható meg…ICO is limited to 256 × 256 pixels Az ICO legfeljebb 256 × 256 képpont lehet+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Maszkbeállítások…+ Layer Mask Display Options… Rétegmaszk megjelenítési beállításai…+# Channel Options and New Spot Channel (#3761)Channel Color Csatorna színeColor Indicates: A szín jelzése:diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 81e850f29..3f0d7c110 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -12,6 +12,10 @@# Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin# letters; the trailing "…" of dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opsi Mask…+ Layer Mask Display Options… Opsi Tampilan Mask Layer…+# Channel Options and New Spot Channel (#3761)Channel Color Warna SaluranColor Indicates: Warna Menunjukkan:diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex c097ded29..fa6f5d60c 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -12,6 +12,10 @@# Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin# letters; the trailing … of dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opzioni maschera…+ Layer Mask Display Options… Opzioni di visualizzazione maschera di livello…+# Channel Options and New Spot Channel (#3761)Channel Color Colore canaleColor Indicates: Il colore indica:diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex b46096512..2c701a0c2 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -15,6 +15,10 @@# Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin# letters; the trailing "…" of dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… マスクオプション…+ Layer Mask Display Options… レイヤーマスクの表示オプション…+# Channel Options and New Spot Channel (#3761)Channel Color チャンネルカラーColor Indicates: 着色表示:diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex 361cef2e9..6503e9f49 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -7,6 +7,10 @@# Licensed MIT OR Apache-2.0. See LICENSE-translations.txt and ATTRIBUTION.md.# Product names and technology names retain their spelling.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… 마스크 옵션…+ Layer Mask Display Options… 레이어 마스크 표시 옵션…+# Channel Options and New Spot Channel (#3761)Channel Color 채널 색상Color Indicates: 색상 표시 내용:diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex f1ac67961..2681e76ae 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -8,6 +8,10 @@# stay as they are; the trailing "…" of dialog commands is kept. UI text addresses the user# informally ("je") and uses sentence case.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Maskeropties…+ Layer Mask Display Options… Weergaveopties voor laagmasker…+# Channel Options and New Spot Channel (#3761)Channel Color KanaalkleurColor Indicates: Kleur geeft aan:diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 04eb15609..939904933 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -18,6 +18,10 @@# Conventions: menus are nouns (Plik, Edycja, Obraz ...), commands are infinitives (Otwórz…,# Zapisz jako…), sentence case as in the English source. Quotes: „…”.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opcje maski…+ Layer Mask Display Options… Opcje wyświetlania maski warstwy…+# Channel Options and New Spot Channel (#3761)Channel Color Kolor kanałuColor Indicates: Kolor oznacza:diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 8d6b88fb5..135a833e4 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -15,6 +15,10 @@# entries the same way. Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...)# stay as they are; the trailing "…" of dialog commands is kept.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opções de máscara…+ Layer Mask Display Options… Opções de exibição de máscara de camada…+# Channel Options and New Spot Channel (#3761)Channel Color Cor do canalColor Indicates: A cor indica:diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 9d733f11a..6dad91f99 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -17,6 +17,10 @@# letters; the trailing "…" of dialog commands is kept; the colon of a label ("Width:") becomes# the Russian typographic equivalent, with the space the source carries.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Параметры маски…+ Layer Mask Display Options… Параметры отображения маски слоя…+# Channel Options and New Spot Channel (#3761)Channel Color Цвет каналаColor Indicates: Цветом обозначены:diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsvindex d384c9bad..e949d90af 100644--- a/crates/ui-egui/src/i18n/sr.tsv+++ b/crates/ui-egui/src/i18n/sr.tsv@@ -4219,6 +4219,10 @@ shape Appearance Izgled# ICO dimensionsICO is limited to 256 × 256 pixels ICO je ograničen na 256 × 256 piksela+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Opcije maske…+ Layer Mask Display Options… Opcije prikaza maske sloja…+# Channel Options and New Spot Channel (#3761)Channel Color Boja kanalaColor Indicates: Boja označava:diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsvindex 5c35aba71..1e0012267 100644--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@ -3878,6 +3878,10 @@ cameraData Lens Lensset in Print Settings… Yazdırma Ayarlarında belirlenir…ICO is limited to 256 × 256 pixels ICO 256 × 256 piksel ile sınırlıdır+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Maske Seçenekleri…+ Layer Mask Display Options… Katman Maskesi Görüntüleme Seçenekleri…+# Channel Options and New Spot Channel (#3761)Channel Color Kanal RengiColor Indicates: Rengin Gösterdiği:diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex cb6f883eb..4bf9d021d 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -8,6 +8,10 @@# No proprietary translation resources were used.# Licensed MIT OR Apache-2.0. See LICENSE-translations.txt and ATTRIBUTION.md.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Параметри маски…+ Layer Mask Display Options… Параметри відображення маски шару…+# Channel Options and New Spot Channel (#3761)Channel Color Колір каналуColor Indicates: Кольором позначено:diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsvindex e2e55ab1b..d385b501e 100644--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@ -20,6 +20,10 @@# (`plural_none` in i18n/mod.rs).+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… Tùy chọn mặt nạ…+ Layer Mask Display Options… Tùy chọn hiển thị mặt nạ lớp…+# Channel Options and New Spot Channel (#3761)Channel Color Màu kênhColor Indicates: Màu biểu thị:diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex eebeabaa6..45db9feb7 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -11,6 +11,10 @@# Licensed MIT OR Apache-2.0, as the code.# Product and technology names retain their spelling. See docs/localization-zh-hans.md.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… 蒙版选项…+ Layer Mask Display Options… 图层蒙版显示选项…+# Channel Options and New Spot Channel (#3761)Channel Color 通道颜色Color Indicates: 色彩指示:diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex b35556b6f..225f11547 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -19,6 +19,10 @@# kept. Full-width punctuation (,。:) inside sentences; half-width parentheses and the " · "# separators as in the English.+# Layer Mask Display Options (the layer mask rubylith's colour and opacity)+ Mask Options… 遮色片選項…+ Layer Mask Display Options… 圖層遮色片顯示選項…+# Channel Options and New Spot Channel (#3761)Channel Color 色版顏色Color Indicates: 色彩指示:diff --git a/crates/ui-egui/src/layer_menu_ui.rs b/crates/ui-egui/src/layer_menu_ui.rsindex beb3e9bc3..a2c1139e9 100644--- a/crates/ui-egui/src/layer_menu_ui.rs+++ b/crates/ui-egui/src/layer_menu_ui.rs@@ -158,8 +158,7 @@ pub fn show(app: &crate::PhotocraftApp, ui: &mut egui::Ui, l: &Layer, on_set: bo}/// The menu of `l`'s layer-mask thumbnail (#4575), in Photoshop's order. It acts on `l`, which it-/// selects first like the row menu. Photoshop's Mask Options… (the overlay colour) has no-/// command yet, so it is left out.+/// selects first like the row menu.pub fn show_mask(app: &crate::PhotocraftApp, ui: &mut egui::Ui, l: &Layer, actions: &mut Vec<(String, Value)>) {let Some(mask) = &l.mask else { return };crate::widgets::menu_scroll(ui, |ui| {@@ -189,6 +188,13 @@ pub fn show_mask(app: &crate::PhotocraftApp, ui: &mut egui::Ui, l: &Layer, actioactions.push(("select.selectAndMask".into(), Value::Null));ui.close();}+ // Layer Mask Display Options: the rubylith's colour and opacity (`channel.options`).+ if ui.button(tl!("Mask Options…")).clicked() {+ actions.push(("layer.select".into(), json!({"layer": l.id.0})));+ actions.push(("ui.maskTarget".into(), json!(true)));+ actions.push(("channel.options".into(), Value::Null));+ ui.close();+ }});}@@ -521,6 +527,15 @@ mod tests {assert!(sel.sample_channel(10, 30, 0) > 0.99, "the selection is kept");assert!(sel.sample_channel(80, 30, 0) > 0.99, "the clicked layer's mask is added");assert!(sel.sample_channel(40, 30, 0) < 0.01, "nothing else is selected");+ // Mask Options…: Layer Mask Display Options (the rubylith's colour and opacity).+ let (thumbs, _) = crate::mask_thumbs_ui::recorded(&h.ctx, masked.0).expect("mask thumbnail drawn");+ let at = thumbs.iter().find(|(k, _)| *k == crate::mask_thumbs_ui::MaskKind::Pixel).unwrap().1.center();+ click(&mut h, at, PointerButton::Secondary);+ let at = h.get_by_label("Mask Options…").rect().center();+ click(&mut h, at, PointerButton::Primary);+ let d = h.state().ui.dialogs.last().expect("Mask Options… opens a dialog");+ assert!(crate::channel_options_ui::owns(&d.fields) && d.fields["channel"] == json!("mask"), "{:?}", d.fields);+ assert_eq!(d.fields["__label"], json!("Layer Mask Display Options…"));}#[test]diff --git a/crates/ui-egui/src/mask_thumbs_ui/tests.rs b/crates/ui-egui/src/mask_thumbs_ui/tests.rsindex 163c7cbae..fcfea89c6 100644--- a/crates/ui-egui/src/mask_thumbs_ui/tests.rs+++ b/crates/ui-egui/src/mask_thumbs_ui/tests.rs@@ -451,7 +451,8 @@ fn mask_view(h: &Harness<'_, PhotocraftApp>) -> serde_json::Value {fn canvas_px(h: &Harness<'_, PhotocraftApp>) -> Option<Vec<egui::Color32>> {let st = h.state().session.active().unwrap();- crate::channel_view::render(&st.doc, &st.channel_view, photocraft_geom::Rect::new(0, 0, 200, 100), 1, false, st.active_layer)+ let look = crate::channel_view::Look::of(&h.state().session);+ crate::channel_view::render(&st.doc, &st.channel_view, photocraft_geom::Rect::new(0, 0, 200, 100), 1, look, st.active_layer)}fn near(a: Rect, b: Rect) -> bool {@@ -621,6 +622,9 @@ fn backslash_toggles_the_rubylith() {assert_eq!(crate::canvas::paint_target(h.state()), json!("mask"), "painting paints the mask");let px = canvas_px(&h).unwrap();assert_eq!(px[50 * 200 + 50], egui::Color32::from_rgba_premultiplied(128, 0, 0, 128), "50% red over hidden areas");+ // Layer Mask Display Options: opaque green over what the mask hides instead.+ h.state_mut().run("channel.options", json!({"channel": "mask", "color": "#00ff00", "opacity": 100})).unwrap();+ assert_eq!(canvas_px(&h).unwrap()[50 * 200 + 50], egui::Color32::from_rgb(0, 255, 0));h.key_press(egui::Key::Backslash);h.run_steps(2);assert_eq!(mask_view(&h), serde_json::Value::Null, "\\ again hides it");diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 2839e51f1..36f8d9700 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -428,13 +428,16 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id:Ok(json!({"dialog": crate::stroke_ui::open(app)}))}// Channels › Channel Options… without params: the dialog on the targeted alpha/spot- // channel, or Quick Mask Options while in Quick Mask (with params: the engine directly).+ // channel, Layer Mask Display Options on a targeted layer mask, or Quick Mask Options while+ // in Quick Mask (with params: the engine directly).crate::channel_options_ui::COMMAND if params.as_object().is_none_or(|o| o.is_empty()) => {+ let mask = app.layer_mask_targeted();let st = app.session.active().ok_or("no document is open")?;let channel = match st.channel_view.target {_ if st.doc.quick_mask.is_some() => json!("quickMask"),photocraft_engine::channel_cmds::ChannelTarget::Alpha(i) => json!(i),- _ => return Err("target an alpha or spot channel first".into()),+ _ if mask => json!("mask"),+ _ => return Err("target an alpha or spot channel, or a layer mask, first".into()),};let dialog = crate::channel_options_ui::open(app, &channel).ok_or("no such channel")?;Ok(json!({"dialog": dialog}))diff --git a/docs/context-menu-inventory.md b/docs/context-menu-inventory.mdindex 3d7bc522f..a932a58b2 100644--- a/docs/context-menu-inventory.md+++ b/docs/context-menu-inventory.md@@ -30,7 +30,7 @@ Canvas invariant: secondary click must not accidentally start a paint stroke, co| Surface | Current entries or behavior | Command route / gap ||---|---|---|| Layers panel row | Blending Options; Duplicate/Delete; Group from Layers; Quick Export PNG / Export As; Artboard/Frame from Layers; Convert to Smart Object; content-specific Rasterize; Add/Disable/Apply/Delete Layer Mask; Create/Release Clipping Mask; Link/Select Linked; Copy/Paste/Clear Layer Style; Merge Layers/Down, Merge Visible, Flatten Image; Rename Layer. Multi-select changes duplicate/delete/merge labels and target. | `layer_menu_ui::entries` supplies IDs for all except inline rename, then `menus::invoke` or engine dispatch. Missing or disabled commands are filtered/greyed. Check menu visibility and enabled state for groups, backgrounds, masks, type, adjustment/fill, smart objects, and multi-selection. |-| Channels panel row | Alpha: Duplicate/Delete/Rename, spot conversion or merge, selection-display and overlay controls. Quick Mask: Exit, display and overlay. Composite/color: Duplicate. Layer mask: Enable/Disable, Delete. Common: New Channel, New Spot Channel, Split, Merge. | `channel.*`, `layer.layerMask.*`, `select.editInQuickMaskMode`, `ui.renameChannel`. Check selection loading/saving, channel options, and per-row enablement against Photoshop. |+| Channels panel row | Alpha: Duplicate/Delete/Rename, spot conversion or merge, selection-display and overlay controls. Quick Mask: Exit, display and overlay. Composite/color: Duplicate. Layer mask: Enable/Disable, Delete, Layer Mask Display Options… (also on double-click). Common: New Channel, New Spot Channel, Split, Merge. | `channel.*`, `layer.layerMask.*`, `select.editInQuickMaskMode`, `ui.renameChannel`. Check selection loading/saving, channel options, and per-row enablement against Photoshop. || Brushes panel preset | Rename Brush, Delete Brush. | Routed through `brush.presets.*` panel actions. Check duplicate/export/import and library organization. || Brushes panel group | Rename Group, Delete Group. | Routed through preset panel actions; confirm group deletion consequences. || Generic presets group (gradients, patterns, swatches, etc.) | Rename Group, Delete Group. | `preset_panels.rs`; verify each collection's appropriate create, export/import, and delete semantics. |diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 14d416f19..4b397a9de 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -105,6 +105,7 @@ store expose and persist the same setting; scripts keep using canonical command| `layer.new.layer` | `{"name":"Ink"}` || `layer.select` | `{"layer":id\|str,"mode":"replace\|toggle\|range\|add\|remove"}` or `{"name":"Background","occurrence":0?}` (occurrence is zero-based document walk order; required for duplicate names): ⌘-click = toggle, ⇧-click = range; `document.inspect` reports `selectedLayers` and a per-layer `selected` flag || `channel.target` / `channel.setVisible` | Channels panel target and eyes (`"composite"`, colour name, alpha index or name, `"quickMask"`). `document.inspect` (and `channel.list`) report `channels`: composite/colour/alpha rows with visibility, channel options, `quickMask`, `target`. Pixel commands without a `target` param follow the targeted channel |+| `channel.options` | `{"channel":index\|name\|"quickMask"\|"mask",…}`: Channel Options (name, `indicates`, overlay `color`, `opacity`/`solidity`). On `"mask"` it is Layer Mask Display Options: the `color` and `opacity` of every layer mask's rubylith (`\`, ⇧⌥-click), kept in the preferences as `layerMaskOverlay` (not an undo step) and returned under that key || `layer.setProps` | `{"layer":id?,"name":…,"visible":…,"opacity":0..1,"blend":"Multiply"}` || `layer.fill.solidColor.set` | `{"layer":id?,"document":id?,"color":"#rrggbb"}`: edit a Solid Color Fill in one undo step; RGB without alpha preserves the fill's alpha. Float RGB arrays and a stored `Color` are also accepted. `document` rejects stale dialog targets. || `layer.fill.pattern.set` | `{"layer":id?,"document":id?,"pattern":id\|name?,"scale":1..1000?,"angle":-180..180?,"link":bool?,"phase":[x,y]?}`: edit a Pattern Fill (the Pattern Fill dialog's OK) in one undo step; omitted values keep the layer's, `phase` `[0,0]` is Snap to Origin. `layer.newFillLayer.pattern` from a menu (no params) and `layer.layerContentOptions` on a Pattern Fill layer open the Pattern Fill dialog. |diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 377ce8583..e6c59d5d3 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 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) | 13 | 6 | 4 | settings that do nothing: 26 of 168 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 170 (target 0) || [Type](#type) | 4 | 3 | 2 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 29 of 29 crates; panic_hunt present |@@ -179,7 +179,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 26 of 168** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.+**Settings that do nothing: 26 of 170** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.