Add "Hide Tree" context menu options when tree has no selection.

Also cleans up some other code to be more consistent between symbol
editor and footprint editor.

Fixes https://gitlab.com/kicad/code/kicad/issues/8052
This commit is contained in:
Jeff Young 2021-03-29 12:01:03 +01:00
parent 14e73d24dc
commit f2e68e68d0
10 changed files with 30 additions and 10 deletions

View File

@ -188,6 +188,11 @@ TOOL_ACTION EE_ACTIONS::showSymbolTree( "eeschema.SymbolLibraryControl.showSymbo
_( "Show Symbol Tree" ), "",
BITMAPS::search_tree );
TOOL_ACTION EE_ACTIONS::hideSymbolTree( "eeschema.SymbolLibraryControl.hideSymbolTree",
AS_GLOBAL, 0, "",
_( "Hide Symbol Tree" ), "",
BITMAPS::search_tree );
TOOL_ACTION EE_ACTIONS::exportSymbolView( "eeschema.SymbolLibraryControl.exportSymbolView",
AS_GLOBAL, 0, "",
_( "Export View as PNG..." ), _( "Create PNG file from the current view" ),

View File

@ -199,6 +199,7 @@ public:
static TOOL_ACTION pushPinNumSize;
static TOOL_ACTION showElectricalTypes;
static TOOL_ACTION showSymbolTree;
static TOOL_ACTION hideSymbolTree;
static TOOL_ACTION toggleForceHV;
static TOOL_ACTION drawSheetOnClipboard;
static TOOL_ACTION exportSymbolView;

View File

@ -112,6 +112,9 @@ bool SYMBOL_EDITOR_CONTROL::Init()
ctxMenu.AddSeparator();
ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition );
ctxMenu.AddItem( EE_ACTIONS::exportSymbol, symbolSelectedCondition );
// If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddItem( EE_ACTIONS::hideSymbolTree, !libInferredCondition );
}
return true;
@ -332,7 +335,7 @@ int SYMBOL_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::ShowSymbolTree( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ToggleSymbolTree( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
@ -551,6 +554,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ShowSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() );
}

View File

@ -65,7 +65,7 @@ public:
int ShowElectricalTypes( const TOOL_EVENT& aEvent );
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ShowSymbolTree( const TOOL_EVENT& aEvent );
int ToggleSymbolTree( const TOOL_EVENT& aEvent );
int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent );
private:

View File

@ -1046,7 +1046,7 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree, CHECK( footprintTreeCond ) );
mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );

View File

@ -171,7 +171,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
viewMenu->AppendSeparator();
viewMenu->Add( PCB_ACTIONS::toggleFootprintTree, ACTION_MENU::CHECK );
viewMenu->Add( PCB_ACTIONS::showFootprintTree, ACTION_MENU::CHECK );
//-- Place menu -------------------------------------------------------

View File

@ -207,7 +207,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( PCB_ACTIONS::toggleFootprintTree, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::showFootprintTree, ACTION_TOOLBAR::TOGGLE );
PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );

View File

@ -129,6 +129,9 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition );
// If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
return true;
}
@ -524,7 +527,8 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
Go( &FOOTPRINT_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::toggleFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::showFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::hideFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );
}

View File

@ -335,9 +335,14 @@ TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
// FOOTPRINT_EDITOR_CONTROL
//
TOOL_ACTION PCB_ACTIONS::toggleFootprintTree( "pcbnew.ModuleEditor.toggleFootprintTree",
TOOL_ACTION PCB_ACTIONS::showFootprintTree( "pcbnew.ModuleEditor.showFootprintTree",
AS_GLOBAL, 0, "",
_( "Show Footprint Tree" ), _( "Toggles the footprint tree visibility" ),
_( "Show Footprint Tree" ), "",
BITMAPS::search_tree );
TOOL_ACTION PCB_ACTIONS::hideFootprintTree( "pcbnew.ModuleEditor.hideFootprintTree",
AS_GLOBAL, 0, "",
_( "Hide Footprint Tree" ), "",
BITMAPS::search_tree );
TOOL_ACTION PCB_ACTIONS::newFootprint( "pcbnew.ModuleEditor.newFootprint",

View File

@ -350,7 +350,8 @@ public:
// Module editor tools
static TOOL_ACTION toggleFootprintTree;
static TOOL_ACTION showFootprintTree;
static TOOL_ACTION hideFootprintTree;
// We don't use ACTION::new here because we need to distinguish between New Library
// and New Footprint.