More ACTIONS work.
This commit is contained in:
parent
33773bad4d
commit
da4fe27447
|
@ -62,31 +62,24 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMg
|
||||||
menuLibrary->AppendSeparator();
|
menuLibrary->AppendSeparator();
|
||||||
menuLibrary->Add( EE_ACTIONS::newSymbol );
|
menuLibrary->Add( EE_ACTIONS::newSymbol );
|
||||||
menuLibrary->Add( EE_ACTIONS::importSymbol );
|
menuLibrary->Add( EE_ACTIONS::importSymbol );
|
||||||
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ),
|
menuLibrary->Add( _( "Paste Symbol" ), ID_LIBEDIT_PASTE_PART, paste_xpm );
|
||||||
KiBitmap( paste_xpm ) );
|
|
||||||
|
|
||||||
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EDIT_PART, _( "Edit Symbol" ),
|
menuPart->Add( _( "Edit Symbol" ), ID_LIBEDIT_EDIT_PART, edit_xpm );
|
||||||
KiBitmap( edit_xpm ) );
|
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
menuPart->Add( ACTIONS::save );
|
menuPart->Add( ACTIONS::save );
|
||||||
menuPart->Add( ACTIONS::saveCopyAs );
|
menuPart->Add( ACTIONS::saveCopyAs );
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_DUPLICATE_PART, _( "Duplicate" ),
|
menuPart->Add( _( "Duplicate" ), ID_LIBEDIT_DUPLICATE_PART, duplicate_xpm );
|
||||||
KiBitmap( duplicate_xpm ) );
|
menuPart->Add( _( "Delete" ), ID_LIBEDIT_REMOVE_PART, delete_xpm );
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_REMOVE_PART, _( "Delete" ),
|
|
||||||
KiBitmap( delete_xpm ) );
|
|
||||||
menuPart->Add( ACTIONS::revert );
|
menuPart->Add( ACTIONS::revert );
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_CUT_PART, _( "Cut" ),
|
menuPart->Add( _( "Cut" ), ID_LIBEDIT_CUT_PART, cut_xpm );
|
||||||
KiBitmap( cut_xpm ) );
|
menuPart->Add( _( "Copy" ), ID_LIBEDIT_COPY_PART, copy_xpm );
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_COPY_PART, _( "Copy" ),
|
|
||||||
KiBitmap( copy_xpm ) );
|
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
|
menuPart->Add( _( "Export Symbol..." ), ID_LIBEDIT_EXPORT_PART, export_part_xpm );
|
||||||
KiBitmap( export_part_xpm ) );
|
|
||||||
|
|
||||||
// Menu displayed when nothing is selected
|
// Menu displayed when nothing is selected
|
||||||
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
||||||
|
|
|
@ -101,8 +101,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
||||||
EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
||||||
EVT_TOOL( ID_MODEDIT_ADD_LIBRARY, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
||||||
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||||
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
|
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
|
||||||
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||||
|
@ -773,6 +771,13 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::FocusOnLibrary( const wxString& aLibName )
|
||||||
|
{
|
||||||
|
LIB_ID libID( aLibName, wxEmptyString );
|
||||||
|
m_treePane->GetLibTree()->SelectLibId( libID );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FOOTPRINT_EDIT_FRAME::IsGridVisible() const
|
bool FOOTPRINT_EDIT_FRAME::IsGridVisible() const
|
||||||
{
|
{
|
||||||
return IsElementVisible( LAYER_GRID );
|
return IsElementVisible( LAYER_GRID );
|
||||||
|
|
|
@ -346,6 +346,7 @@ public:
|
||||||
* @param aProgress
|
* @param aProgress
|
||||||
*/
|
*/
|
||||||
void SyncLibraryTree( bool aProgress );
|
void SyncLibraryTree( bool aProgress );
|
||||||
|
void FocusOnLibrary( const wxString& aLibName );
|
||||||
|
|
||||||
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||||
|
|
||||||
|
|
|
@ -426,25 +426,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
Export_Module( LoadFootprint( getTargetFPID() ) );
|
Export_Module( LoadFootprint( getTargetFPID() ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MODEDIT_CREATE_NEW_LIB:
|
|
||||||
{
|
|
||||||
wxFileName fn( CreateNewLibrary() );
|
|
||||||
wxString name = fn.GetName();
|
|
||||||
|
|
||||||
if( !name.IsEmpty() )
|
|
||||||
{
|
|
||||||
LIB_ID newLib( name, wxEmptyString );
|
|
||||||
|
|
||||||
SyncLibraryTree( true );
|
|
||||||
m_treePane->GetLibTree()->SelectLibId( newLib );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_ADD_LIBRARY:
|
|
||||||
AddLibrary();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_EDIT_MODULE:
|
case ID_MODEDIT_EDIT_MODULE:
|
||||||
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
|
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -571,7 +571,10 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
|
||||||
auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, false );
|
auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, false );
|
||||||
|
|
||||||
if( editor )
|
if( editor )
|
||||||
|
{
|
||||||
editor->SyncLibraryTree( true );
|
editor->SyncLibraryTree( true );
|
||||||
|
editor->FocusOnLibrary( libName );
|
||||||
|
}
|
||||||
|
|
||||||
auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "footprint_tree_pane.h"
|
#include "footprint_tree_pane.h"
|
||||||
#include "fp_tree_synchronizing_adapter.h"
|
#include "fp_tree_synchronizing_adapter.h"
|
||||||
|
#include <tool/actions.h>
|
||||||
|
#include <tool/action_menu.h>
|
||||||
#include <widgets/lib_tree.h>
|
#include <widgets/lib_tree.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
|
@ -46,62 +47,40 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
|
||||||
boxSizer->Fit( this );
|
boxSizer->Fit( this );
|
||||||
|
|
||||||
// Setup right click-context menus
|
// Setup right click-context menus
|
||||||
std::unique_ptr<wxMenu> menuLibrary = std::make_unique<wxMenu>();
|
std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
|
||||||
|
menuLibrary->Add( ACTIONS::newLibrary );
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
|
menuLibrary->Add( ACTIONS::addLibrary );
|
||||||
KiBitmap( new_library_xpm ) );
|
menuLibrary->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm );
|
||||||
|
menuLibrary->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm );
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_ADD_LIBRARY, _( "&Add Library..." ),
|
|
||||||
KiBitmap( add_library_xpm ) );
|
|
||||||
|
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_SAVE, _( "&Save" ),
|
|
||||||
KiBitmap( save_xpm ) );
|
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_SAVE_AS, _( "Save a Copy &As..." ),
|
|
||||||
KiBitmap( save_as_xpm ) );
|
|
||||||
|
|
||||||
menuLibrary->AppendSeparator();
|
menuLibrary->AppendSeparator();
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE, _( "&New Footprint..." ),
|
menuLibrary->Add( _( "New Footprint..." ), ID_MODEDIT_NEW_MODULE, new_footprint_xpm );
|
||||||
KiBitmap( new_footprint_xpm ) );
|
|
||||||
#ifdef KICAD_SCRIPTING
|
#ifdef KICAD_SCRIPTING
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE_FROM_WIZARD, _( "&Create Footprint from Wizard..." ),
|
menuLibrary->Add( _( "Create Footprint from Wizard..." ), ID_MODEDIT_NEW_MODULE_FROM_WIZARD, module_wizard_xpm );
|
||||||
KiBitmap( module_wizard_xpm ) );
|
|
||||||
#endif
|
#endif
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_IMPORT_PART, _( "&Import Footprint..." ),
|
menuLibrary->Add( _( "Import Footprint..." ), ID_MODEDIT_IMPORT_PART, import_module_xpm );
|
||||||
KiBitmap( import_module_xpm ) );
|
menuLibrary->Add( _( "Paste Footprint" ), ID_MODEDIT_PASTE_PART, paste_xpm );
|
||||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ),
|
|
||||||
KiBitmap( paste_xpm ) );
|
|
||||||
|
|
||||||
std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
|
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_EDIT_MODULE, _( "&Edit Footprint" ),
|
menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm );
|
||||||
KiBitmap( edit_xpm ) );
|
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE, _( "&Save" ),
|
menuPart->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm );
|
||||||
KiBitmap( save_xpm ) );
|
menuPart->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm );
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE_AS, _( "Save &As..." ),
|
menuPart->Add( _( "Delete" ), ID_MODEDIT_DELETE_PART, delete_xpm );
|
||||||
KiBitmap( save_xpm ) );
|
menuPart->Add( _( "Revert" ), ID_MODEDIT_REVERT_PART, undo_xpm );
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_DELETE_PART, _( "&Delete" ),
|
|
||||||
KiBitmap( delete_xpm ) );
|
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_REVERT_PART, _( "Revert" ),
|
|
||||||
KiBitmap( undo_xpm ) );
|
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_CUT_PART, _( "Cut" ),
|
menuPart->Add( _( "Cut" ), ID_MODEDIT_CUT_PART, cut_xpm );
|
||||||
KiBitmap( cut_xpm ) );
|
menuPart->Add( _( "Copy" ), ID_MODEDIT_COPY_PART, copy_xpm );
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_COPY_PART, _( "Copy" ),
|
|
||||||
KiBitmap( copy_xpm ) );
|
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_MODEDIT_EXPORT_PART, _( "E&xport Footprint..." ),
|
menuPart->Add( _( "Export Footprint..." ), ID_MODEDIT_EXPORT_PART, export_module_xpm );
|
||||||
KiBitmap( export_module_xpm ) );
|
|
||||||
|
|
||||||
// Menu displayed when nothing is selected
|
// Menu displayed when nothing is selected
|
||||||
std::unique_ptr<wxMenu> menuNoSelection = std::make_unique<wxMenu>();
|
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
||||||
AddMenuItem( menuNoSelection.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
|
menuNoSelection->Add( ACTIONS::newLibrary );
|
||||||
KiBitmap( new_library_xpm ) );
|
menuNoSelection->Add( ACTIONS::addLibrary );
|
||||||
|
|
||||||
AddMenuItem( menuNoSelection.get(), ID_MODEDIT_ADD_LIBRARY, _( "&Add Library..." ),
|
|
||||||
KiBitmap( add_library_xpm ) );
|
|
||||||
|
|
||||||
m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
|
m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
|
||||||
m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) );
|
m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) );
|
||||||
|
|
|
@ -63,16 +63,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
//
|
//
|
||||||
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
|
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
|
||||||
|
|
||||||
fileMenu->AddItem( ID_MODEDIT_CREATE_NEW_LIB,
|
fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||||
_( "New Library..." ),
|
fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||||
_( "Creates an empty library" ),
|
|
||||||
new_library_xpm, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
|
|
||||||
fileMenu->AddItem( ID_MODEDIT_ADD_LIBRARY,
|
|
||||||
_( "Add Library..." ),
|
|
||||||
_( "Adds a previously created library" ),
|
|
||||||
add_library_xpm, SELECTION_CONDITIONS::ShowAlways );
|
|
||||||
|
|
||||||
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE,
|
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE,
|
||||||
AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ),
|
AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ),
|
||||||
_( "Create a new footprint" ),
|
_( "Create a new footprint" ),
|
||||||
|
|
|
@ -183,8 +183,6 @@ enum pcbnew_ids
|
||||||
|
|
||||||
// ID used in module editor:
|
// ID used in module editor:
|
||||||
ID_MODEDIT_CHECK,
|
ID_MODEDIT_CHECK,
|
||||||
ID_MODEDIT_CREATE_NEW_LIB,
|
|
||||||
ID_MODEDIT_ADD_LIBRARY,
|
|
||||||
ID_MODEDIT_SAVE,
|
ID_MODEDIT_SAVE,
|
||||||
ID_MODEDIT_SAVE_AS,
|
ID_MODEDIT_SAVE_AS,
|
||||||
ID_MODEDIT_SAVE_PNG,
|
ID_MODEDIT_SAVE_PNG,
|
||||||
|
|
|
@ -224,6 +224,20 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PCBNEW_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
if( m_frame->IsType( FRAME_PCB_MODULE_EDITOR ) || m_frame->IsType( FRAME_PCB ) )
|
||||||
|
{
|
||||||
|
if( aEvent.IsAction( &ACTIONS::newLibrary ) )
|
||||||
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
|
||||||
|
else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
|
||||||
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->Close( false );
|
m_frame->Close( false );
|
||||||
|
@ -1040,6 +1054,8 @@ int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
void PCBNEW_CONTROL::setTransitions()
|
void PCBNEW_CONTROL::setTransitions()
|
||||||
{
|
{
|
||||||
|
Go( &PCBNEW_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
|
||||||
|
Go( &PCBNEW_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) override;
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
|
int AddLibrary( const TOOL_EVENT& aEvent );
|
||||||
int Print( const TOOL_EVENT& aEvent );
|
int Print( const TOOL_EVENT& aEvent );
|
||||||
int Quit( const TOOL_EVENT& aEvent );
|
int Quit( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue