Share more library tree code.

This commit is contained in:
Jeff Young 2024-06-08 14:00:18 +01:00
parent 832393b07c
commit ed0869aa0c
25 changed files with 614 additions and 713 deletions

View File

@ -582,6 +582,7 @@ set( COMMON_SRCS
tool/action_toolbar.cpp tool/action_toolbar.cpp
tool/actions.cpp tool/actions.cpp
tool/common_control.cpp tool/common_control.cpp
tool/library_editor_control.cpp
tool/common_tools.cpp tool/common_tools.cpp
tool/conditional_menu.cpp tool/conditional_menu.cpp
tool/edit_constraints.cpp tool/edit_constraints.cpp

View File

@ -69,6 +69,13 @@ TOOL_ACTION ACTIONS::open( TOOL_ACTION_ARGS()
.Tooltip( _( "Open existing document" ) ) .Tooltip( _( "Open existing document" ) )
.Icon( BITMAPS::directory_open ) ); .Icon( BITMAPS::directory_open ) );
TOOL_ACTION ACTIONS::openWithTextEditor( TOOL_ACTION_ARGS()
.Name( "common.Control.openWithTextEditor" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Edit in a Text Editor..." ) )
.Tooltip( _( "Open a library file with a text editor" ) )
.Icon( BITMAPS::editor ) );
TOOL_ACTION ACTIONS::save( TOOL_ACTION_ARGS() TOOL_ACTION ACTIONS::save( TOOL_ACTION_ARGS()
.Name( "common.Control.save" ) .Name( "common.Control.save" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )
@ -738,6 +745,24 @@ TOOL_ACTION ACTIONS::unpinLibrary( TOOL_ACTION_ARGS()
.FriendlyName( _( "Unpin Library" ) ) .FriendlyName( _( "Unpin Library" ) )
.Tooltip( _( "No longer keep the library at the top of the list" ) ) ); .Tooltip( _( "No longer keep the library at the top of the list" ) ) );
TOOL_ACTION ACTIONS::showLibraryTree( TOOL_ACTION_ARGS()
.Name( "common.Control.showLibraryTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Show Library Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION ACTIONS::hideLibraryTree( TOOL_ACTION_ARGS()
.Name( "common.Control.hideLibraryTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Hide Library Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION ACTIONS::libraryTreeSearch( TOOL_ACTION_ARGS()
.Name( "common.Control.libraryTreeSearch" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Focus Library Tree Search Field" ) )
.DefaultHotkey( MD_CTRL + 'L' ) );
TOOL_ACTION ACTIONS::panUp( TOOL_ACTION_ARGS() TOOL_ACTION ACTIONS::panUp( TOOL_ACTION_ARGS()
.Name( "common.Control.panUp" ) .Name( "common.Control.panUp" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )

View File

@ -0,0 +1,163 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.TXT for contributors.
*
* This program is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, you may find one at http://www.gnu.org/licenses/
*/
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <eda_draw_frame.h>
#include <widgets/lib_tree.h>
#include <project.h>
#include "wx/generic/textdlgg.h"
#include "library_editor_control.h"
LIBRARY_EDITOR_CONTROL::LIBRARY_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "common.LibraryEditorControl" ),
m_frame( nullptr )
{
}
void LIBRARY_EDITOR_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
}
void LIBRARY_EDITOR_CONTROL::AddContextMenuItems( CONDITIONAL_MENU* aMenu )
{
auto pinnedLibSelectedCondition =
[this]( const SELECTION& aSel )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::LIBRARY && current->m_Pinned;
};
auto unpinnedLibSelectedCondition =
[this](const SELECTION& aSel )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::LIBRARY && !current->m_Pinned;
};
aMenu->AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition, 1 );
aMenu->AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition, 1 );
aMenu->AddSeparator( 1 );
aMenu->AddSeparator( 400 );
aMenu->AddItem( ACTIONS::hideLibraryTree, SELECTION_CONDITIONS::ShowAlways, 400 );
}
void LIBRARY_EDITOR_CONTROL::regenerateLibraryTree()
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_ID target = m_frame->GetTargetLibId();
libTree->Regenerate( true );
if( target.IsValid() )
libTree->CenterLibId( target );
}
int LIBRARY_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
if( current && !current->m_Pinned )
{
m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(), false );
current->m_Pinned = true;
regenerateLibraryTree();
}
return 0;
}
int LIBRARY_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
if( current && current->m_Pinned )
{
m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(), false );
current->m_Pinned = false;
regenerateLibraryTree();
}
return 0;
}
int LIBRARY_EDITOR_CONTROL::ToggleLibraryTree( const TOOL_EVENT& aEvent )
{
m_frame->ToggleLibraryTree();
return 0;
}
int LIBRARY_EDITOR_CONTROL::LibraryTreeSearch( const TOOL_EVENT& aEvent )
{
if (!m_frame->IsLibraryTreeShown() )
m_frame->ToggleLibraryTree();
m_frame->FocusLibraryTreeInput();
return 0;
}
class RENAME_DIALOG : public wxTextEntryDialog
{
public:
RENAME_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxString& aName,
std::function<bool( const wxString& newName )> aValidator ) :
wxTextEntryDialog( aParent, _( "New name:" ), aTitle, aName ),
m_validator( std::move( aValidator ) )
{ }
protected:
bool TransferDataFromWindow() override
{
return m_validator( m_textctrl->GetValue().Trim( true ).Trim( false ) );
}
private:
std::function<bool( const wxString& aNewName )> m_validator;
};
bool LIBRARY_EDITOR_CONTROL::RenameLibrary( const wxString& aTitle, const wxString& aName,
std::function<bool( const wxString& aNewName )> aValidator )
{
RENAME_DIALOG dlg( m_frame, aTitle, aName, std::move( aValidator ) );
return dlg.ShowModal() == wxID_OK;
}
void LIBRARY_EDITOR_CONTROL::setTransitions()
{
Go( &LIBRARY_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &LIBRARY_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &LIBRARY_EDITOR_CONTROL::ToggleLibraryTree, ACTIONS::showLibraryTree.MakeEvent() );
Go( &LIBRARY_EDITOR_CONTROL::ToggleLibraryTree, ACTIONS::hideLibraryTree.MakeEvent() );
Go( &LIBRARY_EDITOR_CONTROL::LibraryTreeSearch, ACTIONS::libraryTreeSearch.MakeEvent() );
}

View File

@ -0,0 +1,57 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.TXT for contributors.
*
* This program is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, you may find one at http://www.gnu.org/licenses/
*/
#ifndef LIBRARY_EDITOR_CONTROL_H
#define LIBRARY_EDITOR_CONTROL_H
#include <tool/tool_interactive.h>
class EDA_DRAW_FRAME;
/**
* Module editor specific tools.
*/
class LIBRARY_EDITOR_CONTROL : public TOOL_INTERACTIVE
{
public:
LIBRARY_EDITOR_CONTROL();
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
void AddContextMenuItems( CONDITIONAL_MENU* aMenu );
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleLibraryTree( const TOOL_EVENT& aEvent );
int LibraryTreeSearch( const TOOL_EVENT& aEvent );
bool RenameLibrary( const wxString& aTitle, const wxString& aName,
std::function<bool( const wxString& aNewName )> aValidator );
private:
///< Set up handlers for various events.
void setTransitions() override;
void regenerateLibraryTree();
private:
EDA_DRAW_FRAME* m_frame;
};
#endif // LIBRARY_EDITOR_CONTROL_H

View File

@ -124,7 +124,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
viewMenu->Add( ACTIONS::zoomRedraw ); viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
viewMenu->Add( EE_ACTIONS::showSymbolTree, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::showLibraryTree, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenPins, ACTION_MENU::CHECK ); viewMenu->Add( EE_ACTIONS::showHiddenPins, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenFields, ACTION_MENU::CHECK ); viewMenu->Add( EE_ACTIONS::showHiddenFields, ACTION_MENU::CHECK );

View File

