diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index 367d04e1ce..2b3aad5a54 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -92,15 +92,29 @@ BITMAP_BUTTON::~BITMAP_BUTTON() wxSize BITMAP_BUTTON::DoGetBestSize() const { + if( hasFlag( wxCONTROL_SEPARATOR ) ) + return wxSize( m_unadjustedMinSize.x + m_padding * 2, wxButton::GetDefaultSize().y ); + return m_unadjustedMinSize + wxSize( m_padding * 2, m_padding * 2 ); } +void BITMAP_BUTTON::invalidateBestSize() +{ +#ifdef __WXMAC__ + // InvalidateBestSize() doesn't appear to work on Mac: DoGetBestSize() is never called. + SetMinSize( DoGetBestSize() ); +#else + InvalidateBestSize(); +#endif +} + + void BITMAP_BUTTON::SetPadding( int aPadding ) { m_padding = aPadding; - InvalidateBestSize(); + invalidateBestSize(); } @@ -123,7 +137,7 @@ void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) #endif } - InvalidateBestSize(); + invalidateBestSize(); } @@ -261,7 +275,7 @@ void BITMAP_BUTTON::OnDPIChanged( wxDPIChangedEvent& aEvent ) if( newBmSize != m_unadjustedMinSize ) { m_unadjustedMinSize = newBmSize; - InvalidateBestSize(); + invalidateBestSize(); } aEvent.Skip(); @@ -414,7 +428,7 @@ void BITMAP_BUTTON::SetIsSeparator() { setFlag( wxCONTROL_SEPARATOR | wxCONTROL_DISABLED ); - InvalidateBestSize(); + invalidateBestSize(); } diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 172e724379..96656171e9 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -21,6 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include @@ -146,6 +147,12 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, const COLOR4D& aColor, int aID, m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ); m_checkerboardBg = aParent->GetBackgroundColour(); +#ifdef __WXMAC__ + // Adjust for Retina + m_size *= KIPLATFORM::UI::GetPixelScaleFactor( aParent ); + m_checkerboardSize *= KIPLATFORM::UI::GetPixelScaleFactor( aParent ); +#endif + auto sizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( sizer ); @@ -176,6 +183,16 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, wxWindowID aID, const wxPoint& aP m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ); m_checkerboardBg = aParent->GetBackgroundColour(); +#ifdef __WXMAC__ + // Adjust for border + m_size.x -= 2; + m_size.y -= 2; + + // Adjust for Retina + m_size *= KIPLATFORM::UI::GetPixelScaleFactor( aParent ); + m_checkerboardSize *= KIPLATFORM::UI::GetPixelScaleFactor( aParent ); +#endif + SetSize( m_size ); auto sizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/include/widgets/bitmap_button.h b/include/widgets/bitmap_button.h index 013ec60cd1..4604482f6e 100644 --- a/include/widgets/bitmap_button.h +++ b/include/widgets/bitmap_button.h @@ -153,6 +153,8 @@ protected: return m_buttonState & aFlag; } + void invalidateBestSize(); + private: wxBitmapBundle m_normalBitmap; wxBitmapBundle m_disabledBitmap;