Shift-click lines aren't smoothed, so they end at the click (#11887)

Measured on #11887: smoothing doesn't apply to a Shift-click line, whatever
Smoothing and Catch-up on Stroke End are set to. With Catch-up on Stroke End
now off by default, the smoothed line stopped short of the click. A
Shift-click drag sends `smoothing: 0` with its stroke params; the options
bar's Smoothing is untouched.
This commit is contained in:
RickiNano committed 2026-11-08 22:01:12 +01:00
1 parent b390bef334
commit ca005139f2
4 files changed
+34 -2

No files matched your search

+4
View File
@@ -16,6 +16,9 @@ pub struct Drag {
pub clear: bool,
/// ⇧ constraint of a painting stroke (stroke_constraint.rs).
pub constrain: Option<crate::stroke_constraint::Axis>,
/// A ⇧-click line from the previous stroke's end. Smoothing doesn't apply to it, so it ends
/// at the click whatever Catch-up on Stroke End is set to, as in Photoshop (#11887).
pub line: bool,
/// Modifiers held now (updated on every pointer event of the gesture).
pub live: egui::Modifiers,
/// Which of the modifiers held at the press have been released since.
@@ -55,6 +58,7 @@ impl Drag {
erase,
clear: false,
constrain: None,
line: false,
live: modifiers,
released: egui::Modifiers::NONE,
reposition: false,
+5 -1
View File
@@ -293,10 +293,14 @@ pub(super) fn live_stroke(app: &PhotocraftApp, idx: usize) -> Option<&LiveStroke
}
/// `paint.stroke` params for a Brush/Eraser drag (shared by the live preview and the commit). The
/// stroke smoothing is the session brush's (the options bar's Smoothing %).
/// stroke smoothing is the session brush's (the options bar's Smoothing %), except on a ⇧-click
/// line, which isn't smoothed (#11887).
pub(super) fn stroke_params(app: &PhotocraftApp, d: &Drag, points: &[Vec<f64>]) -> serde_json::Value {
let tool = d.tool;
let mut p = json!({ "points": points, "erase": d.erase, "zoom": app.point_zoom(), "target": paint_target(app) });
if d.line {
p["smoothing"] = json!(0.0);
}
if d.clear {
p["mode"] = json!("clear");
}
+1 -1
View File
@@ -578,7 +578,7 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)
}
// ⌥ flips Dodge/Burn and Blur/Sharpen for this stroke.
let tool = crate::retouch_ui::alt_flipped(tool, mods.alt);
let mut drag = Drag { clear, ..Drag::new(tool, from.map_or([x, y], |p| [p[0], p[1]]), points, mods, erase) };
let mut drag = Drag { clear, line: from.is_some(), ..Drag::new(tool, from.map_or([x, y], |p| [p[0], p[1]]), points, mods, erase) };
drag.capture_vector_owners(app);
drag.capture_selection_at_press(app);
drag.document = super::drag::DragDocument::capture(app);
@@ -243,6 +243,30 @@ mod tests {
assert!(alpha(&app, 20, 100) > 0.9 && alpha(&app, 40, 80) > 0.9 && alpha(&app, 90, 30) > 0.9);
}
#[test]
fn shift_click_line_ends_at_the_click_with_catch_up_on_stroke_end_off() {
// Measured in Photoshop (#11887): smoothing doesn't apply to a ⇧-click line, whatever
// Smoothing and Catch-up on Stroke End are set to.
let mut app = app();
app.ui.tool = Tool::Brush;
app.session.tools.brush.smoothing.amount = 0.6;
app.session.tools.brush.smoothing.catch_up_on_end = false;
let none = egui::Modifiers::NONE;
// A plain two-point drag at this smoothing ends short of the release point.
tool_event(&mut app, ToolEvent::Down { x: 10.0, y: 60.0, pressure: 1.0 }, none);
tool_event(&mut app, ToolEvent::Move { x: 100.0, y: 60.0, pressure: 1.0 }, none);
tool_event(&mut app, ToolEvent::Up { x: 100.0, y: 60.0 }, none);
assert!(alpha(&app, 100, 60) == 0.0, "a smoothed drag lags");
// ⇧-click: the line runs from the drag's release point all the way to the click.
let shift = egui::Modifiers::SHIFT;
tool_event(&mut app, ToolEvent::Down { x: 100.0, y: 110.0, pressure: 1.0 }, shift);
tool_event(&mut app, ToolEvent::Up { x: 100.0, y: 110.0 }, shift);
assert_eq!(last_stroke_points(&app), vec![[100.0, 60.0], [100.0, 110.0]]);
assert!(alpha(&app, 100, 62) > 0.9 && alpha(&app, 100, 85) > 0.9 && alpha(&app, 100, 110) > 0.9);
// The options bar's Smoothing is unchanged.
assert_eq!(app.session.tools.brush.smoothing.amount, 0.6);
}
#[test]
fn shift_click_interpolates_from_previous_strokes_endpoint_pressure() {
let mut app = app();