Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waveform: avoid QPainter glitch with ranges < 1 px #4804

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/waveform/renderers/waveformrendermarkrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ void WaveformRenderMarkRange::draw(QPainter *painter, QPaintEvent * /*event*/) {

double startPosition = m_waveformRenderer->transformSamplePositionInRendererWorld(startSample);
double endPosition = m_waveformRenderer->transformSamplePositionInRendererWorld(endSample);
// The painter would extend the rectangle to the entire width while
// span is < 1 AND span != 0.25 * [1;3], i.e. works with span = [.25; 0.75] px
// TODO(xxx) Figure what's wrong with QPainter / the renderer
const double span = std::max(endPosition - startPosition, 1.0);

//range not in the current display
if (startPosition > m_waveformRenderer->getLength() || endPosition < 0) {
Expand All @@ -78,9 +82,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