summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-03 22:11:41 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-04 22:21:41 +0900
commit3a2cfc646afe5e2b8a1ff0bdb215897931268ba6 (patch)
tree05e8c80ab38b6008ef799e8893b47092bf2a509e /vcl
parentcf43b676044773414fd35172e5e98422a555ede5 (diff)
tdf#124155 fix slider to not go beyond rect bounds
We need to ask the NWF for the size of the thumb and not just use the hard-coded value. Reviewed-on: https://gerrit.libreoffice.org/70201 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 9956cf0692058414ef3efdb0e8058fbb0b39f6bc) Change-Id: I98c6b5782c6a043fc358198ddf844d36d7aa90d6
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/slider.cxx55
1 files changed, 43 insertions, 12 deletions
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx
index c2af3bf820bc..f5f3984ad158 100644
--- a/vcl/source/control/slider.cxx
+++ b/vcl/source/control/slider.cxx
@@ -29,7 +29,6 @@
#define SLIDER_STATE_THUMB_DOWN ((sal_uInt16)0x0004)
#define SLIDER_THUMB_SIZE 9
-#define SLIDER_THUMB_HALFSIZE 4
#define SLIDER_CHANNEL_OFFSET 0
#define SLIDER_CHANNEL_SIZE 4
#define SLIDER_CHANNEL_HALFSIZE 2
@@ -43,6 +42,7 @@ void Slider::ImplInit( vcl::Window* pParent, WinBits nStyle )
mnThumbPixOffset = 0;
mnThumbPixRange = 0;
mnThumbPixPos = 0; // between mnThumbPixOffset and mnThumbPixOffset+mnThumbPixRange
+ mnThumbSize = SLIDER_THUMB_SIZE;
mnChannelPixOffset = 0;
mnChannelPixRange = 0;
mnChannelPixTop = 0;
@@ -116,8 +116,8 @@ void Slider::ImplUpdateRects( bool bUpdate )
{
if ( GetStyle() & WB_HORZ )
{
- maThumbRect.Left() = mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
- maThumbRect.Right() = maThumbRect.Left()+SLIDER_THUMB_SIZE-1;
+ maThumbRect.Left() = mnThumbPixPos - (mnThumbSize / 2);
+ maThumbRect.Right() = maThumbRect.Left() + mnThumbSize - 1;
if ( mnChannelPixOffset < maThumbRect.Left() )
{
maChannel1Rect.Left() = mnChannelPixOffset;
@@ -137,7 +137,7 @@ void Slider::ImplUpdateRects( bool bUpdate )
else
maChannel2Rect.SetEmpty();
- const tools::Rectangle aControlRegion( tools::Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) );
+ const tools::Rectangle aControlRegion(tools::Rectangle(Point(), Size(mnThumbSize, 10)));
tools::Rectangle aThumbBounds, aThumbContent;
if ( GetNativeControlRegion( ControlType::Slider, ControlPart::ThumbHorz,
aControlRegion, ControlState::NONE, ImplControlValue(),
@@ -150,8 +150,8 @@ void Slider::ImplUpdateRects( bool bUpdate )
}
else
{
- maThumbRect.Top() = mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
- maThumbRect.Bottom() = maThumbRect.Top()+SLIDER_THUMB_SIZE-1;
+ maThumbRect.Top() = mnThumbPixPos - (mnThumbSize / 2);
+ maThumbRect.Bottom() = maThumbRect.Top() + mnThumbSize - 1;
if ( mnChannelPixOffset < maThumbRect.Top() )
{
maChannel1Rect.Top() = mnChannelPixOffset;
@@ -171,7 +171,7 @@ void Slider::ImplUpdateRects( bool bUpdate )
else
maChannel2Rect.SetEmpty();
- const tools::Rectangle aControlRegion( tools::Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) );
+ const tools::Rectangle aControlRegion(tools::Rectangle(Point(), Size(10, mnThumbSize)));
tools::Rectangle aThumbBounds, aThumbContent;
if ( GetNativeControlRegion( ControlType::Slider, ControlPart::ThumbVert,
aControlRegion, ControlState::NONE, ImplControlValue(),
@@ -248,8 +248,39 @@ void Slider::ImplCalc( bool bUpdate )
{
bool bInvalidateAll = false;
- if ( mbCalcSize )
+ if (mbCalcSize)
{
+ if (GetStyle() & WB_HORZ)
+ {
+ const tools::Rectangle aControlRegion(tools::Rectangle(Point(), Size(SLIDER_THUMB_SIZE, 10)));
+ tools::Rectangle aThumbBounds, aThumbContent;
+ if (GetNativeControlRegion(ControlType::Slider, ControlPart::ThumbHorz,
+ aControlRegion, ControlState::NONE, ImplControlValue(),
+ aThumbBounds, aThumbContent))
+ {
+ mnThumbSize = aThumbBounds.GetWidth();
+ }
+ else
+ {
+ mnThumbSize = SLIDER_THUMB_SIZE;
+ }
+ }
+ else
+ {
+ const tools::Rectangle aControlRegion(tools::Rectangle(Point(), Size(10, SLIDER_THUMB_SIZE)));
+ tools::Rectangle aThumbBounds, aThumbContent;
+ if (GetNativeControlRegion( ControlType::Slider, ControlPart::ThumbVert,
+ aControlRegion, ControlState::NONE, ImplControlValue(),
+ aThumbBounds, aThumbContent))
+ {
+ mnThumbSize = aThumbBounds.GetHeight();
+ }
+ else
+ {
+ mnThumbSize = SLIDER_THUMB_SIZE;
+ }
+ }
+
long nOldChannelPixOffset = mnChannelPixOffset;
long nOldChannelPixRange = mnChannelPixRange;
long nOldChannelPixTop = mnChannelPixTop;
@@ -277,10 +308,10 @@ void Slider::ImplCalc( bool bUpdate )
maThumbRect.Right() = aSize.Width()-1;
}
- if ( nCalcWidth >= SLIDER_THUMB_SIZE )
+ if (nCalcWidth >= mnThumbSize)
{
- mnThumbPixOffset = SLIDER_THUMB_HALFSIZE;
- mnThumbPixRange = nCalcWidth-(SLIDER_THUMB_HALFSIZE*2);
+ mnThumbPixOffset = mnThumbSize / 2;
+ mnThumbPixRange = nCalcWidth - mnThumbSize;
mnThumbPixPos = 0;
mnChannelPixOffset = SLIDER_CHANNEL_OFFSET;
mnChannelPixRange = nCalcWidth-(SLIDER_CHANNEL_OFFSET*2);
@@ -951,7 +982,7 @@ void Slider::SetThumbPos( long nNewThumbPos )
Size Slider::CalcWindowSizePixel()
{
- long nWidth = mnMaxRange-mnMinRange+(SLIDER_THUMB_HALFSIZE*2)+1;
+ long nWidth = mnMaxRange - mnMinRange + mnThumbSize + 1;
long nHeight = SLIDER_HEIGHT;
Size aSize;
if ( GetStyle() & WB_HORZ )