@ -51,6 +51,7 @@
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/editor_conditions.h> #include <tool/editor_conditions.h>
#include <tool/library_editor_control.h>
#include <tool/picker_tool.h> #include <tool/picker_tool.h>
#include <tool/properties_tool.h> #include <tool/properties_tool.h>
#include <tool/selection.h> #include <tool/selection.h>
@ -69,7 +70,6 @@
#include <view/view_controls.h> #include <view/view_controls.h>
#include <widgets/app_progress_dialog.h> #include <widgets/app_progress_dialog.h>
#include <widgets/wx_infobar.h> #include <widgets/wx_infobar.h>
#include <widgets/lib_tree.h>
#include <widgets/wx_progress_reporters.h> #include <widgets/wx_progress_reporters.h>
#include <widgets/panel_sch_selection_filter.h> #include <widgets/panel_sch_selection_filter.h>
#include <widgets/sch_properties_panel.h> #include <widgets/sch_properties_panel.h>
@ -201,7 +201,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
.Bottom().Layer( 6 ) ); .Bottom().Layer( 6 ) );
// Columns; layers 1 - 3 // Columns; layers 1 - 3
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "SymbolTree" ) m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "LibraryTree" )
.Left().Layer( 3 ) .Left().Layer( 3 )
.TopDockable( false ).BottomDockable( false ) .TopDockable( false ).BottomDockable( false )
.Caption( _( "Libraries" ) ) .Caption( _( "Libraries" ) )
@ -237,7 +237,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
selTool->GetFilter() = GetSettings()->m_SelectionFilter; selTool->GetFilter() = GetSettings()->m_SelectionFilter;
if( m_settings->m_LibWidth > 0 ) if( m_settings->m_LibWidth > 0 )
SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "SymbolTree" ), m_settings->m_LibWidth, -1 ); SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "LibraryTree" ), m_settings->m_LibWidth, -1 );
Raise(); Raise();
Show( true ); Show( true );
@ -310,9 +310,7 @@ SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME()
} }
if( cfg ) if( cfg )
{
Pgm().GetSettingsManager().Save( cfg ); Pgm().GetSettingsManager().Save( cfg );
}
delete m_libMgr; delete m_libMgr;
} }
@ -345,7 +343,7 @@ void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
m_settings->m_LibWidth = m_treePane->GetSize().x; m_settings->m_LibWidth = m_treePane->GetSize().x;
m_settings->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode(); m_settings->m_LibrarySortMode = GetLibTree()->GetSortMode();
m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion(); m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown(); bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
@ -394,6 +392,7 @@ void SYMBOL_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new EE_POINT_EDITOR ); m_toolManager->RegisterTool( new EE_POINT_EDITOR );
m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL ); m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL );
m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL ); m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL );
m_toolManager->RegisterTool( new LIBRARY_EDITOR_CONTROL );
m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL );
m_toolManager->RegisterTool( new PROPERTIES_TOOL ); m_toolManager->RegisterTool( new PROPERTIES_TOOL );
m_toolManager->InitTools(); m_toolManager->InitTools();
@ -519,10 +518,10 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenFields; return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenFields;
}; };
auto showCompTreeCond = auto showLibraryTreeCond =
[this]( const SELECTION& ) [this]( const SELECTION& )
{ {
return IsSymbolTreeShown(); return IsLibraryTreeShown();
}; };
auto propertiesCond = auto propertiesCond =
@ -533,7 +532,7 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) ); mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) );
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) ); mgr->SetConditions( ACTIONS::showLibraryTree, CHECK( showLibraryTreeCond ) );
mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) ); mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) ); mgr->SetConditions( EE_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) ); mgr->SetConditions( EE_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) );
@ -708,24 +707,24 @@ void SYMBOL_EDIT_FRAME::RebuildSymbolUnitsList()
} }
void SYMBOL_EDIT_FRAME::OnToggleSymbolTree( wxCommandEvent& event ) void SYMBOL_EDIT_FRAME::ToggleLibraryTree()
{ {
wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane ); wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
treePane.Show( !IsSymbolTreeShown() ); treePane.Show( !IsLibraryTreeShown() );
updateSelectionFilterVisbility(); updateSelectionFilterVisbility();
m_auimgr.Update(); m_auimgr.Update();
} }
bool SYMBOL_EDIT_FRAME::IsSymbolTreeShown() const bool SYMBOL_EDIT_FRAME::IsLibraryTreeShown() const
{ {
return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown(); return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
} }
void SYMBOL_EDIT_FRAME::FocusSearchTreeInput() void SYMBOL_EDIT_FRAME::FocusLibraryTreeInput()
{ {
m_treePane->GetLibTree()->FocusSearchFieldIfExists(); GetLibTree()->FocusSearchFieldIfExists();
} }
@ -829,9 +828,9 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
// select the current symbol in the tree widget // select the current symbol in the tree widget
if( !IsSymbolFromSchematic() && m_symbol ) if( !IsSymbolFromSchematic() && m_symbol )
m_treePane->GetLibTree()->SelectLibId( m_symbol->GetLibId() ); GetLibTree()->SelectLibId( m_symbol->GetLibId() );
else else
m_treePane->GetLibTree()->Unselect(); GetLibTree()->Unselect();
wxString symbolName = m_symbol ? m_symbol->GetName() : wxString(); wxString symbolName = m_symbol ? m_symbol->GetName() : wxString();
@ -942,7 +941,7 @@ void SYMBOL_EDIT_FRAME::OnModify()
if( !IsSymbolFromSchematic() ) if( !IsSymbolFromSchematic() )
storeCurrentSymbol(); storeCurrentSymbol();
m_treePane->GetLibTree()->RefreshLibTree(); GetLibTree()->RefreshLibTree();
if( !GetTitle().StartsWith( "*" ) ) if( !GetTitle().StartsWith( "*" ) )
UpdateTitle(); UpdateTitle();
@ -1051,24 +1050,24 @@ void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile )
LIB_ID SYMBOL_EDIT_FRAME::GetTreeLIBID( int* aUnit ) const LIB_ID SYMBOL_EDIT_FRAME::GetTreeLIBID( int* aUnit ) const
{ {
return m_treePane->GetLibTree()->GetSelectedLibId( aUnit ); return GetLibTree()->GetSelectedLibId( aUnit );
} }
int SYMBOL_EDIT_FRAME::GetTreeSelectionCount() const int SYMBOL_EDIT_FRAME::GetTreeSelectionCount() const
{ {
return m_treePane->GetLibTree()->GetSelectionCount(); return GetLibTree()->GetSelectionCount();
} }
int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const
{ {
return m_treePane->GetLibTree()->GetSelectedLibIds( aSelection ); return GetLibTree()->GetSelectedLibIds( aSelection );
} }
LIB_SYMBOL* SYMBOL_EDIT_FRAME::getTargetSymbol() const LIB_SYMBOL* SYMBOL_EDIT_FRAME::getTargetSymbol() const
{ {
if( IsSymbolTreeShown() ) if( IsLibraryTreeShown() )
{ {
LIB_ID libId = GetTreeLIBID(); LIB_ID libId = GetTreeLIBID();
@ -1084,7 +1083,7 @@ LIB_ID SYMBOL_EDIT_FRAME::GetTargetLibId() const
{ {
LIB_ID id; LIB_ID id;
if( IsSymbolTreeShown() ) if( IsLibraryTreeShown() )
id = GetTreeLIBID(); id = GetTreeLIBID();
if( id.GetLibNickname().empty() && m_symbol ) if( id.GetLibNickname().empty() && m_symbol )
@ -1102,12 +1101,6 @@ std::vector<LIB_ID> SYMBOL_EDIT_FRAME::GetSelectedLibIds() const
} }
LIB_TREE_NODE* SYMBOL_EDIT_FRAME::GetCurrentTreeNode() const
{
return m_treePane->GetLibTree()->GetCurrentTreeNode();
}
wxString SYMBOL_EDIT_FRAME::getTargetLib() const wxString SYMBOL_EDIT_FRAME::getTargetLib() const
{ {
return GetTargetLibId().GetLibNickname(); return GetTargetLibId().GetLibNickname();
@ -1120,7 +1113,7 @@ void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelle
LIB_ID selected; LIB_ID selected;
if( m_treePane ) if( m_treePane )
selected = m_treePane->GetLibTree()->GetSelectedLibId(); selected = GetLibTree()->GetSelectedLibId();
if( aShowProgress ) if( aShowProgress )
{ {
@ -1153,10 +1146,10 @@ void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelle
found = m_libMgr->GetAdapter()->FindItem( selected ); found = m_libMgr->GetAdapter()->FindItem( selected );
if( !found ) if( !found )
m_treePane->GetLibTree()->Unselect(); GetLibTree()->Unselect();
} }
m_treePane->GetLibTree()->Regenerate( true ); GetLibTree()->Regenerate( true );
// Try to select the parent library, in case the symbol is not found // Try to select the parent library, in case the symbol is not found
if( !found && selected.IsValid() ) if( !found && selected.IsValid() )
@ -1165,39 +1158,28 @@ void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelle
found = m_libMgr->GetAdapter()->FindItem( selected ); found = m_libMgr->GetAdapter()->FindItem( selected );
if( found ) if( found )
m_treePane->GetLibTree()->SelectLibId( selected ); GetLibTree()->SelectLibId( selected );
} }
// If no selection, see if there's a current symbol to centre // If no selection, see if there's a current symbol to centre
if( !selected.IsValid() && m_symbol ) if( !selected.IsValid() && m_symbol )
{ {
LIB_ID current( GetCurLib(), m_symbol->GetName() ); LIB_ID current( GetCurLib(), m_symbol->GetName() );
m_treePane->GetLibTree()->CenterLibId( current ); GetLibTree()->CenterLibId( current );
} }
} }
} }
void SYMBOL_EDIT_FRAME::RegenerateLibraryTree()
{
LIB_ID target = GetTargetLibId();
m_treePane->GetLibTree()->Regenerate( true );
if( target.IsValid() )
m_treePane->GetLibTree()->CenterLibId( target );
}
void SYMBOL_EDIT_FRAME::RefreshLibraryTree() void SYMBOL_EDIT_FRAME::RefreshLibraryTree()
{ {
m_treePane->GetLibTree()->RefreshLibTree(); GetLibTree()->RefreshLibTree();
} }
void SYMBOL_EDIT_FRAME::FocusOnLibId( const LIB_ID& aLibID ) void SYMBOL_EDIT_FRAME::FocusOnLibId( const LIB_ID& aLibID )
{ {
m_treePane->GetLibTree()->SelectLibId( aLibID ); GetLibTree()->SelectLibId( aLibID );
} }
@ -1207,7 +1189,7 @@ void SYMBOL_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, LIB_
// from file therefore not yet in tree. // from file therefore not yet in tree.
{ {
static_cast<LIB_TREE_NODE_ITEM*>( aTreeItem.GetID() )->Update( aSymbol ); static_cast<LIB_TREE_NODE_ITEM*>( aTreeItem.GetID() )->Update( aSymbol );
m_treePane->GetLibTree()->RefreshLibTree(); GetLibTree()->RefreshLibTree();
} }
} }
@ -1254,7 +1236,7 @@ bool SYMBOL_EDIT_FRAME::IsCurrentSymbol( const LIB_ID& aLibId ) const
void SYMBOL_EDIT_FRAME::emptyScreen() void SYMBOL_EDIT_FRAME::emptyScreen()
{ {
m_treePane->GetLibTree()->Unselect(); GetLibTree()->Unselect();
SetCurLib( wxEmptyString ); SetCurLib( wxEmptyString );
SetCurSymbol( nullptr, false ); SetCurSymbol( nullptr, false );
SetScreen( m_dummyScreen ); SetScreen( m_dummyScreen );
@ -1311,7 +1293,7 @@ void SYMBOL_EDIT_FRAME::ShowChangedLanguage()
tree_pane_info.Show( tree_shown ); tree_pane_info.Show( tree_shown );
m_auimgr.Update(); m_auimgr.Update();
m_treePane->GetLibTree()->ShowChangedLanguage(); GetLibTree()->ShowChangedLanguage();
// status bar // status bar
UpdateMsgPanel(); UpdateMsgPanel();
@ -1387,8 +1369,7 @@ const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) con
int width = schIUScale.mmToIU( 50 ); int width = schIUScale.mmToIU( 50 );
int height = schIUScale.mmToIU( 30 ); int height = schIUScale.mmToIU( 30 );
return BOX2I( VECTOR2I( -width/2, -height/2 ), return BOX2I( VECTOR2I( -width/2, -height/2 ), VECTOR2I( width, height ) );
VECTOR2I( width, height ) );
} }
else else
{ {
@ -1485,9 +1466,9 @@ void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( m_treePane ) if( m_treePane )
{ {
LIB_ID id( libNickname, wxEmptyString ); LIB_ID id( libNickname, wxEmptyString );
m_treePane->GetLibTree()->SelectLibId( id ); GetLibTree()->SelectLibId( id );
m_treePane->GetLibTree()->ExpandLibId( id ); GetLibTree()->ExpandLibId( id );
m_treePane->GetLibTree()->CenterLibId( id ); GetLibTree()->CenterLibId( id );
} }
} }
@ -1727,11 +1708,8 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
if( IsSymbolTreeShown() ) if( IsLibraryTreeShown() )
{ ToggleLibraryTree();
wxCommandEvent evt;
OnToggleSymbolTree( evt );
}
UpdateTitle(); UpdateTitle();
RebuildSymbolUnitsList(); RebuildSymbolUnitsList();

View File

@ -31,12 +31,12 @@
#include <sch_base_frame.h> #include <sch_base_frame.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <ee_collectors.h> #include <ee_collectors.h>
#include <symbol_tree_pane.h>
#include <optional> #include <optional>
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
class SYMBOL_LIB_TABLE; class SYMBOL_LIB_TABLE;
class LIB_SYMBOL; class LIB_SYMBOL;
class SYMBOL_TREE_PANE;
class LIB_TREE_NODE; class LIB_TREE_NODE;
class LIB_ID; class LIB_ID;
class LIB_SYMBOL_LIBRARY_MANAGER; class LIB_SYMBOL_LIBRARY_MANAGER;
@ -88,7 +88,7 @@ public:
*/ */
wxString SetCurLib( const wxString& aLibNickname ); wxString SetCurLib( const wxString& aLibNickname );
LIB_TREE_NODE* GetCurrentTreeNode() const; LIB_TREE* GetLibTree() const override { return m_treePane->GetLibTree(); }
/** /**
* Return the LIB_ID of the library or symbol selected in the symbol tree. * Return the LIB_ID of the library or symbol selected in the symbol tree.
@ -180,12 +180,11 @@ public:
void OnSelectUnit( wxCommandEvent& event ); void OnSelectUnit( wxCommandEvent& event );
void OnToggleSymbolTree( wxCommandEvent& event );
void ToggleProperties() override; void ToggleProperties() override;
bool IsSymbolTreeShown() const; void ToggleLibraryTree() override;
void FocusSearchTreeInput(); bool IsLibraryTreeShown() const override;
void FocusLibraryTreeInput() override;
void FreezeLibraryTree(); void FreezeLibraryTree();
void ThawLibraryTree(); void ThawLibraryTree();
@ -334,13 +333,6 @@ public:
void SyncLibraries( bool aShowProgress, bool aPreloadCancelled = false, void SyncLibraries( bool aShowProgress, bool aPreloadCancelled = false,
const wxString& aForceRefresh = wxEmptyString ); const wxString& aForceRefresh = wxEmptyString );
/**
* Filter, sort, and redisplay the library tree.
*
* Does NOT synchronize it with libraries in disk.
*/
void RegenerateLibraryTree();
/** /**
* Redisplay the library tree. Used after changing modified states, descriptions, etc. * Redisplay the library tree. Used after changing modified states, descriptions, etc.
*/ */
@ -355,7 +347,7 @@ public:
* Return either the symbol selected in the symbol tree (if context menu is active) or the * Return either the symbol selected in the symbol tree (if context menu is active) or the
* symbol on the editor canvas. * symbol on the editor canvas.
*/ */
LIB_ID GetTargetLibId() const; LIB_ID GetTargetLibId() const override;
/** /**
* @return a list of selected items in the symbol tree * @return a list of selected items in the symbol tree

View File

@ -510,7 +510,7 @@ void SYMBOL_EDIT_FRAME::Save()
{ {
wxString libName; wxString libName;
if( IsSymbolTreeShown() ) if( IsLibraryTreeShown() )
libName = GetTreeLIBID().GetUniStringLibNickname(); libName = GetTreeLIBID().GetUniStringLibNickname();
if( libName.empty() ) if( libName.empty() )
@ -531,7 +531,7 @@ void SYMBOL_EDIT_FRAME::Save()
saveLibrary( libName, false ); saveLibrary( libName, false );
} }
if( IsSymbolTreeShown() ) if( IsLibraryTreeShown() )
m_treePane->GetLibTree()->RefreshLibTree(); m_treePane->GetLibTree()->RefreshLibTree();
UpdateTitle(); UpdateTitle();

View File

@ -175,7 +175,7 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( EE_ACTIONS::showSymbolTree, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::showLibraryTree, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::showProperties, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::showProperties, ACTION_TOOLBAR::TOGGLE );
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();

View File

@ -236,13 +236,6 @@ TOOL_ACTION EE_ACTIONS::importSymbol( TOOL_ACTION_ARGS()
.Tooltip( _( "Import a symbol to the current library" ) ) .Tooltip( _( "Import a symbol to the current library" ) )
.Icon( BITMAPS::import_part ) ); .Icon( BITMAPS::import_part ) );
TOOL_ACTION EE_ACTIONS::openWithTextEditor( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.openWithTextEditor" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Edit in a Text Editor..." ) )
.Tooltip( _( "Open a library file with a text editor" ) )
.Icon( BITMAPS::editor ) );
TOOL_ACTION EE_ACTIONS::updateSymbolFields( TOOL_ACTION_ARGS() TOOL_ACTION EE_ACTIONS::updateSymbolFields( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.updateSymbolFields" ) .Name( "eeschema.SymbolLibraryControl.updateSymbolFields" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )
@ -277,24 +270,6 @@ TOOL_ACTION EE_ACTIONS::showPinNumbers( TOOL_ACTION_ARGS()
.Tooltip( _( "Annotate pins with their numbers" ) ) .Tooltip( _( "Annotate pins with their numbers" ) )
.Icon( BITMAPS::pin ) ); .Icon( BITMAPS::pin ) );
TOOL_ACTION EE_ACTIONS::showSymbolTree( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.showSymbolTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Show Symbol Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION EE_ACTIONS::hideSymbolTree( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.hideSymbolTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Hide Symbol Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION EE_ACTIONS::symbolTreeSearch( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.symbolTreeSearch" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Focus Symbol Tree Search Field" ) )
.DefaultHotkey( MD_CTRL + 'L' ) );
TOOL_ACTION EE_ACTIONS::exportSymbolView( TOOL_ACTION_ARGS() TOOL_ACTION EE_ACTIONS::exportSymbolView( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.exportSymbolView" ) .Name( "eeschema.SymbolLibraryControl.exportSymbolView" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )

View File

@ -212,7 +212,6 @@ public:
static TOOL_ACTION exportSymbol; static TOOL_ACTION exportSymbol;
static TOOL_ACTION updateSymbolFields; static TOOL_ACTION updateSymbolFields;
static TOOL_ACTION setUnitDisplayName; static TOOL_ACTION setUnitDisplayName;
static TOOL_ACTION openWithTextEditor;
// Hierarchy navigation // Hierarchy navigation
static TOOL_ACTION changeSheet; static TOOL_ACTION changeSheet;
@ -250,8 +249,6 @@ public:
static TOOL_ACTION pushPinNumSize; static TOOL_ACTION pushPinNumSize;
static TOOL_ACTION showElectricalTypes; static TOOL_ACTION showElectricalTypes;
static TOOL_ACTION showPinNumbers; static TOOL_ACTION showPinNumbers;
static TOOL_ACTION showSymbolTree;
static TOOL_ACTION hideSymbolTree;
static TOOL_ACTION symbolTreeSearch; static TOOL_ACTION symbolTreeSearch;
static TOOL_ACTION drawSheetOnClipboard; static TOOL_ACTION drawSheetOnClipboard;
static TOOL_ACTION importGraphics; static TOOL_ACTION importGraphics;

View File

@ -2253,11 +2253,8 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(),
symbol->GetBodyStyle() ); symbol->GetBodyStyle() );
if( !symbolEditor->IsSymbolTreeShown() ) if( !symbolEditor->IsLibraryTreeShown() )
{ symbolEditor->ToggleLibraryTree();
wxCommandEvent evt;
symbolEditor->OnToggleSymbolTree( evt );
}
} }
} }

View File

@ -27,9 +27,9 @@
#include <pgm_base.h> #include <pgm_base.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/library_editor_control.h>
#include <tools/ee_actions.h> #include <tools/ee_actions.h>
#include <tools/symbol_editor_control.h> #include <tools/symbol_editor_control.h>
#include <symbol_edit_frame.h>
#include <lib_symbol_library_manager.h> #include <lib_symbol_library_manager.h>
#include <symbol_viewer_frame.h> #include <symbol_viewer_frame.h>
#include <symbol_tree_model_adapter.h> #include <symbol_tree_model_adapter.h>
@ -39,7 +39,6 @@
#include <kidialog.h> #include <kidialog.h>
#include <gestfich.h> // To open with a text editor #include <gestfich.h> // To open with a text editor
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include "wx/generic/textdlgg.h"
#include "string_utils.h" #include "string_utils.h"
bool SYMBOL_EDITOR_CONTROL::Init() bool SYMBOL_EDITOR_CONTROL::Init()
@ -50,8 +49,9 @@ bool SYMBOL_EDITOR_CONTROL::Init()
if( m_isSymbolEditor ) if( m_isSymbolEditor )
{ {
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); LIBRARY_EDITOR_CONTROL* libraryTreeTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>(); CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
wxCHECK( editFrame, false ); wxCHECK( editFrame, false );
@ -61,6 +61,7 @@ bool SYMBOL_EDITOR_CONTROL::Init()
LIB_ID sel = editFrame->GetTreeLIBID(); LIB_ID sel = editFrame->GetTreeLIBID();
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 // 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 // symbol selected (in other words, when we know the library context even if the library
// itself isn't selected. // itself isn't selected.
@ -70,35 +71,27 @@ bool SYMBOL_EDITOR_CONTROL::Init()
LIB_ID sel = editFrame->GetTreeLIBID(); LIB_ID sel = editFrame->GetTreeLIBID();
return !sel.GetLibNickname().empty(); return !sel.GetLibNickname().empty();
}; };
auto pinnedLibSelectedCondition =
[ editFrame ]( const SELECTION& aSel )
{
LIB_TREE_NODE* node = editFrame->GetCurrentTreeNode();
return node && node->m_Type == LIB_TREE_NODE::LIBRARY && node->m_Pinned;
};
auto unpinnedLibSelectedCondition =
[ editFrame ](const SELECTION& aSel )
{
LIB_TREE_NODE* node = editFrame->GetCurrentTreeNode();
return node && node->m_Type == LIB_TREE_NODE::LIBRARY && !node->m_Pinned;
};
auto symbolSelectedCondition = auto symbolSelectedCondition =
[ editFrame ]( const SELECTION& aSel ) [ editFrame ]( const SELECTION& aSel )
{ {
LIB_ID sel = editFrame->GetTargetLibId(); LIB_ID sel = editFrame->GetTargetLibId();
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
}; };
auto saveSymbolAsCondition = auto saveSymbolAsCondition =
[ editFrame ]( const SELECTION& aSel ) [ editFrame ]( const SELECTION& aSel )
{ {
LIB_ID sel = editFrame->GetTargetLibId(); LIB_ID sel = editFrame->GetTargetLibId();
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
}; };
auto multiSelectedCondition = auto multiSelectedCondition =
[ editFrame ]( const SELECTION& aSel ) [ editFrame ]( const SELECTION& aSel )
{ {
return editFrame->GetTreeSelectionCount() > 1; return editFrame->GetTreeSelectionCount() > 1;
}; };
auto canOpenWithTextEditor = auto canOpenWithTextEditor =
[ editFrame ]( const SELECTION& aSel ) [ editFrame ]( const SELECTION& aSel )
{ {
@ -109,42 +102,36 @@ bool SYMBOL_EDITOR_CONTROL::Init()
return ret; return ret;
}; };
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition ); // clang-format off
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition ); ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::deriveFromExistingSymbol, symbolSelectedCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 10 );
ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition ); ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::deriveFromExistingSymbol, symbolSelectedCondition ); ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::saveSymbolCopyAs, saveSymbolAsCondition, 10 );
ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 10 );
ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition ); ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition || multiSelectedCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition ); ctxMenu.AddItem( EE_ACTIONS::copySymbol, symbolSelectedCondition || multiSelectedCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::saveSymbolCopyAs, saveSymbolAsCondition ); ctxMenu.AddItem( EE_ACTIONS::pasteSymbol, libInferredCondition, 10 );
ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition ); ctxMenu.AddItem( EE_ACTIONS::duplicateSymbol, symbolSelectedCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::renameSymbol, symbolSelectedCondition, 10 );
ctxMenu.AddItem( EE_ACTIONS::deleteSymbol, symbolSelectedCondition || multiSelectedCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 100 );
ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition || multiSelectedCondition ); ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition, 100 );
ctxMenu.AddItem( EE_ACTIONS::copySymbol, symbolSelectedCondition || multiSelectedCondition );
ctxMenu.AddItem( EE_ACTIONS::pasteSymbol, libInferredCondition );
ctxMenu.AddItem( EE_ACTIONS::duplicateSymbol, symbolSelectedCondition );
ctxMenu.AddItem( EE_ACTIONS::renameSymbol, symbolSelectedCondition );
ctxMenu.AddItem( EE_ACTIONS::deleteSymbol, symbolSelectedCondition || multiSelectedCondition );
ctxMenu.AddSeparator();
ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition );
// If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddSeparator();
ctxMenu.AddItem( EE_ACTIONS::hideSymbolTree, !libInferredCondition );
if( ADVANCED_CFG::GetCfg().m_EnableLibWithText ) if( ADVANCED_CFG::GetCfg().m_EnableLibWithText )
{ {
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 200 );
ctxMenu.AddItem( EE_ACTIONS::openWithTextEditor, ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenWithTextEditor && ( symbolSelectedCondition || libSelectedCondition ), 200 );
canOpenWithTextEditor
&& ( symbolSelectedCondition || libSelectedCondition ) );
} }
libraryTreeTool->AddContextMenuItems( &ctxMenu );
} }
// clang-format on
return true; return true;
} }
@ -164,6 +151,7 @@ int SYMBOL_EDITOR_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::DdAddLibrary( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::DdAddLibrary( const TOOL_EVENT& aEvent )
{ {
wxString libFile = *aEvent.Parameter<wxString*>(); wxString libFile = *aEvent.Parameter<wxString*>();
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->DdAddLibrary( libFile ); static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->DdAddLibrary( libFile );
@ -173,76 +161,68 @@ int SYMBOL_EDITOR_CONTROL::DdAddLibrary( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::EditSymbol( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::EditSymbol( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
{ return 0;
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
int unit = 0;
LIB_ID partId = editFrame->GetTreeLIBID( &unit );
editFrame->LoadSymbol( partId.GetLibItemName(), partId.GetLibNickname(), unit ); SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
} int unit = 0;
LIB_ID partId = editFrame->GetTreeLIBID( &unit );
editFrame->LoadSymbol( partId.GetLibItemName(), partId.GetLibNickname(), unit );
return 0; return 0;
} }
int SYMBOL_EDITOR_CONTROL::AddSymbol( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::AddSymbol( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
LIB_ID target = editFrame->GetTargetLibId();
const wxString& libName = target.GetLibNickname();
wxString msg;
if( libName.IsEmpty() )
{ {
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame ); msg.Printf( _( "No symbol library selected." ) );
m_frame->ShowInfoBarError( msg );
LIB_ID target = editFrame->GetTargetLibId(); return 0;
const wxString& libName = target.GetLibNickname();
wxString msg;
if( libName.IsEmpty() )
{
msg.Printf( _( "No symbol library selected." ) );
m_frame->ShowInfoBarError( msg );
return 0;
}
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{
msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
m_frame->ShowInfoBarError( msg );
return 0;
}
if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) )
{
editFrame->CreateNewSymbol();
}
else if( aEvent.IsAction( &EE_ACTIONS::deriveFromExistingSymbol ) )
{
editFrame->CreateNewSymbol( target.GetLibItemName() );
}
else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
{
editFrame->ImportSymbol();
}
} }
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{
msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
m_frame->ShowInfoBarError( msg );
return 0;
}
if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) )
editFrame->CreateNewSymbol();
else if( aEvent.IsAction( &EE_ACTIONS::deriveFromExistingSymbol ) )
editFrame->CreateNewSymbol( target.GetLibItemName() );
else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
editFrame->ImportSymbol();
return 0; return 0;
} }
int SYMBOL_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvt ) int SYMBOL_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvt )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
{ return 0;
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
if( aEvt.IsAction( &EE_ACTIONS::save ) ) SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
editFrame->Save();
else if( aEvt.IsAction( &EE_ACTIONS::saveLibraryAs ) ) if( aEvt.IsAction( &EE_ACTIONS::save ) )
editFrame->SaveLibraryAs(); editFrame->Save();
else if( aEvt.IsAction( &EE_ACTIONS::saveSymbolCopyAs ) ) else if( aEvt.IsAction( &EE_ACTIONS::saveLibraryAs ) )
editFrame->SaveSymbolCopyAs(); editFrame->SaveLibraryAs();
else if( aEvt.IsAction( &EE_ACTIONS::saveAll ) ) else if( aEvt.IsAction( &EE_ACTIONS::saveSymbolCopyAs ) )
editFrame->SaveAll(); editFrame->SaveSymbolCopyAs();
} else if( aEvt.IsAction( &EE_ACTIONS::saveAll ) )
editFrame->SaveAll();
return 0; return 0;
} }
@ -259,66 +239,62 @@ int SYMBOL_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
wxString textEditorName = Pgm().GetTextEditor();
if( textEditorName.IsEmpty() )
{ {
wxString fullEditorName = Pgm().GetTextEditor(); wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
return 0;
if( fullEditorName.IsEmpty() )
{
wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
return 0;
}
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
LIB_ID libId = editFrame->GetTreeLIBID();
wxString libName = libId.GetLibNickname();
wxString tempFName = libMgr.GetLibrary( libName )->GetFullURI( true ).wc_str();
if( !tempFName.IsEmpty() )
{
ExecuteFile( fullEditorName, tempFName, nullptr, false );
}
} }
LIB_ID libId = editFrame->GetTreeLIBID();
wxString libName = libId.GetLibNickname();
wxString tempFName = libMgr.GetLibrary( libName )->GetFullURI( true ).wc_str();
if( !tempFName.IsEmpty() )
ExecuteFile( textEditorName, tempFName, nullptr, false );
return 0; return 0;
} }
int SYMBOL_EDITOR_CONTROL::CutCopyDelete( const TOOL_EVENT& aEvt ) int SYMBOL_EDITOR_CONTROL::CutCopyDelete( const TOOL_EVENT& aEvt )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::copySymbol ) )
editFrame->CopySymbolToClipboard();
if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::deleteSymbol ) )
{ {
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame ); bool hasWritableLibs = false;
wxString msg;
if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::copySymbol ) ) for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
editFrame->CopySymbolToClipboard();
if( aEvt.IsAction( &EE_ACTIONS::cutSymbol ) || aEvt.IsAction( &EE_ACTIONS::deleteSymbol ) )
{ {
bool hasWritableLibs = false; const wxString& libName = sel.GetLibNickname();
wxString msg;
for( LIB_ID& sel : editFrame->GetSelectedLibIds() ) if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{ msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
const wxString& libName = sel.GetLibNickname(); else
hasWritableLibs = true;
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
else
hasWritableLibs = true;
}
if( !msg.IsEmpty() )
m_frame->ShowInfoBarError( msg );
if( !hasWritableLibs )
return 0;
editFrame->DeleteSymbolFromLibrary();
} }
if( !msg.IsEmpty() )
m_frame->ShowInfoBarError( msg );
if( !hasWritableLibs )
return 0;
editFrame->DeleteSymbolFromLibrary();
} }
return 0; return 0;
@ -327,147 +303,120 @@ int SYMBOL_EDITOR_CONTROL::CutCopyDelete( const TOOL_EVENT& aEvt )
int SYMBOL_EDITOR_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
LIB_ID sel = editFrame->GetTargetLibId();
// DuplicateSymbol() is called to duplicate a symbol, or to paste a previously
// saved symbol in clipboard
bool isPasteAction = aEvent.IsAction( &EE_ACTIONS::pasteSymbol );
wxString msg;
if( !sel.IsValid() && !isPasteAction )
{ {
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame ); // When duplicating a symbol, a source symbol must exists.
LIB_ID sel = editFrame->GetTargetLibId(); msg.Printf( _( "No symbol selected" ) );
// DuplicateSymbol() is called to duplicate a symbol, or to paste a previously m_frame->ShowInfoBarError( msg );
// saved symbol in clipboard return 0;
bool isPasteAction = aEvent.IsAction( &EE_ACTIONS::pasteSymbol );
wxString msg;
if( !sel.IsValid() && !isPasteAction )
{
// When duplicating a symbol, a source symbol must exists.
msg.Printf( _( "No symbol selected" ) );
m_frame->ShowInfoBarError( msg );
return 0;
}
const wxString& libName = sel.GetLibNickname();
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{
msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
m_frame->ShowInfoBarError( msg );
return 0;
}
editFrame->DuplicateSymbol( isPasteAction );
} }
const wxString& libName = sel.GetLibNickname();
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{
msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
m_frame->ShowInfoBarError( msg );
return 0;
}
editFrame->DuplicateSymbol( isPasteAction );
return 0; return 0;
} }
class RENAME_DIALOG : public wxTextEntryDialog
{
public:
RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
std::function<bool( wxString newName )> aValidator ) :
wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Symbol Name" ), aName ),
m_validator( std::move( aValidator ) )
{ }
wxString GetSymbolName()
{
wxString name = EscapeString( m_textctrl->GetValue(), CTX_LIBID );
name.Trim( true ).Trim( false );
return name;
}
protected:
bool TransferDataFromWindow() override
{
return m_validator( GetSymbolName() );
}
private:
std::function<bool( wxString newName )> m_validator;
};
int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( !m_isSymbolEditor )
{ return 0;
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
LIB_ID libId = editFrame->GetTreeLIBID(); SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
wxString libName = libId.GetLibNickname(); LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
wxString symbolName = libId.GetLibItemName(); LIBRARY_EDITOR_CONTROL* libTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
wxString msg;
if( !libMgr.LibraryExists( libName ) ) LIB_ID libId = editFrame->GetTreeLIBID();
return 0; wxString libName = libId.GetLibNickname();
wxString oldName = libId.GetLibItemName();
wxString newName;
wxString msg;
RENAME_DIALOG dlg( m_frame, symbolName, if( !libMgr.LibraryExists( libName ) )
[&]( wxString newName ) return 0;
if( !libTool->RenameLibrary( _( "Change Symbol Name" ), oldName,
[&]( const wxString& aNewName )
{
newName = EscapeString( aNewName, CTX_LIBID );
if( newName.IsEmpty() )
{ {
if( newName.IsEmpty() ) wxMessageBox( _( "Symbol must have a name." ) );
{ return false;
wxMessageBox( _( "Symbol must have a name." ) ); }
return false;
}
if( libMgr.SymbolExists( newName, libName ) ) if( libMgr.SymbolExists( newName, libName ) )
{ {
msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ), msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ),
newName, libName ); newName, libName );
KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ), KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING ); wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) ); errorDlg.SetOKLabel( _( "Overwrite" ) );
return errorDlg.ShowModal() == wxID_OK; return errorDlg.ShowModal() == wxID_OK;
} }
return true; return true;
} ); } ) )
{
return 0; // cancelled by user
}
if( dlg.ShowModal() != wxID_OK ) LIB_SYMBOL* libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
return 0; // canceled by user bool isCurrentSymbol = editFrame->IsCurrentSymbol( libId );
wxString newName = dlg.GetSymbolName(); if( !libSymbol )
wxString oldName = symbolName; return 0;
LIB_SYMBOL* libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
bool isCurrentSymbol = editFrame->IsCurrentSymbol( libId );
if( !libSymbol ) libSymbol->SetName( newName );
return 0;
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
libMgr.SetSymbolModified( newName, libName );
if( isCurrentSymbol && editFrame->GetCurSymbol())
{
libSymbol = editFrame->GetCurSymbol();
libSymbol->SetName( newName ); libSymbol->SetName( newName );
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName ) if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName ); libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName ); editFrame->RebuildView();
libMgr.SetSymbolModified( newName, libName ); editFrame->OnModify();
editFrame->UpdateTitle();
if( isCurrentSymbol && editFrame->GetCurSymbol()) // N.B. The view needs to be rebuilt first as the Symbol Properties change may
{ // invalidate the view pointers by rebuilting the field table
libSymbol = editFrame->GetCurSymbol(); editFrame->UpdateMsgPanel();
libSymbol->SetName( newName );
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
editFrame->RebuildView();
editFrame->OnModify();
editFrame->UpdateTitle();
// N.B. The view needs to be rebuilt first as the Symbol Properties change may
// invalidate the view pointers by rebuilting the field table
editFrame->UpdateMsgPanel();
}
wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
editFrame->UpdateLibraryTree( treeItem, libSymbol );
editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
} }
wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
editFrame->UpdateLibraryTree( treeItem, libSymbol );
editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
return 0; return 0;
} }
@ -498,76 +447,6 @@ int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
} }
int SYMBOL_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
if( currentNode && !currentNode->m_Pinned )
{
m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), true );
currentNode->m_Pinned = true;
editFrame->RegenerateLibraryTree();
}
}
return 0;
}
int SYMBOL_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
if( currentNode && currentNode->m_Pinned )
{
m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), true );
currentNode->m_Pinned = false;
editFrame->RegenerateLibraryTree();
}
}
return 0;
}
int SYMBOL_EDITOR_CONTROL::ToggleSymbolTree( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
wxCommandEvent dummy;
static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->OnToggleSymbolTree( dummy );
}
return 0;
}
int SYMBOL_EDITOR_CONTROL::SymbolTreeSearch( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
SYMBOL_EDIT_FRAME& sym_edit_frame = static_cast<SYMBOL_EDIT_FRAME&>( *m_frame );
if( !sym_edit_frame.IsSymbolTreeShown() )
{
wxCommandEvent dummy;
sym_edit_frame.OnToggleSymbolTree( dummy );
}
sym_edit_frame.FocusSearchTreeInput();
}
return 0;
}
int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent )
{ {
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
@ -617,26 +496,30 @@ int SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
{ {
if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>(); SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
editFrame->GetRenderSettings()->m_ShowHiddenPins = editFrame->GetRenderSettings()->m_ShowHiddenPins =
!editFrame->GetRenderSettings()->m_ShowHiddenPins; !editFrame->GetRenderSettings()->m_ShowHiddenPins;
getView()->UpdateAllItems( KIGFX::REPAINT ); getView()->UpdateAllItems( KIGFX::REPAINT );
editFrame->GetCanvas()->Refresh(); editFrame->GetCanvas()->Refresh();
return 0; return 0;
} }
int SYMBOL_EDITOR_CONTROL::ToggleHiddenFields( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::ToggleHiddenFields( const TOOL_EVENT& aEvent )
{ {
if( !m_isSymbolEditor )
return 0;
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>(); SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
editFrame->GetRenderSettings()->m_ShowHiddenFields = editFrame->GetRenderSettings()->m_ShowHiddenFields =
!editFrame->GetRenderSettings()->m_ShowHiddenFields; !editFrame->GetRenderSettings()->m_ShowHiddenFields;
getView()->UpdateAllItems( KIGFX::REPAINT ); getView()->UpdateAllItems( KIGFX::REPAINT );
editFrame->GetCanvas()->Refresh(); editFrame->GetCanvas()->Refresh();
return 0; return 0;
} }
@ -818,7 +701,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::cutSymbol.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::cutSymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::copySymbol.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::CutCopyDelete, EE_ACTIONS::copySymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::DuplicateSymbol, EE_ACTIONS::pasteSymbol.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::DuplicateSymbol, EE_ACTIONS::pasteSymbol.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::OpenWithTextEditor, EE_ACTIONS::openWithTextEditor.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::OpenWithTextEditor, ACTIONS::openWithTextEditor.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ExportView, EE_ACTIONS::exportSymbolView.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ExportView, EE_ACTIONS::exportSymbolView.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG, EE_ACTIONS::exportSymbolAsSVG.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG, EE_ACTIONS::exportSymbolAsSVG.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic, EE_ACTIONS::addSymbolToSchematic.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic, EE_ACTIONS::addSymbolToSchematic.MakeEvent() );
@ -828,11 +711,6 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ShowPinNumbers, EE_ACTIONS::showPinNumbers.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ShowPinNumbers, EE_ACTIONS::showPinNumbers.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::SymbolTreeSearch, EE_ACTIONS::symbolTreeSearch.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() );

View File

@ -41,8 +41,6 @@ public:
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.SymbolLibraryControl" ) EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.SymbolLibraryControl" )
{ } { }
virtual ~SYMBOL_EDITOR_CONTROL() { }
/// @copydoc TOOL_INTERACTIVE::Init() /// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override; bool Init() override;
@ -56,7 +54,6 @@ public:
int CutCopyDelete( const TOOL_EVENT& aEvent ); int CutCopyDelete( const TOOL_EVENT& aEvent );
int DuplicateSymbol( const TOOL_EVENT& aEvent ); int DuplicateSymbol( const TOOL_EVENT& aEvent );
int RenameSymbol( const TOOL_EVENT& newName ); int RenameSymbol( const TOOL_EVENT& newName );
int ExportSymbol( const TOOL_EVENT& aEvent );
int OpenWithTextEditor( const TOOL_EVENT& aEvent ); int OpenWithTextEditor( const TOOL_EVENT& aEvent );
int ExportView( const TOOL_EVENT& aEvent ); int ExportView( const TOOL_EVENT& aEvent );
int ExportSymbolAsSVG( const TOOL_EVENT& aEvent ); int ExportSymbolAsSVG( const TOOL_EVENT& aEvent );
@ -66,10 +63,6 @@ public:
int ShowElectricalTypes( const TOOL_EVENT& aEvent ); int ShowElectricalTypes( const TOOL_EVENT& aEvent );
int ShowPinNumbers( const TOOL_EVENT& aEvent ); int ShowPinNumbers( const TOOL_EVENT& aEvent );
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleSymbolTree( const TOOL_EVENT& aEvent );
int SymbolTreeSearch( const TOOL_EVENT& aEvent );
int ToggleProperties( const TOOL_EVENT& aEvent ); int ToggleProperties( const TOOL_EVENT& aEvent );
int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ); int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent );

View File

@ -35,7 +35,8 @@
#include <gal/color4d.h> #include <gal/color4d.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <kiid.h> #include <kiid.h>
#include "hotkeys_basic.h" #include <hotkeys_basic.h>
#include <widgets/lib_tree.h>
class EDA_ITEM; class EDA_ITEM;
class wxSingleInstanceChecker; class wxSingleInstanceChecker;
@ -396,6 +397,13 @@ public:
*/ */
virtual void UpdateMsgPanel(); virtual void UpdateMsgPanel();
virtual LIB_TREE* GetLibTree() const { return nullptr; }
virtual LIB_ID GetTargetLibId() const { return LIB_ID(); }
virtual bool IsLibraryTreeShown() const { return false; }
virtual void ToggleLibraryTree() {};
virtual void FocusLibraryTreeInput() {};
PROPERTIES_PANEL* GetPropertiesPanel() { return m_propertiesPanel; } PROPERTIES_PANEL* GetPropertiesPanel() { return m_propertiesPanel; }
void UpdateProperties(); void UpdateProperties();

