Lazy rebuild of color themes dropdown.

This allows you to (for instance) create a new theme in PCBNew and
then select it in Footprint Editor.
This commit is contained in:
Jeff Young 2020-06-30 18:31:37 +01:00
parent 40a72d9530
commit 4694b52e1f
5 changed files with 14 additions and 0 deletions

View File

@ -79,6 +79,15 @@ void PANEL_COLOR_SETTINGS::OnBtnResetClicked( wxCommandEvent& event )
}
void PANEL_COLOR_SETTINGS::OnLeftDownTheme( wxMouseEvent& event )
{
// Lazy rebuild of theme menu to catch any colour theme changes made in other panels
wxString sel = m_cbTheme->GetStringSelection();
createThemeList( sel );
event.Skip();
}
void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
{
int idx = m_cbTheme->GetSelection();

View File

@ -48,6 +48,7 @@ protected:
void OnBtnResetClicked( wxCommandEvent& aEvent ) override;
void OnLeftDownTheme( wxMouseEvent& event ) override;
void OnThemeChanged( wxCommandEvent& aEvent ) override;
void ShowColorContextMenu( wxMouseEvent& aEvent, int aLayer );

View File

@ -90,6 +90,7 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
// Connect Events
this->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_cbTheme->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_COLOR_SETTINGS_BASE::OnLeftDownTheme ), NULL, this );
m_optOverrideColors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
m_btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
@ -100,6 +101,7 @@ PANEL_COLOR_SETTINGS_BASE::~PANEL_COLOR_SETTINGS_BASE()
// Disconnect Events
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_cbTheme->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_COLOR_SETTINGS_BASE::OnLeftDownTheme ), NULL, this );
m_optOverrideColors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
m_btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );

View File

@ -188,6 +188,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChoice">OnThemeChanged</event>
<event name="OnLeftDown">OnLeftDownTheme</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -50,6 +50,7 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
// Virtual event handlers, overide them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnLeftDownTheme( wxMouseEvent& event ) { event.Skip(); }
virtual void OnOverrideItemColorsClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnResetClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) { event.Skip(); }