From e21ca07289dc40082f6665cab2a13b3a9cc2801a Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 20:53:34 -0600 Subject: [PATCH 1/2] Color Replacement: the brush cursor always shows its centre + (#11934) With Normal Brush Tip cursors the Color Replacement cursor draws the tip circle with a + in its centre, the pixel it samples, whatever Show Crosshair in Brush Tip says, as in the reference application and as the Background Eraser already does. Other brush tools keep following the preference; Clone Stamp and Healing Brush keep their Alt behaviour. --- crates/ui-egui/src/canvas/cursors.rs | 9 +++-- .../src/color_replacement_cursor_tests.rs | 33 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 crates/ui-egui/src/color_replacement_cursor_tests.rs diff --git a/crates/ui-egui/src/canvas/cursors.rs b/crates/ui-egui/src/canvas/cursors.rs index e4f0336b1de..6bc48fc59b5 100644 --- a/crates/ui-egui/src/canvas/cursors.rs +++ b/crates/ui-egui/src/canvas/cursors.rs @@ -37,7 +37,8 @@ pub(crate) fn pencil_tip_is_round(size: f32) -> bool { /// Whether a brush-tip circle draws its centre mark. /// Clone Stamp and Healing Brush stay an empty circle until Option is held, the source-point /// cursor. Other brushes follow Preferences › Cursors › Show Crosshair in Brush Tip, as in -/// Photoshop; the Background Eraser always shows its sampling hotspot. +/// Photoshop; the Background Eraser and the Color Replacement tool (#11934) always show their +/// sampling hotspot. pub(super) fn brush_tip_centre(tool: Tool, option: bool, show_crosshair: bool) -> bool { if tool == Tool::QuickSelection { return false; @@ -45,7 +46,7 @@ pub(super) fn brush_tip_centre(tool: Tool, option: bool, show_crosshair: bool) - if matches!(tool, Tool::CloneStamp | Tool::Healing) { return option || show_crosshair; } - show_crosshair || tool == Tool::BackgroundEraser + show_crosshair || matches!(tool, Tool::BackgroundEraser | Tool::ColorReplacement) } /// The display colour of an RGB triple (0..1 per channel) as an egui colour. @@ -290,6 +291,10 @@ pub(crate) fn alt_picks(tool: Tool, mods: egui::Modifiers) -> bool { #[path = "../eyedropper_mask_sample_tests.rs"] mod eyedropper_mask_sample_tests; +#[cfg(test)] +#[path = "../color_replacement_cursor_tests.rs"] +mod color_replacement_cursor_tests; + #[cfg(test)] #[path = "../background_eraser_alt_click_tests.rs"] mod background_eraser_alt_click_tests; diff --git a/crates/ui-egui/src/color_replacement_cursor_tests.rs b/crates/ui-egui/src/color_replacement_cursor_tests.rs new file mode 100644 index 00000000000..5a8ad4ebf90 --- /dev/null +++ b/crates/ui-egui/src/color_replacement_cursor_tests.rs @@ -0,0 +1,33 @@ +//! #11934: with Normal Brush Tip cursors the Color Replacement cursor always draws the centre +, +//! its sampling hotspot, whatever Show Crosshair in Brush Tip says. Other brush tools follow the +//! preference, and Clone Stamp / Healing Brush keep their Alt behaviour. + +use super::*; + +#[test] +fn color_replacement_always_shows_its_centre() { + for show_crosshair in [false, true] { + for option in [false, true] { + assert!(brush_tip_centre(Tool::ColorReplacement, option, show_crosshair), "crosshair pref {show_crosshair}, Alt {option}"); + } + } +} + +#[test] +fn other_brush_tools_follow_the_preference() { + for tool in [Tool::Brush, Tool::Eraser, Tool::PatternStamp, Tool::Dodge, Tool::Pencil, Tool::Smudge] { + assert!(!brush_tip_centre(tool, false, false), "{tool:?} off"); + assert!(brush_tip_centre(tool, false, true), "{tool:?} on"); + } + // The Background Eraser keeps its hotspot, as before. + assert!(brush_tip_centre(Tool::BackgroundEraser, false, false)); +} + +#[test] +fn clone_stamp_and_healing_keep_their_alt_behaviour() { + for tool in [Tool::CloneStamp, Tool::Healing] { + assert!(!brush_tip_centre(tool, false, false), "{tool:?}"); + assert!(brush_tip_centre(tool, true, false), "{tool:?} with Alt"); + assert!(brush_tip_centre(tool, false, true), "{tool:?} with the preference"); + } +} From dadc5b89276ce11f2c80a45f93d24da35d0daf44 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 8 Nov 2026 09:29:39 -0600 Subject: [PATCH 2/2] Color Replacement cursor: tests cover Alt for every tool and Quick Selection; the docs name Full Size Brush Tip (eliets2 review on crates/ui-egui/src/color_replacement_cursor_tests.rs) --- crates/ui-egui/src/canvas/cursors.rs | 10 ++++----- .../src/color_replacement_cursor_tests.rs | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/canvas/cursors.rs b/crates/ui-egui/src/canvas/cursors.rs index 6bc48fc59b5..10343e1ae1f 100644 --- a/crates/ui-egui/src/canvas/cursors.rs +++ b/crates/ui-egui/src/canvas/cursors.rs @@ -34,11 +34,11 @@ pub(crate) fn pencil_tip_is_round(size: f32) -> bool { (h - 0.5) * std::f32::consts::SQRT_2 > h } -/// Whether a brush-tip circle draws its centre mark. -/// Clone Stamp and Healing Brush stay an empty circle until Option is held, the source-point -/// cursor. Other brushes follow Preferences › Cursors › Show Crosshair in Brush Tip, as in -/// Photoshop; the Background Eraser and the Color Replacement tool (#11934) always show their -/// sampling hotspot. +/// Whether a brush-tip circle draws its centre mark, for Normal and Full Size Brush Tip cursors +/// alike (both draw through this). Quick Selection never draws one. Clone Stamp and Healing Brush +/// stay an empty circle until Option is held, the source-point cursor. Other brushes follow +/// Preferences › Cursors › Show Crosshair in Brush Tip, as in Photoshop; the Background Eraser +/// and the Color Replacement tool (#11934) always show their sampling hotspot. pub(super) fn brush_tip_centre(tool: Tool, option: bool, show_crosshair: bool) -> bool { if tool == Tool::QuickSelection { return false; diff --git a/crates/ui-egui/src/color_replacement_cursor_tests.rs b/crates/ui-egui/src/color_replacement_cursor_tests.rs index 5a8ad4ebf90..e2ed2b1859f 100644 --- a/crates/ui-egui/src/color_replacement_cursor_tests.rs +++ b/crates/ui-egui/src/color_replacement_cursor_tests.rs @@ -1,6 +1,6 @@ -//! #11934: with Normal Brush Tip cursors the Color Replacement cursor always draws the centre +, -//! its sampling hotspot, whatever Show Crosshair in Brush Tip says. Other brush tools follow the -//! preference, and Clone Stamp / Healing Brush keep their Alt behaviour. +//! #11934: with Normal and Full Size Brush Tip cursors the Color Replacement cursor always draws +//! the centre +, its sampling hotspot, whatever Show Crosshair in Brush Tip says. Other brush +//! tools follow the preference, and Clone Stamp / Healing Brush keep their Alt behaviour. use super::*; @@ -16,11 +16,18 @@ fn color_replacement_always_shows_its_centre() { #[test] fn other_brush_tools_follow_the_preference() { for tool in [Tool::Brush, Tool::Eraser, Tool::PatternStamp, Tool::Dodge, Tool::Pencil, Tool::Smudge] { - assert!(!brush_tip_centre(tool, false, false), "{tool:?} off"); - assert!(brush_tip_centre(tool, false, true), "{tool:?} on"); + for option in [false, true] { + assert!(!brush_tip_centre(tool, option, false), "{tool:?} off, Alt {option}"); + assert!(brush_tip_centre(tool, option, true), "{tool:?} on, Alt {option}"); + } + } + for show_crosshair in [false, true] { + for option in [false, true] { + // The Background Eraser keeps its hotspot, as before; Quick Selection never has one. + assert!(brush_tip_centre(Tool::BackgroundEraser, option, show_crosshair)); + assert!(!brush_tip_centre(Tool::QuickSelection, option, show_crosshair)); + } } - // The Background Eraser keeps its hotspot, as before. - assert!(brush_tip_centre(Tool::BackgroundEraser, false, false)); } #[test]