Properties: ignore shape props for textbox
This commit is contained in:
parent
e0ff8ba09c
commit
ef3f2a8f1e
|
@ -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<size_t, wxString>& replacedEntry : m_replaced )
|
||||
aReplaced.emplace( replacedEntry );
|
||||
|
@ -250,17 +261,22 @@ void PROPERTY_MANAGER::CLASS_DESC::collectPropsRecur( PROPERTY_LIST& aResult,
|
|||
for( const std::pair<const wxString, std::unique_ptr<PROPERTY_BASE>>& 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<CLASS_DESC>& base : m_bases )
|
||||
base.get().collectPropsRecur( aResult, aReplaced, aDisplayOrder );
|
||||
base.get().collectPropsRecur( aResult, aReplaced, aDisplayOrder, aMasked );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<TYPE_ID, std::unique_ptr<TYPE_CAST_BASE>> 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<PROPERTY_BASE*> 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
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <callback_gal.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <macros.h>
|
||||
#include <ignore.h>
|
||||
|
||||
|
||||
PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* parent ) :
|
||||
|
@ -523,5 +524,12 @@ static struct PCB_TEXTBOX_DESC
|
|||
propMgr.AddTypeCast( new TYPE_CAST<PCB_TEXTBOX, EDA_TEXT> );
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue