diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-04 20:36:55 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-04 21:39:47 +0900 |
commit | b70b4ae26a4d5256444996da46abee85a81b53be (patch) | |
tree | bcfa379831bc2f46f94b50b3cebc0048a82cda27 | |
parent | 46cf9bb76b29f2bfa6639d9aaf4f26dee365bc0c (diff) |
fix slider drawing, change to always draw the whole widget
Change-Id: Ifca2f72962b808a355bd7dcc20babaeb61272bf8
-rw-r--r-- | include/vcl/slider.hxx | 3 | ||||
-rw-r--r-- | vcl/source/control/slider.cxx | 81 |
2 files changed, 23 insertions, 61 deletions
diff --git a/include/vcl/slider.hxx b/include/vcl/slider.hxx index 064d475ae22b..46ab0f30c7d3 100644 --- a/include/vcl/slider.hxx +++ b/include/vcl/slider.hxx @@ -47,7 +47,6 @@ private: long mnPageSize; long mnDelta; sal_uInt16 mnDragDraw; - sal_uInt16 mnDrawFlags; sal_uInt16 mnStateFlags; ScrollType meScrollType; bool mbCalcSize; @@ -68,7 +67,7 @@ private: SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true ); - SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags); + SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); SAL_DLLPRIVATE bool ImplIsPageUp( const Point& rPos ); SAL_DLLPRIVATE bool ImplIsPageDown( const Point& rPos ); SAL_DLLPRIVATE long ImplSlide( long nNewPos, bool bCallEndSlide ); diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index c1c9a34d0f14..f09b493469a0 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -25,12 +25,6 @@ #include "thumbpos.hxx" -#define SLIDER_DRAW_THUMB ((sal_uInt16)0x0001) -#define SLIDER_DRAW_CHANNEL1 ((sal_uInt16)0x0002) -#define SLIDER_DRAW_CHANNEL2 ((sal_uInt16)0x0004) -#define SLIDER_DRAW_CHANNEL (SLIDER_DRAW_CHANNEL1 | SLIDER_DRAW_CHANNEL2) -#define SLIDER_DRAW_ALL (SLIDER_DRAW_THUMB | SLIDER_DRAW_CHANNEL) - #define SLIDER_STATE_CHANNEL1_DOWN ((sal_uInt16)0x0001) #define SLIDER_STATE_CHANNEL2_DOWN ((sal_uInt16)0x0002) #define SLIDER_STATE_THUMB_DOWN ((sal_uInt16)0x0004) @@ -62,7 +56,6 @@ void Slider::ImplInit( vcl::Window* pParent, WinBits nStyle ) mnPageSize = 1; mnDelta = 0; mnDragDraw = 0; - mnDrawFlags = SLIDER_DRAW_ALL; mnStateFlags = 0; meScrollType = SCROLL_DONTKNOW; mbCalcSize = true; @@ -203,9 +196,8 @@ void Slider::ImplUpdateRects( bool bUpdate ) { if ( aOldThumbRect != maThumbRect ) { - mnDrawFlags = SLIDER_DRAW_ALL; if( bInvalidateAll ) - Invalidate(); + Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); else { vcl::Region aInvalidRegion( aOldThumbRect ); @@ -339,14 +331,13 @@ void Slider::ImplCalc( bool bUpdate ) if ( bUpdate && bInvalidateAll ) { - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); bUpdate = false; } ImplUpdateRects( bUpdate ); } -void Slider::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags) +void Slider::ImplDraw(vcl::RenderContext& rRenderContext) { DecorationView aDecoView(&rRenderContext); DrawButtonFlags nStyle; @@ -378,7 +369,7 @@ void Slider::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags) if (bNativeOK) return; - if ((nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty()) + if (!maChannel1Rect.IsEmpty()) { long nRectSize; Rectangle aRect = maChannel1Rect; @@ -422,7 +413,7 @@ void Slider::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags) } } - if ((nDrawFlags & SLIDER_DRAW_CHANNEL2) && !maChannel2Rect.IsEmpty()) + if (!maChannel2Rect.IsEmpty()) { long nRectSize; Rectangle aRect = maChannel2Rect; @@ -463,23 +454,20 @@ void Slider::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags) } } - if (nDrawFlags & SLIDER_DRAW_THUMB) + if (!maThumbRect.IsEmpty()) { - if (!maThumbRect.IsEmpty()) + if (bEnabled) { - if (bEnabled) - { - nStyle = DrawButtonFlags::NONE; - if (mnStateFlags & SLIDER_STATE_THUMB_DOWN) - nStyle |= DrawButtonFlags::Pressed; - aDecoView.DrawButton(maThumbRect, nStyle); - } - else - { - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor()); - rRenderContext.DrawRect(maThumbRect); - } + nStyle = DrawButtonFlags::NONE; + if (mnStateFlags & SLIDER_STATE_THUMB_DOWN) + nStyle |= DrawButtonFlags::Pressed; + aDecoView.DrawButton(maThumbRect, nStyle); + } + else + { + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor()); + rRenderContext.DrawRect(maThumbRect); } } } @@ -614,18 +602,12 @@ void Slider::ImplDoMouseAction( const Point& rMousePos, bool bCallAction ) { if ( ImplDoAction( false ) ) { - // Update the channel complete - if ( mnDragDraw & SLIDER_DRAW_CHANNEL ) - { - Update(); - mnDrawFlags = mnDragDraw; - Invalidate(); - } + Update(); + Invalidate(); } } else if ( nOldStateFlags != mnStateFlags ) { - mnDrawFlags = mnDragDraw; Invalidate(); } } @@ -664,7 +646,6 @@ void Slider::MouseButtonDown( const MouseEvent& rMEvt ) if ( maThumbRect.IsInside( rMousePos ) ) { meScrollType = SCROLL_DRAG; - mnDragDraw = SLIDER_DRAW_THUMB; // calculate additional values Point aCenterPos = maThumbRect.Center(); @@ -682,8 +663,6 @@ void Slider::MouseButtonDown( const MouseEvent& rMEvt ) nTrackFlags = StartTrackingFlags::ButtonRepeat; meScrollType = SCROLL_PAGEUP; } - - mnDragDraw = SLIDER_DRAW_CHANNEL; } else if ( ImplIsPageDown( rMousePos ) ) { @@ -694,8 +673,6 @@ void Slider::MouseButtonDown( const MouseEvent& rMEvt ) nTrackFlags = StartTrackingFlags::ButtonRepeat; meScrollType = SCROLL_PAGEDOWN; } - - mnDragDraw = SLIDER_DRAW_CHANNEL; } // Shall we start Tracking? @@ -723,10 +700,8 @@ void Slider::MouseButtonUp( const MouseEvent& ) if ( nOldStateFlags != mnStateFlags ) { - mnDrawFlags = mnDragDraw; - Invalidate(); + Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); } - mnDragDraw = 0; ImplDoAction( true ); meScrollType = SCROLL_DONTKNOW; } @@ -742,10 +717,8 @@ void Slider::Tracking( const TrackingEvent& rTEvt ) SLIDER_STATE_THUMB_DOWN); if ( nOldStateFlags != mnStateFlags ) { - mnDrawFlags = mnDragDraw; - Invalidate(); + Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); } - mnDragDraw = 0; // on cancel, reset the previous Thumb position if ( rTEvt.IsTrackingCanceled() ) @@ -863,11 +836,7 @@ void Slider::KeyInput( const KeyEvent& rKEvt ) void Slider::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/) { - if (mnDrawFlags) - { - ImplDraw(rRenderContext, mnDrawFlags); - mnDrawFlags = 0; - } + ImplDraw(rRenderContext); } void Slider::Resize() @@ -876,8 +845,7 @@ void Slider::Resize() mbCalcSize = true; if ( IsReallyVisible() ) ImplCalc( false ); - mnDrawFlags = SLIDER_DRAW_ALL; - Invalidate(); + Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); } void Slider::SetLinkedField(VclPtr<NumericField> pField) @@ -908,7 +876,6 @@ void Slider::StateChanged( StateChangedType nType ) if ( IsReallyVisible() && IsUpdateMode() ) { ImplCalc( false ); - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); } } @@ -916,7 +883,6 @@ void Slider::StateChanged( StateChangedType nType ) { if ( IsReallyVisible() && IsUpdateMode() ) { - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); } } @@ -929,7 +895,6 @@ void Slider::StateChanged( StateChangedType nType ) { mbCalcSize = true; ImplCalc( false ); - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); } } @@ -937,7 +902,6 @@ void Slider::StateChanged( StateChangedType nType ) else if ( nType == StateChangedType::ControlBackground ) { ImplInitSettings(); - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); } } @@ -950,7 +914,6 @@ void Slider::DataChanged( const DataChangedEvent& rDCEvt ) (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) { ImplInitSettings(); - mnDrawFlags = SLIDER_DRAW_ALL; Invalidate(); } } |