Smudge: Alt flips Finger Painting only at Strength 100% (CodeRabbit on #16308)

Alt at a lower Strength was not measured, so it keeps following the options bar.
This commit is contained in:
Hector Villarreal committed 2026-11-21 17:00:24 -06:00
1 parent cfe88d3264
commit ff80f68697
2 files changed
+14 -3

No files matched your search

+11 -2
View File
@@ -79,11 +79,20 @@ fn without_alt_the_checkbox_decides() {
#[test]
fn alt_flips_finger_painting_for_the_smudge_tool_only() {
for tool in [Tool::Blur, Tool::Sharpen, Tool::Dodge, Tool::Burn] {
let mut p = json!({"fingerPainting": false});
let mut p = json!({"strength": 100.0, "fingerPainting": false});
crate::retouch_ui::alt_finger_painting(tool, true, &mut p);
assert_eq!(p["fingerPainting"], false, "{tool:?}");
}
let mut p = json!({"fingerPainting": false});
let mut p = json!({"strength": 100.0, "fingerPainting": false});
crate::retouch_ui::alt_finger_painting(Tool::Smudge, true, &mut p);
assert_eq!(p["fingerPainting"], true);
}
#[test]
fn alt_below_full_strength_keeps_the_checkbox_value() {
for on in [false, true] {
let mut p = json!({"strength": 50.0, "fingerPainting": on});
crate::retouch_ui::alt_finger_painting(Tool::Smudge, true, &mut p);
assert_eq!(p["fingerPainting"], on, "Alt at Strength 50 % is not measured: the stroke follows the checkbox");
}
}
+3 -1
View File
@@ -21,10 +21,12 @@ pub(crate) fn alt_flipped(tool: Tool, alt: bool) -> Tool {
}
/// A Smudge stroke with ⌥ held at the press turns Finger Painting the other way for that one stroke, as in Photoshop
/// (#12957): `p` is the stroke's `paint.smudge` params. The options bar keeps its value.
/// (#12957): `p` is the stroke's `paint.smudge` params. The options bar keeps its value. Only measured at Strength
/// 100 %, so a lower Strength keeps today's behaviour (the issue's "not measured" case).
pub(crate) fn alt_finger_painting(tool: Tool, alt: bool, p: &mut Value) {
if tool == Tool::Smudge
&& alt
&& p.get("strength").and_then(Value::as_f64).is_some_and(|s| s >= 100.0)
&& let Some(on) = p.get("fingerPainting").and_then(Value::as_bool)
{
p["fingerPainting"] = json!(!on);