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: fix shifted (text) markers whe using odd scale factors #3936

Merged
merged 1 commit into from
Jun 3, 2021
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
14 changes: 6 additions & 8 deletions src/waveform/renderers/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void WaveformRenderMark::slotCuesUpdated() {

void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) {
// Load the pixmap from file -- takes precedence over text.
float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio();
if (!pMark->m_pixmapPath.isEmpty()) {
QString path = pMark->m_pixmapPath;
QImage image = *WImageStore::getImage(path, scaleFactor());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here scaleFactor() is in use.
Which value has it?
I did not understand why scaleFactor() works here.
Does it?
When is the code used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scaleFactor or devicePixelRatio makes no difference here.
It's 1.0 regardless of the Qt scale factor. some leftover from custom Mixxx scaling?
this is used when markers use icons, like in Deere (Cue, loop_in/out).
then the entire part below is skipped
= the icon needs to be centered so the icon stroke (if any) aligns with the marker position on the waveform

also, the one initial problem here causing the offset is that the marker sroke is not taken from the samplePosition but directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not understand why scaleFactor() works here.

must admit I don't understand it either.
The fixes apply to all QPainter-related calculations below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deere uses it for its cue marker.
I can confirm that it scales fine.

Expand Down Expand Up @@ -174,10 +175,8 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) {
}
}

//QFont font("Bitstream Vera Sans");
//QFont font("Helvetica");
QFont font; // Uses the application default
font.setPointSizeF(10 * scaleFactor());
QFont font; // Uses the application default, if not set per skin
font.setPointSizeF(10 * devicePixelRatio);
font.setStretch(100);
font.setWeight(75);

Expand Down Expand Up @@ -210,11 +209,10 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) {
}

pMark->m_image = QImage(
width * static_cast<int>(m_waveformRenderer->getDevicePixelRatio()),
height * static_cast<int>(m_waveformRenderer->getDevicePixelRatio()),
static_cast<int>(width * devicePixelRatio),
static_cast<int>(height * devicePixelRatio),
QImage::Format_ARGB32_Premultiplied);
pMark->m_image.setDevicePixelRatio(
m_waveformRenderer->getDevicePixelRatio());
pMark->m_image.setDevicePixelRatio(devicePixelRatio);

Qt::Alignment markAlignH = pMark->m_align & Qt::AlignHorizontal_Mask;
Qt::Alignment markAlignV = pMark->m_align & Qt::AlignVertical_Mask;
Expand Down