From 6022ddad8518f1cf71611bf29d7ac8b4cca0a50b Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Mon, 30 Dec 2019 12:25:21 +0100 Subject: [PATCH 01/11] Fixes #5194: Fix knobs moving too fast For systems where QCursor::setPos() has no effect, this fix adds a workaround for the situation where a knob value is changed via mouse click and move. The fix simulates that the cursor is moved back to the original click position. Before this commit, the cursor was always reset over the knob. Now, it runs over the screen and tries to flip on the opposite screen side if it hits the screen border. This changes the meaning of `Knob::m_origMousePos` from "always being the position where the user clicked" to "the last position in mouseMoveEvent". And it renames it to `m_lastMousePos`. On Apple, `setPos` and cursor hiding are now completely disabled. --- include/Knob.h | 11 ++++- src/gui/widgets/Knob.cpp | 92 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 93 insertions(+), 10 deletions(-) diff --git a/include/Knob.h b/include/Knob.h index d4214334ce8..e3a96a6bde3 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -174,8 +174,8 @@ private slots: BoolModel m_volumeKnob; FloatModel m_volumeRatio; - QPoint m_mouseOffset; - QPoint m_origMousePos; + QPoint m_origMousePos; //!< position where user clicked to turn the knob + QPoint m_lastMousePos; //!< mouse position in last mouseMoveEvent float m_leftOver; bool m_buttonPressed; @@ -196,6 +196,13 @@ private slots: knobTypes m_knobNum; + enum class SetPosStatusType + { + NotChecked, + Works, + NoEffect + }; + static SetPosStatusType s_setPosStatus; } ; #endif diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index e559d120c99..f763b664b05 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifndef __USE_XOPEN @@ -50,6 +51,7 @@ #include "TextFloat.h" TextFloat * Knob::s_textFloat = NULL; +Knob::SetPosStatusType Knob::s_setPosStatus = Knob::SetPosStatusType::NotChecked; @@ -586,14 +588,39 @@ void Knob::mousePressEvent( QMouseEvent * _me ) thisModel->saveJournallingState( false ); } + // on apple, we know that setPos will not work in many cases + // (and that the below check won't work either) + // to not confuse the user, we won't hide the cursor on apple, + // and we won't call setPos on apple either +#ifdef LMMS_BUILD_APPLE + (void)s_setPosStatus; +#else + if(s_setPosStatus == SetPosStatusType::NotChecked) + { + QPoint oldPos = QCursor::pos(); + QCursor::setPos(oldPos - QPoint(1,1)); + s_setPosStatus = (QCursor::pos() == oldPos) + ? SetPosStatusType::NoEffect + : SetPosStatusType::Works; + QCursor::setPos(oldPos); + } +#endif + const QPoint & p = _me->pos(); - m_origMousePos = p; - m_mouseOffset = QPoint(0, 0); + m_origMousePos = m_lastMousePos = p; m_leftOver = 0.0f; emit sliderPressed(); - QApplication::setOverrideCursor( Qt::BlankCursor ); +#ifndef LMMS_BUILD_APPLE + if(s_setPosStatus == SetPosStatusType::Works) + { + // if overriding of cursor does not work, the user can + // be confused when a hidden cursor reappears somewhere + // outside of the knob + QApplication::setOverrideCursor( Qt::BlankCursor ); + } +#endif s_textFloat->setText( displayValue() ); s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) ); @@ -618,12 +645,55 @@ void Knob::mousePressEvent( QMouseEvent * _me ) void Knob::mouseMoveEvent( QMouseEvent * _me ) { - if( m_buttonPressed && _me->pos() != m_origMousePos ) + if( m_buttonPressed && _me->pos() != m_lastMousePos ) { - m_mouseOffset = _me->pos() - m_origMousePos; - setPosition( m_mouseOffset ); + // knob position is changed depending on last mouse position + setPosition( _me->pos() - m_lastMousePos ); emit sliderMoved( model()->value() ); - QCursor::setPos( mapToGlobal( m_origMousePos ) ); + + // the rest of the code updates the cursor and/or m_origMousePos + + // get screen min/max values where a flip is not required yet + const QRect& rec = +#if QT_VERSION >= 0x050A00 + QApplication::screenAt(QCursor::pos())->geometry(); +#else + QApplication::desktop()->availableGeometry(); +#endif + int ymax = qMax(rec.height() - 2, 0), xmax = qMax(rec.width() - 2, 0); + int ymin = 1, xmin = 1; + + // calculate new coordinates + int x = QCursor::pos().x(), y = QCursor::pos().y(); + QPoint newPos( + (xxmax) ? xmin : x, + (yymax) ? ymin : y); + + auto setCursor = [&](const QPoint& p) -> bool + { +#ifdef LMMS_BUILD_APPLE + (void)p; + return false; +#else + QCursor::setPos(newPos); + return QCursor::pos() == newPos; +#endif + }; + + // no flip, or calling QCursor::setPos() for flip has no effect? + // (the latter occurs on some systems without accessability) + if(newPos == QCursor::pos() || !setCursor(newPos)) + { + // original position for next time is current position + m_lastMousePos = _me->pos(); + } + else + { + // successful flip of cursor + // bash original position to current position + // to avoid the knob snapping back + m_lastMousePos = mapFromGlobal(QCursor::pos()); + } } s_textFloat->setText( displayValue() ); } @@ -642,7 +712,13 @@ void Knob::mouseReleaseEvent( QMouseEvent* event ) } } - m_buttonPressed = false; + if( m_buttonPressed ) + { + m_buttonPressed = false; +#ifndef LMMS_BUILD_APPLE + QCursor::setPos( mapToGlobal( m_origMousePos ) ); +#endif + } emit sliderReleased(); From b61d8679ced55a276eae42f570d393ba80155aa9 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Tue, 5 May 2020 21:51:17 +0200 Subject: [PATCH 02/11] Make knob increase linear to mouse --- src/gui/widgets/Knob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index f763b664b05..07f0a87e9bf 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -499,8 +499,8 @@ float Knob::getValue( const QPoint & _p ) { float value; - // arcane mathemagicks for calculating knob movement - value = ( ( _p.y() + _p.y() * qMin( qAbs( _p.y() / 2.5f ), 6.0f ) ) ) / 12.0f; + // knob value increase is linear to mouse movement + value = .09f * _p.y(); // if shift pressed we want slower movement if( gui->mainWindow()->isShiftPressed() ) From 30a3d00e180388da3bebd6d61fb48e2d39bc7222 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sun, 10 May 2020 22:10:24 +0200 Subject: [PATCH 03/11] Test that disables setPos everywhere This code differs to stable-1.2 by: * No `setPos`/cursor hiding at all * The mouse-movement-to-knob-increase transition function is now made linear (factor 0.4) The behaviour is consistent on all platforms. --- include/Knob.h | 7 ---- src/gui/widgets/Knob.cpp | 83 ++-------------------------------------- 2 files changed, 3 insertions(+), 87 deletions(-) diff --git a/include/Knob.h b/include/Knob.h index e3a96a6bde3..1aac911e7d2 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -196,13 +196,6 @@ private slots: knobTypes m_knobNum; - enum class SetPosStatusType - { - NotChecked, - Works, - NoEffect - }; - static SetPosStatusType s_setPosStatus; } ; #endif diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 07f0a87e9bf..85f529df366 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #ifndef __USE_XOPEN @@ -51,7 +50,6 @@ #include "TextFloat.h" TextFloat * Knob::s_textFloat = NULL; -Knob::SetPosStatusType Knob::s_setPosStatus = Knob::SetPosStatusType::NotChecked; @@ -588,39 +586,12 @@ void Knob::mousePressEvent( QMouseEvent * _me ) thisModel->saveJournallingState( false ); } - // on apple, we know that setPos will not work in many cases - // (and that the below check won't work either) - // to not confuse the user, we won't hide the cursor on apple, - // and we won't call setPos on apple either -#ifdef LMMS_BUILD_APPLE - (void)s_setPosStatus; -#else - if(s_setPosStatus == SetPosStatusType::NotChecked) - { - QPoint oldPos = QCursor::pos(); - QCursor::setPos(oldPos - QPoint(1,1)); - s_setPosStatus = (QCursor::pos() == oldPos) - ? SetPosStatusType::NoEffect - : SetPosStatusType::Works; - QCursor::setPos(oldPos); - } -#endif - const QPoint & p = _me->pos(); m_origMousePos = m_lastMousePos = p; m_leftOver = 0.0f; emit sliderPressed(); -#ifndef LMMS_BUILD_APPLE - if(s_setPosStatus == SetPosStatusType::Works) - { - // if overriding of cursor does not work, the user can - // be confused when a hidden cursor reappears somewhere - // outside of the knob - QApplication::setOverrideCursor( Qt::BlankCursor ); - } -#endif s_textFloat->setText( displayValue() ); s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) ); @@ -650,50 +621,8 @@ void Knob::mouseMoveEvent( QMouseEvent * _me ) // knob position is changed depending on last mouse position setPosition( _me->pos() - m_lastMousePos ); emit sliderMoved( model()->value() ); - - // the rest of the code updates the cursor and/or m_origMousePos - - // get screen min/max values where a flip is not required yet - const QRect& rec = -#if QT_VERSION >= 0x050A00 - QApplication::screenAt(QCursor::pos())->geometry(); -#else - QApplication::desktop()->availableGeometry(); -#endif - int ymax = qMax(rec.height() - 2, 0), xmax = qMax(rec.width() - 2, 0); - int ymin = 1, xmin = 1; - - // calculate new coordinates - int x = QCursor::pos().x(), y = QCursor::pos().y(); - QPoint newPos( - (xxmax) ? xmin : x, - (yymax) ? ymin : y); - - auto setCursor = [&](const QPoint& p) -> bool - { -#ifdef LMMS_BUILD_APPLE - (void)p; - return false; -#else - QCursor::setPos(newPos); - return QCursor::pos() == newPos; -#endif - }; - - // no flip, or calling QCursor::setPos() for flip has no effect? - // (the latter occurs on some systems without accessability) - if(newPos == QCursor::pos() || !setCursor(newPos)) - { - // original position for next time is current position - m_lastMousePos = _me->pos(); - } - else - { - // successful flip of cursor - // bash original position to current position - // to avoid the knob snapping back - m_lastMousePos = mapFromGlobal(QCursor::pos()); - } + // original position for next time is current position + m_lastMousePos = _me->pos(); } s_textFloat->setText( displayValue() ); } @@ -712,13 +641,7 @@ void Knob::mouseReleaseEvent( QMouseEvent* event ) } } - if( m_buttonPressed ) - { - m_buttonPressed = false; -#ifndef LMMS_BUILD_APPLE - QCursor::setPos( mapToGlobal( m_origMousePos ) ); -#endif - } + m_buttonPressed = false; emit sliderReleased(); From 9d7f1721630868f04dcaf8aae2a288d106f7e5bd Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Mon, 11 May 2020 11:20:58 +0200 Subject: [PATCH 04/11] Fix factor from .09f to .4f --- src/gui/widgets/Knob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 85f529df366..4f5d7ac6b3c 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -498,7 +498,7 @@ float Knob::getValue( const QPoint & _p ) float value; // knob value increase is linear to mouse movement - value = .09f * _p.y(); + value = .4f * _p.y(); // if shift pressed we want slower movement if( gui->mainWindow()->isShiftPressed() ) From 2ebf0168bb59c9f648eb4a8b65c9486123a4c4b4 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Thu, 14 May 2020 21:05:50 +0200 Subject: [PATCH 05/11] Knob: Remove now unused `m_origMousePos` --- include/Knob.h | 1 - src/gui/widgets/Knob.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Knob.h b/include/Knob.h index 1aac911e7d2..e54ed103f05 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -174,7 +174,6 @@ private slots: BoolModel m_volumeKnob; FloatModel m_volumeRatio; - QPoint m_origMousePos; //!< position where user clicked to turn the knob QPoint m_lastMousePos; //!< mouse position in last mouseMoveEvent float m_leftOver; bool m_buttonPressed; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 4f5d7ac6b3c..250eb0ad38d 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -587,7 +587,7 @@ void Knob::mousePressEvent( QMouseEvent * _me ) } const QPoint & p = _me->pos(); - m_origMousePos = m_lastMousePos = p; + m_lastMousePos = p; m_leftOver = 0.0f; emit sliderPressed(); From f662a33ee7ae8778d950d6008e681fcd2bdd77f0 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Thu, 14 May 2020 21:26:07 +0200 Subject: [PATCH 06/11] Fix #5194 also for LcdSpinBox --- include/LcdSpinBox.h | 2 +- src/gui/widgets/LcdSpinBox.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/LcdSpinBox.h b/include/LcdSpinBox.h index 0bac3ddc070..7334ec6cace 100644 --- a/include/LcdSpinBox.h +++ b/include/LcdSpinBox.h @@ -74,7 +74,7 @@ public slots: private: bool m_mouseMoving; - QPoint m_origMousePos; + QPoint m_lastMousePos; //!< mouse position in last mouseMoveEvent int m_displayOffset; void enterValue(); diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 7102f5f6baa..1ece581816f 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -41,7 +41,7 @@ LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), m_mouseMoving( false ), - m_origMousePos(), + m_lastMousePos(), m_displayOffset( 0 ) { } @@ -53,7 +53,7 @@ LcdSpinBox::LcdSpinBox( int numDigits, const QString& style, QWidget* parent, co LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), m_mouseMoving( false ), - m_origMousePos(), + m_lastMousePos(), m_displayOffset( 0 ) { } @@ -98,8 +98,7 @@ void LcdSpinBox::mousePressEvent( QMouseEvent* event ) event->y() < cellHeight() + 2 ) { m_mouseMoving = true; - m_origMousePos = event->globalPos(); - QApplication::setOverrideCursor( Qt::BlankCursor ); + m_lastMousePos = event->globalPos(); AutomatableModel *thisModel = model(); if( thisModel ) @@ -121,7 +120,7 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) { if( m_mouseMoving ) { - int dy = event->globalY() - m_origMousePos.y(); + int dy = 3 * (event->globalY() - m_lastMousePos.y()); if( event->modifiers() & Qt::ShiftModifier ) dy = qBound( -4, dy/4, 4 ); if( dy > 1 || dy < -1 ) @@ -129,8 +128,8 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) model()->setInitValue( model()->value() - dy / 2 * model()->step() ); emit manualChange(); - QCursor::setPos( m_origMousePos ); } + m_lastMousePos = event->globalPos(); } } @@ -142,10 +141,7 @@ void LcdSpinBox::mouseReleaseEvent( QMouseEvent* ) if( m_mouseMoving ) { model()->restoreJournallingState(); - - QCursor::setPos( m_origMousePos ); QApplication::restoreOverrideCursor(); - m_mouseMoving = false; } } From c98bb1914dc755f10955c5b55d2370ab47b7b1d9 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Mon, 18 May 2020 21:28:21 +0200 Subject: [PATCH 07/11] LcdSpinBox: Reset factor to 2 --- src/gui/widgets/LcdSpinBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 1ece581816f..60c5dfaabd3 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -120,7 +120,7 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) { if( m_mouseMoving ) { - int dy = 3 * (event->globalY() - m_lastMousePos.y()); + int dy = 2 * (event->globalY() - m_lastMousePos.y()); if( event->modifiers() & Qt::ShiftModifier ) dy = qBound( -4, dy/4, 4 ); if( dy > 1 || dy < -1 ) From feb12371907c6016b771b1ceac572390b22d4268 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Thu, 21 May 2020 22:32:39 +0200 Subject: [PATCH 08/11] Fix `LcdSpinBox` "mouse to value" algorithm Fixes in `LcdSpinBox::mouseMoveEvent`: * Reduce factor from `2` to `1` * Use floats (just to be on the safe side) * Don't ignore mouse changes of 1 pixel * Round value at x.5 before passing it to AutomatableModel::setInitValue --- src/gui/widgets/LcdSpinBox.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 60c5dfaabd3..ffc7d3e6f9e 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -23,6 +23,7 @@ * */ +#include #include #include #include @@ -120,13 +121,14 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) { if( m_mouseMoving ) { - int dy = 2 * (event->globalY() - m_lastMousePos.y()); + float dy = static_cast(event->globalY() - m_lastMousePos.y()); if( event->modifiers() & Qt::ShiftModifier ) - dy = qBound( -4, dy/4, 4 ); - if( dy > 1 || dy < -1 ) + dy = qBound( -4.f, dy/4.f, 4.f ); + if(dy > .5f || dy < -.5f) // that means "if dy != 0" { - model()->setInitValue( model()->value() - - dy / 2 * model()->step() ); + float initValueNotRounded = model()->value() - + dy / 2 * model()->step(); + model()->setInitValue( roundf(initValueNotRounded) ); emit manualChange(); } m_lastMousePos = event->globalPos(); From 45f1e8606d566af456886b66d1bb34cf4eda12c7 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Fri, 22 May 2020 19:47:24 +0200 Subject: [PATCH 09/11] LcdSpinBox: Recall float offset --- include/LcdSpinBox.h | 1 + src/gui/widgets/LcdSpinBox.cpp | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/LcdSpinBox.h b/include/LcdSpinBox.h index 7334ec6cace..38c524c5ad9 100644 --- a/include/LcdSpinBox.h +++ b/include/LcdSpinBox.h @@ -73,6 +73,7 @@ public slots: virtual void mouseDoubleClickEvent( QMouseEvent * _me ); private: + float m_remainder; //!< floating offset of spinbox in [-0.5, 0.5] bool m_mouseMoving; QPoint m_lastMousePos; //!< mouse position in last mouseMoveEvent int m_displayOffset; diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index ffc7d3e6f9e..5c12ce91d61 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -41,6 +41,7 @@ LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), + m_remainder( 0.f ), m_mouseMoving( false ), m_lastMousePos(), m_displayOffset( 0 ) @@ -53,6 +54,7 @@ LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : LcdSpinBox::LcdSpinBox( int numDigits, const QString& style, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), + m_remainder( 0.f ), m_mouseMoving( false ), m_lastMousePos(), m_displayOffset( 0 ) @@ -121,17 +123,20 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) { if( m_mouseMoving ) { - float dy = static_cast(event->globalY() - m_lastMousePos.y()); - if( event->modifiers() & Qt::ShiftModifier ) - dy = qBound( -4.f, dy/4.f, 4.f ); - if(dy > .5f || dy < -.5f) // that means "if dy != 0" + int dy = event->globalY() - m_lastMousePos.y(); + if( dy ) { - float initValueNotRounded = model()->value() - - dy / 2 * model()->step(); - model()->setInitValue( roundf(initValueNotRounded) ); + float fdy = static_cast(dy); + if( event->modifiers() & Qt::ShiftModifier ) + fdy = qBound( -4.f, fdy/4.f, 4.f ); + float floatValNotRounded = model()->value() + m_remainder - + fdy / 2.f * model()->step(); + float floatValRounded = roundf( floatValNotRounded ); + m_remainder = floatValNotRounded - floatValRounded; + model()->setInitValue( floatValRounded ); emit manualChange(); + m_lastMousePos = event->globalPos(); } - m_lastMousePos = event->globalPos(); } } From 0cda4e80767693c0eea732f6c158173208e8937b Mon Sep 17 00:00:00 2001 From: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com> Date: Fri, 22 May 2020 21:32:10 +0200 Subject: [PATCH 10/11] LcdSpinBox: Improve indentation Co-authored-by: Kevin Zander --- src/gui/widgets/LcdSpinBox.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 5c12ce91d61..4888e93fe84 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -129,8 +129,8 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) float fdy = static_cast(dy); if( event->modifiers() & Qt::ShiftModifier ) fdy = qBound( -4.f, fdy/4.f, 4.f ); - float floatValNotRounded = model()->value() + m_remainder - - fdy / 2.f * model()->step(); + float floatValNotRounded = + model()->value() + m_remainder - fdy / 2.f * model()->step(); float floatValRounded = roundf( floatValNotRounded ); m_remainder = floatValNotRounded - floatValRounded; model()->setInitValue( floatValRounded ); @@ -191,4 +191,3 @@ void LcdSpinBox::enterValue() } - From 52a85541edc7bf9214a33458584dde526f4f76eb Mon Sep 17 00:00:00 2001 From: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com> Date: Fri, 22 May 2020 21:33:04 +0200 Subject: [PATCH 11/11] LcdSpinBox: Explicit braces Co-authored-by: Kevin Zander --- src/gui/widgets/LcdSpinBox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 4888e93fe84..07080edc755 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -127,8 +127,9 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) if( dy ) { float fdy = static_cast(dy); - if( event->modifiers() & Qt::ShiftModifier ) + if( event->modifiers() & Qt::ShiftModifier ) { fdy = qBound( -4.f, fdy/4.f, 4.f ); + } float floatValNotRounded = model()->value() + m_remainder - fdy / 2.f * model()->step(); float floatValRounded = roundf( floatValNotRounded ); @@ -190,4 +191,3 @@ void LcdSpinBox::enterValue() } } -