Hack Mac icon buttons back to size.

It remains unclear to me how this *should* be going forward, but
this at least gets us back to the status quo.
This commit is contained in:
Jeff Young 2023-06-03 21:41:56 +01:00
parent 5875f89531
commit 9da66ccb58
3 changed files with 30 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee dot org> * Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee dot org>
* Copyright (C) 2020-2022 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2023 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -95,7 +95,11 @@ void BITMAP_BUTTON::SetPadding( int aPadding )
void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp )
{ {
m_normalBitmap = aBmp; m_normalBitmap = aBmp;
m_unadjustedMinSize = aBmp.GetPreferredBitmapSizeFor( this ); #ifdef __WXMAC__
m_unadjustedMinSize = m_normalBitmap.GetDefaultSize();
#else
m_unadjustedMinSize = m_normalBitmap.GetPreferredBitmapSizeFor( this );
#endif
SetMinSize( wxSize( m_unadjustedMinSize.GetWidth() + ( m_padding * 2 ), SetMinSize( wxSize( m_unadjustedMinSize.GetWidth() + ( m_padding * 2 ),
m_unadjustedMinSize.GetHeight() + ( m_padding * 2 ) ) ); m_unadjustedMinSize.GetHeight() + ( m_padding * 2 ) ) );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2016 Anil8735(https://stackoverflow.com/users/3659387/anil8753) * Copyright (C) 2016 Anil8735(https://stackoverflow.com/users/3659387/anil8753)
* from https://stackoverflow.com/a/37274011 * from https://stackoverflow.com/a/37274011
* Copyright (C) 2020-2022 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2023 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -97,7 +97,11 @@ void SPLIT_BUTTON::SetBitmap( const wxBitmapBundle& aBmp )
{ {
m_bitmap = aBmp; m_bitmap = aBmp;
#ifdef __WXMAC__
SetMinSize( m_bitmap.GetDefaultSize() );
#else
SetMinSize( m_bitmap.GetPreferredBitmapSizeFor( this ) ); SetMinSize( m_bitmap.GetPreferredBitmapSizeFor( this ) );
#endif
} }
@ -284,17 +288,22 @@ void SPLIT_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
if( m_bitmap.IsOk() ) if( m_bitmap.IsOk() )
{ {
#ifdef __WXMAC__
wxSize bmpSize = m_bitmap.GetDefaultSize();
#else
wxSize bmpSize = m_bitmap.GetPreferredBitmapSizeFor( this );
#endif
wxBitmap bmp = m_bitmap.GetBitmapFor( this ); wxBitmap bmp = m_bitmap.GetBitmapFor( this );
wxMemoryDC mdc( bmp ); wxMemoryDC mdc( bmp );
r1.x = ( width - bmp.GetWidth() ) / 2; r1.x = ( width - bmpSize.GetWidth() ) / 2;
if( r1.x < 0 ) if( r1.x < 0 )
r1.x = 0; r1.x = 0;
r1.y += ( size.GetHeight() - bmp.GetHeight() ) / 2; r1.y += ( size.GetHeight() - bmpSize.GetHeight() ) / 2;
dc.Blit( wxPoint( r1.x, r1.y ), bmp.GetSize(), &mdc, wxPoint( 0, 0 ), wxCOPY, true ); dc.Blit( wxPoint( r1.x, r1.y ), bmpSize, &mdc, wxPoint( 0, 0 ), wxCOPY, true );
} }
else else
{ {

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2016 Anil8735(https://stackoverflow.com/users/3659387/anil8753) * Copyright (C) 2016 Anil8735(https://stackoverflow.com/users/3659387/anil8753)
* from https://stackoverflow.com/a/37274011 * from https://stackoverflow.com/a/37274011
* Copyright (C) 2020-2022 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2023 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -76,7 +76,12 @@ void STD_BITMAP_BUTTON::onThemeChanged( wxSysColourChangedEvent &aEvent )
void STD_BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) void STD_BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp )
{ {
m_bitmap = aBmp; m_bitmap = aBmp;
wxSize size = aBmp.GetPreferredBitmapSizeFor( this );
#ifdef __WXMAC__
wxSize size = m_bitmap.GetDefaultSize();
#else
wxSize size = m_bitmap.GetPreferredBitmapSizeFor( this );
#endif
SetMinSize( wxSize( size.GetWidth() + 8, size.GetHeight() + 8 ) ); SetMinSize( wxSize( size.GetWidth() + 8, size.GetHeight() + 8 ) );
} }
@ -206,7 +211,11 @@ void STD_BITMAP_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
if( m_bitmap.IsOk() ) if( m_bitmap.IsOk() )
{ {
#ifdef __WXMAC__
wxSize bmpSize = m_bitmap.GetDefaultSize();
#else
wxSize bmpSize = m_bitmap.GetPreferredBitmapSizeFor( this ); wxSize bmpSize = m_bitmap.GetPreferredBitmapSizeFor( this );
#endif
r1.x = ( size.GetWidth() - bmpSize.GetWidth() ) / 2; r1.x = ( size.GetWidth() - bmpSize.GetWidth() ) / 2;