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->Add( EE_ACTIONS::newSymbol );
|
||||
menuLibrary->Add( EE_ACTIONS::importSymbol );
|
||||
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ),
|
||||
KiBitmap( paste_xpm ) );
|
||||
menuLibrary->Add( _( "Paste Symbol" ), ID_LIBEDIT_PASTE_PART, paste_xpm );
|
||||
|
||||
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EDIT_PART, _( "Edit Symbol" ),
|
||||
KiBitmap( edit_xpm ) );
|
||||
menuPart->Add( _( "Edit Symbol" ), ID_LIBEDIT_EDIT_PART, edit_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( ACTIONS::save );
|
||||
menuPart->Add( ACTIONS::saveCopyAs );
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_DUPLICATE_PART, _( "Duplicate" ),
|
||||
KiBitmap( duplicate_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_REMOVE_PART, _( "Delete" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
menuPart->Add( _( "Duplicate" ), ID_LIBEDIT_DUPLICATE_PART, duplicate_xpm );
|
||||
menuPart->Add( _( "Delete" ), ID_LIBEDIT_REMOVE_PART, delete_xpm );
|
||||
menuPart->Add( ACTIONS::revert );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_CUT_PART, _( "Cut" ),
|
||||
KiBitmap( cut_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_COPY_PART, _( "Copy" ),
|
||||
KiBitmap( copy_xpm ) );
|
||||
menuPart->Add( _( "Cut" ), ID_LIBEDIT_CUT_PART, cut_xpm );
|
||||
menuPart->Add( _( "Copy" ), ID_LIBEDIT_COPY_PART, copy_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
|
||||
KiBitmap( export_part_xpm ) );
|
||||
menuPart->Add( _( "Export Symbol..." ), ID_LIBEDIT_EXPORT_PART, export_part_xpm );
|
||||
|
||||
// Menu displayed when nothing is selected
|
||||
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_IMPORT_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( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
|
||||
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
|
||||
{
|
||||
return IsElementVisible( LAYER_GRID );
|
||||
|
|
|
@ -346,6 +346,7 @@ public:
|
|||
* @param aProgress
|
||||
*/
|
||||
void SyncLibraryTree( bool aProgress );
|
||||
void FocusOnLibrary( const wxString& aLibName );
|
||||
|
||||
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||
|
||||
|
|
|
@ -426,25 +426,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
Export_Module( LoadFootprint( getTargetFPID() ) );
|
||||
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:
|
||||
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
|
||||
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 );
|
||||
|
||||
if( editor )
|
||||
{
|
||||
editor->SyncLibraryTree( true );
|
||||
editor->FocusOnLibrary( libName );
|
||||
}
|
||||
|
||||
auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "footprint_tree_pane.h"
|
||||
#include "fp_tree_synchronizing_adapter.h"
|
||||
|
||||
#include <tool/actions.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <footprint_edit_frame.h>
|
||||
|
@ -46,62 +47,40 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
|
|||
boxSizer->Fit( this );
|
||||
|
||||
// Setup right click-context menus
|
||||
std::unique_ptr<wxMenu> menuLibrary = std::make_unique<wxMenu>();
|
||||
|
||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
|
||||
KiBitmap( new_library_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 ) );
|
||||
std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
|
||||
menuLibrary->Add( ACTIONS::newLibrary );
|
||||
menuLibrary->Add( ACTIONS::addLibrary );
|
||||
menuLibrary->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm );
|
||||
menuLibrary->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm );
|
||||
|
||||
menuLibrary->AppendSeparator();
|
||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE, _( "&New Footprint..." ),
|
||||
KiBitmap( new_footprint_xpm ) );
|
||||
menuLibrary->Add( _( "New Footprint..." ), ID_MODEDIT_NEW_MODULE, new_footprint_xpm );
|
||||
#ifdef KICAD_SCRIPTING
|
||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE_FROM_WIZARD, _( "&Create Footprint from Wizard..." ),
|
||||
KiBitmap( module_wizard_xpm ) );
|
||||
menuLibrary->Add( _( "Create Footprint from Wizard..." ), ID_MODEDIT_NEW_MODULE_FROM_WIZARD, module_wizard_xpm );
|
||||
#endif
|
||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_IMPORT_PART, _( "&Import Footprint..." ),
|
||||
KiBitmap( import_module_xpm ) );
|
||||
AddMenuItem( menuLibrary.get(), ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ),
|
||||
KiBitmap( paste_xpm ) );
|
||||
menuLibrary->Add( _( "Import Footprint..." ), ID_MODEDIT_IMPORT_PART, import_module_xpm );
|
||||
menuLibrary->Add( _( "Paste Footprint" ), ID_MODEDIT_PASTE_PART, paste_xpm );
|
||||
|
||||
std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_EDIT_MODULE, _( "&Edit Footprint" ),
|
||||
KiBitmap( edit_xpm ) );
|
||||
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||
menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE, _( "&Save" ),
|
||||
KiBitmap( save_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE_AS, _( "Save &As..." ),
|
||||
KiBitmap( save_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_DELETE_PART, _( "&Delete" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_REVERT_PART, _( "Revert" ),
|
||||
KiBitmap( undo_xpm ) );
|
||||
menuPart->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm );
|
||||
menuPart->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm );
|
||||
menuPart->Add( _( "Delete" ), ID_MODEDIT_DELETE_PART, delete_xpm );
|
||||
menuPart->Add( _( "Revert" ), ID_MODEDIT_REVERT_PART, undo_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_CUT_PART, _( "Cut" ),
|
||||
KiBitmap( cut_xpm ) );
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_COPY_PART, _( "Copy" ),
|
||||
KiBitmap( copy_xpm ) );
|
||||
menuPart->Add( _( "Cut" ), ID_MODEDIT_CUT_PART, cut_xpm );
|
||||
menuPart->Add( _( "Copy" ), ID_MODEDIT_COPY_PART, copy_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
AddMenuItem( menuPart.get(), ID_MODEDIT_EXPORT_PART, _( "E&xport Footprint..." ),
|
||||
KiBitmap( export_module_xpm ) );
|
||||
menuPart->Add( _( "Export Footprint..." ), ID_MODEDIT_EXPORT_PART, export_module_xpm );
|
||||
|
||||
// Menu displayed when nothing is selected
|
||||
std::unique_ptr<wxMenu> menuNoSelection = std::make_unique<wxMenu>();
|
||||
AddMenuItem( menuNoSelection.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
|
||||
KiBitmap( new_library_xpm ) );
|
||||
|
||||
AddMenuItem( menuNoSelection.get(), ID_MODEDIT_ADD_LIBRARY, _( "&Add Library..." ),
|
||||
KiBitmap( add_library_xpm ) );
|
||||
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
||||
menuNoSelection->Add( ACTIONS::newLibrary );
|
||||
menuNoSelection->Add( ACTIONS::addLibrary );
|
||||
|
||||
m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
|
||||
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 );
|
||||
|
||||
fileMenu->AddItem( ID_MODEDIT_CREATE_NEW_LIB,
|
||||
_( "New Library..." ),
|
||||
_( "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( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE,
|
||||
AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ),
|
||||
_( "Create a new footprint" ),
|
||||
|
|
|
@ -183,8 +183,6 @@ enum pcbnew_ids
|
|||
|
||||
// ID used in module editor:
|
||||
ID_MODEDIT_CHECK,
|
||||
ID_MODEDIT_CREATE_NEW_LIB,
|
||||
ID_MODEDIT_ADD_LIBRARY,
|
||||
ID_MODEDIT_SAVE,
|
||||
ID_MODEDIT_SAVE_AS,
|
||||
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 )
|
||||
{
|
||||
m_frame->Close( false );
|
||||
|
@ -1040,6 +1054,8 @@ int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
|||
|
||||
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::Quit, ACTIONS::quit.MakeEvent() );
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
int AddLibrary( const TOOL_EVENT& aEvent );
|
||||
int Print( const TOOL_EVENT& aEvent );
|
||||
int Quit( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
|
Loading…
Reference in New Issue