Whittle down library tree context menus to be more contextual.
(From discussion on Zulip.)
This commit is contained in:
parent
48853d0c88
commit
c2f68ca4da
|
@ -98,21 +98,14 @@ bool SYMBOL_EDITOR_CONTROL::Init()
|
||||||
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
|
||||||
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
|
||||||
ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
ctxMenu.AddItem( ACTIONS::save, libSelectedCondition );
|
|
||||||
ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition );
|
|
||||||
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition );
|
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition && canEditLibrary );
|
ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition && canEditLibrary );
|
||||||
ctxMenu.AddItem( EE_ACTIONS::editSymbol, symbolSelectedCondition && canEditLibrary );
|
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition );
|
||||||
|
ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition );
|
||||||
ctxMenu.AddItem( EE_ACTIONS::saveSymbolAs, saveSymbolAsCondition );
|
ctxMenu.AddItem( EE_ACTIONS::saveSymbolAs, saveSymbolAsCondition );
|
||||||
ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition );
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition && canEditLibrary );
|
ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition && canEditLibrary );
|
||||||
|
|
|
@ -76,6 +76,15 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
|
||||||
LIB_ID sel = m_frame->GetTreeFPID();
|
LIB_ID sel = m_frame->GetTreeFPID();
|
||||||
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
|
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
|
||||||
};
|
};
|
||||||
|
// The libInferredCondition allows you to do things like New Symbol and Paste with a
|
||||||
|
// symbol selected (in other words, when we know the library context even if the library
|
||||||
|
// itself isn't selected.
|
||||||
|
auto libInferredCondition =
|
||||||
|
[ this ]( const SELECTION& aSel )
|
||||||
|
{
|
||||||
|
LIB_ID sel = m_frame->GetTreeFPID();
|
||||||
|
return !sel.GetLibNickname().empty();
|
||||||
|
};
|
||||||
auto pinnedLibSelectedCondition =
|
auto pinnedLibSelectedCondition =
|
||||||
[ this ]( const SELECTION& aSel )
|
[ this ]( const SELECTION& aSel )
|
||||||
{
|
{
|
||||||
|
@ -98,33 +107,26 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
|
||||||
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
|
||||||
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
|
||||||
ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
ctxMenu.AddItem( ACTIONS::save, libSelectedCondition );
|
|
||||||
ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition );
|
|
||||||
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition );
|
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition );
|
||||||
#ifdef KICAD_SCRIPTING
|
#ifdef KICAD_SCRIPTING
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition );
|
||||||
#endif
|
#endif
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::editFootprint, fpSelectedCondition );
|
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( ACTIONS::save, fpSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::save, libSelectedCondition || libInferredCondition );
|
||||||
|
ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition );
|
||||||
ctxMenu.AddItem( ACTIONS::saveCopyAs, fpSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::saveCopyAs, fpSelectedCondition );
|
||||||
ctxMenu.AddItem( ACTIONS::revert, fpSelectedCondition );
|
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition );
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, SELECTION_CONDITIONS::ShowAlways );
|
ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition );
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
|
||||||
|
|
||||||
ctxMenu.AddSeparator();
|
ctxMenu.AddSeparator();
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
|
||||||
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition );
|
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue