[Libreoffice-commits] core.git: include/vcl vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 4 00:41:03 UTC 2019
include/vcl/slider.hxx | 1
vcl/source/control/slider.cxx | 55 ++++++++++++++++++++++++++++++++----------
2 files changed, 44 insertions(+), 12 deletions(-)
New commits:
commit 9956cf0692058414ef3efdb0e8058fbb0b39f6bc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Apr 3 22:11:41 2019 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Apr 4 02:40:36 2019 +0200
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.
Change-Id: I98c6b5782c6a043fc358198ddf844d36d7aa90d6
Reviewed-on: https://gerrit.libreoffice.org/70201
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/slider.hxx b/include/vcl/slider.hxx
index 6549b4c0ac54..36247d52381a 100644
--- a/include/vcl/slider.hxx
+++ b/include/vcl/slider.hxx
@@ -36,6 +36,7 @@ private:
long mnThumbPixOffset;
long mnThumbPixRange;
long mnThumbPixPos;
+ long mnThumbSize;
long mnChannelPixOffset;
long mnChannelPixRange;
long mnChannelPixTop;
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx
index c9288aacf566..e2b7a2baa26c 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;
@@ -115,8 +115,8 @@ void Slider::ImplUpdateRects( bool bUpdate )
{
if ( GetStyle() & WB_HORZ )
{
- maThumbRect.SetLeft( mnThumbPixPos-SLIDER_THUMB_HALFSIZE );
- maThumbRect.SetRight( maThumbRect.Left()+SLIDER_THUMB_SIZE-1 );
+ maThumbRect.SetLeft(mnThumbPixPos - (mnThumbSize / 2));
+ maThumbRect.SetRight(maThumbRect.Left() + mnThumbSize - 1);
if ( mnChannelPixOffset < maThumbRect.Left() )
{
maChannel1Rect.SetLeft( mnChannelPixOffset );
@@ -136,7 +136,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(),
@@ -149,8 +149,8 @@ void Slider::ImplUpdateRects( bool bUpdate )
}
else
{
- maThumbRect.SetTop( mnThumbPixPos-SLIDER_THUMB_HALFSIZE );
- maThumbRect.SetBottom( maThumbRect.Top()+SLIDER_THUMB_SIZE-1 );
+ maThumbRect.SetTop( mnThumbPixPos - (mnThumbSize / 2));
+ maThumbRect.SetBottom( maThumbRect.Top() + mnThumbSize - 1);
if ( mnChannelPixOffset < maThumbRect.Top() )
{
maChannel1Rect.SetTop( mnChannelPixOffset );
@@ -170,7 +170,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(),
@@ -247,8 +247,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;
@@ -276,10 +307,10 @@ void Slider::ImplCalc( bool bUpdate )
maThumbRect.SetRight( 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);
@@ -936,7 +967,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 )
More information about the Libreoffice-commits
mailing list