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");