Improve wxBitmapButton best size for small bitmaps in wxOSX
The correct condition for adding the extra border to the buttons that would be clipped without it due to the bezel style used for them is to check that their height is < 20, as SetBezelStyleFromBorderFlags(), which determines the bezel to use, does, and not if their width is 16, as this is not the same thing, especially for non-square buttons. Closes https://github.com/wxWidgets/wxWidgets/pull/1887
This commit is contained in:
committed by
Vadim Zeitlin
parent
d0ed90075c
commit
0941b25a97
@@ -58,11 +58,17 @@ wxSize wxBitmapButton::DoGetBestSize() const
|
||||
|
||||
if ( GetBitmapLabel().IsOk() )
|
||||
{
|
||||
// Hack to stop 16x16 bitmap being clipped
|
||||
if (GetBitmapLabel().GetScaledSize().x == 16)
|
||||
const wxSize bitmapSize = GetBitmapLabel().GetScaledSize();
|
||||
best += bitmapSize;
|
||||
|
||||
// The NSRoundedBezelStyle and NSTexturedRoundedBezelStyle used when
|
||||
// the image is less than 20px tall have a small horizontal border,
|
||||
// account for it here to prevent part of the image from being cut off.
|
||||
//
|
||||
// Note that the magic 20px comes from SetBezelStyleFromBorderFlags()
|
||||
// defined in src/osx/cocoa/button.mm.
|
||||
if ( bitmapSize.y < 20 )
|
||||
best += wxSize(4,0);
|
||||
|
||||
best += GetBitmapLabel().GetScaledSize();
|
||||
}
|
||||
|
||||
return best;
|
||||
|
Reference in New Issue
Block a user