Skip to content

Commit

Permalink
use struct instead of qpair
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dB committed Nov 6, 2023
1 parent 5c44e54 commit df7dd68
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void allshader::WaveformRenderMark::drawMark(const QRectF& rect, QColor color) {

void allshader::WaveformRenderMark::paintGL() {
const float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio();
QList<QPair<WaveformMarkPointer, int>> marksOnScreen;
QList<WaveformWidgetRenderer::WaveformMarkOnScreen> marksOnScreen;

checkCuesUpdated();

Expand Down Expand Up @@ -221,7 +221,9 @@ void allshader::WaveformRenderMark::paintGL() {
}

if (visible) {
marksOnScreen.append(qMakePair(pMark, drawOffset));
marksOnScreen.append(
WaveformWidgetRenderer::WaveformMarkOnScreen{
pMark, static_cast<int>(drawOffset)});
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/waveform/renderers/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void WaveformRenderMark::setup(const QDomNode& node, const SkinContext& context)
void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) {
PainterScope PainterScope(painter);
// Associates mark objects with their positions in the widget.
QList<QPair<WaveformMarkPointer, int>> marksOnScreen;
QList<WaveformWidgetRenderer::WaveformMarkOnScreen> marksOnScreen;

painter->setWorldMatrixEnabled(false);

Expand Down Expand Up @@ -102,7 +102,9 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) {
}

if (visible) {
marksOnScreen.append(qMakePair(pMark, drawOffset));
marksOnScreen.append(
WaveformWidgetRenderer::WaveformMarkOnScreen{
pMark, drawOffset});
}
} else {
const int markHalfHeight =
Expand Down Expand Up @@ -146,7 +148,9 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) {
}

if (visible) {
marksOnScreen.append(qMakePair(pMark, drawOffset));
marksOnScreen.append(
WaveformWidgetRenderer::WaveformMarkOnScreen{
pMark, drawOffset});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/renderers/waveformwidgetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ WaveformMarkPointer WaveformWidgetRenderer::getCueMarkAtPoint(QPoint point) cons
// drawoffset from the drawing and c) storing it in WaveformMark.

for (auto it = m_markPositions.crbegin(); it != m_markPositions.crend(); ++it) {
const WaveformMarkPointer& pMark = it->first;
const WaveformMarkPointer& pMark = it->m_pMark;
VERIFY_OR_DEBUG_ASSERT(pMark) {
continue;
}

int markImagePositionInWidgetSpace = it->second;
int markImagePositionInWidgetSpace = it->m_offsetOnScreen;
QPoint pointInImageSpace;
if (getOrientation() == Qt::Horizontal) {
pointInImageSpace = QPoint(point.x() - markImagePositionInWidgetSpace, point.y());
Expand Down
9 changes: 7 additions & 2 deletions src/waveform/renderers/waveformwidgetrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class WaveformWidgetRenderer {
static const double s_waveformDefaultZoom;
static const double s_defaultPlayMarkerPosition;

struct WaveformMarkOnScreen {
WaveformMarkPointer m_pMark;
int m_offsetOnScreen;
};

public:
explicit WaveformWidgetRenderer(const QString& group);
virtual ~WaveformWidgetRenderer();
Expand Down Expand Up @@ -149,7 +154,7 @@ class WaveformWidgetRenderer {
}

void setTrack(TrackPointer track);
void setMarkPositions(const QList<QPair<WaveformMarkPointer, int>>& markPositions) {
void setMarkPositions(const QList<WaveformMarkOnScreen>& markPositions) {
m_markPositions = markPositions;
}

Expand Down Expand Up @@ -217,7 +222,7 @@ class WaveformWidgetRenderer {
private:
DISALLOW_COPY_AND_ASSIGN(WaveformWidgetRenderer);
friend class WaveformWidgetFactory;
QList<QPair<WaveformMarkPointer, int>> m_markPositions;
QList<WaveformMarkOnScreen> m_markPositions;
// draw play position indicator triangles
void drawPlayPosmarker(QPainter* painter);
void drawTriangle(QPainter* painter,
Expand Down

0 comments on commit df7dd68

Please sign in to comment.