7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 00:21:36 +00:00

Infobar close buttons also need to react to theme changes

This commit is contained in:
Jon Evans 2025-01-11 18:53:58 -05:00
parent 1bce0b733e
commit 37a3c6f8cf
2 changed files with 21 additions and 3 deletions
common/widgets
include/widgets

View File

@ -216,6 +216,13 @@ void WX_INFOBAR::onThemeChange( wxSysColourChangedEvent& aEvent )
KIPLATFORM::UI::GetInfoBarColours( fg, bg );
SetBackgroundColour( bg );
SetForegroundColour( fg );
if( wxBitmapButton* btn = GetCloseButton() )
{
wxString tooltip = btn->GetToolTipText();
RemoveAllButtons();
AddCloseButton( tooltip );
}
}
@ -335,18 +342,27 @@ void WX_INFOBAR::RemoveAllButtons()
bool WX_INFOBAR::HasCloseButton() const
{
return GetCloseButton();
}
wxBitmapButton* WX_INFOBAR::GetCloseButton() const
{
wxSizer* sizer = GetSizer();
if( sizer->GetItemCount() == 0 )
return false;
return nullptr;
if( sizer->GetItem( sizer->GetItemCount() - 1 )->IsSpacer() )
return false;
return nullptr;
wxSizerItem* item = sizer->GetItem( sizer->GetItemCount() - 1 );
return ( item->GetWindow()->GetId() == ID_CLOSE_INFOBAR );
if( item->GetWindow()->GetId() == ID_CLOSE_INFOBAR )
return static_cast<wxBitmapButton*>( item->GetWindow() );
return nullptr;
}

View File

@ -150,6 +150,8 @@ public:
bool HasCloseButton() const;
wxBitmapButton* GetCloseButton() const;
/**
* Provide a callback to be called when the infobar is dismissed (either by user action
* or timer).