Don't allow color overrides for Default netclass
Fixes https://gitlab.com/kicad/code/kicad/-/issues/5330
This commit is contained in:
parent
41f53cc138
commit
342fae7768
|
@ -65,14 +65,14 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
||||||
{ "line_style", netclass->GetLineStyle() }
|
{ "line_style", netclass->GetLineStyle() }
|
||||||
};
|
};
|
||||||
|
|
||||||
if( netclass->GetPcbColor() != KIGFX::COLOR4D::UNSPECIFIED )
|
|
||||||
netclassJson["pcb_color"] = netclass->GetPcbColor();
|
|
||||||
|
|
||||||
if( netclass->GetSchematicColor() != KIGFX::COLOR4D::UNSPECIFIED )
|
if( netclass->GetSchematicColor() != KIGFX::COLOR4D::UNSPECIFIED )
|
||||||
netclassJson["schematic_color"] = netclass->GetSchematicColor();
|
netclassJson["schematic_color"] = netclass->GetSchematicColor();
|
||||||
|
|
||||||
if( idx > 0 )
|
if( idx > 0 )
|
||||||
{
|
{
|
||||||
|
if( netclass->GetPcbColor() != KIGFX::COLOR4D::UNSPECIFIED )
|
||||||
|
netclassJson["pcb_color"] = netclass->GetPcbColor();
|
||||||
|
|
||||||
nlohmann::json membersJson = nlohmann::json::array();
|
nlohmann::json membersJson = nlohmann::json::array();
|
||||||
|
|
||||||
for( const auto& ii : *netclass )
|
for( const auto& ii : *netclass )
|
||||||
|
|
|
@ -1346,7 +1346,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto appendNetclass =
|
auto appendNetclass =
|
||||||
[&]( int aId, const NETCLASSPTR& aClass )
|
[&]( int aId, const NETCLASSPTR& aClass, bool isDefaultClass = false )
|
||||||
{
|
{
|
||||||
wxString name = aClass->GetName();
|
wxString name = aClass->GetName();
|
||||||
|
|
||||||
|
@ -1368,6 +1368,10 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
||||||
&APPEARANCE_CONTROLS::onNetclassColorChanged, this );
|
&APPEARANCE_CONTROLS::onNetclassColorChanged, this );
|
||||||
|
|
||||||
|
// Default netclass can't have an override color
|
||||||
|
if( isDefaultClass )
|
||||||
|
setting->ctl_color->Hide();
|
||||||
|
|
||||||
setting->ctl_visibility =
|
setting->ctl_visibility =
|
||||||
new BITMAP_TOGGLE( setting->ctl_panel, aId, KiBitmap( visibility_xpm ),
|
new BITMAP_TOGGLE( setting->ctl_panel, aId, KiBitmap( visibility_xpm ),
|
||||||
KiBitmap( visibility_off_xpm ), true );
|
KiBitmap( visibility_off_xpm ), true );
|
||||||
|
@ -1379,11 +1383,13 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
|
setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
|
||||||
setting->ctl_text->Wrap( -1 );
|
setting->ctl_text->Wrap( -1 );
|
||||||
|
|
||||||
sizer->Add( setting->ctl_color, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
int flags = wxALIGN_CENTER_VERTICAL;
|
||||||
|
|
||||||
|
sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
|
||||||
sizer->AddSpacer( 7 );
|
sizer->AddSpacer( 7 );
|
||||||
sizer->Add( setting->ctl_visibility, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
sizer->Add( setting->ctl_visibility, 0, flags, 5 );
|
||||||
sizer->AddSpacer( 3 );
|
sizer->AddSpacer( 3 );
|
||||||
sizer->Add( setting->ctl_text, 1, wxALIGN_CENTER_VERTICAL, 5 );
|
sizer->Add( setting->ctl_text, 1, flags, 5 );
|
||||||
|
|
||||||
m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
|
m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
|
||||||
m_netclassOuterSizer->AddSpacer( 1 );
|
m_netclassOuterSizer->AddSpacer( 1 );
|
||||||
|
@ -1393,15 +1399,18 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
this );
|
this );
|
||||||
|
|
||||||
auto menuHandler =
|
auto menuHandler =
|
||||||
[&, name]( wxMouseEvent& aEvent )
|
[&, name, isDefaultClass]( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
m_contextMenuNetclass = name;
|
m_contextMenuNetclass = name;
|
||||||
|
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
|
||||||
|
if( !isDefaultClass)
|
||||||
|
{
|
||||||
menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
|
menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
|
||||||
_( "Set netclass color" ), wxEmptyString,
|
_( "Set netclass color" ), wxEmptyString,
|
||||||
wxITEM_NORMAL ) );
|
wxITEM_NORMAL ) );
|
||||||
|
}
|
||||||
|
|
||||||
menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
|
menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
|
||||||
wxString::Format( _( "Highlight nets in %s" ), name ),
|
wxString::Format( _( "Highlight nets in %s" ), name ),
|
||||||
|
@ -1414,7 +1423,8 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
|
|
||||||
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
|
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
|
||||||
_( "Show all netclasses" ), wxEmptyString, wxITEM_NORMAL ) );
|
_( "Show all netclasses" ), wxEmptyString,
|
||||||
|
wxITEM_NORMAL ) );
|
||||||
menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
|
menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
|
||||||
_( "Hide all other netclasses" ), wxEmptyString,
|
_( "Hide all other netclasses" ), wxEmptyString,
|
||||||
wxITEM_NORMAL ) );
|
wxITEM_NORMAL ) );
|
||||||
|
@ -1462,7 +1472,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
|
NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
|
||||||
|
|
||||||
m_netclassIdMap[idx] = defaultClass->GetName();
|
m_netclassIdMap[idx] = defaultClass->GetName();
|
||||||
appendNetclass( idx++, defaultClass );
|
appendNetclass( idx++, defaultClass, true );
|
||||||
|
|
||||||
for( const wxString& name : names )
|
for( const wxString& name : names )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue