summaryrefslogtreecommitdiff
path: root/vcl/source/control/scrbar.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 09:22:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 11:21:22 +0200
commitf45ff1a7147e6a9479c669f082dd74349c6bcb4b (patch)
tree9ec5eee03fe7bbc5e026318efd6dcca3502d4696 /vcl/source/control/scrbar.cxx
parent58937aa4a50ecd681382f03331340da4c843b01e (diff)
loplugin:flatten in vcl
Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/control/scrbar.cxx')
-rw-r--r--vcl/source/control/scrbar.cxx101
1 files changed, 50 insertions, 51 deletions
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 )