Only update colors on layer widget when closing preferences

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4545
This commit is contained in:
Jon Evans 2020-05-26 20:42:19 -04:00
parent e61185775f
commit d46c651d80
3 changed files with 44 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include <panel_pcbnew_color_settings.h>
#include <pcbnew_settings.h>
#include <pcb_edit_frame.h>
#include <pcb_layer_widget.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
@ -101,8 +102,7 @@ bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow()
PCBNEW_SETTINGS* app_settings = settingsMgr.GetAppSettings<PCBNEW_SETTINGS>();
app_settings->m_ColorTheme = m_currentSettings->GetFilename();
m_frame->ReFillLayerWidget();
m_frame->SyncRenderStates();
m_frame->GetLayerManager()->SyncLayerColors();
return true;
}

View File

@ -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<COLOR_SWATCH*>( 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<COLOR_SWATCH*>( 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();

View File

@ -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