PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Brush Settings: disable minimum inputs when Control is Off (#4775)
Arif Uğur Çelik36112e35d492
diff --git a/crates/ui-egui/src/brush_sections.rs b/crates/ui-egui/src/brush_sections.rsindex 16332e4d0..db044557a 100644--- a/crates/ui-egui/src/brush_sections.rs+++ b/crates/ui-egui/src/brush_sections.rs@@ -89,11 +89,16 @@ fn dynamic(ui: &mut egui::Ui, id: &str, label: &str, d: &mut Dynamic, max: f32,pct(ui, label, &mut d.jitter, max);control_row(ui, id, d, angle);if let Some(m) = minimum {- pct(ui, m, &mut d.minimum, 1.0);+ minimum_row(ui, m, d);}ui.add_space(6.0);}+/// Minimum belongs to the control. Off disables editing without discarding its saved value.+fn minimum_row(ui: &mut egui::Ui, label: &str, d: &mut Dynamic) {+ ui.add_enabled_ui(d.control != Control::Off, |ui| pct(ui, label, &mut d.minimum, 1.0));+}+/// Size: a value field over a logarithmic slider (small sizes get most of the travel)./// `restore` adds Photoshop's "Restore original size" button (sampled tips).fn size_row(ui: &mut egui::Ui, label: &str, size: &mut f32, max: f32, restore: Option<f32>) {@@ -332,7 +337,7 @@ fn shape_dynamics(ui: &mut egui::Ui, b: &mut BrushSettings) {let sd = &mut b.shape_dynamics;pct(ui, tl!("Size Jitter"), &mut sd.size.jitter, 1.0);control_row(ui, "brush-size-ctl", &mut sd.size, false);- pct(ui, tl!("Minimum Diameter"), &mut sd.size.minimum, 1.0);+ minimum_row(ui, tl!("Minimum Diameter"), &mut sd.size);// Tilt Scale applies with the size control on Pen Tilt (greyed out otherwise, like Photoshop).let tilt = sd.size.control == Control::PenTilt;ui.add_enabled_ui(tilt, |ui| pct(ui, tl!("Tilt Scale"), &mut sd.tilt_scale, 2.0));@@ -609,6 +614,127 @@ pub fn section_body(ui: &mut egui::Ui, b: &mut BrushSettings, i: usize, presets:#[cfg(test)]mod tests {use super::*;+ use egui::accesskit::Role;+ use egui_kittest::{+ Harness,+ kittest::{NodeT, Queryable},+ };++ fn minimum_brush() -> BrushSettings {+ let mut b = BrushSettings::default();+ b.shape_dynamics.size.minimum = 0.2;+ b.shape_dynamics.roundness.minimum = 0.35;+ b.transfer.opacity.minimum = 0.4;+ b.transfer.flow.minimum = 0.55;+ b.transfer.wetness.minimum = 0.6;+ b.transfer.mix.minimum = 0.75;+ b+ }++ fn section_harness(section: usize, b: BrushSettings) -> Harness<'static, BrushSettings> {+ let mut ready = false;+ let mut h = Harness::builder().with_size(vec2(340.0, 1100.0)).build_ui_state(+ move |ui, b: &mut BrushSettings| {+ if !ready {+ crate::PhotocraftApp::setup_context(ui.ctx(), theme::ThemeKind::ProMedium);+ ready = true;+ return;+ }+ section_body(ui, b, section, &[], None);+ },+ b,+ );+ h.run_steps(3);+ h+ }++ fn set_controls(b: &mut BrushSettings, control: Control) {+ for d in [+ &mut b.shape_dynamics.size,+ &mut b.shape_dynamics.roundness,+ &mut b.transfer.opacity,+ &mut b.transfer.flow,+ &mut b.transfer.wetness,+ &mut b.transfer.mix,+ ] {+ d.control = control;+ }+ }++ /// #3825: all six minimum fields follow their own Control; jitter remains editable.+ #[test]+ fn minimum_fields_are_disabled_only_when_their_control_is_off() {+ for (section, values) in [(1, vec![20.0, 35.0]), (6, vec![40.0, 55.0, 60.0, 75.0])] {+ let mut h = section_harness(section, minimum_brush());+ for (control, _) in CONTROLS {+ set_controls(h.state_mut(), control);+ h.run_steps(2);+ for value in &values {+ let field = h.query_all_by_role(Role::SpinButton).find(|n| n.accesskit_node().numeric_value() == Some(*value)).expect("minimum input");+ assert_eq!(field.accesskit_node().is_disabled(), control == Control::Off, "section {section}, minimum {value}, {control:?}");+ }+ assert!(+ h.query_all_by_role(Role::SpinButton).any(|n| n.accesskit_node().numeric_value() == Some(0.0) && !n.accesskit_node().is_disabled()),+ "jitter stays editable"+ );+ }+ set_controls(h.state_mut(), Control::PenPressure);+ if section == 1 {+ h.state_mut().shape_dynamics.size.control = Control::Off;+ } else {+ h.state_mut().transfer.opacity.control = Control::Off;+ }+ h.run_steps(2);+ for (index, value) in values.iter().enumerate() {+ let field = h.query_all_by_role(Role::SpinButton).find(|n| n.accesskit_node().numeric_value() == Some(*value)).unwrap();+ assert_eq!(field.accesskit_node().is_disabled(), index == 0, "each minimum follows its own control");+ }+ }+ }++ fn drag(h: &mut Harness<'static, BrushSettings>, from: egui::Pos2, to: egui::Pos2) {+ h.event(egui::Event::PointerMoved(from));+ h.run_steps(1);+ h.event(egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });+ h.run_steps(1);+ h.event(egui::Event::PointerMoved(to));+ h.run_steps(1);+ h.event(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });+ h.run_steps(2);+ }++ #[test]+ fn disabled_minimum_ignores_input_and_keeps_its_value_for_reactivation() {+ let mut h = section_harness(1, minimum_brush());+ let before = h.state().clone();+ let field = h.query_all_by_role(Role::SpinButton).find(|n| n.accesskit_node().numeric_value() == Some(20.0)).unwrap();+ let center = field.rect().center();+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.event(egui::Event::Text("99".into()));+ h.key_press(egui::Key::Enter);+ // The slider below the number and its scrubby label are disabled too.+ let track = pos2(300.0, center.y + 24.0);+ drag(&mut h, track, track);+ let label = h.get_by_label("Minimum Diameter").rect().center();+ drag(&mut h, label, label + vec2(60.0, 0.0));+ assert_eq!(h.state(), &before, "disabled interactions never rewrite brush settings");++ h.state_mut().shape_dynamics.size.control = Control::PenPressure;+ h.run_steps(2);+ let field = h.query_all_by_role(Role::SpinButton).find(|n| n.accesskit_node().numeric_value() == Some(20.0)).unwrap();+ assert!(!field.accesskit_node().is_disabled());+ field.click();+ h.key_press(egui::Key::ArrowUp);+ h.run_steps(2);+ assert_eq!(h.state().shape_dynamics.size.minimum, 0.21, "active minimum is editable");+ drag(&mut h, track, track);+ let minimum = h.state().shape_dynamics.size.minimum;+ assert!(minimum > 0.8, "the active slider accepts the same pointer position: {minimum}");+ h.state_mut().shape_dynamics.size.control = Control::Off;+ h.run_steps(2);+ assert_eq!(h.state().shape_dynamics.size.minimum, minimum, "Off keeps the saved minimum");+ }#[test]fn ellipse_widget_drags_angle_and_roundness() {diff --git a/docs/brush-parity.md b/docs/brush-parity.mdindex 4022f7a65..39efd3637 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-12 · **Change:** minor (checkbox-only Brush Settings 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 (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@@ -25,6 +25,7 @@ tablets against Photoshop side by side.| Dual Brush | done | || Color Dynamics (FG/BG, hue/sat/brightness jitter, purity, per tip) | done | || Transfer (opacity/flow/wetness/mix jitter and controls) | done | |+| 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 | || Smoothing: amount, Pulled String, Stroke Catch-up, Catch-up on End, Adjust for Zoom | done | `brush.rs:428-438` |@@ -117,3 +118,4 @@ tablets against Photoshop side by side.| 2026-10-11 | minor | `~` held with the Brush or Pencil erases with that tool's brush, and Clear joins their Mode menus (#3439) || 2026-10-12 | minor | Five Brush Settings switch rows toggle without selecting a properties pane; Smoothing has a default-on switch and retains its settings while disabled (#4283). No brush-feel estimate changed. || 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. |diff --git a/docs/gaps.md b/docs/gaps.mdindex 65102e2d0..23b375123 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-12 · **Change:** minor (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: 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@@ -151,6 +151,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):** Shape Dynamics' Minimum Diameter / Minimum+ Roundness and Transfer's four Minimum rows disable editing when their Control is Off,+ retaining the configured values. The other layout and control gaps in #3825 remain open.- **Progress (2026-10-12, #4283):** the five checkbox-only Brush Settings rows keep the opencontrols selected; Smoothing can be disabled without discarding its amount or mode. Thiscloses that panel interaction gap, not the stroke-quality or performance gaps below.@@ -252,6 +255,7 @@ what an agent can't finish alone.| Date | Change | Summary ||---|---|---|+| 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 || 2026-10-12 | minor | G11: `.atn` import maps 112 events (Select and Mask, Spatter, Ripple, Crystallize, Pattern Fill, mask targeting, Step Backward, points, Bitmap) || 2026-10-12 | minor | G9: toolbar tool shortcut editing (#4086); the remaining workspace gaps stay open |