Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
b4911b0d
Commit
b4911b0d
authored
Feb 04, 2022
by
Jean-Baptiste Mardelle
Browse files
minor optimization for audio thumbs drawing
parent
24e12eba
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/timeline2/view/qml/ClipAudioThumbs.qml
View file @
b4911b0d
...
...
@@ -53,6 +53,7 @@ Row {
width
:
Math
.
min
(
waveform
.
width
,
waveform
.
maxWidth
)
height
:
waveform
.
height
channels
:
clipRoot
.
audioChannels
isOpaque
:
true
binId
:
clipRoot
.
binId
audioStream
:
clipRoot
.
audioStream
isFirstChunk
:
index
==
0
...
...
@@ -62,8 +63,9 @@ Row {
normalize
:
timeline
.
audioThumbNormalize
drawInPoint
:
Math
.
max
(
0
,
clipRoot
.
scrollStart
-
(
index
*
waveform
.
maxWidth
))
drawOutPoint
:
(
clipRoot
.
scrollStart
+
scrollView
.
width
-
(
index
*
waveform
.
maxWidth
))
waveInPoint
:
clipRoot
.
speed
<
0
?
(
Math
.
round
((
clipRoot
.
maxDuration
-
1
-
clipRoot
.
inPoint
)
*
Math
.
abs
(
clipRoot
.
speed
)
-
(
index
*
waveform
.
maxWidth
/
clipRoot
.
timeScale
)
*
Math
.
abs
(
clipRoot
.
speed
))
*
channels
)
:
(
Math
.
round
((
clipRoot
.
inPoint
+
(
index
*
waveform
.
maxWidth
/
clipRoot
.
timeScale
))
*
clipRoot
.
speed
)
*
channels
)
waveOutPoint
:
clipRoot
.
speed
<
0
?
(
waveInPoint
-
Math
.
ceil
(
width
/
clipRoot
.
timeScale
*
Math
.
abs
(
clipRoot
.
speed
))
*
channels
)
:
(
waveInPoint
+
Math
.
round
(
width
/
clipRoot
.
timeScale
*
clipRoot
.
speed
)
*
channels
)
waveInPoint
:
clipRoot
.
speed
<
0
?
(
Math
.
round
((
clipRoot
.
maxDuration
-
1
-
clipRoot
.
inPoint
)
*
Math
.
abs
(
clipRoot
.
speed
)
-
(
index
*
waveform
.
maxWidth
/
timeline
.
scaleFactor
)
*
Math
.
abs
(
clipRoot
.
speed
))
*
clipRoot
.
audioChannels
)
:
(
Math
.
round
((
clipRoot
.
inPoint
+
(
index
*
waveform
.
maxWidth
/
timeline
.
scaleFactor
))
*
clipRoot
.
speed
)
*
clipRoot
.
audioChannels
)
waveOutPoint
:
clipRoot
.
speed
<
0
?
(
waveInPoint
-
Math
.
ceil
(
width
/
timeline
.
scaleFactor
*
Math
.
abs
(
clipRoot
.
speed
))
*
clipRoot
.
audioChannels
)
:
(
waveInPoint
+
Math
.
round
(
width
/
timeline
.
scaleFactor
*
clipRoot
.
speed
)
*
clipRoot
.
audioChannels
)
fillColor0
:
clipRoot
.
color
fillColor1
:
root
.
thumbColor1
fillColor2
:
root
.
thumbColor2
}
...
...
src/timeline2/view/qml/timelineitems.cpp
View file @
b4911b0d
...
...
@@ -66,26 +66,31 @@ private:
class
TimelineWaveform
:
public
QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY
(
QColor
fillColor0
MEMBER
m_bgColor
NOTIFY
propertyChanged
)
Q_PROPERTY
(
QColor
fillColor1
MEMBER
m_color
NOTIFY
propertyChanged
)
Q_PROPERTY
(
QColor
fillColor2
MEMBER
m_color2
NOTIFY
propertyChanged
)
Q_PROPERTY
(
int
waveInPoint
MEMBER
m_inPoint
NOTIFY
propertyChanged
)
Q_PROPERTY
(
int
drawInPoint
MEMBER
m_drawInPoint
NOTIFY
propertyChanged
)
Q_PROPERTY
(
int
drawOutPoint
MEMBER
m_drawOutPoint
NOTIFY
propertyChanged
)
Q_PROPERTY
(
int
channels
MEMBER
m_channels
NOTIFY
audioChannels
Changed
)
Q_PROPERTY
(
int
channels
MEMBER
m_channels
NOTIFY
property
Changed
)
Q_PROPERTY
(
QString
binId
MEMBER
m_binId
NOTIFY
levelsChanged
)
Q_PROPERTY
(
int
waveOutPoint
MEMBER
m_outPoint
)
Q_PROPERTY
(
int
waveOutPointWithUpdate
MEMBER
m_outPoint
NOTIFY
propertyChanged
)
Q_PROPERTY
(
int
audioStream
MEMBER
m_stream
)
Q_PROPERTY
(
double
scaleFactor
MEMBER
m_scale
)
Q_PROPERTY
(
bool
format
MEMBER
m_format
NOTIFY
propertyChanged
)
Q_PROPERTY
(
bool
normalize
MEMBER
m_normalize
NOTIFY
property
Changed
)
Q_PROPERTY
(
bool
normalize
MEMBER
m_normalize
NOTIFY
normalize
Changed
)
Q_PROPERTY
(
bool
showItem
READ
showItem
WRITE
setShowItem
NOTIFY
showItemChanged
)
Q_PROPERTY
(
bool
isFirstChunk
MEMBER
m_firstChunk
)
Q_PROPERTY
(
bool
isOpaque
MEMBER
m_isOpaque
)
public:
TimelineWaveform
()
TimelineWaveform
(
QQuickItem
*
parent
=
nullptr
)
:
QQuickPaintedItem
(
parent
)
,
m_isOpaque
(
false
)
{
setAntialiasing
(
false
);
setOpaquePainting
(
m_isOpaque
);
// setClip(true);
setEnabled
(
false
);
m_showItem
=
false
;
...
...
@@ -103,10 +108,11 @@ public:
}
}
});
connect
(
this
,
&
TimelineWaveform
::
property
Changed
,
[
&
]()
{
connect
(
this
,
&
TimelineWaveform
::
normalize
Changed
,
[
&
]()
{
m_audioMax
=
KdenliveSettings
::
normalizechannels
()
?
pCore
->
projectItemModel
()
->
getAudioMaxLevel
(
m_binId
,
m_stream
)
:
0
;
update
();
});
connect
(
this
,
&
TimelineWaveform
::
propertyChanged
,
this
,
static_cast
<
void
(
QQuickItem
::*
)()
>
(
&
QQuickItem
::
update
));
}
bool
showItem
()
const
{
...
...
@@ -140,6 +146,10 @@ public:
if
(
m_outPoint
==
m_inPoint
)
{
return
;
}
QRectF
bgRect
(
0
,
0
,
width
(),
height
());
if
(
m_isOpaque
)
{
painter
->
fillRect
(
bgRect
,
m_bgColor
);
}
QPen
pen
=
painter
->
pen
();
pen
.
setColor
(
m_color
);
painter
->
setBrush
(
m_color
.
darker
(
200
));
...
...
@@ -201,7 +211,7 @@ public:
scaleFactor
=
channelHeight
/
(
2
*
scaleFactor
);
double
i
=
0
;
double
level
;
QRectF
bgRect
(
0
,
0
,
width
(),
channelHeight
);
bgRect
.
setHeight
(
channelHeight
);
// Path for vector drawing
//qDebug()<<"==== DRAWING FROM: "<<m_drawInPoint<<" - "<<m_drawOutPoint<<", FIRST: "<<m_firstChunk;
for
(
int
channel
=
0
;
channel
<
m_channels
;
channel
++
)
{
...
...
@@ -264,6 +274,7 @@ public:
signals:
void
levelsChanged
();
void
propertyChanged
();
void
normalizeChanged
();
void
inPointChanged
();
void
showItemChanged
();
void
audioChannelsChanged
();
...
...
@@ -278,6 +289,7 @@ private:
QString
m_binId
;
QColor
m_color
;
QColor
m_color2
;
QColor
m_bgColor
;
bool
m_format
;
bool
m_normalize
;
bool
m_showItem
;
...
...
@@ -287,6 +299,7 @@ private:
double
m_scale
;
double
m_audioMax
;
bool
m_firstChunk
;
bool
m_isOpaque
;
};
void
registerTimelineItems
()
...
...
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