Better handling of excluded layers for Color Preferences.

Fixes https://gitlab.com/kicad/code/kicad/issues/5184
This commit is contained in:
Jeff Young 2020-08-17 20:27:03 +01:00
parent 8234e70e77
commit 01eb8ad032
3 changed files with 23 additions and 21 deletions

View File

@ -209,6 +209,9 @@ wxString LayerName( int aLayer )
case LAYER_GRID: case LAYER_GRID:
return _( "Grid" ); return _( "Grid" );
case LAYER_GRID_AXES:
return _( "Grid Axes" );
case LAYER_PCB_BACKGROUND: case LAYER_PCB_BACKGROUND:
return _( "Background" ); return _( "Background" );

View File

@ -58,13 +58,16 @@ PANEL_MODEDIT_COLOR_SETTINGS::PANEL_MODEDIT_COLOR_SETTINGS( FOOTPRINT_EDIT_FRAME
mgr.ReloadColorSettings(); mgr.ReloadColorSettings();
createThemeList( settings->m_ColorTheme ); createThemeList( settings->m_ColorTheme );
for( int id = F_Cu; id < PCB_LAYER_ID_COUNT; id++ ) m_validLayers.push_back( F_Cu );
m_validLayers.push_back( id ); m_validLayers.push_back( In1_Cu ); // "Internal Layers"
m_validLayers.push_back( B_Cu );
for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; 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 if( id == LAYER_VIAS
|| id == LAYER_VIAS_HOLES ) || id == LAYER_GRID_AXES
|| id == LAYER_PADS_PLATEDHOLES
|| id == LAYER_VIAS_HOLES )
{ {
continue; continue;
} }
@ -115,33 +118,27 @@ bool PANEL_MODEDIT_COLOR_SETTINGS::TransferDataToWindow()
void PANEL_MODEDIT_COLOR_SETTINGS::createSwatches() void PANEL_MODEDIT_COLOR_SETTINGS::createSwatches()
{ {
std::vector<int> layers; std::vector<GAL_LAYER_ID> galLayers;
for( GAL_LAYER_ID i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; ++i ) // Sort the gal layers by name
for( int i : m_validLayers )
{ {
if( m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED ) if( i >= GAL_LAYER_ID_START && m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED )
layers.push_back( i ); galLayers.push_back( (GAL_LAYER_ID) i );
} }
std::sort( layers.begin(), layers.end(), std::sort( galLayers.begin(), galLayers.end(),
[]( int a, int b ) []( int a, int b )
{ {
return LayerName( a ) < LayerName( b ); return LayerName( a ) < LayerName( b );
} ); } );
// 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 );
BOARD* board = m_frame->GetBoard(); BOARD* board = m_frame->GetBoard();
for( int layer : layers ) createSwatch( F_Cu, board ? board->GetLayerName( F_Cu ) : LayerName( F_Cu ) );
{ createSwatch( In1_Cu, _( "Internal Layers" ) );
wxString name = LayerName( layer ); createSwatch( B_Cu, board ? board->GetLayerName( B_Cu ) : LayerName( B_Cu ) );
if( board && layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT ) for( GAL_LAYER_ID layer : galLayers )
name = board->GetLayerName( static_cast<PCB_LAYER_ID>( layer ) ); createSwatch( layer, LayerName( layer ) );
createSwatch( layer, name );
}
} }

View File

@ -360,6 +360,8 @@ std::set<int> g_excludedLayers =
LAYER_MOD_VALUES, LAYER_MOD_VALUES,
LAYER_MOD_REFERENCES, LAYER_MOD_REFERENCES,
LAYER_TRACKS, LAYER_TRACKS,
LAYER_MOD_TEXT_FR,
LAYER_MOD_TEXT_BK,
LAYER_PADS_PLATEDHOLES, LAYER_PADS_PLATEDHOLES,
LAYER_VIAS_HOLES, LAYER_VIAS_HOLES,
LAYER_GP_OVERLAY, LAYER_GP_OVERLAY,