From 65193487a6f7a8e76077878e9b04a73317c608a3 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 26 Mar 2023 19:43:16 -0400 Subject: [PATCH] Properties: Rename methods to better reflect their purposes --- common/eda_item.cpp | 2 +- common/widgets/properties_panel.cpp | 2 +- include/properties/property.h | 24 ++++++++++++------------ pcbnew/board_connected_item.cpp | 13 ++++++++----- pcbnew/dialogs/panel_setup_rules.cpp | 4 ++-- pcbnew/zone.cpp | 8 ++++---- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/common/eda_item.cpp b/common/eda_item.cpp index b4b9aa9203..272e33fdc9 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -394,7 +394,7 @@ static struct EDA_ITEM_DESC propMgr.AddProperty( new PROPERTY_ENUM( wxS( "Type" ), NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ) ) - .SetIsInternal(); + .SetIsHiddenFromPropertiesManager(); } } _EDA_ITEM_DESC; diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index 32b10f08c3..87fce6ab61 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -209,7 +209,7 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection ) // Find a set of properties that is common to all selected items for( PROPERTY_BASE* property : commonProps ) { - if( property->IsInternal() ) + if( property->IsHiddenFromPropertiesManager() ) continue; if( isFootprintEditor && property->IsHiddenFromLibraryEditors() ) diff --git a/include/properties/property.h b/include/properties/property.h index a6129271b4..671ad665de 100644 --- a/include/properties/property.h +++ b/include/properties/property.h @@ -185,8 +185,8 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT, m_name( aName ), m_display( aDisplay ), m_coordType( aCoordType ), - m_isInternal( false ), - m_isDeprecated( false ), + m_hideFromPropertiesManager( false ), + m_hideFromRulesEditor( false ), m_hideFromLibraryEditors( false ), m_availFunc( [](INSPECTABLE*)->bool { return true; } ), m_writeableFunc( [](INSPECTABLE*)->bool { return true; } ), @@ -280,17 +280,17 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT, return *this; } - bool IsInternal() const { return m_isInternal; } - PROPERTY_BASE& SetIsInternal( bool aIsInternal = true ) + bool IsHiddenFromPropertiesManager() const { return m_hideFromPropertiesManager; } + PROPERTY_BASE& SetIsHiddenFromPropertiesManager( bool aHide = true ) { - m_isInternal = aIsInternal; + m_hideFromPropertiesManager = aHide; return *this; } - bool IsDeprecated() const { return m_isDeprecated; } - PROPERTY_BASE& SetIsDeprecated( bool aIsDeprecated = true ) + bool IsHiddenFromRulesEditor() const { return m_hideFromRulesEditor; } + PROPERTY_BASE& SetIsHiddenFromRulesEditor( bool aHide = true ) { - m_isDeprecated = aIsDeprecated; + m_hideFromRulesEditor = aHide; return *this; } @@ -377,11 +377,11 @@ private: /// The coordinate type controls how distances are mapped to the user coordinate system ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType; - /// Internal properties are hidden from the GUI but not from the rules editor autocomplete - bool m_isInternal; + /// Some properties should not be shown in the Properties Manager GUI + bool m_hideFromPropertiesManager; - /// Deprecated properties are hidden from the GUI and rules editor autocomplete - bool m_isDeprecated; + /// Some properties should not be shown in the Custom Rules editor autocomplete + bool m_hideFromRulesEditor; /// This property should only be shown in the design editor, not the library editor bool m_hideFromLibraryEditors; diff --git a/pcbnew/board_connected_item.cpp b/pcbnew/board_connected_item.cpp index 062c7f2852..f3bd9cd437 100644 --- a/pcbnew/board_connected_item.cpp +++ b/pcbnew/board_connected_item.cpp @@ -173,28 +173,31 @@ static struct BOARD_CONNECTED_ITEM_DESC propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Net" ), &BOARD_CONNECTED_ITEM::SetNetCode, &BOARD_CONNECTED_ITEM::GetNetCode ) ) - .SetIsDeprecated() + .SetIsHiddenFromRulesEditor() .SetIsHiddenFromLibraryEditors(); - // Not really deprecated, but hidden from rule editor suggestions + /** + * This property should just be an alias for the one below, it only exists so that we + * maintain compatibility with both `NetClass` and `Net_Class` in custom rules. + */ propMgr.AddProperty( new PROPERTY( _HKI( "Net Class" ), NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetClassName ) ) - .SetIsDeprecated() + .SetIsHiddenFromRulesEditor() .SetIsHiddenFromLibraryEditors(); // Compatibility alias for DRC engine propMgr.AddProperty( new PROPERTY( _HKI( "NetClass" ), NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetClassName ) ) - .SetIsInternal() + .SetIsHiddenFromPropertiesManager() .SetIsHiddenFromLibraryEditors(); // Used only in DRC engine propMgr.AddProperty( new PROPERTY( _HKI( "NetName" ), NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetname ) ) - .SetIsInternal() + .SetIsHiddenFromPropertiesManager() .SetIsHiddenFromLibraryEditors(); } } _BOARD_CONNECTED_ITEM_DESC; diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 17a5efa1a1..4096b6f05a 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -442,10 +442,10 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent ) for( PROPERTY_BASE* prop : props ) { - // TODO: It would be nice to replace IsDeprecated with a property nickname + // TODO: It would be nice to replace IsHiddenFromRulesEditor with a nickname // system, so that two different properies don't need to be created. This is // a bigger change than I want to make right now, though. - if( prop->IsDeprecated() ) + if( prop->IsHiddenFromRulesEditor() ) continue; wxString ref( prop->Name() ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 92e55b90f9..e49a8e3cf3 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -1414,13 +1414,13 @@ static struct ZONE_DESC reinterpret_cast( &ZONE::GetX ), PROPERTY_DISPLAY::PT_COORD, ORIGIN_TRANSFORMS::ABS_X_COORD ); - posX->SetIsInternal( true ); + posX->SetIsHiddenFromPropertiesManager(); auto posY = new PROPERTY( _HKI( "Position Y" ), NO_SETTER( ZONE, int ), reinterpret_cast( &ZONE::GetY ), PROPERTY_DISPLAY::PT_COORD, ORIGIN_TRANSFORMS::ABS_Y_COORD ); - posY->SetIsInternal( true ); + posY->SetIsHiddenFromPropertiesManager(); propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ), posX ); propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ), posY ); @@ -1443,13 +1443,13 @@ static struct ZONE_DESC return false; }; - // Layer property is internal because it only holds a single layer and zones actually use + // Layer property is hidden because it only holds a single layer and zones actually use // a layer set propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ), new PROPERTY_ENUM( _HKI( "Layer" ), &ZONE::SetLayer, &ZONE::GetLayer ) ) - .SetIsInternal(); + .SetIsHiddenFromPropertiesManager(); propMgr.OverrideAvailability( TYPE_HASH( ZONE ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Net" ), isCopperZone );