diff --git a/common/bitmap.cpp b/common/bitmap.cpp index c8ed41fbf3..94fb3fdb4c 100644 --- a/common/bitmap.cpp +++ b/common/bitmap.cpp @@ -107,9 +107,9 @@ wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag ) } -wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap ) +wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap, int aMinHeight ) { - return GetBitmapStore()->GetBitmapBundle( aBitmap ); + return GetBitmapStore()->GetBitmapBundle( aBitmap, aMinHeight ); } diff --git a/common/bitmap_store.cpp b/common/bitmap_store.cpp index 9e542ebe80..861f781d59 100644 --- a/common/bitmap_store.cpp +++ b/common/bitmap_store.cpp @@ -121,7 +121,7 @@ wxBitmap BITMAP_STORE::GetBitmap( BITMAPS aBitmapId, int aHeight ) } -wxBitmapBundle BITMAP_STORE::GetBitmapBundle( BITMAPS aBitmapId ) +wxBitmapBundle BITMAP_STORE::GetBitmapBundle( BITMAPS aBitmapId, int aMinHeight ) { wxVector<wxBitmap> bmps; @@ -130,6 +130,9 @@ wxBitmapBundle BITMAP_STORE::GetBitmapBundle( BITMAPS aBitmapId ) if( info.theme != m_theme ) continue; + if( aMinHeight > 0 && info.height < aMinHeight ) + continue; + bmps.push_back( wxBitmap( getImage( info.id, info.height ) ) ); } diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index ac2f54e4b5..0f77f11b3e 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -114,16 +114,15 @@ ACTION_TOOLBAR_PALETTE::ACTION_TOOLBAR_PALETTE( wxWindow* aParent, bool aVertica void ACTION_TOOLBAR_PALETTE::AddAction( const TOOL_ACTION& aAction ) { - wxBitmapBundle normalBmp = KiBitmapBundle( aAction.GetIcon() ); + int size = Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size; + wxBitmapBundle normalBmp = KiBitmapBundle( aAction.GetIcon(), size ); int bmpWidth = normalBmp.GetPreferredBitmapSizeFor( this ).GetWidth(); int padding = ( m_buttonSize.GetWidth() - bmpWidth ) / 2; - int size = Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size; wxSize bmSize( size, size ); - bmSize *= KIPLATFORM::UI::GetPixelScaleFactor( m_parent ); + bmSize *= KIPLATFORM::UI::GetContentScaleFactor( m_parent ); - BITMAP_BUTTON* button = new BITMAP_BUTTON( m_panel, aAction.GetUIId(), wxDefaultPosition, - bmSize ); + BITMAP_BUTTON* button = new BITMAP_BUTTON( m_panel, aAction.GetUIId() ); button->SetIsToolbarButton(); button->SetBitmap( normalBmp ); diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index 286db0b60b..51119e4168 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -336,14 +336,14 @@ void BITMAP_BUTTON::OnPaint( wxPaintEvent& aEvent ) wxPoint drawBmpPos( m_padding, m_padding ); wxBitmap bmpImg; - double scale = KIPLATFORM::UI::GetPixelScaleFactor( this ); + double scale = KIPLATFORM::UI::GetContentScaleFactor( this ); wxSize bmSize; if( m_isToolbarButton ) { int size = Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size; - bmSize = wxSize( size, size ); - bmpImg = bmp.GetBitmap( bmSize * scale ); + bmSize = wxSize( size, size ) * scale; + bmpImg = bmp.GetBitmap( bmSize ); // wxBitmapBundle::GetBitmap thinks we need this rescaled to match the base size if( bmpImg.IsOk() ) diff --git a/include/bitmap_store.h b/include/bitmap_store.h index db66c7139b..239aff2563 100644 --- a/include/bitmap_store.h +++ b/include/bitmap_store.h @@ -60,9 +60,13 @@ public: /** * Constructs and returns a bitmap bundle containing all available sizes of the given ID * @param aBitmapId is from the BITMAPS enum in bitmaps_list.h + * @param aMinHeight is the minimum height of the bitmaps to include in the bundle. + * This is important for uses of GetPreferredBitmap and more on wxBitmap bundles because + * wx assumes the smallest bitmap is the "original" intended size. This is a problem where + * some icons may be reused between controls at different intended sizes. */ - wxBitmapBundle GetBitmapBundle( BITMAPS aBitmapId ); - + wxBitmapBundle GetBitmapBundle( BITMAPS aBitmapId, int aMinHeight = -1 ); + /** * Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps * converted to disabled state according to the current UI theme. diff --git a/include/bitmaps/bitmap_types.h b/include/bitmaps/bitmap_types.h index 7e5f907b89..3fd58fac9b 100644 --- a/include/bitmaps/bitmap_types.h +++ b/include/bitmaps/bitmap_types.h @@ -56,7 +56,7 @@ KICOMMON_API BITMAP_STORE* GetBitmapStore(); */ KICOMMON_API wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 ); -KICOMMON_API wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap ); +KICOMMON_API wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap, int aMinHeight = -1 ); KICOMMON_API wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap );