Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a70681a1
Commit
a70681a1
authored
Apr 08, 2013
by
Erwan Tulou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skins2: slider background (some rework)
parent
2339bb72
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
48 deletions
+73
-48
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/controls/ctrl_slider.cpp
+67
-48
modules/gui/skins2/controls/ctrl_slider.hpp
modules/gui/skins2/controls/ctrl_slider.hpp
+6
-0
No files found.
modules/gui/skins2/controls/ctrl_slider.cpp
View file @
a70681a1
...
...
@@ -315,31 +315,18 @@ CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf,
CtrlGeneric
(
pIntf
,
rHelp
,
pVisible
),
m_pCursor
(
NULL
),
m_rVariable
(
rVariable
),
m_thickness
(
thickness
),
m_rCurve
(
rCurve
),
m_width
(
rCurve
.
getWidth
()
),
m_height
(
rCurve
.
getHeight
()
),
m_pImgSeq
(
pBackground
),
m_pScaledBmp
(
NULL
),
m_nbHoriz
(
nbHoriz
),
m_nbVert
(
nbVert
),
m_padHoriz
(
padHoriz
),
m_padVert
(
padVert
),
m_pImgSeq
(
pBackground
),
m_pScaledBmp
(
NULL
),
m_nbHoriz
(
nbHoriz
),
m_nbVert
(
nbVert
),
m_padHoriz
(
padHoriz
),
m_padVert
(
padVert
),
m_bgWidth
(
0
),
m_bgHeight
(
0
),
m_position
(
0
)
{
if
(
m_pImgSeq
)
{
// Build the background image sequence
// Note: we suppose that the last padding is not included in the
// given image
// TODO: we should probably change this assumption, as it would make
// the code a bit simpler and it would be more natural for the skins
// designers
m_bgWidth
=
(
pBackground
->
getWidth
()
+
m_padHoriz
)
/
m_nbHoriz
;
m_bgHeight
=
(
pBackground
->
getHeight
()
+
m_padVert
)
/
m_nbVert
;
// Observe the position variable
m_rVariable
.
addObserver
(
this
);
// Initial position
m_position
=
(
int
)(
m_rVariable
.
get
()
*
(
m_nbHoriz
*
m_nbVert
-
1
)
);
// Initialize the scaled image for the control
int
width
=
m_bgWidth
*
m_nbHoriz
-
m_padHoriz
;
int
height
=
m_bgHeight
*
m_nbVert
-
m_padVert
;
m_pScaledBmp
=
new
ScaledBitmap
(
getIntf
(),
*
m_pImgSeq
,
width
,
height
);
}
}
...
...
@@ -359,18 +346,20 @@ bool CtrlSliderBg::mouseOver( int x, int y ) const
float
factorX
,
factorY
;
getResizeFactors
(
factorX
,
factorY
);
bool
b_isWithinCurve
=
m_rCurve
.
getMinDist
(
(
int
)(
x
/
factorX
),
(
int
)(
y
/
factorY
),
if
(
m_pScaledBmp
)
{
// background size that is displayed
int
width
=
m_bgWidth
-
(
int
)(
m_padHoriz
*
factorX
);
int
height
=
m_bgHeight
-
(
int
)(
m_padVert
*
factorY
);
return
x
>=
0
&&
x
<
width
&&
y
>=
0
&&
y
<
height
;
}
else
{
return
m_rCurve
.
getMinDist
(
(
int
)(
x
/
factorX
),
(
int
)(
y
/
factorY
),
factorX
,
factorY
)
<
m_thickness
;
bool
b_isWithinBitmap
=
m_pScaledBmp
&&
x
>=
0
&&
x
<
m_pScaledBmp
->
getWidth
()
&&
y
>=
0
&&
y
<
m_pScaledBmp
->
getHeight
();
return
m_pScaledBmp
?
b_isWithinCurve
&&
b_isWithinBitmap
:
b_isWithinCurve
;
}
}
...
...
@@ -442,29 +431,20 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
}
void
CtrlSliderBg
::
on
Resiz
e
()
void
CtrlSliderBg
::
on
PositionChang
e
()
{
if
(
m_pImgSeq
)
{
// Compute the resize factors
float
factorX
,
factorY
;
getResizeFactors
(
factorX
,
factorY
);
setCurrentImage
();
}
}
// Size of one elementary background image (padding included)
m_bgWidth
=
(
int
)((
m_pImgSeq
->
getWidth
()
+
m_padHoriz
)
*
factorX
/
m_nbHoriz
);
m_bgHeight
=
(
int
)((
m_pImgSeq
->
getHeight
()
+
m_padVert
)
*
factorY
/
m_nbVert
);
// Rescale the image with the actual size of the control if needed
int
width
=
m_bgWidth
*
m_nbHoriz
-
(
int
)(
m_padHoriz
*
factorX
);
int
height
=
m_bgHeight
*
m_nbVert
-
(
int
)(
m_padVert
*
factorY
);
if
(
m_pScaledBmp
->
getWidth
()
!=
width
||
m_pScaledBmp
->
getHeight
()
!=
height
)
void
CtrlSliderBg
::
onResize
()
{
if
(
m_pImgSeq
)
{
delete
m_pScaledBmp
;
m_pScaledBmp
=
new
ScaledBitmap
(
getIntf
(),
*
m_pImgSeq
,
width
,
height
);
}
setCurrentImage
();
}
}
...
...
@@ -483,7 +463,15 @@ void CtrlSliderBg::onUpdate( Subject<VarPercent> &rVariable, void*arg )
return
;
m_position
=
position
;
notifyLayout
(
m_bgWidth
,
m_bgHeight
);
// Compute the resize factors
float
factorX
,
factorY
;
getResizeFactors
(
factorX
,
factorY
);
// real background size
int
width
=
m_bgWidth
-
(
int
)(
m_padHoriz
*
factorX
);
int
height
=
m_bgHeight
-
(
int
)(
m_padVert
*
factorY
);
notifyLayout
(
width
,
height
);
}
...
...
@@ -502,3 +490,34 @@ void CtrlSliderBg::getResizeFactors( float &rFactorX, float &rFactorY ) const
rFactorY
=
(
float
)
pPos
->
getHeight
()
/
(
float
)
m_height
;
}
void
CtrlSliderBg
::
setCurrentImage
()
{
// Compute the resize factors
float
factorX
,
factorY
;
getResizeFactors
(
factorX
,
factorY
);
// Build the background image sequence
// Note: we suppose that the last padding is not included in the
// given image
// TODO: we should probably change this assumption, as it would make
// the code a bit simpler and it would be more natural for the skins
// designers
// Size of one elementary background image (padding included)
m_bgWidth
=
(
int
)((
m_pImgSeq
->
getWidth
()
+
m_padHoriz
)
*
factorX
/
m_nbHoriz
);
m_bgHeight
=
(
int
)((
m_pImgSeq
->
getHeight
()
+
m_padVert
)
*
factorY
/
m_nbVert
);
// Rescale the image accordingly
int
width
=
m_bgWidth
*
m_nbHoriz
-
(
int
)(
m_padHoriz
*
factorX
);
int
height
=
m_bgHeight
*
m_nbVert
-
(
int
)(
m_padVert
*
factorY
);
if
(
!
m_pScaledBmp
||
m_pScaledBmp
->
getWidth
()
!=
width
||
m_pScaledBmp
->
getHeight
()
!=
height
)
{
// scaled bitmap
delete
m_pScaledBmp
;
m_pScaledBmp
=
new
ScaledBitmap
(
getIntf
(),
*
m_pImgSeq
,
width
,
height
);
}
}
modules/gui/skins2/controls/ctrl_slider.hpp
View file @
a70681a1
...
...
@@ -147,6 +147,9 @@ public:
/// Handle an event
virtual
void
handleEvent
(
EvtGeneric
&
rEvent
);
/// Called when the position is set
virtual
void
onPositionChange
();
/// Method called when the control is resized
virtual
void
onResize
();
...
...
@@ -185,6 +188,9 @@ private:
/// Method to compute the resize factors
void
getResizeFactors
(
float
&
rFactorX
,
float
&
rFactorY
)
const
;
/// Method to (re)set the current image
void
setCurrentImage
(
);
};
...
...
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