Center bitmaps in bitmap buttons by default.

This commit is contained in:
Alex Shvartzkop 2024-05-26 23:34:21 +03:00
parent 2a5903cd9b
commit 5e64bd6256
1 changed files with 4 additions and 6 deletions

View File

@ -45,7 +45,7 @@ BITMAP_BUTTON::BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint&
m_padding( 0 ),
m_isToolbarButton( false ),
m_acceptDraggedInClicks( false ),
m_centerBitmap( false )
m_centerBitmap( true )
{
m_badgeFont = GetFont().Smaller().MakeBold();
@ -64,7 +64,7 @@ BITMAP_BUTTON::BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxBitmap&
m_padding( 5 ),
m_isToolbarButton( false ),
m_acceptDraggedInClicks( false ),
m_centerBitmap( false )
m_centerBitmap( true )
{
m_badgeFont = GetFont().Smaller().MakeBold();
@ -351,10 +351,8 @@ void BITMAP_BUTTON::OnPaint( wxPaintEvent& aEvent )
if( m_centerBitmap )
{
// dont let it go negative if bmp is larger than the button
int x = std::max( ( rect.width - bmSize.x ) / 2, 0 );
int y = std::max( ( rect.height - bmSize.y ) / 2, 0 );
drawBmpPos = wxPoint( x, y );
drawBmpPos.x = ( rect.width - bmSize.x ) / 2;
drawBmpPos.y = ( rect.height - bmSize.y ) / 2;
}
// Draw the bitmap with the upper-left corner offset by the padding