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
baf9dedd
Commit
baf9dedd
authored
Mar 03, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: SoundSlider: optimize paint method
parent
29fe32be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+14
-11
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+6
-0
No files found.
modules/gui/qt4/util/input_slider.cpp
View file @
baf9dedd
...
@@ -600,6 +600,15 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
...
@@ -600,6 +600,15 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
for
(
int
i
=
colorList
.
count
();
i
<
12
;
i
++
)
for
(
int
i
=
colorList
.
count
();
i
<
12
;
i
++
)
colorList
.
append
(
"255"
);
colorList
.
append
(
"255"
);
background
=
palette
().
color
(
QPalette
::
Active
,
QPalette
::
Background
);
foreground
=
palette
().
color
(
QPalette
::
Active
,
QPalette
::
WindowText
);
foreground
.
setHsv
(
foreground
.
hue
(),
(
background
.
saturation
()
+
foreground
.
saturation
()
)
/
2
,
(
background
.
value
()
+
foreground
.
value
()
)
/
2
);
textfont
.
setPixelSize
(
9
);
textrect
.
setRect
(
0
,
0
,
34
,
15
);
/* Regular colors */
/* Regular colors */
#define c(i) colorList.at(i).toInt()
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
#define add_color(gradient, range, c1, c2, c3) \
...
@@ -623,7 +632,7 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
...
@@ -623,7 +632,7 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
add_colors
(
gradient
,
gradient2
,
0.55
,
6
,
7
,
8
);
add_colors
(
gradient
,
gradient2
,
0.55
,
6
,
7
,
8
);
add_colors
(
gradient
,
gradient2
,
1.0
,
9
,
10
,
11
);
add_colors
(
gradient
,
gradient2
,
1.0
,
9
,
10
,
11
);
QPainter
painter
(
&
pixGradient
);
painter
.
begin
(
&
pixGradient
);
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
setBrush
(
gradient
);
painter
.
setBrush
(
gradient
);
painter
.
drawRect
(
pixGradient
.
rect
()
);
painter
.
drawRect
(
pixGradient
.
rect
()
);
...
@@ -716,13 +725,14 @@ void SoundSlider::setMuted( bool m )
...
@@ -716,13 +725,14 @@ void SoundSlider::setMuted( bool m )
void
SoundSlider
::
paintEvent
(
QPaintEvent
*
e
)
void
SoundSlider
::
paintEvent
(
QPaintEvent
*
e
)
{
{
QPainter
painter
(
this
);
QPixmap
*
paintGradient
;
QPixmap
*
paintGradient
;
if
(
b_isMuted
)
if
(
b_isMuted
)
paintGradient
=
&
this
->
pixGradient2
;
paintGradient
=
&
this
->
pixGradient2
;
else
else
paintGradient
=
&
this
->
pixGradient
;
paintGradient
=
&
this
->
pixGradient
;
painter
.
begin
(
this
);
const
int
offset
=
int
(
(
WLENGTH
*
value
()
+
100
)
/
maximum
()
)
+
paddingL
;
const
int
offset
=
int
(
(
WLENGTH
*
value
()
+
100
)
/
maximum
()
)
+
paddingL
;
const
QRectF
boundsG
(
0
,
0
,
offset
,
paintGradient
->
height
()
);
const
QRectF
boundsG
(
0
,
0
,
offset
,
paintGradient
->
height
()
);
...
@@ -731,16 +741,9 @@ void SoundSlider::paintEvent( QPaintEvent *e )
...
@@ -731,16 +741,9 @@ void SoundSlider::paintEvent( QPaintEvent *e )
const
QRectF
boundsO
(
0
,
0
,
pixOutside
.
width
(),
pixOutside
.
height
()
);
const
QRectF
boundsO
(
0
,
0
,
pixOutside
.
width
(),
pixOutside
.
height
()
);
painter
.
drawPixmap
(
boundsO
,
pixOutside
,
boundsO
);
painter
.
drawPixmap
(
boundsO
,
pixOutside
,
boundsO
);
QColor
background
=
palette
().
color
(
QPalette
::
Active
,
QPalette
::
Background
);
QColor
foreground
=
palette
().
color
(
QPalette
::
Active
,
QPalette
::
WindowText
);
foreground
.
setHsv
(
foreground
.
hue
(),
(
background
.
saturation
()
+
foreground
.
saturation
()
)
/
2
,
(
background
.
value
()
+
foreground
.
value
()
)
/
2
);
painter
.
setPen
(
foreground
);
painter
.
setPen
(
foreground
);
QFont
font
;
font
.
setPixelSize
(
9
);
painter
.
setFont
(
textfont
);
painter
.
setFont
(
font
);
painter
.
drawText
(
textrect
,
Qt
::
AlignRight
|
Qt
::
AlignVCenter
,
const
QRect
rect
(
0
,
0
,
34
,
15
);
painter
.
drawText
(
rect
,
Qt
::
AlignRight
|
Qt
::
AlignVCenter
,
QString
::
number
(
value
()
)
+
'%'
);
QString
::
number
(
value
()
)
+
'%'
);
painter
.
end
();
painter
.
end
();
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
baf9dedd
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "timetooltip.hpp"
#include "timetooltip.hpp"
#include <QSlider>
#include <QSlider>
#include <QPainter>
#define MSTRTIME_MAX_SIZE 22
#define MSTRTIME_MAX_SIZE 22
...
@@ -133,6 +134,11 @@ private:
...
@@ -133,6 +134,11 @@ private:
QPixmap
pixGradient
;
/* Gradient pix storage */
QPixmap
pixGradient
;
/* Gradient pix storage */
QPixmap
pixGradient2
;
/* Muted Gradient pix storage */
QPixmap
pixGradient2
;
/* Muted Gradient pix storage */
QPixmap
pixOutside
;
/* OutLine pix storage */
QPixmap
pixOutside
;
/* OutLine pix storage */
QPainter
painter
;
QColor
background
;
QColor
foreground
;
QFont
textfont
;
QRect
textrect
;
void
changeValue
(
int
x
);
/* Function to modify the value from pixel x() */
void
changeValue
(
int
x
);
/* Function to modify the value from pixel x() */
};
};
...
...
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