Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Reverse clip audio thumbs (WIP)

parent 63e863d7
Pipeline #1886 passed with stage
in 15 minutes and 19 seconds
......@@ -278,10 +278,12 @@ Rectangle {
}
Item {
// Clipping container
id: container
// Thumbs container
anchors.fill: parent
anchors.margins:1.5
anchors.leftMargin: 0
anchors.rightMargin: 0
anchors.topMargin: parent.border.width
anchors.bottomMargin: parent.border.width
clip: true
Loader {
id: thumbsLoader
......@@ -293,6 +295,14 @@ Rectangle {
item.reload()
}
}
}
Item {
// Clipping container
id: container
anchors.fill: parent
anchors.margins: 1.5
clip: true
Rectangle {
// text background
......
......@@ -9,7 +9,6 @@ Row {
visible: clipStatus != ClipState.VideoOnly && parentTrack.isAudio && !parentTrack.isMute
opacity: clipStatus == ClipState.Disabled ? 0.2 : 1
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
property int scrollEnd: scrollStart + scrollView.viewport.width
......@@ -36,7 +35,7 @@ Row {
if (!waveform.visible || !timeline.showAudioThumbnails || (waveform.scrollMin > clipRoot.modelStart + clipRoot.clipDuration) || (clipRoot.modelStart > waveform.scrollMax) || clipRoot.audioLevels == '') {
return;
}
var chunks = Math.ceil(waveform.innerWidth / waveform.maxWidth)
var chunks = Math.ceil(waveform.width / waveform.maxWidth)
if (waveformRepeater.model == undefined || chunks != waveformRepeater.model) {
waveformRepeater.model = chunks
}
......@@ -45,15 +44,17 @@ Row {
Repeater {
id: waveformRepeater
TimelineWaveform {
width: Math.min(waveform.innerWidth, waveform.maxWidth)
width: Math.min(waveform.width, waveform.maxWidth)
height: waveform.height
channels: clipRoot.audioChannels
binId: clipRoot.binId
isFirstChunk: index == 0
showItem: waveform.visible && (index * width) < waveform.scrollEnd && (index * width + width) > waveform.scrollStart
format: timeline.audioThumbFormat
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
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*/
fillColor: activePalette.text
onShowItemChanged: {
if (showItem) {
......
......@@ -112,7 +112,7 @@ public:
if (!m_showItem || m_audioLevels.isEmpty()) {
return;
}
const qreal indicesPrPixel = qreal(m_outPoint - m_inPoint) / width();
qreal indicesPrPixel = qreal(m_outPoint - m_inPoint) / width();
QPen pen = painter->pen();
pen.setColor(m_color);
pen.setWidthF(0);
......@@ -122,12 +122,14 @@ public:
QPainterPath path;
path.moveTo(-1, height());
double i = 0;
double increment = qMax(1., 1 / indicesPrPixel);
double increment = qMax(1., 1 / qAbs(indicesPrPixel));
double level;
int lastIdx = -1;
for (; i <= width(); i += increment) {
int idx = m_inPoint + int(i * indicesPrPixel);
if (idx + m_channels >= m_audioLevels.length()) break;
if (idx + m_channels >= m_audioLevels.length() || idx < 0) {
break;
}
if (lastIdx == idx) {
continue;
}
......@@ -196,7 +198,6 @@ signals:
void audioChannelsChanged();
private:
bool m_levels;
QList<double> m_audioLevels;
int m_inPoint;
int m_outPoint;
......
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