From 96d203477e5ade981d7044f1f22e2c54a5a709ea Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 23 Oct 2023 08:55:51 -0400 Subject: [PATCH] Fix launcher buttons on macOS --- common/tool/action_toolbar.cpp | 2 +- common/widgets/bitmap_button.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 8276c35797..46fd9da919 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -125,12 +125,12 @@ void ACTION_TOOLBAR_PALETTE::AddAction( const TOOL_ACTION& aAction ) BITMAP_BUTTON* button = new BITMAP_BUTTON( m_panel, aAction.GetUIId(), wxDefaultPosition, bmSize ); + button->SetIsToolbarButton(); button->SetBitmap( normalBmp ); button->SetDisabledBitmap( KiDisabledBitmapBundle( aAction.GetIcon() ) ); button->SetPadding( padding ); button->SetToolTip( aAction.GetTooltip() ); button->AcceptDragInAsClick(); - button->SetIsToolbarButton(); button->SetBitmapCentered(); m_buttons[aAction.GetUIId()] = button; diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index b7b634a7b0..07436a54d4 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -105,7 +105,21 @@ void BITMAP_BUTTON::SetPadding( int aPadding ) void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) { m_normalBitmap = aBmp; - m_unadjustedMinSize = m_normalBitmap.GetPreferredBitmapSizeFor( this ); + + // This is a bit of a hack, but fixes button scaling issues on some platforms when those buttons + // use KiScaledBitmap. When that method is retired, this can probably be revisited. + if( m_isToolbarButton ) + { + m_unadjustedMinSize = m_normalBitmap.GetPreferredBitmapSizeFor( this ); + } + else + { +#ifndef __WXMSW__ + m_unadjustedMinSize = m_normalBitmap.GetDefaultSize(); +#else + m_unadjustedMinSize = m_normalBitmap.GetPreferredBitmapSizeFor( this ); +#endif + } SetMinSize( wxSize( m_unadjustedMinSize.GetWidth() + ( m_padding * 2 ), m_unadjustedMinSize.GetHeight() + ( m_padding * 2 ) ) );