diff --git a/common/properties/property_mgr.cpp b/common/properties/property_mgr.cpp index ea608fc1f3..3c0510de55 100644 --- a/common/properties/property_mgr.cpp +++ b/common/properties/property_mgr.cpp @@ -183,6 +183,16 @@ void PROPERTY_MANAGER::InheritsAfter( TYPE_ID aDerived, TYPE_ID aBase ) } +void PROPERTY_MANAGER::Mask( TYPE_ID aDerived, TYPE_ID aBase, const wxString& aName ) +{ + wxASSERT_MSG( aDerived != aBase, "Class cannot mask from itself" ); + + CLASS_DESC& derived = getClass( aDerived ); + derived.m_maskedBaseProperties.insert( std::make_pair( aBase, aName ) ); + m_dirty = true; +} + + bool PROPERTY_MANAGER::IsOfType( TYPE_ID aDerived, TYPE_ID aBase ) const { if( aDerived == aBase ) @@ -226,7 +236,7 @@ void PROPERTY_MANAGER::CLASS_DESC::rebuild() { PROPERTY_SET replaced( m_replaced ); m_allProperties.clear(); - collectPropsRecur( m_allProperties, replaced, m_displayOrder ); + collectPropsRecur( m_allProperties, replaced, m_displayOrder, m_maskedBaseProperties ); // We need to keep properties sorted to be able to use std::set_* functions sort( m_allProperties.begin(), m_allProperties.end() ); } @@ -234,7 +244,8 @@ void PROPERTY_MANAGER::CLASS_DESC::rebuild() void PROPERTY_MANAGER::CLASS_DESC::collectPropsRecur( PROPERTY_LIST& aResult, PROPERTY_SET& aReplaced, - PROPERTY_DISPLAY_ORDER& aDisplayOrder ) const + PROPERTY_DISPLAY_ORDER& aDisplayOrder, + const PROPERTY_SET& aMasked ) const { for( const std::pair& replacedEntry : m_replaced ) aReplaced.emplace( replacedEntry ); @@ -250,17 +261,22 @@ void PROPERTY_MANAGER::CLASS_DESC::collectPropsRecur( PROPERTY_LIST& aResult, for( const std::pair>& prop : m_ownProperties ) { PROPERTY_BASE* property = prop.second.get(); - + PROPERTY_SET::key_type propertyKey = std::make_pair( property->OwnerHash(), + property->Name() ); // Do not store replaced properties - if( aReplaced.count( std::make_pair( property->OwnerHash(), property->Name() ) ) == 0 ) - { - aDisplayOrder[property] = displayOrderStart + idx++; - aResult.push_back( property ); - } + if( aReplaced.count( propertyKey ) ) + continue; + + // Do not store masked properties + if( aMasked.count( propertyKey ) ) + continue; + + aDisplayOrder[property] = displayOrderStart + idx++; + aResult.push_back( property ); } for( const std::reference_wrapper& base : m_bases ) - base.get().collectPropsRecur( aResult, aReplaced, aDisplayOrder ); + base.get().collectPropsRecur( aResult, aReplaced, aDisplayOrder, aMasked ); } diff --git a/include/properties/property_mgr.h b/include/properties/property_mgr.h index b04f9c26c9..ac54719a1b 100644 --- a/include/properties/property_mgr.h +++ b/include/properties/property_mgr.h @@ -170,6 +170,15 @@ public: */ void InheritsAfter( TYPE_ID aDerived, TYPE_ID aBase ); + /** + * Sets a base class property as masked in a derived class. Masked properties are hidden from + * the list of editable properties for this class. + * @param aDerived is the type to apply the mask for. + * @param aBase is the type that aName belongs to. + * @param aName is the name of a property. + */ + void Mask( TYPE_ID aDerived, TYPE_ID aBase, const wxString& aName ); + /** * Return true if aDerived is inherited from aBase. */ @@ -237,6 +246,9 @@ private: ///< Type converters available for this type std::map> m_typeCasts; + ///< Properties from bases that should be masked (hidden) on this subclass + PROPERTY_SET m_maskedBaseProperties; + ///< All properties (both unique to the type and inherited) std::vector m_allProperties; @@ -255,7 +267,8 @@ private: ///< Traverses the class inheritance hierarchy bottom-to-top, gathering ///< all properties available to a type void collectPropsRecur( PROPERTY_LIST& aResult, PROPERTY_SET& aReplaced, - PROPERTY_DISPLAY_ORDER& aDisplayOrder ) const; + PROPERTY_DISPLAY_ORDER& aDisplayOrder, + const PROPERTY_SET& aMasked ) const; }; ///< Returns metadata for a specific type diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index f917dbc96c..45e2ab4260 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -35,6 +35,7 @@ #include #include #include +#include PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* parent ) : @@ -523,5 +524,12 @@ static struct PCB_TEXTBOX_DESC propMgr.AddTypeCast( new TYPE_CAST ); propMgr.InheritsAfter( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( PCB_SHAPE ) ); propMgr.InheritsAfter( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_TEXT ) ); + + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) ); + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) ); + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) ); + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) ); + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) ); + propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) ); } } _PCB_TEXTBOX_DESC;