Bring panel_pcbnew_color_settings in line with eeschema equivalent.

Also fixes a bug where color changes weren't getting saved because
the set of valid layers didn't include the copper layers.
This commit is contained in:
Jeff Young 2020-08-04 14:56:33 +01:00
parent 6075112ea0
commit aa8fb38445
1 changed files with 8 additions and 17 deletions

View File

@ -38,27 +38,22 @@ PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame
m_page( nullptr ),
m_titleBlock( nullptr )
{
// Currently this only applies to eeschema
m_optOverrideColors->Hide();
m_colorNamespace = "board";
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
mgr.ReloadColorSettings();
PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings<PCBNEW_SETTINGS>();
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
// Store the current settings before reloading below
current->Store();
mgr.SaveColorSettings( current, "board" );
createThemeList( app_settings->m_ColorTheme );
m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
// Currently this only applies to eeschema
m_optOverrideColors->Hide();
m_currentSettings = new COLOR_SETTINGS( *current );
mgr.ReloadColorSettings();
createThemeList( app_settings->m_ColorTheme );
for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_BITMASK_END; id++ )
{
if( id == LAYER_VIAS || id == LAYER_GRID_AXES || id == LAYER_PADS_PLATEDHOLES
@ -91,8 +86,6 @@ PANEL_PCBNEW_COLOR_SETTINGS::~PANEL_PCBNEW_COLOR_SETTINGS()
bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow()
{
m_currentSettings->SetOverrideSchItemColors( m_optOverrideColors->GetValue() );
if( !saveCurrentTheme( true ) )
return false;
@ -116,9 +109,7 @@ bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataToWindow()
void PANEL_PCBNEW_COLOR_SETTINGS::createSwatches()
{
std::vector<int> layers( m_validLayers );
std::sort( layers.begin(), layers.end(),
std::sort( m_validLayers.begin(), m_validLayers.end(),
[]( int a, int b )
{
return LayerName( a ) < LayerName( b );
@ -126,11 +117,11 @@ void PANEL_PCBNEW_COLOR_SETTINGS::createSwatches()
// Don't sort board layers by name
for( int i = PCBNEW_LAYER_ID_START; i < PCB_LAYER_ID_COUNT; ++i )
layers.insert( layers.begin() + i, i );
m_validLayers.insert( m_validLayers.begin() + i, i );
BOARD* board = m_frame->GetBoard();
for( int layer : layers )
for( int layer : m_validLayers )
{
wxString name = LayerName( layer );