From 87a68b0a81ec8b6cd4205c96b9ccf6afd4a0c939 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 2 Sep 2022 11:47:09 -0300 Subject: [PATCH] Fix Ctrl+Alt+drag mouse to increase brush size when moving to the right (fix #3496) Regression introduced in 50707117f6856557e6dc77ee7a022d1a3a4fe6c2 --- src/app/ui/editor/dragging_value_state.cpp | 3 ++- .../ui/editor/state_with_wheel_behavior.cpp | 24 +++++++++++-------- src/app/ui/editor/state_with_wheel_behavior.h | 8 ++++++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/app/ui/editor/dragging_value_state.cpp b/src/app/ui/editor/dragging_value_state.cpp index 45075b282..1bed93ee8 100644 --- a/src/app/ui/editor/dragging_value_state.cpp +++ b/src/app/ui/editor/dragging_value_state.cpp @@ -126,7 +126,8 @@ bool DraggingValueState::onMouseMove(Editor* editor, MouseMessage* msg) delta, dz, ScrollBigSteps::Off, - preciseWheel); + preciseWheel, + FromMouseWheel::Off); } } diff --git a/src/app/ui/editor/state_with_wheel_behavior.cpp b/src/app/ui/editor/state_with_wheel_behavior.cpp index 6b2c26505..48648aa6e 100644 --- a/src/app/ui/editor/state_with_wheel_behavior.cpp +++ b/src/app/ui/editor/state_with_wheel_behavior.cpp @@ -151,7 +151,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg) ScrollBigSteps::Off, (msg->preciseWheel() ? PreciseWheel::On: - PreciseWheel::Off)); + PreciseWheel::Off), + FromMouseWheel::On); return true; } @@ -162,7 +163,8 @@ void StateWithWheelBehavior::processWheelAction( gfx::Point delta, double dz, const ScrollBigSteps scrollBigSteps, - const PreciseWheel preciseWheel) + const PreciseWheel preciseWheel, + const FromMouseWheel fromMouseWheel) { switch (wheelAction) { @@ -274,17 +276,19 @@ void StateWithWheelBehavior::processWheelAction( ToolPreferences::Brush& brush = Preferences::instance().tool(tool).brush; + if (fromMouseWheel == FromMouseWheel::On) { #if LAF_WINDOWS || LAF_LINUX - // By default on macOS the mouse wheel is correct, up increase - // brush size, and down decrease it. But on Windows and Linux - // it's inverted. - dz = -dz; + // By default on macOS the mouse wheel is correct, up increase + // brush size, and down decrease it. But on Windows and Linux + // it's inverted. + dz = -dz; #endif - // We can configure the mouse wheel for brush size to behave as - // in previous versions. - if (Preferences::instance().editor.invertBrushSizeWheel()) - dz = -dz; + // We can configure the mouse wheel for brush size to behave as + // in previous versions. + if (Preferences::instance().editor.invertBrushSizeWheel()) + dz = -dz; + } brush.size( std::clamp( diff --git a/src/app/ui/editor/state_with_wheel_behavior.h b/src/app/ui/editor/state_with_wheel_behavior.h index bc9568f70..093b47fc4 100644 --- a/src/app/ui/editor/state_with_wheel_behavior.h +++ b/src/app/ui/editor/state_with_wheel_behavior.h @@ -33,6 +33,11 @@ namespace app { enum class ScrollBigSteps { Off, On }; enum class PreciseWheel { Off, On }; + // Indicates that the message comes from a real mouse wheel (which + // might have special handling inverting the direction of the + // wheel action depending on the operating system, etc.) + enum class FromMouseWheel { Off, On }; + StateWithWheelBehavior(); bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override; @@ -46,7 +51,8 @@ namespace app { gfx::Point delta, double dz, const ScrollBigSteps scrollBigSteps, - const PreciseWheel preciseWheel); + const PreciseWheel preciseWheel, + const FromMouseWheel fromMouseWheel); const doc::LayerList& browsableLayers(Editor* editor) const; virtual Color initialFgColor() const;