From fa02f2b1b5eef1c74783c1a8a61ec5aba0b6c8ef Mon Sep 17 00:00:00 2001 From: Nigel Ihza Firdausy <106657905+Ni-zav@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:31:17 +0700 Subject: [PATCH 1/3] fix(ui): separate brush section selection from enable toggles --- crates/ui-egui/src/brush_panel.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/brush_panel.rs b/crates/ui-egui/src/brush_panel.rs index 515e6e5a21..b6e87da199 100644 --- a/crates/ui-egui/src/brush_panel.rs +++ b/crates/ui-egui/src/brush_panel.rs @@ -1,7 +1,7 @@ //! Window › Brush Settings (F5) and Window › Brushes: Photoshop's floating brush panel. //! -//! Brush Settings: the section list with enable boxes on the left (clicking a controls section -//! shows and enables it; the last five rows only toggle), the selected section's controls on the right (see [`crate::brush_sections`]), +//! Brush Settings: the section list with enable boxes on the left (selecting a controls section +//! shows its options without enabling it; the last five rows only toggle), the selected section's controls on the right (see [`crate::brush_sections`]), //! and a live stroke preview strip below, rendered with the real brush engine and cached on the //! settings (it re-renders only when they change). Brushes: the presets in collapsible groups with //! tip thumbnails and stroke previews, a size slider and a search field. @@ -241,7 +241,7 @@ pub(crate) fn full_uv() -> egui::Rect { egui::Rect::from_min_max(egui::Pos2::ZERO, egui::pos2(1.0, 1.0)) } -/// Clicking a controls section shows and enables it; the final five rows only toggle, keeping +/// Selecting a controls section shows its settings without enabling it; the final five rows toggle, keeping /// the current controls open. The lock on the right is a separate hit target. fn section_list(app: &mut PhotocraftApp, ui: &mut egui::Ui, b: &mut BrushSettings) { let t = Tokens::get(ui.ctx()); @@ -284,6 +284,7 @@ fn section_list(app: &mut PhotocraftApp, ui: &mut egui::Ui, b: &mut BrushSetting ui.painter().rect_filled(r, t.radius_sm, t.hover); } let mut x = r.left() + 6.0; + let mut box_clicked = false; if *has_box && let Some(flag) = section_flag(b, i) { let br = egui::Rect::from_center_size(egui::pos2(x + 6.0, r.center().y), vec2(13.0, 13.0)); // A checkbox-only row is one accessible checkbox across its whole width. A @@ -296,15 +297,14 @@ fn section_list(app: &mut PhotocraftApp, ui: &mut egui::Ui, b: &mut BrushSetting resp }); let on_lock = resp.interact_pointer_pos().is_some_and(|p| p.x > r.right() - 22.0); - // A press on the row (but not its lock) presses the box too: a release there - // turns the section on, or toggles a checkbox-only row (#4476). - let pressed = box_resp.as_ref().is_some_and(|b| b.is_pointer_button_down_on()) || (resp.is_pointer_button_down_on() && !on_lock); + // For controls sections, only the checkbox toggles the setting; a row + // click selects the settings without enabling them (#5136). + let pressed = box_resp.as_ref().is_some_and(|b| b.is_pointer_button_down_on()) || (toggle_only && resp.is_pointer_button_down_on() && !on_lock); let hovered = box_resp.as_ref().is_some_and(|b| b.hovered()) || (toggle_only && resp.hovered()); widgets::check_box(ui.painter(), br, *flag, hovered, pressed, &t); - if box_resp.is_some_and(|resp| resp.clicked()) || (toggle_only && resp.clicked() && !on_lock) { + box_clicked = box_resp.as_ref().is_some_and(|resp| resp.clicked()); + if box_clicked || (toggle_only && resp.clicked() && !on_lock) { *flag = !*flag; - } else if !toggle_only && resp.clicked() && !on_lock { - *flag = true; } x += 20.0; } else { @@ -334,7 +334,7 @@ fn section_list(app: &mut PhotocraftApp, ui: &mut egui::Ui, b: &mut BrushSetting lock_clicked = true; } } - if !toggle_only && resp.clicked() && !lock_clicked { + if !toggle_only && resp.clicked() && !lock_clicked && !box_clicked { app.ui.brush_section = i; } if i == 0 { From a7ff8a0a4cebe036e996a032741f58bdf1b3ee45 Mon Sep 17 00:00:00 2001 From: Nigel Ihza Firdausy <106657905+Ni-zav@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:31:51 +0700 Subject: [PATCH 2/3] test(ui): cover independent brush section selection and checkboxes --- crates/ui-egui/src/brush_panel_tests.rs | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rs index 750a9d5506..72af37269a 100644 --- a/crates/ui-egui/src/brush_panel_tests.rs +++ b/crates/ui-egui/src/brush_panel_tests.rs @@ -22,6 +22,48 @@ fn sections_with_boxes_have_flags() { assert!(b.texture.enabled); } +#[test] +fn selecting_a_controls_section_keeps_its_enabled_flag_and_brush_history() { + use egui_kittest::kittest::Queryable; + + for (section, name) in [(1, "Shape Dynamics"), (2, "Scattering"), (3, "Texture")] { + let mut h = harness(0, 0); + let before = h.state().session.tools.brush.clone(); + let journal = h.state().session.journal.len(); + + h.get_by_label(name).click(); + h.run_steps(3); + + assert_eq!(h.state().ui.brush_section, section, "{name} settings are visible"); + assert_eq!(h.state().session.tools.brush, before, "{name} remains disabled"); + assert_eq!(h.state().session.journal.len(), journal, "selecting {name} is not a brush edit"); + } +} + +#[test] +fn controls_section_checkbox_toggles_without_selecting_its_settings() { + use egui_kittest::kittest::Queryable; + + let mut h = harness(0, 0); + let row = h.get_by_label("Scattering").rect(); + let checkbox = egui::pos2(row.left() + 12.0, row.center().y); + let journal = h.state().session.journal.len(); + + for enabled in [true, false] { + h.hover_at(checkbox); + h.run_steps(1); + h.drag_at(checkbox); + h.run_steps(1); + h.drop_at(checkbox); + h.run_steps(3); + + assert_eq!(h.state().session.tools.brush.scattering.enabled, enabled); + assert_eq!(h.state().ui.brush_section, 0, "the checkbox does not select Scattering"); + assert_eq!(last_journal(h.state()).unwrap().1["brush"], json!({"scattering": {"enabled": enabled}})); + } + assert_eq!(h.state().session.journal.len(), journal + 2); +} + /// What each section's controls edit, set to non-default values. fn edit_section(i: usize, b: &mut BrushSettings) { let dynamic = |jitter: f32, control: Control, minimum: f32| paint::Dynamic { jitter, control, fade_steps: 40, minimum }; From a0211bf5db88753046c07c91baa76ce343796fcd Mon Sep 17 00:00:00 2001 From: Nigel Ihza Firdausy <106657905+Ni-zav@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:42:01 +0700 Subject: [PATCH 3/3] test(ui): update existing brush selection expectations --- crates/ui-egui/src/brush_panel_tests.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rs index 72af37269a..7e429aaec7 100644 --- a/crates/ui-egui/src/brush_panel_tests.rs +++ b/crates/ui-egui/src/brush_panel_tests.rs @@ -1141,22 +1141,20 @@ fn f5_edits_the_default_brush_with_every_section() { for (name, _) in SECTIONS { assert!(h.query_all_by_label(name).next().is_some(), "{name} listed"); } - // Clicking a section's name shows it and turns it on: one tools.setBrush. + // Clicking a section's name shows its settings without changing its enable flag. let n = h.state().session.journal.len(); + let shape_enabled = h.state().session.tools.brush.shape_dynamics.enabled; h.get_by_label("Shape Dynamics").click(); h.run_steps(3); assert_eq!(h.state().ui.brush_section, 1); - assert!(h.state().session.tools.brush.shape_dynamics.enabled); - assert_eq!(h.state().session.journal.len(), n + 1); - let (id, p) = last_journal(h.state()).unwrap(); - assert_eq!(id, "tools.setBrush"); - assert_eq!(p["brush"]["shapeDynamics"]["enabled"], json!(true)); + assert_eq!(h.state().session.tools.brush.shape_dynamics.enabled, shape_enabled); + assert_eq!(h.state().session.journal.len(), n); // A section's box toggles it without showing it. h.get_by_label("Enable Transfer").click(); h.run_steps(3); assert!(h.state().session.tools.brush.transfer.enabled); assert_eq!(h.state().ui.brush_section, 1); - assert_eq!(h.state().session.journal.len(), n + 2); + assert_eq!(h.state().session.journal.len(), n + 1); // The rest of the brush is untouched. let b = &h.state().session.tools.brush; assert_eq!((b.size, b.hardness, &b.tip), (fresh.size, fresh.hardness, &fresh.tip));