From 39e7c51b4498a91114ca0b25facbbfcf4908b09a Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 19 Nov 2026 18:22:40 +0100 Subject: [PATCH] Address CodeRabbit review: start the Art History Brush's Angle and pressure toggles at their defaults on a first use A first pick of the Art History Brush took the outgoing brush's angle and pressure toggles, so after a Brush with 45 degrees and both toggles on the new bar controls showed those instead of 0 degrees and off (#12629). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas/paint_mouse.rs | 9 ++++++++- .../src/panels/art_history_bar_controls_tests.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/paint_mouse.rs b/crates/ui-egui/src/canvas/paint_mouse.rs index 992c1c825c4..2240173812b 100644 --- a/crates/ui-egui/src/canvas/paint_mouse.rs +++ b/crates/ui-egui/src/canvas/paint_mouse.rs @@ -68,7 +68,14 @@ pub fn sync_tool_brush(app: &mut PhotocraftApp) { }; // The Remove tool starts at its measured 19 px; the rest is the current brush (#12548). let size = if tool == Tool::Remove { REMOVE_TOOL_SIZE } else { current.size }; - BrushSettings { smoothing: first_smoothing(), mode: photocraft_color::BlendMode::Normal, opacity, flow, size, ..current } + let brush = BrushSettings { smoothing: first_smoothing(), mode: photocraft_color::BlendMode::Normal, opacity, flow, size, ..current }; + // The Art History Brush's Angle and pressure toggles are its own bar controls, off and + // at 0° until it changes them (#12629), whatever the outgoing brush has. + if tool == Tool::ArtHistoryBrush { + BrushSettings { angle: fresh.angle, pressure_opacity: fresh.pressure_opacity, pressure_size: fresh.pressure_size, ..brush } + } else { + brush + } } }; // The picked preset was the outgoing tool's brush: forget it, so Update Brush can't overwrite diff --git a/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs b/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs index b34eff6c7a4..fc8e6b9e117 100644 --- a/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs +++ b/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs @@ -141,3 +141,17 @@ fn the_bar_has_no_flow_and_no_airbrush() { assert!(field(&h, "Flow").is_none(), "no Flow field"); assert!(h.query_by_label("Enable airbrush-style build-up effects").is_none(), "no Airbrush toggle"); } + +#[test] +fn a_first_use_starts_off_and_at_0_whatever_the_outgoing_brush_has() { + let mut h = bar(Tool::Brush); + { + let b = &mut h.state_mut().session.tools.brush; + (b.pressure_opacity, b.angle, b.pressure_size) = (true, 45.0, true); + } + switch(&mut h, Tool::ArtHistoryBrush); + assert_eq!(controls(h.state()), (false, 0.0, false), "the first Art History Brush starts at its defaults"); + assert!(angle_field(&h).and_then(|n| n.accesskit_node().numeric_value()) == Some(0.0), "the field shows 0°"); + switch(&mut h, Tool::Brush); + assert_eq!(controls(h.state()), (true, 45.0, true), "the Brush keeps its own settings"); +}