-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix scaling of PixmapButton in layouts #7053
Conversation
Fix the scaling of `PixmapButton` when used in layouts. In this case `PixmapButton::sizeHint` is queried which used `devicePixelRatio` to divide the size of the active pixmap. As a result the size is always the same in pixels regardless of the scaling factor of the application. This is fixed by removing the calls. Example: If the scaling factor is 2 then the pixmap will also report twice the size in pixels and hence request more space in layouts, etc. However, if we divide by the device/pixel ratio then the original size of the image/pixmap will be reported and therefore it will be too small in layouts. The calls to `devicePixelRatio` have been introduced with pull request LMMS#4950 (via commit c3b4d51) which replaced the old Spectrum Analyzer. The pixmaps of the Spectrum Analyzer still look good with this change. Fixes LMMS#7052.
Remove duplicate code which checks if the `PixmapButton` is active by introducing the new method `isActive`. Simplify the drawing code by first determining which pixmap to draw and then to draw the result if it is not null. Format code in the adjusted areas.
Sorry @he29-net, I was not aware that some other elements of the dialog also use the I am not really sure if such "knowledge" should go into the |
Yeah, that makes sense, a custom class derived from Although I'm not sure if that would be the right way forward for LMMS-wide native scaling, since it feels like a bit of a hack: it just counteracts what Qt really wants to do, which is scale all physical-pixel dimensions by a constant. It does not tie into all the other bells and whistles; for example, the SVG gets rendered only once during initialization, so if the application dynamically changes scale when moving between HighDPI and standard screen, the pixmap won't not refresh. It just receives some form of "dumb scaling" and ends up blurry (or otherwise mangled) anyway. Last time I checked the SVG icons were also broken on our Windows builds due to a missing Qt SVG library, so if that issue still persists, the easiest solution may be to simply fall back to standard pixelated icons in the analyzer until we have a "proper" solution that could be applied to everything (which in practice probably means Qt 6 or something). |
Fix the scaling of
PixmapButton
when used in layouts. In this casePixmapButton::sizeHint
is queried which useddevicePixelRatio
to divide the size of the active pixmap. As a result the size is always the same in pixels regardless of the scaling factor of the application. This is fixed by removing the calls.Example: If the scaling factor is 2 then the pixmap will also report twice the size in pixels and hence request more space in layouts, etc. However, if we divide by the device/pixel ratio then the original size of the image/pixmap will be reported and therefore it will be too small in layouts.
The calls to
devicePixelRatio
have been introduced with pull request #4950 (via commit c3b4d51) which replaced the old Spectrum Analyzer. The pixmaps of the Spectrum Analyzer still look good with this change.Can be tested on any system by building LMMS and then starting it with:
Fixes #7052.