PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Brush Settings: disable Wetness/Mix controls outside Mixer Brush
augrclk69cd2abafc10
diff --git a/crates/ui-egui/src/brush_panel.rs b/crates/ui-egui/src/brush_panel.rsindex 515e6e5a2..efae719f1 100644--- a/crates/ui-egui/src/brush_panel.rs+++ b/crates/ui-egui/src/brush_panel.rs@@ -369,9 +369,11 @@ fn settings_tab(app: &mut PhotocraftApp, ui: &mut egui::Ui) {// The picked preset is recorded by name (`brush.presets.setCurrent`, identity, so// look-alike duplicates stay distinct), since the engine can't infer it from the// brush afterwards.- ui.add_enabled_ui(on, |ui| section_body(ui, &mut b, section, &app.session.tools.presets, app.session.tools.current_preset.as_deref()))- .inner- .inspect(|name| run_or_status(app, "brush.presets.setCurrent", json!({ "name": name })));+ ui.add_enabled_ui(on, |ui| {+ section_body(ui, &mut b, section, &app.session.tools.presets, app.session.tools.current_preset.as_deref(), app.ui.tool)+ })+ .inner+ .inspect(|name| run_or_status(app, "brush.presets.setCurrent", json!({ "name": name })));});});});diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rsindex 750a9d550..4713b9610 100644--- a/crates/ui-egui/src/brush_panel_tests.rs+++ b/crates/ui-egui/src/brush_panel_tests.rs@@ -547,6 +547,64 @@ fn harness(tab: usize, section: usize) -> Harness<'static, PhotocraftApp> {h}+#[test]+fn transfer_mixer_edits_use_the_brush_command_and_survive_real_tool_swaps() {+ use crate::state::Tool;+ use egui_kittest::kittest::{NodeT, Queryable};++ let mut h = harness(0, 6);+ let a = h.state_mut();+ a.ui.tool = Tool::Brush;+ a.session.tools.brush.transfer.enabled = true;+ a.session.tools.brush.transfer.wetness = paint::Dynamic { jitter: 0.41, minimum: 0.43, control: Control::PenPressure, fade_steps: 339 };+ a.session.tools.brush.transfer.mix = paint::Dynamic { jitter: 0.63, minimum: 0.67, control: Control::PenPressure, fade_steps: 449 };+ crate::paint_mouse::sync_tool_brush(a);+ a.ui.tool = Tool::MixerBrush;+ crate::paint_mouse::sync_tool_brush(a);+ h.run_steps(2);+ h.hover_at(h.get_by_label("Opacity Jitter").rect().center());+ h.event(egui::Event::MouseWheel {+ unit: egui::MouseWheelUnit::Point,+ delta: vec2(0.0, -250.0),+ phase: egui::TouchPhase::Move,+ modifiers: egui::Modifiers::NONE,+ });+ h.run_steps(20);+ let journal = h.state().session.journal.len();+ let field = h.query_all_by_role(egui::accesskit::Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(41.0)).unwrap();+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.run_steps(2);+ assert!((h.state().session.tools.brush.transfer.wetness.jitter - 0.42).abs() < 1e-6);+ assert_eq!(h.state().session.journal.len(), journal + 1);+ let (id, params) = last_journal(h.state()).unwrap();+ assert_eq!(id, "tools.setBrush");+ assert_eq!(params["brush"], json!({"transfer": {"wetness": {"jitter": 0.42_f32}}}));+ let mixer = h.state().session.tools.brush.clone();++ let a = h.state_mut();+ a.ui.tool = Tool::Brush;+ crate::paint_mouse::sync_tool_brush(a);+ h.run_steps(2);+ let brush = h.state().session.tools.brush.clone();+ let field = h.query_all_by_role(egui::accesskit::Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(41.0)).unwrap();+ assert!(field.accesskit_node().is_disabled());+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.run_steps(2);+ assert_eq!(h.state().session.tools.brush, brush);+ assert_eq!(h.state().session.journal.len(), journal + 1, "inactive edits and tool swaps add no brush command");+ let a = h.state_mut();+ a.ui.tool = Tool::MixerBrush;+ crate::paint_mouse::sync_tool_brush(a);+ h.run_steps(2);+ assert_eq!(h.state().session.tools.brush, mixer, "the Mixer Brush keeps its own edited settings");+ assert!(+ h.query_all_by_role(egui::accesskit::Role::SpinButton)+ .any(|node| node.accesskit_node().numeric_value() == Some(42.0) && !node.accesskit_node().is_disabled())+ );+}+fn toggle_value(app: &PhotocraftApp, section: usize) -> bool {let brush = serde_json::to_value(&app.session.tools.brush).unwrap();let path = match section {diff --git a/crates/ui-egui/src/brush_sections.rs b/crates/ui-egui/src/brush_sections.rsindex ff7ca5d29..65e5abc82 100644--- a/crates/ui-egui/src/brush_sections.rs+++ b/crates/ui-egui/src/brush_sections.rs@@ -8,6 +8,7 @@ use photocraft_engine::BrushSettings;use photocraft_engine::paint::{self, BrushPreset, Control, Dynamic, MAX_BRUSH_SIZE, MaskMode, Pattern, PatternStyle, TipShape};use crate::brush_preview;+use crate::state::Tool;use crate::theme::{self, Tokens};use crate::widgets;@@ -518,12 +519,16 @@ fn color_dynamics(ui: &mut egui::Ui, b: &mut BrushSettings) {signed_pct(ui, tl!("Purity"), &mut c.purity, -1.0, 1.0);}-fn transfer(ui: &mut egui::Ui, b: &mut BrushSettings) {+fn transfer(ui: &mut egui::Ui, b: &mut BrushSettings, tool: Tool) {let tr = &mut b.transfer;dynamic(ui, "brush-opacity-ctl", tl!("Opacity Jitter"), &mut tr.opacity, 1.0, Some(tl!("Minimum")), false);dynamic(ui, "brush-flow-ctl", tl!("Flow Jitter"), &mut tr.flow, 1.0, Some(tl!("Minimum")), false);- dynamic(ui, "brush-wet-ctl", tl!("Wetness Jitter"), &mut tr.wetness, 1.0, Some(tl!("Minimum")), false);- dynamic(ui, "brush-mix-ctl", tl!("Mix Jitter"), &mut tr.mix, 1.0, Some(tl!("Minimum")), false);+ // Wetness and mix only affect the Mixer Brush. Keep their settings visible and saved+ // for other tools, but disable the whole blocks, including controllers and minimums.+ ui.add_enabled_ui(tool == Tool::MixerBrush, |ui| {+ dynamic(ui, "brush-wet-ctl", tl!("Wetness Jitter"), &mut tr.wetness, 1.0, Some(tl!("Minimum")), false);+ dynamic(ui, "brush-mix-ctl", tl!("Mix Jitter"), &mut tr.mix, 1.0, Some(tl!("Minimum")), false);+ });}/// The Mixer Brush options the brush carries (Photoshop shows them in the Mixer Brush's options@@ -576,7 +581,8 @@ fn smoothing(ui: &mut egui::Ui, b: &mut BrushSettings) {/// Controls for section `i` (see [`crate::brush_panel::SECTIONS`]). `presets` feed the tip grids./// Returns the name of a preset whose tip was picked in the Brush Tip Shape grid, for/// `brush.presets.setCurrent`.-pub fn section_body(ui: &mut egui::Ui, b: &mut BrushSettings, i: usize, presets: &[BrushPreset], current: Option<&str>) -> Option<String> {+/// The active `tool` determines which Transfer controls apply.+pub fn section_body(ui: &mut egui::Ui, b: &mut BrushSettings, i: usize, presets: &[BrushPreset], current: Option<&str>, tool: Tool) -> Option<String> {let t = Tokens::get(ui.ctx());let note = |ui: &mut egui::Ui, s: &str| {ui.label(RichText::new(s).color(t.text_faint).font(theme::medium(11.5)));@@ -591,7 +597,7 @@ pub fn section_body(ui: &mut egui::Ui, b: &mut BrushSettings, i: usize, presets:4 => dual_brush(ui, b, presets),5 => color_dynamics(ui, b),6 => {- transfer(ui, b);+ transfer(ui, b, tool);mixer_options(ui, b);}7 => pose(ui, b),@@ -637,7 +643,7 @@ mod tests {ready = true;return;}- section_body(ui, b, section, &[], None);+ section_body(ui, b, section, &[], None, Tool::MixerBrush);},b,);@@ -668,6 +674,134 @@ mod tests {}}+ struct TransferState {+ brush: BrushSettings,+ tool: Tool,+ }++ fn transfer_mixer_brush() -> BrushSettings {+ let mut b = BrushSettings::default();+ b.transfer.enabled = true;+ for (dynamic, jitter, minimum, fade_steps) in [+ (&mut b.transfer.opacity, 0.13, 0.17, 119),+ (&mut b.transfer.flow, 0.27, 0.29, 229),+ (&mut b.transfer.wetness, 0.41, 0.43, 339),+ (&mut b.transfer.mix, 0.63, 0.67, 449),+ ] {+ *dynamic = Dynamic { control: Control::Fade, jitter, minimum, fade_steps };+ }+ b+ }++ fn transfer_mixer_harness(kind: theme::ThemeKind, tool: Tool) -> Harness<'static, TransferState> {+ let mut ready = false;+ let mut h = Harness::builder().with_size(vec2(340.0, 1400.0)).build_ui_state(+ move |ui, state: &mut TransferState| {+ if !ready {+ crate::PhotocraftApp::setup_context(ui.ctx(), kind);+ ready = true;+ return;+ }+ ui.add_enabled_ui(state.brush.transfer.enabled, |ui| section_body(ui, &mut state.brush, 6, &[], None, state.tool));+ },+ TransferState { brush: transfer_mixer_brush(), tool },+ );+ h.run_steps(3);+ h+ }++ /// #3825: Mixer-only blocks follow the tool, including sliders, minimums and Fade steps.+ #[test]+ fn transfer_mixer_controls_follow_the_tool_and_section_in_every_theme() {+ for kind in theme::ThemeKind::ALL {+ let mut h = transfer_mixer_harness(kind, Tool::Brush);+ let before = h.state().brush.clone();+ for tool in Tool::ALL {+ h.state_mut().tool = tool;+ h.run_steps(2);+ for (mixer_only, values) in [(false, [13.0, 17.0, 119.0, 27.0, 29.0, 229.0]), (true, [41.0, 43.0, 339.0, 63.0, 67.0, 449.0])] {+ for value in values {+ let field = h.query_all_by_role(Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(value)).unwrap();+ assert_eq!(field.accesskit_node().is_disabled(), mixer_only && tool != Tool::MixerBrush, "{kind:?}, {tool:?}, {value}");+ }+ }+ for (index, node) in h.query_all_by_role(Role::ComboBox).enumerate() {+ assert_eq!(node.accesskit_node().is_disabled(), index >= 2 && tool != Tool::MixerBrush, "{kind:?}, {tool:?}: controller {index}");+ }+ assert_eq!(h.state().brush, before, "changing tool context only changes availability");+ }+ h.state_mut().tool = Tool::MixerBrush;+ h.state_mut().brush.transfer.enabled = false;+ h.run_steps(2);+ assert!(h.query_all_by_role(Role::SpinButton).all(|node| node.accesskit_node().is_disabled()), "section Off still disables every field");+ assert!(h.query_all_by_role(Role::ComboBox).all(|node| node.accesskit_node().is_disabled()));+ h.state_mut().brush.transfer.enabled = true;+ h.state_mut().brush.transfer.wetness.control = Control::Off;+ h.run_steps(2);+ let minimum = h.query_all_by_role(Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(43.0)).unwrap();+ assert!(minimum.accesskit_node().is_disabled(), "Control Off still disables the applicable minimum");+ }+ }++ #[test]+ fn transfer_mixer_controls_ignore_disabled_edits_and_keep_values_on_reactivation() {+ let mut h = transfer_mixer_harness(theme::ThemeKind::ProMedium, Tool::Brush);+ let before = h.state().brush.clone();+ for value in [41.0, 43.0, 339.0, 63.0, 67.0, 449.0] {+ let field = h.query_all_by_role(Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(value)).unwrap();+ let at = field.rect().center();+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.event(egui::Event::Text("999".into()));+ h.key_press(egui::Key::Enter);+ h.run_steps(2);+ h.hover_at(at);+ h.drag_at(at);+ h.run_steps(1);+ h.drop_at(at + vec2(60.0, 0.0));+ h.run_steps(2);+ assert_eq!(h.state().brush, before, "inactive field {value} ignores keyboard and pointer input");+ }+ for label in ["Wetness Jitter", "Mix Jitter"] {+ let row = h.get_by_label(label).rect();+ let from = pos2(row.left() + 120.0, row.bottom() + 16.0);+ h.hover_at(from);+ h.drag_at(from);+ h.run_steps(1);+ h.hover_at(from + vec2(150.0, 0.0));+ h.run_steps(1);+ h.drop_at(from + vec2(150.0, 0.0));+ h.run_steps(2);+ assert_eq!(h.state().brush, before, "the inactive {label} track ignores a drag");+ }+ h.state_mut().tool = Tool::MixerBrush;+ h.run_steps(2);+ let row = h.get_by_label("Wetness Jitter").rect();+ let from = pos2(row.left() + 120.0, row.bottom() + 16.0);+ h.hover_at(from);+ h.drag_at(from);+ h.run_steps(1);+ h.hover_at(from + vec2(150.0, 0.0));+ h.run_steps(1);+ h.drop_at(from + vec2(150.0, 0.0));+ h.run_steps(2);+ assert!(h.state().brush.transfer.wetness.jitter > 0.6, "the same track accepts a drag when applicable");+ h.state_mut().brush.transfer.wetness.jitter = 0.41;+ h.run_steps(2);+ let field = h.query_all_by_role(Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(41.0)).unwrap();+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.run_steps(2);+ assert!((h.state().brush.transfer.wetness.jitter - 0.42).abs() < 1e-6);+ let after = h.state().brush.clone();+ h.state_mut().tool = Tool::Brush;+ h.run_steps(2);+ h.state_mut().tool = Tool::MixerBrush;+ h.run_steps(2);+ assert_eq!(h.state().brush, after);+ assert!(h.query_all_by_role(Role::SpinButton).any(|node| node.accesskit_node().numeric_value() == Some(42.0) && !node.accesskit_node().is_disabled()));+ }+fn set_controls(b: &mut BrushSettings, control: Control) {for d in [&mut b.shape_dynamics.size,diff --git a/docs/brush-parity.md b/docs/brush-parity.mdindex 7a5e49982..d973482f8 100644--- a/docs/brush-parity.md+++ b/docs/brush-parity.md@@ -1,6 +1,6 @@# Brush and painting parity-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Transfer Wetness/Mix tool applicability; Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view) · **Target:** Adobe Photoshop 2026Painting is where Photoshop users notice differences first, so it gets its own checklist: thebrush engine (`crates/paint/src/brush.rs`), the Brush Settings UI@@ -26,6 +26,7 @@ tablets against Photoshop side by side.| Color Dynamics (FG/BG, hue/sat/brightness jitter, purity, per tip) | done | || Hue Jitter uses a standard percentage-amount track instead of a hue spectrum | done | #3825 (Hue Jitter appearance only); rendered track checked in all 14 themes; numeric and pointer edits retain percentage units and engine command routing. || Transfer (opacity/flow/wetness/mix jitter and controls) | done | |+| Transfer Wetness/Mix blocks disabled outside Mixer Brush, retaining their settings | done | #3825 (tool applicability only); UI regressions cover all 14 themes and 67 tools, disabled input, section/Control Off, command routing and per-tool settings || Shape Dynamics and Transfer minimum fields disabled when their Control is Off, retaining their values | done | #3825 (minimum-field interaction only); `brush_sections.rs` UI regressions cover all six fields, reactivation and disabled input || Brush Pose (tilt, rotation, pressure overrides) | done | || Noise, Wet Edges, Build-up, Protect Texture | done | |@@ -121,3 +122,4 @@ tablets against Photoshop side by side.| 2026-10-12 | minor | A shaped tip's cursor outline turns and flips with a rotated or flipped view, and follows pixel aspect correction || 2026-10-13 | minor | Shape Dynamics and Transfer minimum inputs follow their Control and retain their values while disabled (#3825, partial). No brush-feel estimate changed. || 2026-10-13 | minor | Hue Jitter uses the same themed amount slider as other jitter controls (#3825, partial). No brush-feel estimate changed. |+| 2026-10-13 | minor | Transfer Wetness/Mix controls follow the active tool and retain their settings while disabled (#3825, partial). No brush-feel estimate changed. |diff --git a/docs/gaps.md b/docs/gaps.mdindex 25a286aab..f2571d35b 100644--- a/docs/gaps.md+++ b/docs/gaps.md@@ -1,6 +1,6 @@# Where PhotoCraft falls short of Photoshop-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (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) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G4: Transfer Mixer-only controls, #3825 partial; 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) · **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@@ -156,6 +156,9 @@ what an agent can't finish alone.- **Estimate:** 250–400 h (many overlap with other gaps; count each fix once).### G4. Brush feel+- **Progress (2026-10-13, #3825 partial):** Transfer’s Wetness Jitter and Mix Jitter+ blocks are disabled outside the Mixer Brush, retaining their saved settings. Opacity+ and Flow keep their existing availability; other layout and brush-feel gaps remain open.- **Progress (2026-10-13, #3825 partial):** Hue Jitter shows a standard themedpercentage-amount track rather than a hue spectrum. Other Brush Settings layoutand brush-behaviour gaps remain open.@@ -263,6 +266,7 @@ what an agent can't finish alone.| Date | Change | Summary ||---|---|---|+| 2026-10-13 | minor | G4: Transfer Wetness/Mix tool applicability (#3825, partial); no readiness percentage or estimate changed || 2026-10-13 | minor | G4: Hue Jitter amount-track appearance (#3825, partial); no readiness percentage or estimate changed || 2026-10-13 | minor | G4: minimum inputs in Shape Dynamics and Transfer follow their Control (#3825, partial); no readiness percentage or estimate changed || 2026-10-12 | minor | G5: Free Transform options bar H/V skew fields done |