Fix color-swatch sizing on MacOS.
Also fixes BITMAP_BUTTON sizing.
This commit is contained in:
parent
6baceedea4
commit
ecb7cd6b84
|
@ -92,15 +92,29 @@ BITMAP_BUTTON::~BITMAP_BUTTON()
|
||||||
|
|
||||||
wxSize BITMAP_BUTTON::DoGetBestSize() const
|
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 );
|
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 )
|
void BITMAP_BUTTON::SetPadding( int aPadding )
|
||||||
{
|
{
|
||||||
m_padding = aPadding;
|
m_padding = aPadding;
|
||||||
|
|
||||||
InvalidateBestSize();
|
invalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +137,7 @@ void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateBestSize();
|
invalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +275,7 @@ void BITMAP_BUTTON::OnDPIChanged( wxDPIChangedEvent& aEvent )
|
||||||
if( newBmSize != m_unadjustedMinSize )
|
if( newBmSize != m_unadjustedMinSize )
|
||||||
{
|
{
|
||||||
m_unadjustedMinSize = newBmSize;
|
m_unadjustedMinSize = newBmSize;
|
||||||
InvalidateBestSize();
|
invalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
aEvent.Skip();
|
aEvent.Skip();
|
||||||
|
@ -414,7 +428,7 @@ void BITMAP_BUTTON::SetIsSeparator()
|
||||||
{
|
{
|
||||||
setFlag( wxCONTROL_SEPARATOR | wxCONTROL_DISABLED );
|
setFlag( wxCONTROL_SEPARATOR | wxCONTROL_DISABLED );
|
||||||
|
|
||||||
InvalidateBestSize();
|
invalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <kiplatform/ui.h>
|
||||||
#include <widgets/color_swatch.h>
|
#include <widgets/color_swatch.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
|
|
||||||
|
@ -146,6 +147,12 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, const COLOR4D& aColor, int aID,
|
||||||
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
||||||
m_checkerboardBg = aParent->GetBackgroundColour();
|
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 );
|
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
SetSizer( sizer );
|
SetSizer( sizer );
|
||||||
|
|
||||||
|
@ -176,6 +183,16 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, wxWindowID aID, const wxPoint& aP
|
||||||
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
||||||
m_checkerboardBg = aParent->GetBackgroundColour();
|
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 );
|
SetSize( m_size );
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
|
@ -153,6 +153,8 @@ protected:
|
||||||
return m_buttonState & aFlag;
|
return m_buttonState & aFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void invalidateBestSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxBitmapBundle m_normalBitmap;
|
wxBitmapBundle m_normalBitmap;
|
||||||
wxBitmapBundle m_disabledBitmap;
|
wxBitmapBundle m_disabledBitmap;
|
||||||
|
|
Loading…
Reference in New Issue