Skip to content

Commit

Permalink
Fix scaling of PixmapButton in layouts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelgregorius committed Jan 7, 2024
1 parent 1eff322 commit b02a831
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gui/widgets/PixmapButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ QSize PixmapButton::sizeHint() const
{
if( ( model() != nullptr && model()->value() ) || m_pressed )
{
return m_activePixmap.size() / devicePixelRatio();
return m_activePixmap.size();
}
else
{
return m_inactivePixmap.size() / devicePixelRatio();
return m_inactivePixmap.size();
}
}

Expand Down

0 comments on commit b02a831

Please sign in to comment.