From 7236bb88a66ea93b0ecd6c52a5e7272e696a3888 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 11 Nov 2026 13:49:57 +0100 Subject: [PATCH] PR #12056: opacity keeps its 200-point HUD rate; Select and Mask test follows the hardness rate With Vary Round Brush Hardness on HUD off, the vertical drag sets the opacity, which now keeps main's rate (200 points for 100 %) while the hardness takes the measured 385. The Select and Mask resize test computes its expected hardness from HARDNESS_TRAVEL. Co-Authored-By: DuBearte Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/select_mask_ui/tests.rs | 5 +++-- crates/ui-egui/src/tools/brush_resize.rs | 8 ++++++-- crates/ui-egui/src/tools/brush_resize/tests.rs | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/select_mask_ui/tests.rs b/crates/ui-egui/src/dialogs/select_mask_ui/tests.rs index e1d320322c..e6e321985a 100644 --- a/crates/ui-egui/src/dialogs/select_mask_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/select_mask_ui/tests.rs @@ -888,7 +888,8 @@ fn alt_right_drag_resizes_the_workspace_brush() { let w = h.state().distort.select_mask.as_ref().unwrap(); let want = (30.0 + 2.0 * f64::from(40.0 / zoom)).round(); assert_eq!(w.brush_size, want, "horizontal motion sets the diameter (zoom {zoom})"); - assert_eq!(w.hardness, 70.0, "upward motion softens the brush, 200 points for 100 %"); + let soft = (100.0 - 60.0 * 100.0 / crate::brush_resize::HARDNESS_TRAVEL).round(); + assert_eq!(w.hardness, soft, "upward motion softens the brush, at the canvas HUD's rate"); assert_eq!((w.quick_size, w.refine_size), (30.0, 30.0), "the other tools keep their sizes"); assert!(w.strokes.is_empty() && w.edits.is_empty() && w.undo.is_empty(), "resizing selected nothing"); assert!(w.resize.is_none(), "the gesture ends with the button"); @@ -904,7 +905,7 @@ fn alt_right_drag_resizes_the_workspace_brush() { pointer_drag(&mut h, over, PointerButton::Primary, Modifiers::CTRL | Modifiers::ALT, vec2(-10.0, 0.0)); let w = h.state().distort.select_mask.as_ref().unwrap(); assert_eq!(w.quick_size, (30.0 - 2.0 * f64::from(10.0 / zoom)).round().max(1.0)); - assert_eq!((w.brush_size, w.hardness), (want, 70.0), "the Brush keeps its size and hardness"); + assert_eq!((w.brush_size, w.hardness), (want, soft), "the Brush keeps its size and hardness"); assert!(w.strokes.is_empty() && w.edits.len() == 1, "resizing Quick Selection selected nothing"); } diff --git a/crates/ui-egui/src/tools/brush_resize.rs b/crates/ui-egui/src/tools/brush_resize.rs index 24596b34d6..075c06b579 100644 --- a/crates/ui-egui/src/tools/brush_resize.rs +++ b/crates/ui-egui/src/tools/brush_resize.rs @@ -22,6 +22,9 @@ use crate::state::Tool; /// Screen points of vertical drag that take the hardness from 0 % to 100 %: Photoshop's rate, /// where 50 points down from 0 % give 13 % (#11891). pub const HARDNESS_TRAVEL: f32 = 385.0; +/// Screen points of vertical drag that take the opacity from 0 % to 100 % when "Vary Round Brush +/// Hardness on HUD" is off: the rate it had before the hardness rate was measured (#11891). +pub const OPACITY_TRAVEL: f32 = 200.0; /// The brush size range (`tools.setBrush` accepts the same). const SIZE: std::ops::RangeInclusive = 1.0..=MAX_BRUSH_SIZE; @@ -123,10 +126,11 @@ fn update(app: &mut PhotocraftApp, r: Resize, x: f64, y: f64) { // No view: document axes, mirrored by View › Flip Horizontal. _ => ((x - r.anchor[0]) * if app.ui.view.flip_horizontal { -1.0 } else { 1.0 }, y - r.anchor[1], app.point_zoom()), }; - let (size, v) = resized(r.start, dx, dy, zoom); // "Vary Round Brush Hardness on HUD" (Preferences ▸ Tools, on by default): off, the vertical - // movement takes the opacity instead of the hardness, as in Photoshop. + // movement takes the opacity instead of the hardness, as in Photoshop, at its own rate. let vary = app.session.prefs().tools.vary_round_brush_hardness_on_hud; + let dy = if vary { dy } else { dy * f64::from(HARDNESS_TRAVEL / OPACITY_TRAVEL) }; + let (size, v) = resized(r.start, dx, dy, zoom); let b = &app.session.tools.brush; if b.size == size && if vary { b.hardness == v } else { b.opacity == v } { return; diff --git a/crates/ui-egui/src/tools/brush_resize/tests.rs b/crates/ui-egui/src/tools/brush_resize/tests.rs index 89cc875cf9..b2e5790b68 100644 --- a/crates/ui-egui/src/tools/brush_resize/tests.rs +++ b/crates/ui-egui/src/tools/brush_resize/tests.rs @@ -297,9 +297,11 @@ fn vary_round_brush_hardness_on_hud_switches_the_vertical_target() { app.run("prefs.set", json!({"path": "tools.varyRoundBrushHardnessOnHud", "value": false})).unwrap(); } let (h0, o0) = (app.session.tools.brush.hardness, app.session.tools.brush.opacity); + // 20 % of each travel: 77 points for the hardness, 40 for the opacity, which keeps its rate. + let y = if vary { 177.0 } else { 140.0 }; tool_event(&mut app, ToolEvent::Down { x: 100.0, y: 100.0, pressure: 1.0 }, CTRL_ALT); - tool_event(&mut app, ToolEvent::Move { x: 100.0, y: 177.0, pressure: 1.0 }, CTRL_ALT); - tool_event(&mut app, ToolEvent::Up { x: 100.0, y: 177.0 }, CTRL_ALT); + tool_event(&mut app, ToolEvent::Move { x: 100.0, y, pressure: 1.0 }, CTRL_ALT); + tool_event(&mut app, ToolEvent::Up { x: 100.0, y }, CTRL_ALT); let b = &app.session.tools.brush; if vary { assert_eq!((b.hardness, b.opacity), (h0 + 0.2, o0), "hardness moves with the drag");