From d46c651d8098de0fb864ee3366b445b72521e83c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 26 May 2020 20:42:19 -0400 Subject: [PATCH] Only update colors on layer widget when closing preferences Fixes https://gitlab.com/kicad/code/kicad/-/issues/4545 --- .../dialogs/panel_pcbnew_color_settings.cpp | 4 +- pcbnew/pcb_layer_widget.cpp | 37 +++++++++++++++++++ pcbnew/pcb_layer_widget.h | 5 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index 1281d9029b..9208304053 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -101,8 +102,7 @@ bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow() PCBNEW_SETTINGS* app_settings = settingsMgr.GetAppSettings(); app_settings->m_ColorTheme = m_currentSettings->GetFilename(); - m_frame->ReFillLayerWidget(); - m_frame->SyncRenderStates(); + m_frame->GetLayerManager()->SyncLayerColors(); return true; } diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index fd0daef53f..727e020d05 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -443,6 +443,43 @@ void PCB_LAYER_WIDGET::SyncLayerAlphaIndicators() } +void PCB_LAYER_WIDGET::SyncLayerColors() +{ + COLOR_SETTINGS* cs = myframe->GetColorSettings(); + + COLOR4D bg = cs->GetColor( LAYER_PCB_BACKGROUND ); + + int count = GetLayerRowCount(); + int row; + int col = 1; // bitmap button is column 1 in layers tab + + for( row = 0; row < count; ++row ) + { + COLOR_SWATCH* swatch = dynamic_cast( getLayerComp( row, col ) ); + + if( swatch ) + { + swatch->SetSwatchBackground( bg ); + swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false ); + } + } + + count = GetRenderRowCount(); + col = 0; // bitmap button is column 0 in render tab + + for( row = 0; row < count; ++row ) + { + COLOR_SWATCH* swatch = dynamic_cast( getRenderComp( row, col ) ); + + if( swatch ) + { + swatch->SetSwatchBackground( bg ); + swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false ); + } + } +} + + void PCB_LAYER_WIDGET::ReFill() { BOARD* brd = myframe->GetBoard(); diff --git a/pcbnew/pcb_layer_widget.h b/pcbnew/pcb_layer_widget.h index 19f98ed09c..b9b111b1e1 100644 --- a/pcbnew/pcb_layer_widget.h +++ b/pcbnew/pcb_layer_widget.h @@ -76,6 +76,11 @@ public: */ void SyncLayerAlphaIndicators(); + /** + * Updates the color for each layer and item from the active color theme + */ + void SyncLayerColors(); + /** * Function SetLayersManagerTabsText * Update the layer manager tabs labels