eeschema: Add select all to schematic and library editor
Fixes https://gitlab.com/kicad/code/kicad/issues/2497
This commit is contained in:
parent
1e315bc3fe
commit
7565a08396
|
@ -167,8 +167,7 @@ TOOL_ACTION ACTIONS::paste( "common.Interactive.paste",
|
|||
TOOL_ACTION ACTIONS::selectAll( "common.Interactive.selectAll",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'A', "",
|
||||
_( "Select All" ), _( "Paste clipboard into schematic" ),
|
||||
paste_xpm );
|
||||
_( "Select All" ), _( "Paste clipboard into schematic" ) );
|
||||
|
||||
TOOL_ACTION ACTIONS::pasteSpecial( "common.Interactive.pasteSpecial",
|
||||
AS_GLOBAL, 0, "",
|
||||
|
|
|
@ -335,6 +335,7 @@ void LIB_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::paste, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::Idle ) );
|
||||
mgr->SetConditions( ACTIONS::doDelete, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::duplicate, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
||||
|
|
|
@ -87,6 +87,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
editMenu->Add( ACTIONS::doDelete );
|
||||
editMenu->Add( ACTIONS::duplicate );
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
editMenu->Add( ACTIONS::selectAll );
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
editMenu->Add( EE_ACTIONS::symbolProperties );
|
||||
editMenu->Add( EE_ACTIONS::pinTable );
|
||||
|
|
|
@ -142,6 +142,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
editMenu->Add( ACTIONS::doDelete );
|
||||
editMenu->Add( ACTIONS::duplicate );
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
editMenu->Add( ACTIONS::selectAll );
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
editMenu->Add( ACTIONS::find );
|
||||
editMenu->Add( ACTIONS::findAndReplace );
|
||||
|
|
|
@ -361,6 +361,12 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
|
||||
wxASSERT( mgr );
|
||||
|
||||
auto hasElements =
|
||||
[ this ] ( const SELECTION& aSel )
|
||||
{
|
||||
return !GetScreen()->Items().empty();
|
||||
};
|
||||
|
||||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
||||
|
||||
|
@ -381,6 +387,7 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
||||
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::duplicate, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
||||
|
|
|
@ -110,6 +110,7 @@ EE_SELECTION_TOOL::EE_SELECTION_TOOL() :
|
|||
m_unit( 0 ),
|
||||
m_convert( 0 )
|
||||
{
|
||||
m_selection.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -562,6 +563,52 @@ bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFil
|
|||
}
|
||||
|
||||
|
||||
int EE_SELECTION_TOOL::SelectAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_multiple = true; // Multiple selection mode is active
|
||||
KIGFX::VIEW* view = getView();
|
||||
|
||||
// hold all visible items
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> sheetPins;
|
||||
|
||||
// Filter the view items based on the selection box
|
||||
BOX2I selectionBox;
|
||||
|
||||
selectionBox.SetMaximum();
|
||||
view->Query( selectionBox, selectedItems ); // Get the list of selected items
|
||||
|
||||
// Sheet pins aren't in the view; add them by hand
|
||||
for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
|
||||
{
|
||||
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
|
||||
|
||||
if( sheet )
|
||||
{
|
||||
int layer = pair.second;
|
||||
|
||||
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
|
||||
sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
|
||||
}
|
||||
}
|
||||
|
||||
selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() );
|
||||
|
||||
for( auto& item_pair : selectedItems )
|
||||
{
|
||||
if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( item_pair.first ) )
|
||||
{
|
||||
if( Selectable( item ) )
|
||||
select( item );
|
||||
}
|
||||
}
|
||||
|
||||
m_multiple = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aPos )
|
||||
{
|
||||
// There are certain parent/child and enclosure combinations that can be handled
|
||||
|
@ -1466,6 +1513,8 @@ void EE_SELECTION_TOOL::setTransitions()
|
|||
Go( &EE_SELECTION_TOOL::RemoveItemFromSel, EE_ACTIONS::removeItemFromSel.MakeEvent() );
|
||||
Go( &EE_SELECTION_TOOL::RemoveItemsFromSel, EE_ACTIONS::removeItemsFromSel.MakeEvent() );
|
||||
Go( &EE_SELECTION_TOOL::SelectionMenu, EE_ACTIONS::selectionMenu.MakeEvent() );
|
||||
|
||||
Go( &EE_SELECTION_TOOL::SelectAll, EE_ACTIONS::selectAll.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -130,6 +130,9 @@ public:
|
|||
///> Clear current selection event handler.
|
||||
int ClearSelection( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Select all visible items in sheet
|
||||
int SelectAll( const TOOL_EVENT& aEvent );
|
||||
|
||||
void ClearSelection();
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,6 +60,12 @@ bool LIB_EDIT_TOOL::Init()
|
|||
|
||||
wxASSERT_MSG( drawingTools, "eeschema.SymbolDrawing tool is not available" );
|
||||
|
||||
auto havePartCondition =
|
||||
[&]( const SELECTION& sel )
|
||||
{
|
||||
return m_isLibEdit && static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
|
||||
};
|
||||
|
||||
// Add edit actions to the move tool menu
|
||||
//
|
||||
if( moveTool )
|
||||
|
@ -79,6 +85,9 @@ bool LIB_EDIT_TOOL::Init()
|
|||
moveMenu.AddItem( ACTIONS::cut, EE_CONDITIONS::IdleSelection, 300 );
|
||||
moveMenu.AddItem( ACTIONS::copy, EE_CONDITIONS::IdleSelection, 300 );
|
||||
moveMenu.AddItem( ACTIONS::duplicate, EE_CONDITIONS::NotEmpty, 300 );
|
||||
|
||||
moveMenu.AddSeparator( 400 );
|
||||
moveMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
|
||||
}
|
||||
|
||||
// Add editing actions to the drawing tool menu
|
||||
|
@ -111,6 +120,9 @@ bool LIB_EDIT_TOOL::Init()
|
|||
selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 300 );
|
||||
selToolMenu.AddItem( ACTIONS::duplicate, EE_CONDITIONS::NotEmpty, 300 );
|
||||
|
||||
selToolMenu.AddSeparator( 400 );
|
||||
selToolMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,12 @@ bool SCH_EDIT_TOOL::Init()
|
|||
|
||||
wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
|
||||
|
||||
auto hasElements =
|
||||
[ this ] ( const SELECTION& aSel )
|
||||
{
|
||||
return !m_frame->GetScreen()->Items().empty();
|
||||
};
|
||||
|
||||
auto sheetTool =
|
||||
[ this ] ( const SELECTION& aSel )
|
||||
{
|
||||
|
@ -301,6 +307,9 @@ bool SCH_EDIT_TOOL::Init()
|
|||
moveMenu.AddItem( ACTIONS::cut, E_C::IdleSelection );
|
||||
moveMenu.AddItem( ACTIONS::copy, E_C::IdleSelection );
|
||||
moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
|
||||
|
||||
moveMenu.AddSeparator();
|
||||
moveMenu.AddItem( ACTIONS::selectAll, hasElements );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -374,6 +383,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
|
||||
selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
|
||||
|
||||
selToolMenu.AddSeparator( 400 );
|
||||
selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue