Properties: Stop sorting by name
It's more useful to have properties shown in add order, since we can group them
This commit is contained in:
parent
778d01c46b
commit
96fe93618e
|
@ -24,9 +24,15 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <wx/wx.h>
|
||||
|
||||
static wxString EMPTY_STRING( wxEmptyString );
|
||||
|
||||
const PROPERTY_MANAGER::PROPERTY_GROUP PROPERTY_MANAGER::DEFAULT_GROUP = {
|
||||
0,
|
||||
_( "Other Properties" )
|
||||
};
|
||||
|
||||
|
||||
void PROPERTY_MANAGER::RegisterType( TYPE_ID aType, const wxString& aName )
|
||||
{
|
||||
|
@ -99,12 +105,16 @@ const void* PROPERTY_MANAGER::TypeCast( const void* aSource, TYPE_ID aBase, TYPE
|
|||
}
|
||||
|
||||
|
||||
void PROPERTY_MANAGER::AddProperty( PROPERTY_BASE* aProperty )
|
||||
void PROPERTY_MANAGER::AddProperty( PROPERTY_BASE* aProperty, const PROPERTY_GROUP& aGroup )
|
||||
{
|
||||
const wxString& name = aProperty->Name();
|
||||
TYPE_ID hash = aProperty->OwnerHash();
|
||||
CLASS_DESC& classDesc = getClass( hash );
|
||||
classDesc.m_ownProperties.emplace( name, aProperty );
|
||||
|
||||
if( aGroup.id > DEFAULT_GROUP.id && aGroup.id < classDesc.m_groups.size() )
|
||||
aProperty->SetGroup( aGroup.id );
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
|
@ -118,6 +128,14 @@ void PROPERTY_MANAGER::ReplaceProperty( size_t aBase, const wxString& aName, PRO
|
|||
}
|
||||
|
||||
|
||||
const PROPERTY_MANAGER::PROPERTY_GROUP& PROPERTY_MANAGER::AddPropertyGroup( TYPE_ID aOwner,
|
||||
const wxString& aName )
|
||||
{
|
||||
CLASS_DESC& desc = getClass( aOwner );
|
||||
return desc.m_groups.emplace_back( PROPERTY_GROUP( { desc.m_groups.size(), aName } ) );
|
||||
}
|
||||
|
||||
|
||||
void PROPERTY_MANAGER::AddTypeCast( TYPE_CAST_BASE* aCast )
|
||||
{
|
||||
TYPE_ID derivedHash = aCast->DerivedHash();
|
||||
|
|
|
@ -54,7 +54,7 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
|
|||
mainSizer->Add( m_caption, 0, wxALL | wxEXPAND, 5 );
|
||||
|
||||
m_grid = new wxPropertyGrid( this, wxID_ANY, wxDefaultPosition, wxSize( 300, 400 ),
|
||||
wxPG_AUTO_SORT | wxPG_DEFAULT_STYLE );
|
||||
wxPG_DEFAULT_STYLE );
|
||||
m_grid->SetUnspecifiedValueAppearance( wxPGCell( wxT( "<...>" ) ) );
|
||||
m_grid->SetExtraStyle( wxPG_EX_HELP_AS_TOOLTIPS );
|
||||
mainSizer->Add( m_grid, 1, wxALL | wxEXPAND, 5 );
|
||||
|
@ -107,7 +107,7 @@ void PROPERTIES_PANEL::update( const SELECTION& aSelection )
|
|||
|
||||
if( aSelection.Size() > 1 )
|
||||
{
|
||||
m_caption->SetLabel( _( "Multiple objects selected" ) );
|
||||
m_caption->SetLabel( wxString::Format( _( "%d objects selected" ), aSelection.Size() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -184,6 +184,7 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
|
|||
m_display( aDisplay ),
|
||||
m_coordType( aCoordType ),
|
||||
m_isInternal( false ),
|
||||
m_groupId( -1 ),
|
||||
m_availFunc( [](INSPECTABLE*)->bool { return true; } )
|
||||
{
|
||||
}
|
||||
|
@ -267,6 +268,9 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
|
|||
void SetIsInternal( bool aIsInternal ) { m_isInternal = aIsInternal; }
|
||||
bool IsInternal() const { return m_isInternal; }
|
||||
|
||||
void SetGroup( int aGroup ) { m_groupId = aGroup; }
|
||||
int Group() const { return m_groupId; }
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
void set( void* aObject, T aValue )
|
||||
|
@ -298,6 +302,8 @@ private:
|
|||
/// Internal properties are hidden from the GUI
|
||||
bool m_isInternal;
|
||||
|
||||
int m_groupId;
|
||||
|
||||
std::function<bool(INSPECTABLE*)> m_availFunc; ///< Eval to determine if prop is available
|
||||
|
||||
friend class INSPECTABLE;
|
||||
|
|
|
@ -122,12 +122,24 @@ public:
|
|||
return const_cast<void*>( TypeCast( (const void*) aSource, aBase, aTarget ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a grouping of properties in the editor
|
||||
*/
|
||||
struct PROPERTY_GROUP
|
||||
{
|
||||
size_t id; ///< Controls the display order of the group (lowest first)
|
||||
wxString name; ///< Header to display in the properties manager
|
||||
};
|
||||
|
||||
static const PROPERTY_GROUP DEFAULT_GROUP;
|
||||
|
||||
/**
|
||||
* Register a property.
|
||||
*
|
||||
* @param aProperty is the property to register.
|
||||
* @param aGroup is the group to place the property in
|
||||
*/
|
||||
void AddProperty( PROPERTY_BASE* aProperty );
|
||||
void AddProperty( PROPERTY_BASE* aProperty, const PROPERTY_GROUP& aGroup = DEFAULT_GROUP );
|
||||
|
||||
/**
|
||||
* Replace an existing property for a specific type.
|
||||
|
@ -193,6 +205,13 @@ public:
|
|||
|
||||
std::vector<TYPE_ID> GetMatchingClasses( PROPERTY_BASE* aProperty );
|
||||
|
||||
/**
|
||||
* Defines a named group of properties belonging to a certain class
|
||||
* @param aOwner is the class type that delivers the properties in the group
|
||||
* @param aName will be shown as the group name in the properties manager
|
||||
*/
|
||||
const PROPERTY_GROUP& AddPropertyGroup( TYPE_ID aOwner, const wxString& aName );
|
||||
|
||||
private:
|
||||
PROPERTY_MANAGER() :
|
||||
m_dirty( false ),
|
||||
|
@ -207,6 +226,7 @@ private:
|
|||
CLASS_DESC( TYPE_ID aId )
|
||||
: m_id( aId )
|
||||
{
|
||||
m_groups.emplace_back( DEFAULT_GROUP );
|
||||
}
|
||||
|
||||
///< Unique type identifier (obtained using TYPE_HASH)
|
||||
|
@ -224,6 +244,8 @@ private:
|
|||
///< All properties (both unique to the type and inherited)
|
||||
std::vector<PROPERTY_BASE*> m_allProperties;
|
||||
|
||||
std::vector<PROPERTY_GROUP> m_groups;
|
||||
|
||||
///< Replaced properties (TYPE_ID / name)
|
||||
PROPERTY_SET m_replaced;
|
||||
|
||||
|
|
|
@ -279,10 +279,10 @@ static struct BOARD_ITEM_DESC
|
|||
|
||||
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, int>( _HKI( "Position X" ),
|
||||
&BOARD_ITEM::SetX, &BOARD_ITEM::GetX, PROPERTY_DISPLAY::PT_COORD,
|
||||
ORIGIN_TRANSFORMS::ABS_X_COORD) );
|
||||
ORIGIN_TRANSFORMS::ABS_X_COORD ) );
|
||||
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, int>( _HKI( "Position Y" ),
|
||||
&BOARD_ITEM::SetY, &BOARD_ITEM::GetY, PROPERTY_DISPLAY::PT_COORD,
|
||||
ORIGIN_TRANSFORMS::ABS_Y_COORD) );
|
||||
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
|
||||
propMgr.AddProperty( new PROPERTY_ENUM<BOARD_ITEM, PCB_LAYER_ID>( _HKI( "Layer" ),
|
||||
&BOARD_ITEM::SetLayer, &BOARD_ITEM::GetLayer ) );
|
||||
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, bool>( _HKI( "Locked" ),
|
||||
|
|
|
@ -103,7 +103,8 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
|
|||
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
||||
const SELECTION& selection = selectionTool->GetSelection();
|
||||
BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||
PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ), aEvent.GetPropertyName() );
|
||||
PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ),
|
||||
aEvent.GetPropertyName() );
|
||||
wxVariant newValue = aEvent.GetPropertyValue();
|
||||
BOARD_COMMIT changes( m_frame );
|
||||
|
||||
|
@ -134,7 +135,8 @@ void PCB_PROPERTIES_PANEL::updateLists( const BOARD* aBoard )
|
|||
m_propMgr.GetProperty( TYPE_HASH( PCB_SHAPE ), _HKI( "Layer" ) )->SetChoices( layersAll );
|
||||
|
||||
// Copper only properties
|
||||
m_propMgr.GetProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) )->SetChoices( layersCu );
|
||||
m_propMgr.GetProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ),
|
||||
_HKI( "Layer" ) )->SetChoices( layersCu );
|
||||
m_propMgr.GetProperty( TYPE_HASH( PCB_VIA ), _HKI( "Layer Top" ) )->SetChoices( layersCu );
|
||||
m_propMgr.GetProperty( TYPE_HASH( PCB_VIA ), _HKI( "Layer Bottom" ) )->SetChoices( layersCu );
|
||||
|
||||
|
|
|
@ -2852,16 +2852,7 @@ static struct FOOTPRINT_DESC
|
|||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Orientation" ),
|
||||
&FOOTPRINT::SetOrientationDegrees, &FOOTPRINT::GetOrientationDegrees,
|
||||
PROPERTY_DISPLAY::PT_DEGREE ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Clearance Override" ),
|
||||
&FOOTPRINT::SetLocalClearance, &FOOTPRINT::GetLocalClearance,
|
||||
PROPERTY_DISPLAY::PT_SIZE ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Solderpaste Margin Override" ),
|
||||
&FOOTPRINT::SetLocalSolderPasteMargin, &FOOTPRINT::GetLocalSolderPasteMargin,
|
||||
PROPERTY_DISPLAY::PT_SIZE ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>(
|
||||
_HKI( "Solderpaste Margin Ratio Override" ),
|
||||
&FOOTPRINT::SetLocalSolderPasteMarginRatio,
|
||||
&FOOTPRINT::GetLocalSolderPasteMarginRatio ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library link" ),
|
||||
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetFPIDAsString ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Description" ),
|
||||
|
@ -2878,6 +2869,17 @@ static struct FOOTPRINT_DESC
|
|||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>(
|
||||
_HKI( "Exempt from courtyard requirement" ),
|
||||
&FOOTPRINT::SetAllowMissingCourtyard, &FOOTPRINT::AllowMissingCourtyard ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Clearance Override" ),
|
||||
&FOOTPRINT::SetLocalClearance, &FOOTPRINT::GetLocalClearance,
|
||||
PROPERTY_DISPLAY::PT_SIZE ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Solderpaste Margin Override" ),
|
||||
&FOOTPRINT::SetLocalSolderPasteMargin, &FOOTPRINT::GetLocalSolderPasteMargin,
|
||||
PROPERTY_DISPLAY::PT_SIZE ) );
|
||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>(
|
||||
_HKI( "Solderpaste Margin Ratio Override" ),
|
||||
&FOOTPRINT::SetLocalSolderPasteMarginRatio,
|
||||
&FOOTPRINT::GetLocalSolderPasteMarginRatio ) );
|
||||
// TODO zone connection
|
||||
}
|
||||
} _FOOTPRINT_DESC;
|
||||
|
|
Loading…
Reference in New Issue