Commit 50f0b71e authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix first audio thumb disappears on color theme change, prevent unnecessary refresh

Fixes #40
parent 1367a56e
......@@ -68,7 +68,7 @@ Rectangle {
property string hash: 'ccc' //TODO
property double speed: 1.0
property color borderColor: 'black'
property bool forceReloadThumb: false
property bool forceReloadThumb
width : clipDuration * timeScale;
opacity: dragProxyArea.drag.active && dragProxy.draggedItem == clipId ? 0.8 : 1.0
......@@ -285,8 +285,13 @@ Rectangle {
clip: true
Loader {
id: thumbsLoader
asynchronous: true
visible: status == Loader.Ready
anchors.fill: parent
source: parentTrack.isAudio ? (timeline.showAudioThumbnails ? "ClipAudioThumbs.qml" : "") : itemType == ProducerType.Color ? "" : timeline.showThumbnails ? "ClipThumbs.qml" : ""
onLoaded: {
item.reload()
}
}
Rectangle {
......
......@@ -8,7 +8,7 @@ Row {
id: waveform
visible: clipStatus != ClipState.VideoOnly && parentTrack.isAudio && !parentTrack.isMute
opacity: clipStatus == ClipState.Disabled ? 0.2 : 1
property int maxWidth: 2000
property int maxWidth: 1000
property int innerWidth: clipRoot.width - clipRoot.border.width * 2
anchors.fill: parent
property int scrollStart: scrollView.flickableItem.contentX - clipRoot.modelStart * timeline.scaleFactor
......@@ -18,7 +18,7 @@ Row {
Timer {
id: waveTimer
interval: 5; running: false; repeat: false
interval: 50; running: false; repeat: false
onTriggered: processReload()
}
......@@ -36,13 +36,10 @@ Row {
if (!waveform.visible || !timeline.showAudioThumbnails || (waveform.scrollMin > clipRoot.modelStart + clipRoot.clipDuration) || (clipRoot.modelStart > waveform.scrollMax) || clipRoot.audioLevels == '') {
return;
}
//var t0 = new Date();
waveformRepeater.model = Math.ceil(waveform.innerWidth / waveform.maxWidth)
var firstWaveRepeater = Math.max(0, Math.floor((waveform.scrollMin - clipRoot.modelStart) / (waveform.maxWidth / timeline.scaleFactor)))
var lastWaveRepeater = Math.min(waveformRepeater.count - 1, firstWaveRepeater + Math.ceil((waveform.scrollMax - waveform.scrollMin) / (waveform.maxWidth / timeline.scaleFactor)))
for (var i = firstWaveRepeater; i <= lastWaveRepeater; i++) {
waveformRepeater.itemAt(i).update()
}
var chunks = Math.ceil(waveform.innerWidth / waveform.maxWidth)
if (waveformRepeater.model == undefined || chunks != waveformRepeater.model) {
waveformRepeater.model = chunks
}
}
Repeater {
......@@ -58,6 +55,11 @@ Row {
inPoint: Math.round((clipRoot.inPoint + (index * waveform.maxWidth / clipRoot.timeScale)) * Math.abs(clipRoot.speed)) * channels
outPoint: inPoint + Math.round(width / clipRoot.timeScale * Math.abs(clipRoot.speed)) * channels
fillColor: activePalette.text
onShowItemChanged: {
if (showItem) {
update();
}
}
}
}
}
......@@ -84,7 +84,7 @@ class TimelineWaveform : public QQuickPaintedItem
Q_PROPERTY(QString binId MEMBER m_binId NOTIFY levelsChanged)
Q_PROPERTY(int outPoint MEMBER m_outPoint NOTIFY outPointChanged)
Q_PROPERTY(bool format MEMBER m_format NOTIFY propertyChanged)
Q_PROPERTY(bool showItem MEMBER m_showItem)
Q_PROPERTY(bool showItem MEMBER m_showItem NOTIFY showItemChanged)
Q_PROPERTY(bool isFirstChunk MEMBER m_firstChunk)
public:
......@@ -109,7 +109,9 @@ public:
void paint(QPainter *painter) override
{
if (!m_showItem || m_audioLevels.isEmpty()) return;
if (!m_showItem || m_audioLevels.isEmpty()) {
return;
}
const qreal indicesPrPixel = qreal(m_outPoint - m_inPoint) / width();
QPen pen = painter->pen();
pen.setColor(m_color);
......@@ -190,6 +192,7 @@ signals:
void propertyChanged();
void inPointChanged();
void outPointChanged();
void showItemChanged();
void audioChannelsChanged();
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment