Fix launcher buttons on macOS

This commit is contained in:
Jon Evans 2023-10-23 08:55:51 -04:00
parent f4b872226b
commit 96d203477e
2 changed files with 16 additions and 2 deletions

View File

@ -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;

View File

@ -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 ) ) );