Fix Ctrl+Alt+drag mouse to increase brush size when moving to the right (fix #3496)

Regression introduced in 50707117f6
This commit is contained in:
David Capello 2022-09-02 11:47:09 -03:00
parent b168b1191f
commit 87a68b0a81
3 changed files with 23 additions and 12 deletions

View File

@ -126,7 +126,8 @@ bool DraggingValueState::onMouseMove(Editor* editor, MouseMessage* msg)
delta, delta,
dz, dz,
ScrollBigSteps::Off, ScrollBigSteps::Off,
preciseWheel); preciseWheel,
FromMouseWheel::Off);
} }
} }

View File

@ -151,7 +151,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
ScrollBigSteps::Off, ScrollBigSteps::Off,
(msg->preciseWheel() ? (msg->preciseWheel() ?
PreciseWheel::On: PreciseWheel::On:
PreciseWheel::Off)); PreciseWheel::Off),
FromMouseWheel::On);
return true; return true;
} }
@ -162,7 +163,8 @@ void StateWithWheelBehavior::processWheelAction(
gfx::Point delta, gfx::Point delta,
double dz, double dz,
const ScrollBigSteps scrollBigSteps, const ScrollBigSteps scrollBigSteps,
const PreciseWheel preciseWheel) const PreciseWheel preciseWheel,
const FromMouseWheel fromMouseWheel)
{ {
switch (wheelAction) { switch (wheelAction) {
@ -274,17 +276,19 @@ void StateWithWheelBehavior::processWheelAction(
ToolPreferences::Brush& brush = ToolPreferences::Brush& brush =
Preferences::instance().tool(tool).brush; Preferences::instance().tool(tool).brush;
if (fromMouseWheel == FromMouseWheel::On) {
#if LAF_WINDOWS || LAF_LINUX #if LAF_WINDOWS || LAF_LINUX
// By default on macOS the mouse wheel is correct, up increase // By default on macOS the mouse wheel is correct, up increase
// brush size, and down decrease it. But on Windows and Linux // brush size, and down decrease it. But on Windows and Linux
// it's inverted. // it's inverted.
dz = -dz; dz = -dz;
#endif #endif
// We can configure the mouse wheel for brush size to behave as // We can configure the mouse wheel for brush size to behave as
// in previous versions. // in previous versions.
if (Preferences::instance().editor.invertBrushSizeWheel()) if (Preferences::instance().editor.invertBrushSizeWheel())
dz = -dz; dz = -dz;
}
brush.size( brush.size(
std::clamp( std::clamp(

View File

@ -33,6 +33,11 @@ namespace app {
enum class ScrollBigSteps { Off, On }; enum class ScrollBigSteps { Off, On };
enum class PreciseWheel { 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(); StateWithWheelBehavior();
bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override; bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override;
@ -46,7 +51,8 @@ namespace app {
gfx::Point delta, gfx::Point delta,
double dz, double dz,
const ScrollBigSteps scrollBigSteps, const ScrollBigSteps scrollBigSteps,
const PreciseWheel preciseWheel); const PreciseWheel preciseWheel,
const FromMouseWheel fromMouseWheel);
const doc::LayerList& browsableLayers(Editor* editor) const; const doc::LayerList& browsableLayers(Editor* editor) const;
virtual Color initialFgColor() const; virtual Color initialFgColor() const;