From e37bbde31f87ed1f94fd92d60342593590492131 Mon Sep 17 00:00:00 2001 From: Lcoding15 <125505497+Lcoding15@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:04:26 +0100 Subject: [PATCH 1/6] Eyedroppers: one cursor over the image, and caps lock's precise crosshair (#9836) With a Levels or Curves eyedropper armed (in the dialog or in Properties), or a colour picker's or Replace Color's, the image showed the pipette and the current tool's own cursor at once (the Zoom tool's magnifier, a brush's crosshair), drawn a little apart: the tool cursor was painted after the eyedropper had set its own. While an eyedropper owns the image the tool's cursor is no longer drawn (a held Space or zoom key still shows its own). These eyedroppers also only followed Cursors > Other Cursors; caps lock now swaps the pipette and the precise crosshair there as it does for the Eyedropper tool, as in Photoshop. --- crates/ui-egui/src/canvas.rs | 19 +++++++++- crates/ui-egui/src/caps_lock_tests.rs | 54 +++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index da59b5a7ca..44b9c3e8f8 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -716,7 +716,9 @@ fn handle_dialog_canvas_input(app: &mut PhotocraftApp, input: DialogCanvasInput< } } } else if picking && let Some(p) = crate::dialogs::free_pointer_over(input.ctx, input.rect) { - if app.session.prefs().cursors.other == photocraft_engine::prefs::OtherCursor::Precise { + // The dialogs' eyedroppers (Levels, Curves, a colour picker's) swap the pipette for the + // precise crosshair with caps lock too, as the Eyedropper tool does (#9836). + if precise_other_cursor(app) { input.ctx.set_cursor_icon(egui::CursorIcon::Crosshair); } else { input.ctx.set_cursor_icon(pipette_cursor(input.ctx, p)); @@ -1315,6 +1317,15 @@ fn paint_primary_overlays(app: &mut PhotocraftApp, ui: &mut egui::Ui, view: &mut draw_canvas_tool_cursor(app, ui, input, resizing); } +/// An eyedropper owns the image: a dialog's (Levels, Curves, Replace Color, a colour picker's) +/// or a Properties Levels/Curves one. It sets the cursor itself. +fn eyedropper_owns_image(app: &PhotocraftApp) -> bool { + crate::adjust_dialog::picker_armed(app) + || crate::filter_dialog::color_eyedropper_armed(app) + || crate::color_picker_ui::top(app).is_some() + || crate::layer_picker::armed(app).is_some() +} + fn draw_canvas_tool_cursor(app: &mut PhotocraftApp, ui: &mut egui::Ui, input: &CanvasOverlayInput<'_>, resizing: bool) { let ctx = input.ctx; let xf = input.xf; @@ -1331,6 +1342,9 @@ fn draw_canvas_tool_cursor(app: &mut PhotocraftApp, ui: &mut egui::Ui, input: &C }); if panning { // The fist set with the pan above stays (#2196). + } else if tool == app.ui.tool && eyedropper_owns_image(app) { + // The eyedropper set its own cursor; the tool's isn't drawn over it (#9836). A held + // Space or zoom key (another `tool`) still shows its own. } else if crate::tool_cursor::pointer_elsewhere(ctx, &crate::panel_docking::native_viewports(app, ctx)) { // The pointer is over a floating panel's own window; this window's last position of // it is stale, so no tool cursor or brush outline is painted at it. @@ -1700,7 +1714,8 @@ fn layer_picker_eyedropper(app: &mut PhotocraftApp, ui: &egui::Ui, ctx: &egui::C if response.hovered() && let Some(p) = ui.input(|i| i.pointer.hover_pos()) { - if app.session.prefs().cursors.other == photocraft_engine::prefs::OtherCursor::Precise { + // Caps lock swaps the pipette and the precise crosshair, as everywhere (#9836). + if precise_other_cursor(app) { ctx.set_cursor_icon(egui::CursorIcon::Crosshair); } else { ctx.set_cursor_icon(pipette_cursor(ctx, p)); diff --git a/crates/ui-egui/src/caps_lock_tests.rs b/crates/ui-egui/src/caps_lock_tests.rs index 1e57c40920..8876087119 100644 --- a/crates/ui-egui/src/caps_lock_tests.rs +++ b/crates/ui-egui/src/caps_lock_tests.rs @@ -154,3 +154,57 @@ fn caps_lock_swaps_the_other_cursors_between_their_icon_and_the_crosshair() { assert_eq!(fp(&h), standard, "{tool:?}: releasing caps lock restores the icon"); } } + +/// #9836: an armed Levels or Curves eyedropper (and the dialogs' other pickers) shows its own +/// cursor alone, not with the tool's drawn over it, and takes caps lock's precise crosshair as +/// well, as in Photoshop, instead of only following the preference. +#[test] +fn caps_lock_gives_the_curves_eyedroppers_the_precise_crosshair() { + let mut h = capslock_harness(); + // A tool whose own cursor ignores caps lock, so only the eyedropper can answer it. + h.state_mut().ui.tool = Tool::Move; + let id = crate::adjust_dialog::open(h.state_mut(), "image.adjustments.curves").unwrap(); + let base = h.state_mut().ui.dialog_mut(id).map(|d| crate::filter_dialog::params_of(&d.fields)).unwrap(); + let dialog = h.state_mut().ui.dialog_mut(id).unwrap(); + dialog.fields.insert("__curvePicker".into(), json!("black")); + dialog.fields.insert("__curvePickerBase".into(), base); + assert!(crate::adjust_dialog::picker_armed(h.state()), "the black-point eyedropper is armed"); + h.run_steps(3); + other(&mut h, "standard"); + let standard = fp(&h); + assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); + other(&mut h, "precise"); + let precise = fp(&h); + assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + assert_ne!(standard, precise, "Standard: the pipette"); + other(&mut h, "standard"); + caps(&mut h, true); + assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); + other(&mut h, "precise"); + assert_eq!(fp(&h), standard, "and the precise crosshair back into the pipette"); + caps(&mut h, false); + assert_eq!(fp(&h), precise, "releasing caps lock restores the preference"); +} + +/// #9836: the same for a Properties Levels or Curves eyedropper (layer_picker.rs). +#[test] +fn caps_lock_gives_the_properties_eyedroppers_the_precise_crosshair() { + let mut h = capslock_harness(); + h.state_mut().ui.tool = Tool::Move; + h.state_mut().run("layer.newAdjustmentLayer.curves", json!({})).unwrap(); + let layer = h.state().session.active().unwrap().active_layer.unwrap(); + h.state_mut().ui.layer_picker = Some(crate::layer_picker::LayerPicker { layer: layer.0, point: "black".into(), tool: Tool::Move }); + assert!(crate::layer_picker::armed(h.state()).is_some(), "the Properties black-point eyedropper is armed"); + h.run_steps(3); + other(&mut h, "standard"); + let standard = fp(&h); + assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); + other(&mut h, "precise"); + let precise = fp(&h); + assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + other(&mut h, "standard"); + caps(&mut h, true); + assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); + caps(&mut h, false); + assert_eq!(fp(&h), standard, "releasing caps lock restores the pipette"); +} From 28de7240f4d9d364f8ddb948bcf10b8b7dd59337 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 31 Oct 2026 21:51:03 +0000 Subject: [PATCH 2/6] #9836: document the two cursor paths this PR changes The review's docstring-coverage check found half the functions touched here undocumented: what `handle_dialog_canvas_input` takes over the image for, and the order of cases `draw_canvas_tool_cursor` decides by. No behaviour change. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LymhVaGZCWwB9HNEbLzeMM --- crates/ui-egui/src/canvas.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 44b9c3e8f8..592251d1b8 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -640,6 +640,10 @@ struct DialogCanvasInput<'a> { img_rect: Rect, } +/// Pointer input on the image while a dialog or panel owns it, before the tools see it: an armed +/// eyedropper (a colour picker's, Curves, Replace Color, Color Range), Select and Mask's Refine +/// Edge Brush, Field Blur's pins, a Layer Style shadow drag, a ⌘/Ctrl-click adding a Curves point, +/// and the zoom and pan that stay available throughout. It also sets the cursor these show. fn handle_dialog_canvas_input(app: &mut PhotocraftApp, input: DialogCanvasInput<'_>) { let sticky_alt = app.ui.shell.sticky_alt; let zoom_out = |alt: bool| match input.temporary { @@ -1326,6 +1330,11 @@ fn eyedropper_owns_image(app: &PhotocraftApp) -> bool { || crate::layer_picker::armed(app).is_some() } +/// Set the cursor for the tool over the image, and paint the ones PhotoCraft draws itself (the +/// brush tip outline, the crosshair, a tool's own icon). The first case that applies wins: a pan +/// keeps the fist it set, an eyedropper that owns the image keeps the cursor it set, a stale +/// pointer position over another window paints nothing, then a guide under the pointer, then the +/// tool's own cursor. fn draw_canvas_tool_cursor(app: &mut PhotocraftApp, ui: &mut egui::Ui, input: &CanvasOverlayInput<'_>, resizing: bool) { let ctx = input.ctx; let xf = input.xf; From bd1c8b54e3fc407128ca69f7ccf425ae371df891 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Nov 2026 18:23:50 +0000 Subject: [PATCH 3/6] #9836: cover the Color Picker's eyedropper too Review asks for the cursor in each dialog state with caps lock on and off, and for the tools outside dialogs to keep working. The dialog Levels/Curves picker and the Properties one were already covered both ways; the Color Picker's own eyedropper, the third state `eyedropper_owns_image` names, was not. It is now, over both Other Cursors settings and caps lock either way, and it fails if the dialog path stops reading caps lock. The tools outside dialogs stay covered by the two tests at the top of this file, which this PR does not touch. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LymhVaGZCWwB9HNEbLzeMM --- crates/ui-egui/src/caps_lock_tests.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/ui-egui/src/caps_lock_tests.rs b/crates/ui-egui/src/caps_lock_tests.rs index 8876087119..8dd93969ab 100644 --- a/crates/ui-egui/src/caps_lock_tests.rs +++ b/crates/ui-egui/src/caps_lock_tests.rs @@ -208,3 +208,29 @@ fn caps_lock_gives_the_properties_eyedroppers_the_precise_crosshair() { caps(&mut h, false); assert_eq!(fp(&h), standard, "releasing caps lock restores the pipette"); } + +/// #9836 review: the Color Picker's own eyedropper is the third dialog state that owns the image, +/// beside Levels/Curves and Properties, and it answers caps lock the same way. +#[test] +fn caps_lock_gives_the_color_pickers_eyedropper_the_precise_crosshair() { + let mut h = capslock_harness(); + // A tool whose own cursor ignores caps lock, so only the eyedropper can answer it. + h.state_mut().ui.tool = Tool::Move; + crate::color_picker_ui::open(h.state_mut(), "foreground"); + assert!(crate::color_picker_ui::top(h.state()).is_some(), "the Color Picker owns the image"); + h.run_steps(3); + other(&mut h, "standard"); + let standard = fp(&h); + assert_eq!(standard.icon, CursorIcon::None, "the drawn pipette, not the Move tool's arrow over it"); + other(&mut h, "precise"); + let precise = fp(&h); + assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + assert_ne!(standard, precise); + other(&mut h, "standard"); + caps(&mut h, true); + assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); + other(&mut h, "precise"); + assert_eq!(fp(&h), standard, "and the precise crosshair back into the pipette"); + caps(&mut h, false); + assert_eq!(fp(&h), precise, "releasing caps lock restores the preference"); +} From 28c2429a045dbe1dc92f00c85cfbf6cd64659075 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 19:40:33 +0000 Subject: [PATCH 4/6] #9836: a tool lent by a held key shows its cursor over an eyedropper, even when it is also selected Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GbuSKAS2k5248LGFEapMUR --- crates/ui-egui/src/canvas.rs | 9 +++++++-- crates/ui-egui/src/caps_lock_tests.rs | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index d8a448cca4..cbead9e956 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1256,6 +1256,9 @@ struct CanvasOverlayInput<'a> { response: &'a egui::Response, doc: &'a std::sync::Arc, tool: Tool, + /// `tool` is lent by a held key or the middle button (the Hand, the Zoom, the Move with ⌘), + /// even when it is the selected tool too: it shows its own cursor. + lent: bool, idx: usize, output: Option, border: photocraft_engine::prefs::CanvasBorder, @@ -1368,9 +1371,10 @@ fn draw_canvas_tool_cursor(app: &mut PhotocraftApp, ui: &mut egui::Ui, input: &C }); if panning { // The fist set with the pan above stays (#2196). - } else if tool == app.ui.tool && eyedropper_owns_image(app) { + } else if !input.lent && eyedropper_owns_image(app) { // The eyedropper set its own cursor; the tool's isn't drawn over it (#9836). A held - // Space or zoom key (another `tool`) still shows its own. + // Space or zoom key, or the middle button, still shows the tool it lends, even when + // that is the selected tool as well. } else if crate::tool_cursor::pointer_elsewhere(ctx, &crate::panel_docking::native_viewports(app, ctx)) { // The pointer is over a floating panel's own window; this window's last position of // it is stale, so no tool cursor or brush outline is painted at it. @@ -2067,6 +2071,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: response: &response, doc: &doc, tool, + lent: temporary.is_some() || middle, idx, output, border, diff --git a/crates/ui-egui/src/caps_lock_tests.rs b/crates/ui-egui/src/caps_lock_tests.rs index 8dd93969ab..0a55efab3a 100644 --- a/crates/ui-egui/src/caps_lock_tests.rs +++ b/crates/ui-egui/src/caps_lock_tests.rs @@ -234,3 +234,25 @@ fn caps_lock_gives_the_color_pickers_eyedropper_the_precise_crosshair() { caps(&mut h, false); assert_eq!(fp(&h), precise, "releasing caps lock restores the preference"); } + +/// CodeRabbit on #10406: the middle button lends the Hand, and its cursor shows over an +/// eyedropper that owns the image even when the Hand is the selected tool as well. +#[test] +fn a_lent_hand_shows_its_cursor_over_an_eyedropper_when_it_is_also_selected() { + let mut h = capslock_harness(); + h.state_mut().ui.tool = Tool::Hand; + crate::color_picker_ui::open(h.state_mut(), "foreground"); + assert!(crate::color_picker_ui::top(h.state()).is_some(), "the Color Picker owns the image"); + other(&mut h, "standard"); + let pipette = fp(&h); + assert_eq!(pipette.icon, CursorIcon::None, "the eyedropper's drawn pipette"); + let p = h.state().last_canvas_rect.center(); + let middle = |pressed| egui::Event::PointerButton { pos: p, button: egui::PointerButton::Middle, pressed, modifiers: egui::Modifiers::NONE }; + h.event(middle(true)); + h.run_steps(2); + let lent = fp(&h); + h.event(middle(false)); + h.run_steps(2); + assert_ne!(lent, pipette, "the Hand's cursor, not the pipette"); + assert!(lent.icon == CursorIcon::Grab || lent.image.is_some(), "the open hand: {:?}", lent.icon); +} From bb8dd1075e8e0206a87bb53577a1a6559ebdc602 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 06:06:42 +0000 Subject: [PATCH 5/6] #9836: the Standard cursor tests check that the pipette is painted Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GbuSKAS2k5248LGFEapMUR --- crates/ui-egui/src/caps_lock_tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ui-egui/src/caps_lock_tests.rs b/crates/ui-egui/src/caps_lock_tests.rs index 0a55efab3a..6dc2531d89 100644 --- a/crates/ui-egui/src/caps_lock_tests.rs +++ b/crates/ui-egui/src/caps_lock_tests.rs @@ -176,6 +176,8 @@ fn caps_lock_gives_the_curves_eyedroppers_the_precise_crosshair() { other(&mut h, "precise"); let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. + assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); assert_ne!(standard, precise, "Standard: the pipette"); other(&mut h, "standard"); caps(&mut h, true); @@ -202,6 +204,8 @@ fn caps_lock_gives_the_properties_eyedroppers_the_precise_crosshair() { other(&mut h, "precise"); let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. + assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); other(&mut h, "standard"); caps(&mut h, true); assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); @@ -225,6 +229,8 @@ fn caps_lock_gives_the_color_pickers_eyedropper_the_precise_crosshair() { other(&mut h, "precise"); let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); + // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. + assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); assert_ne!(standard, precise); other(&mut h, "standard"); caps(&mut h, true); From dce3138d4e4e1d53ee7945cc8f6d58e2a15a0543 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 11:22:57 +0000 Subject: [PATCH 6/6] #9836: the Standard cursor check says what it shows Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GbuSKAS2k5248LGFEapMUR --- crates/ui-egui/src/caps_lock_tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/caps_lock_tests.rs b/crates/ui-egui/src/caps_lock_tests.rs index 6dc2531d89..12b3427da3 100644 --- a/crates/ui-egui/src/caps_lock_tests.rs +++ b/crates/ui-egui/src/caps_lock_tests.rs @@ -177,7 +177,7 @@ fn caps_lock_gives_the_curves_eyedroppers_the_precise_crosshair() { let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. - assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); + assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); assert_ne!(standard, precise, "Standard: the pipette"); other(&mut h, "standard"); caps(&mut h, true); @@ -205,7 +205,7 @@ fn caps_lock_gives_the_properties_eyedroppers_the_precise_crosshair() { let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. - assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); + assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); other(&mut h, "standard"); caps(&mut h, true); assert_eq!(fp(&h), precise, "caps lock turns the pipette into the precise crosshair"); @@ -230,7 +230,7 @@ fn caps_lock_gives_the_color_pickers_eyedropper_the_precise_crosshair() { let precise = fp(&h); assert_eq!(precise.icon, CursorIcon::Crosshair, "Precise: the crosshair"); // CodeRabbit on #10406: the pipette is painted, not only the icon hidden. - assert_ne!(standard.shapes, precise.shapes, "Standard paints the pipette"); + assert_ne!(standard.shapes, precise.shapes, "Standard paints a cursor of its own where Precise shows the crosshair"); assert_ne!(standard, precise); other(&mut h, "standard"); caps(&mut h, true);