From f45ff1a7147e6a9479c669f082dd74349c6bcb4b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Aug 2020 09:22:10 +0200 Subject: loplugin:flatten in vcl Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/control/scrbar.cxx | 101 +++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 51 deletions(-) (limited to 'vcl/source/control/scrbar.cxx') diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index 8e008465e279..01b645c1b80c 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -799,34 +799,34 @@ void ScrollBar::ImplDragThumb( const Point& rMousePos ) nMovePix = rMousePos.Y()-(maThumbRect.Top()+mnMouseOff); // Move thumb if necessary - if ( nMovePix ) - { - mnThumbPixPos += nMovePix; - if ( mnThumbPixPos < 0 ) - mnThumbPixPos = 0; - if ( mnThumbPixPos > (mnThumbPixRange-mnThumbPixSize) ) - mnThumbPixPos = mnThumbPixRange-mnThumbPixSize; - long nOldPos = mnThumbPos; - mnThumbPos = ImplCalcThumbPos( mnThumbPixPos ); - ImplUpdateRects(); - if ( mbFullDrag && (nOldPos != mnThumbPos) ) - { - // When dragging in windows the repaint request gets starved so dragging - // the scrollbar feels slower than it actually is. Let's force an immediate - // repaint of the scrollbar. - if (SupportsDoubleBuffering()) - { - Invalidate(); - PaintImmediately(); - } - else - ImplDraw(*this); + if ( !nMovePix ) + return; - mnDelta = mnThumbPos-nOldPos; - Scroll(); - mnDelta = 0; - } + mnThumbPixPos += nMovePix; + if ( mnThumbPixPos < 0 ) + mnThumbPixPos = 0; + if ( mnThumbPixPos > (mnThumbPixRange-mnThumbPixSize) ) + mnThumbPixPos = mnThumbPixRange-mnThumbPixSize; + long nOldPos = mnThumbPos; + mnThumbPos = ImplCalcThumbPos( mnThumbPixPos ); + ImplUpdateRects(); + if ( !(mbFullDrag && (nOldPos != mnThumbPos)) ) + return; + + // When dragging in windows the repaint request gets starved so dragging + // the scrollbar feels slower than it actually is. Let's force an immediate + // repaint of the scrollbar. + if (SupportsDoubleBuffering()) + { + Invalidate(); + PaintImmediately(); } + else + ImplDraw(*this); + + mnDelta = mnThumbPos-nOldPos; + Scroll(); + mnDelta = 0; } void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) @@ -951,19 +951,19 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) } // Should we start Tracking? - if ( meScrollType != ScrollType::DontKnow ) - { - // store original position for cancel and EndScroll delta - mnStartPos = mnThumbPos; - // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise - // MouseButtonUp() / EndTracking() may be called if somebody is spending - // a lot of time in the scroll handler - StartTracking( nTrackFlags ); - ImplDoMouseAction( rMousePos ); - - if( bDragToMouse ) - ImplDragThumb( rMousePos ); - } + if ( meScrollType == ScrollType::DontKnow ) + return; + + // store original position for cancel and EndScroll delta + mnStartPos = mnThumbPos; + // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise + // MouseButtonUp() / EndTracking() may be called if somebody is spending + // a lot of time in the scroll handler + StartTracking( nTrackFlags ); + ImplDoMouseAction( rMousePos ); + + if( bDragToMouse ) + ImplDragThumb( rMousePos ); } @@ -1344,20 +1344,19 @@ void ScrollBar::SetRange( const Range& rRange ) long nNewMaxRange = aRange.Max(); // If Range differs, set a new one - if ( (mnMinRange != nNewMinRange) || - (mnMaxRange != nNewMaxRange) ) - { - mnMinRange = nNewMinRange; - mnMaxRange = nNewMaxRange; + if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange)) + return; - // Adapt Thumb - if ( mnThumbPos > mnMaxRange-mnVisibleSize ) - mnThumbPos = mnMaxRange-mnVisibleSize; - if ( mnThumbPos < mnMinRange ) - mnThumbPos = mnMinRange; + mnMinRange = nNewMinRange; + mnMaxRange = nNewMaxRange; - CompatStateChanged( StateChangedType::Data ); - } + // Adapt Thumb + if ( mnThumbPos > mnMaxRange-mnVisibleSize ) + mnThumbPos = mnMaxRange-mnVisibleSize; + if ( mnThumbPos < mnMinRange ) + mnThumbPos = mnMinRange; + + CompatStateChanged( StateChangedType::Data ); } void ScrollBar::SetThumbPos( long nNewThumbPos ) -- cgit