Skip to content

Commit

Permalink
convert to const methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hacksdump committed May 15, 2020
1 parent b45bf21 commit 22b1915
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/waveform/renderers/waveformmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void WaveformMark::setBaseColor(QColor baseColor) {
m_labelColor = Color::chooseColorByBrightness(baseColor, QColor(255,255,255,255), QColor(0,0,0,255));
};

bool WaveformMark::contains(QPoint point, Qt::Orientation orientation) {
bool WaveformMark::contains(QPoint point, Qt::Orientation orientation) const {
// Without some padding, the user would only have a single pixel width that
// would count as hovering over the WaveformMark.
float lineHoverPadding = 5.0;
Expand All @@ -118,5 +118,5 @@ bool WaveformMark::contains(QPoint point, Qt::Orientation orientation) {
bool lineHovered = m_linePosition >= position - lineHoverPadding &&
m_linePosition <= position + lineHoverPadding;

return (m_label.area().contains(point) || lineHovered);
return m_label.area().contains(point) || lineHovered;
}
2 changes: 1 addition & 1 deletion src/waveform/renderers/waveformmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class WaveformMark {
}

// Check if a point (in image co-ordinates) lies on drawn image.
bool contains(QPoint point, Qt::Orientation orientation);
bool contains(QPoint point, Qt::Orientation orientation) const;

QColor m_textColor;
QString m_text;
Expand Down
5 changes: 3 additions & 2 deletions src/waveform/renderers/waveformwidgetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,14 @@ void WaveformWidgetRenderer::setTrack(TrackPointer track) {
}
}

WaveformMarkPointer WaveformWidgetRenderer::getCueMarkAtPoint(QPoint point) {
WaveformMarkPointer WaveformWidgetRenderer::getCueMarkAtPoint(QPoint point) const {
for (const auto& pMark : m_markPositions.keys()) {
int markImagePositionInWidgetSpace = m_markPositions[pMark];
QPoint pointInImageSpace;
if (getOrientation() == Qt::Horizontal) {
pointInImageSpace = QPoint(point.x() - markImagePositionInWidgetSpace, point.y());
} else { /* Vertical */
} else {
DEBUG_ASSERT(getOrientation() == Qt::Vertical);
pointInImageSpace = QPoint(point.x(), point.y() - markImagePositionInWidgetSpace);
}
if (pMark->contains(pointInImageSpace, getOrientation())) {
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/waveformwidgetrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WaveformWidgetRenderer {
inline const char* getGroup() const { return m_group;}
const TrackPointer getTrackInfo() const { return m_pTrack;}
/// Get cue mark at a point on the waveform widget.
WaveformMarkPointer getCueMarkAtPoint(QPoint point);
WaveformMarkPointer getCueMarkAtPoint(QPoint point) const;

double getFirstDisplayedPosition() const { return m_firstDisplayedPosition;}
double getLastDisplayedPosition() const { return m_lastDisplayedPosition;}
Expand Down
4 changes: 2 additions & 2 deletions src/widget/wwaveformviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void WWaveformViewer::setWaveformWidget(WaveformWidgetAbstract* waveformWidget)
}
}

CuePointer WWaveformViewer::getCuePointerFromCueMark(WaveformMarkPointer pMark) {
CuePointer WWaveformViewer::getCuePointerFromCueMark(WaveformMarkPointer pMark) const {
if (pMark && pMark->getHotCue() != Cue::kNoHotCue) {
QList<CuePointer> cueList = m_waveformWidget->getTrackInfo()->getCuePoints();
for (const auto& pCue : cueList) {
Expand All @@ -277,6 +277,6 @@ void WWaveformViewer::unhighlightMark(WaveformMarkPointer pMark) {
pMark->setBaseColor(originalColor);
}

bool WWaveformViewer::isPlaying() {
bool WWaveformViewer::isPlaying() const {
return m_pPlayEnabled->get();
}
4 changes: 2 additions & 2 deletions src/widget/wwaveformviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ private slots:

friend class WaveformWidgetFactory;

CuePointer getCuePointerFromCueMark(WaveformMarkPointer pMark);
CuePointer getCuePointerFromCueMark(WaveformMarkPointer pMark) const;
void highlightMark(WaveformMarkPointer pMark);
void unhighlightMark(WaveformMarkPointer pMark);
bool isPlaying();
bool isPlaying() const;
};

#endif

0 comments on commit 22b1915

Please sign in to comment.