Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
8df18ef0
Kaydet (Commit)
8df18ef0
authored
May 06, 2015
tarafından
Tomaž Vajngerl
Kaydeden (comit)
Jan Holesovsky
May 07, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor "Slider" - use RenderContext & Invalidate
Change-Id: I3c733ac46b89b0a6b413eadf2796b80ec033c2c9
üst
5485ef70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
75 deletions
+100
-75
slider.hxx
include/vcl/slider.hxx
+5
-4
slider.cxx
vcl/source/control/slider.cxx
+95
-71
No files found.
include/vcl/slider.hxx
Dosyayı görüntüle @
8df18ef0
...
...
@@ -45,8 +45,9 @@ private:
long
mnLineSize
;
long
mnPageSize
;
long
mnDelta
;
sal_uInt16
mnDragDraw
;
sal_uInt16
mnStateFlags
;
sal_uInt16
mnDragDraw
;
sal_uInt16
mnDrawFlags
;
sal_uInt16
mnStateFlags
;
ScrollType
meScrollType
;
bool
mbCalcSize
;
bool
mbFullDrag
;
...
...
@@ -61,7 +62,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
(
sal_uInt16
nDrawFlags
);
SAL_DLLPRIVATE
void
ImplDraw
(
vcl
::
RenderContext
&
rRenderContext
,
sal_uInt16
nDrawFlags
);
SAL_DLLPRIVATE
bool
ImplIsPageUp
(
const
Point
&
rPos
);
SAL_DLLPRIVATE
bool
ImplIsPageDown
(
const
Point
&
rPos
);
SAL_DLLPRIVATE
long
ImplSlide
(
long
nNewPos
,
bool
bCallEndSlide
);
...
...
@@ -77,7 +78,7 @@ public:
virtual
void
MouseButtonUp
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
Tracking
(
const
TrackingEvent
&
rTEvt
)
SAL_OVERRIDE
;
virtual
void
KeyInput
(
const
KeyEvent
&
rKEvt
)
SAL_OVERRIDE
;
virtual
void
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
SAL_OVERRIDE
;
virtual
void
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
SAL_OVERRIDE
;
virtual
void
Resize
()
SAL_OVERRIDE
;
virtual
void
RequestHelp
(
const
HelpEvent
&
rHEvt
)
SAL_OVERRIDE
;
virtual
void
StateChanged
(
StateChangedType
nType
)
SAL_OVERRIDE
;
...
...
vcl/source/control/slider.cxx
Dosyayı görüntüle @
8df18ef0
...
...
@@ -62,6 +62,7 @@ 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
;
...
...
@@ -189,6 +190,7 @@ void Slider::ImplUpdateRects( bool bUpdate )
{
if
(
aOldThumbRect
!=
maThumbRect
)
{
mnDrawFlags
=
SLIDER_DRAW_ALL
;
if
(
bInvalidateAll
)
Invalidate
();
else
...
...
@@ -296,145 +298,146 @@ void Slider::ImplCalc( bool bUpdate )
if
(
bUpdate
&&
bInvalidateAll
)
{
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
bUpdate
=
false
;
}
ImplUpdateRects
(
bUpdate
);
}
void
Slider
::
ImplDraw
(
sal_uInt16
nDrawFlags
)
void
Slider
::
ImplDraw
(
vcl
::
RenderContext
&
rRenderContext
,
sal_uInt16
nDrawFlags
)
{
DecorationView
aDecoView
(
this
);
sal_uInt16
nStyle
;
const
StyleSettings
&
rStyleSettings
=
GetSettings
().
GetStyleSettings
();
bool
bEnabled
=
IsEnabled
();
DecorationView
aDecoView
(
&
rRenderContext
);
sal_uInt16
nStyle
;
const
StyleSettings
&
rStyleSettings
=
rRenderContext
.
GetSettings
().
GetStyleSettings
();
bool
bEnabled
=
IsEnabled
();
// do missing calculations
if
(
mbCalcSize
)
ImplCalc
(
false
);
if
(
mbCalcSize
)
ImplCalc
(
false
);
ControlPart
nPart
=
(
GetStyle
()
&
WB_HORZ
)
?
PART_TRACK_HORZ_AREA
:
PART_TRACK_VERT_AREA
;
ControlState
nState
=
(
IsEnabled
()
?
ControlState
::
ENABLED
:
ControlState
::
NONE
)
|
(
HasFocus
()
?
ControlState
::
FOCUSED
:
ControlState
::
NONE
);
SliderValue
sldValue
;
ControlState
nState
=
(
IsEnabled
()
?
ControlState
::
ENABLED
:
ControlState
::
NONE
);
nState
|=
(
HasFocus
()
?
ControlState
::
FOCUSED
:
ControlState
::
NONE
);
SliderValue
sldValue
;
sldValue
.
mnMin
=
mnMinRange
;
sldValue
.
mnMax
=
mnMaxRange
;
sldValue
.
mnCur
=
mnThumbPos
;
sldValue
.
mnMin
=
mnMinRange
;
sldValue
.
mnMax
=
mnMaxRange
;
sldValue
.
mnCur
=
mnThumbPos
;
sldValue
.
maThumbRect
=
maThumbRect
;
if
(
IsMouseOver
()
)
if
(
IsMouseOver
()
)
{
if
(
maThumbRect
.
IsInside
(
GetPointerPosPixel
()
)
)
if
(
maThumbRect
.
IsInside
(
GetPointerPosPixel
())
)
sldValue
.
mnThumbState
|=
ControlState
::
ROLLOVER
;
}
const
Rectangle
aCtrlRegion
(
Point
(
0
,
0
),
GetOutputSizePixel
()
);
bool
bNativeOK
=
DrawNativeControl
(
CTRL_SLIDER
,
nPart
,
aCtrlRegion
,
nState
,
sldValue
,
OUString
()
);
if
(
bNativeOK
)
const
Rectangle
aCtrlRegion
(
Point
(
0
,
0
),
rRenderContext
.
GetOutputSizePixel
());
bool
bNativeOK
=
rRenderContext
.
DrawNativeControl
(
CTRL_SLIDER
,
nPart
,
aCtrlRegion
,
nState
,
sldValue
,
OUString
());
if
(
bNativeOK
)
return
;
if
(
(
nDrawFlags
&
SLIDER_DRAW_CHANNEL1
)
&&
!
maChannel1Rect
.
IsEmpty
()
)
if
(
(
nDrawFlags
&
SLIDER_DRAW_CHANNEL1
)
&&
!
maChannel1Rect
.
IsEmpty
()
)
{
long
nRectSize
;
Rectangle
aRect
=
maChannel1Rect
;
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
rRenderContext
.
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
{
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Left
(),
aRect
.
Bottom
()
-
1
)
);
DrawLine
(
aRect
.
TopLeft
(),
aRect
.
TopRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Left
(),
aRect
.
Bottom
()
-
1
)
);
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
aRect
.
TopRight
()
);
}
else
{
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Right
()
-
1
,
aRect
.
Top
()
)
);
DrawLine
(
aRect
.
TopLeft
(),
aRect
.
BottomLeft
()
);
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Right
()
-
1
,
aRect
.
Top
())
);
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
aRect
.
BottomLeft
()
);
}
SetLineColor
(
rStyleSettings
.
GetLightColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
rRenderContext
.
SetLineColor
(
rStyleSettings
.
GetLightColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
{
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
nRectSize
=
aRect
.
GetWidth
();
}
else
{
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
nRectSize
=
aRect
.
GetHeight
();
}
if
(
nRectSize
>
1
)
if
(
nRectSize
>
1
)
{
aRect
.
Left
()
++
;
aRect
.
Top
()
++
;
if
(
GetStyle
()
&
WB_HORZ
)
if
(
GetStyle
()
&
WB_HORZ
)
aRect
.
Bottom
()
--
;
else
aRect
.
Right
()
--
;
SetLineColor
();
if
(
mnStateFlags
&
SLIDER_STATE_CHANNEL1_DOWN
)
SetFillColor
(
rStyleSettings
.
GetShadowColor
()
);
rRenderContext
.
SetLineColor
();
if
(
mnStateFlags
&
SLIDER_STATE_CHANNEL1_DOWN
)
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetShadowColor
()
);
else
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
DrawRect
(
aRect
);
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
rRenderContext
.
DrawRect
(
aRect
);
}
}
if
(
(
nDrawFlags
&
SLIDER_DRAW_CHANNEL2
)
&&
!
maChannel2Rect
.
IsEmpty
()
)
if
(
(
nDrawFlags
&
SLIDER_DRAW_CHANNEL2
)
&&
!
maChannel2Rect
.
IsEmpty
()
)
{
long
nRectSize
;
Rectangle
aRect
=
maChannel2Rect
;
SetLineColor
(
rStyleSettings
.
GetLightColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
long
nRectSize
;
Rectangle
aRect
=
maChannel2Rect
;
rRenderContext
.
SetLineColor
(
rStyleSettings
.
GetLightColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
{
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
nRectSize
=
aRect
.
GetWidth
();
}
else
{
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
BottomLeft
(),
aRect
.
BottomRight
()
);
rRenderContext
.
DrawLine
(
aRect
.
TopRight
(),
aRect
.
BottomRight
()
);
nRectSize
=
aRect
.
GetHeight
();
}
if
(
nRectSize
>
1
)
if
(
nRectSize
>
1
)
{
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Right
()
-
1
,
aRect
.
Top
()
)
);
rRenderContext
.
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
if
(
GetStyle
()
&
WB_HORZ
)
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Right
()
-
1
,
aRect
.
Top
())
);
else
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Left
(),
aRect
.
Bottom
()
-
1
)
);
rRenderContext
.
DrawLine
(
aRect
.
TopLeft
(),
Point
(
aRect
.
Left
(),
aRect
.
Bottom
()
-
1
)
);
aRect
.
Right
()
--
;
aRect
.
Bottom
()
--
;
if
(
GetStyle
()
&
WB_HORZ
)
if
(
GetStyle
()
&
WB_HORZ
)
aRect
.
Top
()
++
;
else
aRect
.
Left
()
++
;
SetLineColor
();
if
(
mnStateFlags
&
SLIDER_STATE_CHANNEL2_DOWN
)
SetFillColor
(
rStyleSettings
.
GetShadowColor
()
);
rRenderContext
.
SetLineColor
();
if
(
mnStateFlags
&
SLIDER_STATE_CHANNEL2_DOWN
)
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetShadowColor
()
);
else
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
DrawRect
(
aRect
);
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
rRenderContext
.
DrawRect
(
aRect
);
}
}
if
(
nDrawFlags
&
SLIDER_DRAW_THUMB
)
if
(
nDrawFlags
&
SLIDER_DRAW_THUMB
)
{
if
(
!
maThumbRect
.
IsEmpty
()
)
if
(
!
maThumbRect
.
IsEmpty
()
)
{
if
(
bEnabled
)
if
(
bEnabled
)
{
nStyle
=
0
;
if
(
mnStateFlags
&
SLIDER_STATE_THUMB_DOWN
)
if
(
mnStateFlags
&
SLIDER_STATE_THUMB_DOWN
)
nStyle
|=
BUTTON_DRAW_PRESSED
;
aDecoView
.
DrawButton
(
maThumbRect
,
nStyle
);
aDecoView
.
DrawButton
(
maThumbRect
,
nStyle
);
}
else
{
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
DrawRect
(
maThumbRect
);
rRenderContext
.
SetLineColor
(
rStyleSettings
.
GetShadowColor
()
);
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetCheckedColor
()
);
rRenderContext
.
DrawRect
(
maThumbRect
);
}
}
}
...
...
@@ -574,12 +577,16 @@ void Slider::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
if
(
mnDragDraw
&
SLIDER_DRAW_CHANNEL
)
{
Update
();
ImplDraw
(
mnDragDraw
);
mnDrawFlags
=
mnDragDraw
;
Invalidate
();
}
}
}
else
if
(
nOldStateFlags
!=
mnStateFlags
)
ImplDraw
(
mnDragDraw
);
{
mnDrawFlags
=
mnDragDraw
;
Invalidate
();
}
}
long
Slider
::
ImplDoSlide
(
long
nNewPos
)
...
...
@@ -675,8 +682,10 @@ void Slider::MouseButtonUp( const MouseEvent& )
mnStateFlags
&=
~
(
SLIDER_STATE_CHANNEL1_DOWN
|
SLIDER_STATE_CHANNEL2_DOWN
|
SLIDER_STATE_THUMB_DOWN
);
if
(
nOldStateFlags
!=
mnStateFlags
)
ImplDraw
(
mnDragDraw
);
{
mnDrawFlags
=
mnDragDraw
;
Invalidate
();
}
mnDragDraw
=
0
;
ImplDoAction
(
true
);
meScrollType
=
SCROLL_DONTKNOW
;
...
...
@@ -692,7 +701,10 @@ void Slider::Tracking( const TrackingEvent& rTEvt )
mnStateFlags
&=
~
(
SLIDER_STATE_CHANNEL1_DOWN
|
SLIDER_STATE_CHANNEL2_DOWN
|
SLIDER_STATE_THUMB_DOWN
);
if
(
nOldStateFlags
!=
mnStateFlags
)
ImplDraw
(
mnDragDraw
);
{
mnDrawFlags
=
mnDragDraw
;
Invalidate
();
}
mnDragDraw
=
0
;
// on cancel, reset the previous Thumb position
...
...
@@ -808,9 +820,13 @@ void Slider::KeyInput( const KeyEvent& rKEvt )
Control
::
KeyInput
(
rKEvt
);
}
void
Slider
::
Paint
(
vcl
::
RenderContext
&
/*rRenderContext*/
,
const
Rectangle
&
)
void
Slider
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
/*rRect*/
)
{
ImplDraw
(
SLIDER_DRAW_ALL
);
if
(
mnDrawFlags
)
{
ImplDraw
(
rRenderContext
,
mnDrawFlags
);
mnDrawFlags
=
0
;
}
}
void
Slider
::
Resize
()
...
...
@@ -819,6 +835,7 @@ void Slider::Resize()
mbCalcSize
=
true
;
if
(
IsReallyVisible
()
)
ImplCalc
(
false
);
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
...
...
@@ -843,13 +860,17 @@ void Slider::StateChanged( StateChangedType nType )
if
(
IsReallyVisible
()
&&
IsUpdateMode
()
)
{
ImplCalc
(
false
);
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
}
else
if
(
nType
==
StateChangedType
::
Enable
)
{
if
(
IsReallyVisible
()
&&
IsUpdateMode
()
)
{
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
}
else
if
(
nType
==
StateChangedType
::
Style
)
{
...
...
@@ -860,6 +881,7 @@ void Slider::StateChanged( StateChangedType nType )
{
mbCalcSize
=
true
;
ImplCalc
(
false
);
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
}
...
...
@@ -867,6 +889,7 @@ void Slider::StateChanged( StateChangedType nType )
else
if
(
nType
==
StateChangedType
::
ControlBackground
)
{
ImplInitSettings
();
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
}
...
...
@@ -879,6 +902,7 @@ void Slider::DataChanged( const DataChangedEvent& rDCEvt )
(
rDCEvt
.
GetFlags
()
&
AllSettingsFlags
::
STYLE
)
)
{
ImplInitSettings
();
mnDrawFlags
=
SLIDER_DRAW_ALL
;
Invalidate
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment