Skip to content

Commit

Permalink
Waveform: avoid QPaitner glitch with ranges < 1 px
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jun 14, 2022
1 parent 0c51e10 commit c6e2683
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/waveform/renderers/waveformrendermarkrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ void WaveformRenderMarkRange::draw(QPainter *painter, QPaintEvent * /*event*/) {

double startPosition = m_waveformRenderer->transformSamplePositionInRendererWorld(startSample);
double endPosition = m_waveformRenderer->transformSamplePositionInRendererWorld(endSample);
double span = endPosition - startPosition;
// If span is < 1 painter would extend the rectangle to width() as long as
// startPosition is in view.
// TODO(xxx) Figure what's wrong with QPainter / the renderer
if (span < 1.0) {
span = 1.0;
}

//range not in the current display
if (startPosition > m_waveformRenderer->getLength() || endPosition < 0) {
Expand All @@ -78,9 +85,9 @@ void WaveformRenderMarkRange::draw(QPainter *painter, QPaintEvent * /*event*/) {
// this shouldn't involve *any* scaling it should be fast even in software mode
QRectF rect;
if (m_waveformRenderer->getOrientation() == Qt::Horizontal) {
rect.setRect(startPosition, 0, endPosition - startPosition, m_waveformRenderer->getHeight());
rect.setRect(startPosition, 0, span, m_waveformRenderer->getHeight());
} else {
rect.setRect(0, startPosition, m_waveformRenderer->getWidth(), endPosition - startPosition);
rect.setRect(0, startPosition, m_waveformRenderer->getWidth(), span);
}
painter->drawImage(rect, *selectedImage, rect);
}
Expand Down

0 comments on commit c6e2683

Please sign in to comment.