Use board layer names for properties grid.
Fixes https://gitlab.com/kicad/code/kicad/issues/13553
This commit is contained in:
parent
0ff32d20cd
commit
729b2deb5c
|
@ -126,9 +126,9 @@ protected:
|
||||||
class PGPROPERTY_COLORENUM : public wxEnumProperty
|
class PGPROPERTY_COLORENUM : public wxEnumProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PGPROPERTY_COLORENUM( const wxString& aLabel, wxString& aName, const wxPGChoices& aChoices,
|
PGPROPERTY_COLORENUM( const wxString& aLabel, wxString& aName, wxPGChoices* aChoices,
|
||||||
int aValue = 0 ) :
|
int aValue = 0 ) :
|
||||||
wxEnumProperty( aLabel, aName, const_cast<wxPGChoices&>( aChoices ), aValue ),
|
wxEnumProperty( aLabel, aName, *aChoices, aValue ),
|
||||||
m_colorFunc( []( const wxString& aChoice ) { return wxNullColour; } )
|
m_colorFunc( []( const wxString& aChoice ) { return wxNullColour; } )
|
||||||
{
|
{
|
||||||
SetFlag( wxPG_PROP_CUSTOMIMAGE );
|
SetFlag( wxPG_PROP_CUSTOMIMAGE );
|
||||||
|
|
|
@ -116,15 +116,31 @@ wxPGProperty* PCB_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProp
|
||||||
{
|
{
|
||||||
wxASSERT( aProperty->HasChoices() );
|
wxASSERT( aProperty->HasChoices() );
|
||||||
|
|
||||||
|
const wxPGChoices& canonicalLayers = aProperty->Choices();
|
||||||
|
wxArrayString boardLayerNames;
|
||||||
|
wxArrayInt boardLayerIDs;
|
||||||
|
|
||||||
|
for( int ii = 0; ii < (int) aProperty->Choices().GetCount(); ++ii )
|
||||||
|
{
|
||||||
|
int layer = canonicalLayers.GetValue( ii );
|
||||||
|
|
||||||
|
boardLayerNames.push_back( m_frame->GetBoard()->GetLayerName( ToLAYER_ID( layer ) ) );
|
||||||
|
boardLayerIDs.push_back( canonicalLayers.GetValue( ii ) );
|
||||||
|
}
|
||||||
|
|
||||||
auto ret = new PGPROPERTY_COLORENUM( wxPG_LABEL, wxPG_LABEL,
|
auto ret = new PGPROPERTY_COLORENUM( wxPG_LABEL, wxPG_LABEL,
|
||||||
const_cast<wxPGChoices&>( aProperty->Choices() ) );
|
new wxPGChoices( boardLayerNames, boardLayerIDs ) );
|
||||||
|
|
||||||
ret->SetColorFunc(
|
ret->SetColorFunc(
|
||||||
[&]( const wxString& aChoice ) -> wxColour
|
[&]( const wxString& aChoice ) -> wxColour
|
||||||
{
|
{
|
||||||
PCB_LAYER_ID l = ENUM_MAP<PCB_LAYER_ID>::Instance().ToEnum( aChoice );
|
for( int layer = PCBNEW_LAYER_ID_START; layer < PCB_LAYER_ID_COUNT; ++layer )
|
||||||
wxASSERT( IsPcbLayer( l ) );
|
{
|
||||||
return m_frame->GetColorSettings()->GetColor( l ).ToColour();
|
if( m_frame->GetBoard()->GetLayerName( ToLAYER_ID( layer ) ) == aChoice )
|
||||||
|
return m_frame->GetColorSettings()->GetColor( layer ).ToColour();
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxNullColour;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
ret->SetLabel( wxGetTranslation( aProperty->Name() ) );
|
ret->SetLabel( wxGetTranslation( aProperty->Name() ) );
|
||||||
|
|
Loading…
Reference in New Issue