View File

@ -58,6 +58,7 @@ public:
static TOOL_ACTION plot; static TOOL_ACTION plot;
static TOOL_ACTION quit; static TOOL_ACTION quit;
static TOOL_ACTION ddAddLibrary; // for drag and drop lib static TOOL_ACTION ddAddLibrary; // for drag and drop lib
static TOOL_ACTION openWithTextEditor;
// Generic edit actions // Generic edit actions
static TOOL_ACTION cancelInteractive; static TOOL_ACTION cancelInteractive;
@ -139,6 +140,9 @@ public:
static TOOL_ACTION pinLibrary; static TOOL_ACTION pinLibrary;
static TOOL_ACTION unpinLibrary; static TOOL_ACTION unpinLibrary;
static TOOL_ACTION showLibraryTree;
static TOOL_ACTION hideLibraryTree;
static TOOL_ACTION libraryTreeSearch;
/// Cursor control with keyboard /// Cursor control with keyboard
static TOOL_ACTION cursorUp; static TOOL_ACTION cursorUp;

View File

@ -41,15 +41,12 @@
#include <footprint_edit_frame.h> #include <footprint_edit_frame.h>
#include <footprint_editor_settings.h> #include <footprint_editor_settings.h>
#include <footprint_info_impl.h> #include <footprint_info_impl.h>
#include <footprint_tree_pane.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <kiface_base.h> #include <kiface_base.h>
#include <kiplatform/app.h> #include <kiplatform/app.h>
#include <kiway.h> #include <kiway.h>
#include <macros.h> #include <macros.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <project.h> #include <project.h>
@ -60,6 +57,7 @@
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/properties_tool.h> #include <tool/properties_tool.h>
#include <tool/selection.h> #include <tool/selection.h>
#include <tool/library_editor_control.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
@ -379,12 +377,12 @@ void FOOTPRINT_EDIT_FRAME::HardRedraw()
} }
void FOOTPRINT_EDIT_FRAME::ToggleSearchTree() void FOOTPRINT_EDIT_FRAME::ToggleLibraryTree()
{ {
wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane ); wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
treePane.Show( !IsSearchTreeShown() ); treePane.Show( !IsLibraryTreeShown() );
if( IsSearchTreeShown() ) if( IsLibraryTreeShown() )
{ {
// SetAuiPaneSize also updates m_auimgr // SetAuiPaneSize also updates m_auimgr
SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 ); SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 );
@ -397,7 +395,7 @@ void FOOTPRINT_EDIT_FRAME::ToggleSearchTree()
} }
void FOOTPRINT_EDIT_FRAME::FocusSearchTreeInput() void FOOTPRINT_EDIT_FRAME::FocusLibraryTreeInput()
{ {
m_treePane->FocusSearchFieldIfExists(); m_treePane->FocusSearchFieldIfExists();
} }
@ -426,7 +424,7 @@ void FOOTPRINT_EDIT_FRAME::ToggleLayersManager()
} }
bool FOOTPRINT_EDIT_FRAME::IsSearchTreeShown() const bool FOOTPRINT_EDIT_FRAME::IsLibraryTreeShown() const
{ {
return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown(); return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
} }
@ -438,24 +436,12 @@ BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
} }
LIB_ID FOOTPRINT_EDIT_FRAME::GetTreeFPID() const
{
return m_treePane->GetLibTree()->GetSelectedLibId();
}
LIB_TREE_NODE* FOOTPRINT_EDIT_FRAME::GetCurrentTreeNode() const
{
return m_treePane->GetLibTree()->GetCurrentTreeNode();
}
LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const
{ {
LIB_ID id; LIB_ID id;
if( IsSearchTreeShown() ) if( IsLibraryTreeShown() )
id = GetTreeFPID(); id = GetLibTree()->GetSelectedLibId();
if( id.GetLibNickname().empty() ) if( id.GetLibNickname().empty() )
id = GetLoadedFPID(); id = GetLoadedFPID();
@ -638,7 +624,7 @@ void FOOTPRINT_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter() = cfg->m_SelectionFilter; GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter() = cfg->m_SelectionFilter;
m_selectionFilterPanel->SetCheckboxesFromFilter( cfg->m_SelectionFilter ); m_selectionFilterPanel->SetCheckboxesFromFilter( cfg->m_SelectionFilter );
m_treePane->GetLibTree()->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) cfg->m_LibrarySortMode ); GetLibTree()->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) cfg->m_LibrarySortMode );
} }
} }
@ -682,7 +668,7 @@ void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion(); cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
} }
cfg->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode(); cfg->m_LibrarySortMode = GetLibTree()->GetSortMode();
if( m_appearancePanel ) if( m_appearancePanel )
{ {
@ -924,7 +910,7 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage()
tree_pane_info.Show( tree_shown ); tree_pane_info.Show( tree_shown );
m_auimgr.Update(); m_auimgr.Update();
m_treePane->GetLibTree()->ShowChangedLanguage(); GetLibTree()->ShowChangedLanguage();
UpdateTitle(); UpdateTitle();
} }
@ -934,7 +920,7 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
{ {
PCB_BASE_FRAME::OnModify(); PCB_BASE_FRAME::OnModify();
Update3DView( true, true ); Update3DView( true, true );
m_treePane->GetLibTree()->RefreshLibTree(); GetLibTree()->RefreshLibTree();
if( !GetTitle().StartsWith( wxT( "*" ) ) ) if( !GetTitle().StartsWith( wxT( "*" ) ) )
UpdateTitle(); UpdateTitle();
@ -1040,7 +1026,7 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
FP_LIB_TABLE* fpTable = PROJECT_PCB::PcbFootprintLibs( &Prj() ); FP_LIB_TABLE* fpTable = PROJECT_PCB::PcbFootprintLibs( &Prj() );
auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() ); auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
LIB_ID target = GetTargetFPID(); LIB_ID target = GetTargetFPID();
bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() ); bool targetSelected = ( target == GetLibTree()->GetSelectedLibId() );
// Sync FOOTPRINT_INFO list to the libraries on disk // Sync FOOTPRINT_INFO list to the libraries on disk
if( aProgress ) if( aProgress )
@ -1057,48 +1043,37 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
// Sync the LIB_TREE to the FOOTPRINT_INFO list // Sync the LIB_TREE to the FOOTPRINT_INFO list
adapter->Sync( fpTable ); adapter->Sync( fpTable );
m_treePane->GetLibTree()->Unselect(); GetLibTree()->Unselect();
m_treePane->GetLibTree()->Regenerate( true ); GetLibTree()->Regenerate( true );
if( target.IsValid() ) if( target.IsValid() )
{ {
if( adapter->FindItem( target ) ) if( adapter->FindItem( target ) )
{ {
if( targetSelected ) if( targetSelected )
m_treePane->GetLibTree()->SelectLibId( target ); GetLibTree()->SelectLibId( target );
else else
m_treePane->GetLibTree()->CenterLibId( target ); GetLibTree()->CenterLibId( target );
} }
else else
{ {
// Try to focus on parent // Try to focus on parent
target.SetLibItemName( wxEmptyString ); target.SetLibItemName( wxEmptyString );
m_treePane->GetLibTree()->CenterLibId( target ); GetLibTree()->CenterLibId( target );
} }
} }
} }
void FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree()
{
LIB_ID target = GetTargetFPID();
m_treePane->GetLibTree()->Regenerate( true );
if( target.IsValid() )
m_treePane->GetLibTree()->CenterLibId( target );
}
void FOOTPRINT_EDIT_FRAME::RefreshLibraryTree() void FOOTPRINT_EDIT_FRAME::RefreshLibraryTree()
{ {
m_treePane->GetLibTree()->RefreshLibTree(); GetLibTree()->RefreshLibTree();
} }
void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID ) void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID )
{ {
m_treePane->GetLibTree()->SelectLibId( aLibID ); GetLibTree()->SelectLibId( aLibID );
} }
@ -1129,6 +1104,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new DRAWING_TOOL );
m_toolManager->RegisterTool( new PCB_POINT_EDITOR ); m_toolManager->RegisterTool( new PCB_POINT_EDITOR );
m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
m_toolManager->RegisterTool( new LIBRARY_EDITOR_CONTROL );
m_toolManager->RegisterTool( new FOOTPRINT_EDITOR_CONTROL ); m_toolManager->RegisterTool( new FOOTPRINT_EDITOR_CONTROL );
m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL ); m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
@ -1242,10 +1218,10 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
return GetCanvas() && GetCanvas()->GetView()->IsMirroredX(); return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
}; };
auto footprintTreeCond = auto libraryTreeCond =
[this](const SELECTION& ) [this](const SELECTION& )
{ {
return IsSearchTreeShown(); return IsLibraryTreeShown();
}; };
auto layerManagerCond = auto layerManagerCond =
@ -1265,7 +1241,7 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) ); mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) ); mgr->SetConditions( ACTIONS::showLibraryTree, CHECK( libraryTreeCond ) );
mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) ); mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) ); mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) );

