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

Some cleanup in audio thumbs. Fix recent regression and bug where audio thumbs...

Some cleanup in audio thumbs. Fix recent regression and bug where audio thumbs were not displayed after extending a clip in timeline
Fixes #252
parent 1c8a88a9
Pipeline #4311 passed with stage
in 14 minutes and 5 seconds
......@@ -190,23 +190,30 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo, bool l
m_producer->set("length", outPoint + 1);
}
}
Fun operation = [this, inPoint, outPoint, track_operation]() {
QVector<int> roles{TimelineModel::DurationRole};
if (!right) {
roles.push_back(TimelineModel::StartRole);
roles.push_back(TimelineModel::InPointRole);
} else {
roles.push_back(TimelineModel::OutPointRole);
}
Fun operation = [this, inPoint, outPoint, roles, track_operation]() {
if (track_operation()) {
setInOut(inPoint, outPoint);
if (m_currentTrackId > -1) {
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->dataChanged(ix, ix, roles);
}
}
return true;
}
return false;
};
if (operation()) {
// Now, we are in the state in which the timeline should be when we try to revert current action. So we can build the reverse action from here
QVector<int> roles{TimelineModel::DurationRole};
if (m_currentTrackId != -1) {
if (!right) {
roles.push_back(TimelineModel::StartRole);
roles.push_back(TimelineModel::InPointRole);
} else {
roles.push_back(TimelineModel::OutPointRole);
}
if (auto ptr = m_parent.lock()) {
track_reverse = ptr->getTrackById(m_currentTrackId)->requestClipResize_lambda(m_id, old_in, old_out, right);
}
......@@ -214,9 +221,11 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo, bool l
Fun reverse = [this, old_in, old_out, track_reverse, roles]() {
if (track_reverse()) {
setInOut(old_in, old_out);
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->dataChanged(ix, ix, roles);
if (m_currentTrackId > -1) {
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->dataChanged(ix, ix, roles);
}
}
return true;
}
......
......@@ -94,12 +94,6 @@ Rectangle {
controller.requestAddToSelection(clipRoot.clipId)
}
onInPointChanged: {
if (parentTrack && parentTrack.isAudio && thumbsLoader.item) {
thumbsLoader.item.reload()
}
}
onClipResourceChanged: {
if (itemType == ProducerType.Color) {
color: Qt.darker(getColor(), 1.5)
......@@ -129,6 +123,10 @@ Rectangle {
onClipDurationChanged: {
width = clipDuration * timeScale;
if (parentTrack && parentTrack.isAudio && thumbsLoader.item) {
// Duration changed, we may need a different number of repeaters
thumbsLoader.item.reload()
}
}
onModelStartChanged: {
......
......@@ -51,10 +51,8 @@ Row {
isFirstChunk: index == 0
showItem: waveform.visible && (index * width) < waveform.scrollEnd && (index * width + width) > waveform.scrollStart
format: timeline.audioThumbFormat
inPoint: clipRoot.speed < 0 ? (Math.round(clipRoot.outPoint - (index * waveform.maxWidth / clipRoot.timeScale) * Math.abs(clipRoot.speed)) * channels) : (Math.round(clipRoot.inPoint + (index * waveform.maxWidth / clipRoot.timeScale) * clipRoot.speed) * channels)
outPoint: clipRoot.speed < 0 ? (inPoint - Math.ceil(width / clipRoot.timeScale * Math.abs(clipRoot.speed)) * channels) : (inPoint + Math.round(width / clipRoot.timeScale * clipRoot.speed) * channels)
/*inPoint: Math.round((clipFrameStart * Math.abs(clipRoot.timeScale)) + (index * waveform.maxWidth / clipRoot.timeScale) * clipRoot.speed) * channels
outPoint: inPoint + Math.round(width / clipRoot.timeScale * clipRoot.speed) * channels*/
waveInPoint: clipRoot.speed < 0 ? (Math.round(clipRoot.outPoint - (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)
fillColor: activePalette.text
onShowItemChanged: {
if (showItem) {
......
......@@ -79,10 +79,10 @@ class TimelineWaveform : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QColor fillColor MEMBER m_color NOTIFY propertyChanged)
Q_PROPERTY(int inPoint MEMBER m_inPoint NOTIFY propertyChanged)
Q_PROPERTY(int waveInPoint MEMBER m_inPoint NOTIFY propertyChanged)
Q_PROPERTY(int channels MEMBER m_channels NOTIFY audioChannelsChanged)
Q_PROPERTY(QString binId MEMBER m_binId NOTIFY levelsChanged)
Q_PROPERTY(int outPoint MEMBER m_outPoint NOTIFY outPointChanged)
Q_PROPERTY(int waveOutPoint MEMBER m_outPoint)
Q_PROPERTY(bool format MEMBER m_format NOTIFY propertyChanged)
Q_PROPERTY(bool showItem MEMBER m_showItem NOTIFY showItemChanged)
Q_PROPERTY(bool isFirstChunk MEMBER m_firstChunk)
......@@ -200,7 +200,6 @@ signals:
void levelsChanged();
void propertyChanged();
void inPointChanged();
void outPointChanged();
void showItemChanged();
void audioChannelsChanged();
......
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