From 69db66e1eabdbf1921cf1385e5d3a7452534896f Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 23 Apr 2020 22:33:02 -0400 Subject: [PATCH] Fix saving of pcbnew colors when edited from layers widget --- common/dialogs/panel_color_settings.cpp | 4 ++-- common/dialogs/panel_color_settings.h | 2 +- common/dialogs/panel_color_settings_base.cpp | 2 +- common/dialogs/panel_color_settings_base.fbp | 2 +- .../dialogs/panel_eeschema_color_settings.cpp | 2 +- .../dialogs/panel_pcbnew_color_settings.cpp | 24 ++++++++++++++----- pcbnew/pcb_edit_frame.cpp | 1 - pcbnew/pcb_layer_widget.cpp | 7 +++--- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index 476fdc8f88..3e27ed329a 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -158,7 +158,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) } -void PANEL_COLOR_SETTINGS::createThemeList( const COLOR_SETTINGS* aCurrent ) +void PANEL_COLOR_SETTINGS::createThemeList( const wxString& aCurrent ) { m_cbTheme->Clear(); @@ -166,7 +166,7 @@ void PANEL_COLOR_SETTINGS::createThemeList( const COLOR_SETTINGS* aCurrent ) { int pos = m_cbTheme->Append( settings->GetName(), static_cast( settings ) ); - if( settings == aCurrent ) + if( settings->GetFilename() == aCurrent ) m_cbTheme->SetSelection( pos ); } diff --git a/common/dialogs/panel_color_settings.h b/common/dialogs/panel_color_settings.h index ab0e433fb3..aede3532f6 100644 --- a/common/dialogs/panel_color_settings.h +++ b/common/dialogs/panel_color_settings.h @@ -53,7 +53,7 @@ protected: void SetColor( wxCommandEvent& aEvent ); - void createThemeList( const COLOR_SETTINGS* aCurrent ); + void createThemeList( const wxString& aCurrent ); void createButton( int aLayer, const KIGFX::COLOR4D& aColor, const wxString& aName ); diff --git a/common/dialogs/panel_color_settings_base.cpp b/common/dialogs/panel_color_settings_base.cpp index ca50edfcc5..91f10d11b3 100644 --- a/common/dialogs/panel_color_settings_base.cpp +++ b/common/dialogs/panel_color_settings_base.cpp @@ -50,7 +50,7 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow bControlSizer->Add( m_btnOpenFolder, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_mainSizer->Add( bControlSizer, 0, wxEXPAND|wxRIGHT, 10 ); + m_mainSizer->Add( bControlSizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_mainSizer->Add( m_staticline1, 0, wxEXPAND|wxALL, 5 ); diff --git a/common/dialogs/panel_color_settings_base.fbp b/common/dialogs/panel_color_settings_base.fbp index aa823d21d3..6060055a42 100644 --- a/common/dialogs/panel_color_settings_base.fbp +++ b/common/dialogs/panel_color_settings_base.fbp @@ -57,7 +57,7 @@ protected 10 - wxEXPAND|wxRIGHT + wxEXPAND|wxLEFT|wxRIGHT 0 diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index b9179480bf..fa38f1a20c 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -75,7 +75,7 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF EESCHEMA_SETTINGS* app_settings = mgr.GetAppSettings(); COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); - createThemeList( current ); + createThemeList( app_settings->m_ColorTheme ); m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() ); diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index b0371c138d..ce8f92a9fa 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -45,23 +45,35 @@ PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - mgr.ReloadColorSettings(); - PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings(); COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); + // Store the current settings before reloading below + current->SetColorContext( COLOR_CONTEXT::PCB ); + current->Store(); + mgr.SaveColorSettings( current, "board" ); + m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() ); m_currentSettings = new COLOR_SETTINGS( *current ); - createThemeList( current ); - - for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ ) - m_validLayers.push_back( id ); + mgr.ReloadColorSettings(); + createThemeList( app_settings->m_ColorTheme ); for( int id = F_Cu; id < PCB_LAYER_ID_COUNT; id++ ) m_validLayers.push_back( id ); + for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ ) + { + if( id == LAYER_VIAS || id == LAYER_GRID_AXES || id == LAYER_PADS_PLATEDHOLES + || id == LAYER_VIAS_HOLES ) + { + continue; + } + + m_validLayers.push_back( id ); + } + m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 ); createButtons(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index a2dada3e82..6ddb63850d 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -664,7 +664,6 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { PCB_BASE_FRAME::SaveSettings( aCfg ); - // TODO(JE) remove once color themes exist COLOR_SETTINGS* cs = ColorSettings(); cs->SetColorContext( COLOR_CONTEXT::PCB ); cs->Store(); diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index b2f809e9df..db638fb899 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -521,9 +521,10 @@ void PCB_LAYER_WIDGET::ReFill() void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) { - myframe->ColorSettings()->SetColorContext( m_fp_editor_mode ? - COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB ); - myframe->ColorSettings()->SetColor( aLayer, aColor ); + COLOR_SETTINGS* cs = myframe->ColorSettings(); + cs->SetColorContext( m_fp_editor_mode ? COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB ); + cs->SetColor( aLayer, aColor ); + myframe->GetCanvas()->UpdateColors(); KIGFX::VIEW* view = myframe->GetCanvas()->GetView();