View File

@ -23,6 +23,8 @@
#include <pcb_base_frame.h> #include <pcb_base_frame.h>
#include <pcb_base_edit_frame.h> #include <pcb_base_edit_frame.h>
#include <pcb_io/pcb_io_mgr.h> #include <pcb_io/pcb_io_mgr.h>
#include <widgets/lib_tree.h>
#include <footprint_tree_pane.h>
#include <fp_tree_synchronizing_adapter.h> #include <fp_tree_synchronizing_adapter.h>
class PCB_LAYER_BOX_SELECTOR; class PCB_LAYER_BOX_SELECTOR;
@ -138,9 +140,10 @@ public:
void OnSaveFootprintAsPng( wxCommandEvent& event ); void OnSaveFootprintAsPng( wxCommandEvent& event );
bool IsSearchTreeShown() const; bool IsLibraryTreeShown() const override;
void ToggleSearchTree(); void ToggleLibraryTree() override;
void FocusSearchTreeInput(); void FocusLibraryTreeInput() override;
void ToggleLayersManager(); void ToggleLayersManager();
/** /**
@ -201,11 +204,6 @@ public:
*/ */
bool Clear_Pcb( bool doAskAboutUnsavedChanges ); bool Clear_Pcb( bool doAskAboutUnsavedChanges );
/// Return the LIB_ID of the part or library selected in the footprint tree.
LIB_ID GetTreeFPID() const;
LIB_TREE_NODE* GetCurrentTreeNode() const;
/// Return the LIB_ID of the part being edited. /// Return the LIB_ID of the part being edited.
LIB_ID GetLoadedFPID() const; LIB_ID GetLoadedFPID() const;
@ -295,18 +293,17 @@ public:
*/ */
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override; void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
LIB_TREE* GetLibTree() const override
{
return m_treePane->GetLibTree();
}
/** /**
* Synchronize the footprint library tree to the current state of the footprint library * Synchronize the footprint library tree to the current state of the footprint library
* table. * table.
*/ */
void SyncLibraryTree( bool aProgress ); void SyncLibraryTree( bool aProgress );
/**
* Filter, sort, and redisplay the library tree. Does NOT synchronize it with libraries
* in disk.
*/
void RegenerateLibraryTree();
/** /**
* Redisplay the library tree. Used after changing modified states, descriptions, etc. * Redisplay the library tree. Used after changing modified states, descriptions, etc.
*/ */

