diff options
author | Harshit Maurya <hmaurya999@gmail.com> | 2020-05-13 03:09:29 +0530 |
---|---|---|
committer | Harshit Maurya <hmaurya999@gmail.com> | 2020-05-16 02:17:43 +0530 |
commit | c16cfc143b94e48b732761286a70270028b4aa54 (patch) | |
tree | 77561cc7cff2c6de7f1116c00ee19a84d0fef4a3 | |
parent | e129710c8b5b210f747fe0b8832be3b6b7eb3e9d (diff) |
wwaveformviewer: add menu to vertical orientation
-rw-r--r-- | src/waveform/renderers/waveformrendermark.cpp | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/waveform/renderers/waveformrendermark.cpp b/src/waveform/renderers/waveformrendermark.cpp index 213d74e7e1..f46ed5e071 100644 --- a/src/waveform/renderers/waveformrendermark.cpp +++ b/src/waveform/renderers/waveformrendermark.cpp @@ -60,30 +60,36 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) { if (samplePosition != -1.0) { double currentMarkPoint = m_waveformRenderer->transformSamplePositionInRendererWorld(samplePosition); - + const auto& labelBoundingRect = m_markBoundaries[pMark]; if (m_waveformRenderer->getOrientation() == Qt::Horizontal) { // NOTE: vRince I guess image width is odd to display the center on the exact line ! // external image should respect that ... - auto& labelBoundingRect = m_markBoundaries[pMark]; const int markHalfWidth = pMark->m_image.width() / 2.0 / m_waveformRenderer->getDevicePixelRatio(); // Check if the current point need to be displayed if (currentMarkPoint > -markHalfWidth && currentMarkPoint < m_waveformRenderer->getWidth() + markHalfWidth) { int drawOffset = currentMarkPoint - markHalfWidth; - int labelBoundaryOffset = currentMarkPoint - labelBoundingRect.width() / 2.0; - const auto topLeft = QPoint(drawOffset, 0); - painter->drawImage(topLeft, pMark->m_image); - labelBoundingRect.setRect(labelBoundaryOffset, - 0, + int labelBoundaryStartOffset = drawOffset + labelBoundingRect.left(); + painter->drawImage(QPoint(drawOffset, 0), pMark->m_image); + marksOnScreen[pMark] = QRect(labelBoundaryStartOffset, + labelBoundingRect.top(), labelBoundingRect.width(), labelBoundingRect.height()); - marksOnScreen[pMark] = labelBoundingRect; } } else { const int markHalfHeight = pMark->m_image.height() / 2.0; - if (currentMarkPoint > -markHalfHeight && currentMarkPoint < m_waveformRenderer->getHeight() + markHalfHeight) { - painter->drawImage(QPoint(0,currentMarkPoint - markHalfHeight), pMark->m_image); + if (currentMarkPoint > -markHalfHeight && + currentMarkPoint < m_waveformRenderer->getHeight() + + markHalfHeight) { + int drawOffset = currentMarkPoint - markHalfHeight; + int labelBoundaryStartOffset = + drawOffset + labelBoundingRect.top(); + painter->drawImage(QPoint(0, drawOffset), pMark->m_image); + marksOnScreen[pMark] = QRect(labelBoundingRect.left(), + labelBoundaryStartOffset, + labelBoundingRect.width(), + labelBoundingRect.height()); } } } @@ -93,8 +99,8 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) { void WaveformRenderMark::onResize() { // Delete all marks' images. New images will be created on next paint. - for (const auto& pMark: m_marks) { - pMark->m_image = QImage(); + for (const auto& pMark : m_marks) { + pMark->m_image = QImage(); } } @@ -113,12 +119,12 @@ void WaveformRenderMark::onSetTrack() { void WaveformRenderMark::slotCuesUpdated() { TrackPointer trackInfo = m_waveformRenderer->getTrackInfo(); - if (!trackInfo){ + if (!trackInfo) { return; } QList<CuePointer> loadedCues = trackInfo->getCuePoints(); - for (const CuePointer pCue: loadedCues) { + for (const CuePointer pCue : loadedCues) { int hotCue = pCue->getHotCue(); if (hotCue == Cue::kNoHotCue) { continue; @@ -134,7 +140,8 @@ void WaveformRenderMark::slotCuesUpdated() { QString newLabel = pCue->getLabel(); QColor newColor = mixxx::RgbColor::toQColor(pCue->getColor()); if (pMark->m_text.isNull() || newLabel != pMark->m_text || - !pMark->fillColor().isValid() || newColor != pMark->fillColor()) { + !pMark->fillColor().isValid() || + newColor != pMark->fillColor()) { pMark->m_text = newLabel; pMark->setBaseColor(newColor); generateMarkImage(pMark); @@ -151,7 +158,8 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) { // If loading the image didn't fail, then we're done. Otherwise fall // through and render a label. if (!image.isNull()) { - pMark->m_image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + pMark->m_image = + image.convertToFormat(QImage::Format_ARGB32_Premultiplied); //WImageStore::correctImageColors(&pMark->m_image); return; } @@ -209,7 +217,8 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) { pMark->m_image = QImage(width * m_waveformRenderer->getDevicePixelRatio(), height * m_waveformRenderer->getDevicePixelRatio(), QImage::Format_ARGB32_Premultiplied); - pMark->m_image.setDevicePixelRatio(m_waveformRenderer->getDevicePixelRatio()); + pMark->m_image.setDevicePixelRatio( + m_waveformRenderer->getDevicePixelRatio()); Qt::Alignment markAlignH = pMark->m_align & Qt::AlignHorizontal_Mask; Qt::Alignment markAlignV = pMark->m_align & Qt::AlignVertical_Mask; @@ -226,7 +235,8 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) { labelRect.moveBottom(height - 1); } - m_markBoundaries[pMark].setRect(0, 0, labelRectWidth, labelRectHeight); + m_markBoundaries[pMark].setRect( + labelRect.left(), labelRect.top(), labelRectWidth, labelRectHeight); // Fill with transparent pixels pMark->m_image.fill(QColor(0, 0, 0, 0).rgba()); |