View File

@ -165,8 +165,8 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
if( IsSearchTreeShown() ) if( IsLibraryTreeShown() )
ToggleSearchTree(); ToggleLibraryTree();
} }
Update3DView( true, true ); Update3DView( true, true );

View File

@ -154,7 +154,7 @@ void FOOTPRINT_EDIT_FRAME::doReCreateMenuBar()
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
viewMenu->Add( ACTIONS::showProperties, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
viewMenu->Add( PCB_ACTIONS::showFootprintTree, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::showLibraryTree, ACTION_MENU::CHECK );
viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK ); viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );

View File

@ -249,7 +249,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( PCB_ACTIONS::showFootprintTree, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::showLibraryTree, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::showLayersManager, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::showLayersManager, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::showProperties, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::showProperties, ACTION_TOOLBAR::TOGGLE );

View File

@ -24,11 +24,10 @@
*/ */
#include <advanced_config.h> #include <advanced_config.h>
#include "footprint_editor_control.h"
#include <wx/generic/textdlgg.h>
#include <string_utils.h> #include <string_utils.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/library_editor_control.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <footprint_edit_frame.h> #include <footprint_edit_frame.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
@ -45,12 +44,13 @@
#include <dialogs/dialog_footprint_checker.h> #include <dialogs/dialog_footprint_checker.h>
#include <footprint_wizard_frame.h> #include <footprint_wizard_frame.h>
#include <kiway.h> #include <kiway.h>
#include <drc/drc_item.h>
#include <project_pcb.h> #include <project_pcb.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <memory> #include <memory>
#include "footprint_editor_control.h"
FOOTPRINT_EDITOR_CONTROL::FOOTPRINT_EDITOR_CONTROL() : FOOTPRINT_EDITOR_CONTROL::FOOTPRINT_EDITOR_CONTROL() :
PCB_TOOL_BASE( "pcbnew.ModuleEditor" ), PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
@ -60,11 +60,6 @@ FOOTPRINT_EDITOR_CONTROL::FOOTPRINT_EDITOR_CONTROL() :
} }
FOOTPRINT_EDITOR_CONTROL::~FOOTPRINT_EDITOR_CONTROL()
{
}
void FOOTPRINT_EDITOR_CONTROL::Reset( RESET_REASON aReason ) void FOOTPRINT_EDITOR_CONTROL::Reset( RESET_REASON aReason )
{ {
m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>(); m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
@ -76,6 +71,8 @@ void FOOTPRINT_EDITOR_CONTROL::Reset( RESET_REASON aReason )
bool FOOTPRINT_EDITOR_CONTROL::Init() bool FOOTPRINT_EDITOR_CONTROL::Init()
{ {
LIBRARY_EDITOR_CONTROL* libraryTreeTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
// Build a context menu for the footprint tree // Build a context menu for the footprint tree
// //
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
@ -83,7 +80,7 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
auto libSelectedCondition = auto libSelectedCondition =
[ this ]( const SELECTION& aSel ) [ this ]( const SELECTION& aSel )
{ {
LIB_ID sel = m_frame->GetTreeFPID(); LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty(); return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
}; };
@ -93,25 +90,14 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
auto libInferredCondition = auto libInferredCondition =
[ this ]( const SELECTION& aSel ) [ this ]( const SELECTION& aSel )
{ {
LIB_ID sel = m_frame->GetTreeFPID(); LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
return !sel.GetLibNickname().empty(); return !sel.GetLibNickname().empty();
}; };
auto pinnedLibSelectedCondition =
[ this ]( const SELECTION& aSel )
{
LIB_TREE_NODE* current = m_frame->GetCurrentTreeNode();
return current && current->m_Type == LIB_TREE_NODE::LIBRARY && current->m_Pinned;
};
auto unpinnedLibSelectedCondition =
[ this ](const SELECTION& aSel )
{
LIB_TREE_NODE* current = m_frame->GetCurrentTreeNode();
return current && current->m_Type == LIB_TREE_NODE::LIBRARY && !current->m_Pinned;
};
auto fpSelectedCondition = auto fpSelectedCondition =
[ this ]( const SELECTION& aSel ) [ this ]( const SELECTION& aSel )
{ {
LIB_ID sel = m_frame->GetTreeFPID(); LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
}; };
@ -131,39 +117,35 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
return ret; return ret;
}; };
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition ); // clang-format off
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition ); ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition, 10 );
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 10 );
ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition ); ctxMenu.AddItem( ACTIONS::save, SELECTION_CONDITIONS::ShowAlways, 10 );
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition ); ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition, 10 );
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 10 );
ctxMenu.AddItem( ACTIONS::save, SELECTION_CONDITIONS::ShowAlways ); ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition, 10 );
ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition ); ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition, 10 );
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition ); ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition, 10 );
ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition, 10 );
ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition, 10 );
ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition, 10 );
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 100 );
ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition ); ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition, 100 );
ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition ); ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition, 100 );
ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition );
ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
ctxMenu.AddSeparator();
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition );
// If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
if( ADVANCED_CFG::GetCfg().m_EnableLibWithText ) if( ADVANCED_CFG::GetCfg().m_EnableLibWithText )
{ {
ctxMenu.AddSeparator(); ctxMenu.AddSeparator( 200 );
ctxMenu.AddItem( PCB_ACTIONS::openWithTextEditor, ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenWithTextEditor && fpSelectedCondition, 200 );
canOpenWithTextEditor && fpSelectedCondition );
} }
// clang-format on
libraryTreeTool->AddContextMenuItems( &ctxMenu );
return true; return true;
} }
@ -213,7 +195,7 @@ int FOOTPRINT_EDITOR_CONTROL::NewFootprint( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::CreateFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::CreateFootprint( const TOOL_EVENT& aEvent )
{ {
LIB_ID selected = m_frame->GetTreeFPID(); LIB_ID selected = m_frame->GetLibTree()->GetSelectedLibId();
if( m_frame->IsContentModified() ) if( m_frame->IsContentModified() )
{ {
@ -357,7 +339,7 @@ int FOOTPRINT_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::CutCopyFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::CutCopyFootprint( const TOOL_EVENT& aEvent )
{ {
LIB_ID fpID = m_frame->GetTreeFPID(); LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
if( fpID == m_frame->GetLoadedFPID() ) if( fpID == m_frame->GetLoadedFPID() )
{ {
@ -378,9 +360,9 @@ int FOOTPRINT_EDITOR_CONTROL::CutCopyFootprint( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::PasteFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::PasteFootprint( const TOOL_EVENT& aEvent )
{ {
if( m_copiedFootprint && !m_frame->GetTreeFPID().GetLibNickname().empty() ) if( m_copiedFootprint && !m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname().empty() )
{ {
wxString newLib = m_frame->GetTreeFPID().GetLibNickname(); wxString newLib = m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname();
wxString newName = m_copiedFootprint->GetFPID().GetLibItemName(); wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) ) while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
@ -401,7 +383,7 @@ int FOOTPRINT_EDITOR_CONTROL::PasteFootprint( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::DuplicateFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::DuplicateFootprint( const TOOL_EVENT& aEvent )
{ {
LIB_ID fpID = m_frame->GetTreeFPID(); LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
FOOTPRINT* footprint; FOOTPRINT* footprint;
if( fpID == m_frame->GetLoadedFPID() ) if( fpID == m_frame->GetLoadedFPID() )
@ -421,44 +403,22 @@ int FOOTPRINT_EDITOR_CONTROL::DuplicateFootprint( const TOOL_EVENT& aEvent )
} }
class RENAME_DIALOG : public wxTextEntryDialog
{
public:
RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
std::function<bool( wxString newName )> aValidator ) :
wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Footprint Name" ), aName ),
m_validator( std::move( aValidator ) )
{ }
wxString GetFPName()
{
wxString name = m_textctrl->GetValue();
name.Trim( true ).Trim( false );
return name;
}
protected:
bool TransferDataFromWindow() override
{
return m_validator( GetFPName() );
}
private:
std::function<bool( wxString newName )> m_validator;
};
int FOOTPRINT_EDITOR_CONTROL::RenameFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::RenameFootprint( const TOOL_EVENT& aEvent )
{ {
FP_LIB_TABLE* tbl = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() ); LIBRARY_EDITOR_CONTROL* libTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
LIB_ID fpID = m_frame->GetTreeFPID(); FP_LIB_TABLE* tbl = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() );
wxString libraryName = fpID.GetLibNickname();
wxString oldName = fpID.GetLibItemName();
wxString msg;
RENAME_DIALOG dlg( m_frame, oldName, LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
[&]( wxString newName ) wxString libraryName = fpID.GetLibNickname();
wxString oldName = fpID.GetLibItemName();
wxString newName;
wxString msg;
if( !libTool->RenameLibrary( _( "Change Footprint Name" ), oldName,
[&]( const wxString& aNewName )
{ {
newName = aNewName;
if( newName.IsEmpty() ) if( newName.IsEmpty() )
{ {
wxMessageBox( _( "Footprint must have a name." ) ); wxMessageBox( _( "Footprint must have a name." ) );
@ -478,12 +438,11 @@ int FOOTPRINT_EDITOR_CONTROL::RenameFootprint( const TOOL_EVENT& aEvent )
} }
return true; return true;
} ); } ) )
{
return 0; // cancelled by user
}
if( dlg.ShowModal() != wxID_OK )
return 0; // canceled by user
wxString newName = dlg.GetFPName();
FOOTPRINT* footprint = nullptr; FOOTPRINT* footprint = nullptr;
if( fpID == m_frame->GetLoadedFPID() ) if( fpID == m_frame->GetLoadedFPID() )
@ -602,7 +561,7 @@ int FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent )
FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable ); FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
FP_LIB_TABLE* projectTable = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() ); FP_LIB_TABLE* projectTable = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() );
LIB_ID libId = m_frame->GetTreeFPID(); LIB_ID libId = m_frame->GetLibTree()->GetSelectedLibId();
const char* libName = libId.GetLibNickname().c_str(); const char* libName = libId.GetLibNickname().c_str();
wxString libItemName = wxEmptyString; wxString libItemName = wxEmptyString;
@ -619,9 +578,7 @@ int FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent )
} }
if( !libItemName.IsEmpty() ) if( !libItemName.IsEmpty() )
{
ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false ); ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
}
return 0; return 0;
} }
@ -629,56 +586,7 @@ int FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::EditFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::EditFootprint( const TOOL_EVENT& aEvent )
{ {
m_frame->LoadFootprintFromLibrary( m_frame->GetTreeFPID() ); m_frame->LoadFootprintFromLibrary( m_frame->GetLibTree()->GetSelectedLibId() );
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent )
{
LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
if( currentNode && !currentNode->m_Pinned )
{
m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), false );
currentNode->m_Pinned = true;
m_frame->RegenerateLibraryTree();
}
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
{
LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
if( currentNode && currentNode->m_Pinned )
{
m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), false );
currentNode->m_Pinned = false;
m_frame->RegenerateLibraryTree();
}
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree( const TOOL_EVENT& aEvent )
{
m_frame->ToggleSearchTree();
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch( const TOOL_EVENT& aEvent )
{
if (!m_frame->IsSearchTreeShown()) {
m_frame->ToggleSearchTree();
}
m_frame->FocusSearchTreeInput();
return 0; return 0;
} }
@ -816,14 +724,6 @@ int FOOTPRINT_EDITOR_CONTROL::RepairFootprint( const TOOL_EVENT& aEvent )
details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates ); details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
} }
/*******************************
* Your test here
*/
/*******************************
* Inform the user
*/
if( errors ) if( errors )
{ {
m_frame->OnModify(); m_frame->OnModify();
@ -858,7 +758,7 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
Go( &FOOTPRINT_EDITOR_CONTROL::ImportFootprint, PCB_ACTIONS::importFootprint.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ImportFootprint, PCB_ACTIONS::importFootprint.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ExportFootprint, PCB_ACTIONS::exportFootprint.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ExportFootprint, PCB_ACTIONS::exportFootprint.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor, PCB_ACTIONS::openWithTextEditor.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor, ACTIONS::openWithTextEditor.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::EditTextAndGraphics, PCB_ACTIONS::editTextAndGraphics.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::EditTextAndGraphics, PCB_ACTIONS::editTextAndGraphics.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::CleanupGraphics, PCB_ACTIONS::cleanupGraphics.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::CleanupGraphics, PCB_ACTIONS::cleanupGraphics.MakeEvent() );
@ -866,11 +766,6 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
Go( &FOOTPRINT_EDITOR_CONTROL::CheckFootprint, PCB_ACTIONS::checkFootprint.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::CheckFootprint, PCB_ACTIONS::checkFootprint.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::RepairFootprint, PCB_ACTIONS::repairFootprint.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::RepairFootprint, PCB_ACTIONS::repairFootprint.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::showFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::hideFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch, PCB_ACTIONS::footprintTreeSearch.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );

View File

@ -40,7 +40,6 @@ class FOOTPRINT_EDITOR_CONTROL : public PCB_TOOL_BASE
{ {
public: public:
FOOTPRINT_EDITOR_CONTROL(); FOOTPRINT_EDITOR_CONTROL();
~FOOTPRINT_EDITOR_CONTROL() override;
/// @copydoc TOOL_INTERACTIVE::Reset() /// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
@ -65,10 +64,6 @@ public:
int ExportFootprint( const TOOL_EVENT& aEvent ); int ExportFootprint( const TOOL_EVENT& aEvent );
int OpenWithTextEditor( const TOOL_EVENT& aEvent ); int OpenWithTextEditor( const TOOL_EVENT& aEvent );
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleFootprintTree( const TOOL_EVENT& aEvent );
int FootprintTreeSearch( const TOOL_EVENT& aEvent );
int ToggleLayersManager( const TOOL_EVENT& aEvent ); int ToggleLayersManager( const TOOL_EVENT& aEvent );
int ToggleProperties( const TOOL_EVENT& aEvent ); int ToggleProperties( const TOOL_EVENT& aEvent );
int Properties( const TOOL_EVENT& aEvent ); int Properties( const TOOL_EVENT& aEvent );

View File

@ -685,24 +685,6 @@ TOOL_ACTION PCB_ACTIONS::properties( TOOL_ACTION_ARGS()
// FOOTPRINT_EDITOR_CONTROL // FOOTPRINT_EDITOR_CONTROL
// //
TOOL_ACTION PCB_ACTIONS::showFootprintTree( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.showFootprintTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Show Footprint Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION PCB_ACTIONS::hideFootprintTree( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.hideFootprintTree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Hide Footprint Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION PCB_ACTIONS::footprintTreeSearch( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.footprintTreeSearch" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Focus the Footprint Tree Search Field" ) )
.DefaultHotkey( MD_CTRL + 'L' ) );
TOOL_ACTION PCB_ACTIONS::newFootprint( TOOL_ACTION_ARGS() TOOL_ACTION PCB_ACTIONS::newFootprint( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.newFootprint" ) .Name( "pcbnew.ModuleEditor.newFootprint" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )
@ -779,13 +761,6 @@ TOOL_ACTION PCB_ACTIONS::exportFootprint( TOOL_ACTION_ARGS()
.Tooltip( _( "Export edited footprint to file" ) ) .Tooltip( _( "Export edited footprint to file" ) )
.Icon( BITMAPS::export_module ) ); .Icon( BITMAPS::export_module ) );
TOOL_ACTION PCB_ACTIONS::openWithTextEditor( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.openWithTextEditor" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Edit in a Text Editor..." ) )
.Tooltip( _( "Open a library file with a text editor" ) )
.Icon( BITMAPS::editor ) );
TOOL_ACTION PCB_ACTIONS::footprintProperties( TOOL_ACTION_ARGS() TOOL_ACTION PCB_ACTIONS::footprintProperties( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.footprintProperties" ) .Name( "pcbnew.ModuleEditor.footprintProperties" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )

View File

@ -444,11 +444,7 @@ public:
static TOOL_ACTION showPythonConsole; static TOOL_ACTION showPythonConsole;
static TOOL_ACTION zonesManager; static TOOL_ACTION zonesManager;
// Module editor tools // Footprint editor tools
static TOOL_ACTION showFootprintTree;
static TOOL_ACTION hideFootprintTree;
static TOOL_ACTION footprintTreeSearch;
// We don't use ACTION::new here because we need to distinguish between New Library // We don't use ACTION::new here because we need to distinguish between New Library
// and New Footprint. // and New Footprint.
@ -466,7 +462,6 @@ public:
static TOOL_ACTION pasteFootprint; static TOOL_ACTION pasteFootprint;
static TOOL_ACTION importFootprint; static TOOL_ACTION importFootprint;
static TOOL_ACTION exportFootprint; static TOOL_ACTION exportFootprint;
static TOOL_ACTION openWithTextEditor;
static TOOL_ACTION footprintProperties; static TOOL_ACTION footprintProperties;
static TOOL_ACTION defaultPadProperties; static TOOL_ACTION defaultPadProperties;