From 5e49517781705f11c4c046e13dac8815b535b2c5 Mon Sep 17 00:00:00 2001 From: Jeff Young <jeff@rokeby.ie> Date: Sun, 9 Jun 2019 22:57:23 +0100 Subject: [PATCH] Move hotkeys to ACTION architecture. --- 3d-viewer/3d_viewer/eda_3d_viewer.h | 3 +- 3d-viewer/3d_viewer/hotkeys.cpp | 2 +- bitmap2component/CMakeLists.txt | 2 + bitmap2component/bitmap2cmp_gui.cpp | 5 +- common/CMakeLists.txt | 1 + common/dialogs/dialog_hotkey_list.cpp | 6 +- common/dialogs/dialog_hotkey_list.h | 13 +- common/dialogs/panel_hotkeys_editor.cpp | 55 +- common/eda_base_frame.cpp | 132 +--- common/eda_draw_frame.cpp | 25 - common/hotkey_store.cpp | 169 ++--- common/hotkeys_basic.cpp | 379 ++++------- common/tool/action_manager.cpp | 69 +- common/tool/actions.cpp | 407 ++++++++---- common/tool/common_control.cpp | 201 ++++++ common/tool/common_tools.cpp | 70 +- common/tool/tool_action.cpp | 18 +- common/tool/tool_base.cpp | 2 +- common/tool/tool_manager.cpp | 10 +- common/tool/zoom_tool.cpp | 9 - common/widgets/widget_hotkey_list.cpp | 127 ++-- cvpcb/cvpcb_mainframe.cpp | 7 +- cvpcb/display_footprints_frame.cpp | 5 +- cvpcb/display_footprints_frame.h | 3 - cvpcb/menubar.cpp | 1 + cvpcb/tools/cvpcb_selection_tool.cpp | 4 +- eeschema/CMakeLists.txt | 2 - eeschema/ee_hotkeys.cpp | 413 ------------ eeschema/ee_hotkeys.h | 87 --- eeschema/eeschema.cpp | 7 - eeschema/eeschema_config.cpp | 58 +- eeschema/libedit/lib_edit_frame.cpp | 10 +- eeschema/libedit/lib_edit_frame.h | 8 +- eeschema/libedit/menubar_libedit.cpp | 3 +- eeschema/libedit/toolbars_libedit.cpp | 4 +- eeschema/menubar.cpp | 4 +- eeschema/sch_edit_frame.cpp | 8 +- eeschema/sch_edit_frame.h | 10 +- eeschema/toolbars_viewlib.cpp | 15 +- eeschema/tools/ee_actions.h | 5 +- eeschema/tools/ee_inspection_tool.cpp | 10 +- eeschema/tools/ee_picker_tool.cpp | 5 +- eeschema/tools/ee_point_editor.cpp | 10 +- eeschema/tools/ee_selection_tool.cpp | 21 +- eeschema/tools/lib_control.cpp | 22 +- eeschema/tools/lib_drawing_tools.cpp | 19 +- eeschema/tools/lib_edit_tool.cpp | 1 - eeschema/tools/lib_move_tool.cpp | 1 - eeschema/tools/lib_pin_tool.cpp | 9 +- eeschema/tools/sch_drawing_tools.cpp | 64 +- eeschema/tools/sch_edit_tool.cpp | 62 +- eeschema/tools/sch_editor_control.cpp | 46 +- eeschema/tools/sch_move_tool.cpp | 9 +- eeschema/tools/sch_wire_bus_tool.cpp | 32 +- eeschema/viewlib_frame.cpp | 9 +- eeschema/viewlib_frame.h | 8 - gerbview/CMakeLists.txt | 1 - gerbview/events_called_functions.cpp | 7 +- gerbview/gerbview.cpp | 6 - gerbview/gerbview_config.cpp | 28 +- gerbview/gerbview_frame.cpp | 7 +- gerbview/gerbview_frame.h | 7 +- gerbview/hotkeys.cpp | 138 ---- gerbview/hotkeys.h | 53 -- gerbview/menubar.cpp | 3 +- gerbview/toolbars_gerber.cpp | 2 +- gerbview/tools/gerbview_actions.h | 3 - gerbview/tools/gerbview_control.cpp | 62 +- gerbview/tools/gerbview_control.h | 3 +- gerbview/tools/gerbview_selection_tool.cpp | 16 +- include/eda_base_frame.h | 46 +- include/eda_draw_frame.h | 33 - include/hotkey_store.h | 127 +--- include/hotkeys_basic.h | 175 +---- include/panel_hotkeys_editor.h | 17 +- include/pgm_base.h | 3 - include/tool/action_manager.h | 14 +- include/tool/actions.h | 14 +- include/tool/common_control.h | 67 ++ include/tool/common_tools.h | 8 +- include/tool/selection_conditions.h | 1 - include/tool/tool_action.h | 116 ++-- include/tool/tool_base.h | 9 +- include/tool/tool_manager.h | 4 +- include/widgets/widget_hotkey_list.h | 13 +- kicad/commandframe.cpp | 5 +- kicad/kicad.cpp | 5 - kicad/kicad_manager_frame.cpp | 57 +- kicad/kicad_manager_frame.h | 12 +- kicad/menubar.cpp | 46 +- kicad/tools/kicad_manager_control.cpp | 24 +- pagelayout_editor/CMakeLists.txt | 1 - pagelayout_editor/hotkeys.cpp | 138 ---- pagelayout_editor/hotkeys.h | 46 -- pagelayout_editor/menubar.cpp | 3 +- pagelayout_editor/pl_editor.cpp | 8 - pagelayout_editor/pl_editor_frame.cpp | 47 +- pagelayout_editor/pl_editor_frame.h | 5 +- pagelayout_editor/properties_frame.cpp | 2 +- pagelayout_editor/toolbars_pl_editor.cpp | 3 +- pagelayout_editor/tools/pl_drawing_tools.cpp | 16 +- pagelayout_editor/tools/pl_edit_tool.cpp | 8 +- pagelayout_editor/tools/pl_editor_control.cpp | 4 +- pagelayout_editor/tools/pl_picker_tool.cpp | 5 +- pagelayout_editor/tools/pl_selection_tool.cpp | 14 +- pcbnew/CMakeLists.txt | 4 +- pcbnew/array_creator.h | 10 +- pcbnew/autorouter/autoplacer_tool.cpp | 4 +- .../dialog_global_edit_tracks_and_vias.cpp | 4 +- pcbnew/dialogs/dialog_set_grid.cpp | 5 +- .../dialogs/dialog_track_via_properties.cpp | 2 +- pcbnew/dialogs/dialog_track_via_properties.h | 24 +- pcbnew/footprint_edit_frame.cpp | 38 +- pcbnew/footprint_edit_frame.h | 8 +- pcbnew/footprint_viewer_frame.cpp | 7 +- pcbnew/footprint_viewer_frame.h | 3 - pcbnew/footprint_wizard_frame.cpp | 11 +- pcbnew/footprint_wizard_frame.h | 3 - pcbnew/hotkeys.cpp | 607 ------------------ pcbnew/hotkeys.h | 150 ----- pcbnew/kicad_clipboard.cpp | 2 +- pcbnew/kicad_clipboard.h | 5 +- pcbnew/menubar_footprint_editor.cpp | 3 +- pcbnew/menubar_pcb_editor.cpp | 3 +- pcbnew/netlist.cpp | 4 +- pcbnew/pcb_edit_frame.cpp | 11 +- pcbnew/pcb_edit_frame.h | 8 +- pcbnew/pcb_layer_box_selector.cpp | 39 +- pcbnew/pcb_layer_box_selector.h | 5 - pcbnew/pcbnew.cpp | 5 - pcbnew/pcbnew_config.cpp | 31 +- pcbnew/router/length_tuner_tool.cpp | 61 +- pcbnew/router/pns_tool_base.cpp | 1 - pcbnew/router/router_tool.cpp | 156 ++--- pcbnew/swig/pcbnew_action_plugins.cpp | 1 + pcbnew/toolbars_footprint_editor.cpp | 2 +- pcbnew/toolbars_footprint_viewer.cpp | 20 +- pcbnew/toolbars_pcb_editor.cpp | 21 +- pcbnew/tools/drawing_tool.cpp | 59 +- pcbnew/tools/drc.cpp | 2 +- pcbnew/tools/edit_tool.cpp | 50 +- pcbnew/tools/footprint_editor_tools.cpp | 38 +- pcbnew/tools/global_edit_tool.cpp | 18 +- pcbnew/tools/microwave_tool.cpp | 10 +- pcbnew/tools/pad_tool.cpp | 15 +- pcbnew/tools/pcb_actions.h | 4 +- pcbnew/tools/pcb_editor_control.cpp | 92 +-- pcbnew/tools/pcbnew_control.cpp | 144 ++--- pcbnew/tools/pcbnew_control.h | 4 - pcbnew/tools/pcbnew_picker_tool.cpp | 5 +- pcbnew/tools/placement_tool.cpp | 16 +- pcbnew/tools/placement_tool.h | 3 +- pcbnew/tools/point_editor.cpp | 5 +- pcbnew/tools/position_relative_tool.cpp | 10 +- pcbnew/tools/position_relative_tool.h | 4 +- pcbnew/tools/selection_tool.cpp | 37 +- pcbnew/tools/zone_filler_tool.cpp | 13 +- qa/common/CMakeLists.txt | 1 - qa/common/test_hotkey_store.cpp | 148 ----- qa/gal/gal_pixel_alignment/CMakeLists.txt | 2 +- qa/pcb_test_window/CMakeLists.txt | 2 +- qa/qa_utils/mocks.cpp | 19 +- 162 files changed, 1851 insertions(+), 4227 deletions(-) create mode 100644 common/tool/common_control.cpp delete mode 100644 eeschema/ee_hotkeys.cpp delete mode 100644 eeschema/ee_hotkeys.h delete mode 100644 gerbview/hotkeys.cpp delete mode 100644 gerbview/hotkeys.h create mode 100644 include/tool/common_control.h delete mode 100644 pagelayout_editor/hotkeys.cpp delete mode 100644 pagelayout_editor/hotkeys.h delete mode 100644 pcbnew/hotkeys.cpp delete mode 100644 pcbnew/hotkeys.h delete mode 100644 qa/common/test_hotkey_store.cpp diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.h b/3d-viewer/3d_viewer/eda_3d_viewer.h index 4051048e01..bc21cd4df0 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer.h @@ -201,7 +201,8 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER void DisplayHotKeys() { - DisplayHotkeyList( this, GetHotkeyConfig() ); + // JEY TODO: need a toolManager.... + DisplayHotkeyList( this, GetToolManager() ); } /** diff --git a/3d-viewer/3d_viewer/hotkeys.cpp b/3d-viewer/3d_viewer/hotkeys.cpp index b04dea3cdf..93d5179029 100644 --- a/3d-viewer/3d_viewer/hotkeys.cpp +++ b/3d-viewer/3d_viewer/hotkeys.cpp @@ -31,7 +31,7 @@ #include "../3d_viewer_id.h" // Define 3D Viewer Hotkeys -static EDA_HOTKEY HkHotkeysHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); +static EDA_HOTKEY HkHotkeysHelp( _HKI( "List Hotkeys" ), wxID_HELP, GR_KB_CTRL + WXK_F1 ); static EDA_HOTKEY Hk3D_PivotCenter( _HKI( "Center pivot rotation (Middle mouse click)" ), 0, WXK_SPACE ); static EDA_HOTKEY Hk3D_MoveLeft( _HKI( "Move board Left" ), ID_POPUP_MOVE3D_LEFT, WXK_LEFT ); static EDA_HOTKEY Hk3D_MoveRight( _HKI( "Move board Right" ), ID_POPUP_MOVE3D_RIGHT, WXK_RIGHT ); diff --git a/bitmap2component/CMakeLists.txt b/bitmap2component/CMakeLists.txt index 1b143d1dda..59e68f4f94 100644 --- a/bitmap2component/CMakeLists.txt +++ b/bitmap2component/CMakeLists.txt @@ -3,6 +3,8 @@ if( COMPILER_SUPPORTS_WSHADOW ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WSHADOW_FLAGS}") endif() +add_definitions( -DBITMAP_2_CMP ) + include_directories( BEFORE ${INC_BEFORE} ) include_directories( ../potrace diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 49c14cf92b..e4e9510885 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -25,20 +25,17 @@ #include <fctsys.h> #include <macros.h> #include <wx/clipbrd.h> - #include <pgm_base.h> #include <confirm.h> #include <gestfich.h> #include <wildcards_and_files_ext.h> #include <bitmap_io.h> +#include <bitmaps.h> #include <build_version.h> -#include <menus_helpers.h> #include <kiway.h> #include <kiface_i.h> - #include <wx/rawbmp.h> #include <potracelib.h> - #include "bitmap2component.h" #include "bitmap2cmp_gui_base.h" diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 19051b5f58..23cff68235 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -376,6 +376,7 @@ set( COMMON_SRCS tool/action_menu.cpp tool/action_toolbar.cpp tool/actions.cpp + tool/common_control.cpp tool/common_tools.cpp tool/conditional_menu.cpp tool/edit_constraints.cpp diff --git a/common/dialogs/dialog_hotkey_list.cpp b/common/dialogs/dialog_hotkey_list.cpp index 3400311721..44c690b43c 100644 --- a/common/dialogs/dialog_hotkey_list.cpp +++ b/common/dialogs/dialog_hotkey_list.cpp @@ -30,15 +30,15 @@ #include <wx/button.h> -DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aDescList ): +DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolMgr ): DIALOG_SHIM( aParent, wxID_ANY, _( "Hotkey List" ) ) { const auto margin = KIUI::GetStdMargin(); auto main_sizer = new wxBoxSizer( wxVERTICAL ); - m_hk_list = new PANEL_HOTKEYS_EDITOR( aParent, this, true, - aDescList, aDescList, {} ); + m_hk_list = new PANEL_HOTKEYS_EDITOR( this, true ); + m_hk_list->AddHotKeys( aToolMgr ); main_sizer->Add( m_hk_list, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, margin ); diff --git a/common/dialogs/dialog_hotkey_list.h b/common/dialogs/dialog_hotkey_list.h index e9c01bb29a..4c871c10e5 100644 --- a/common/dialogs/dialog_hotkey_list.h +++ b/common/dialogs/dialog_hotkey_list.h @@ -32,27 +32,23 @@ #include <dialog_shim.h> -// Private forwards +class TOOL_MANAGER; class PANEL_HOTKEYS_EDITOR; /** - * A dialog that presents the user with a read-only list of hotkeys and - * their current bindings. + * A dialog that presents the user with a read-only list of hotkeys and their current bindings. */ class DIALOG_LIST_HOTKEYS: public DIALOG_SHIM { public: /** - * Construct a hotkey list dialog on the given frame, with a set of hotkeys + * Construct a hotkey list dialog on the given frame * * @param aParent the parent frame - * @param aDescList the list of hotkey sections (each of which has a list - * of hotkeys) to display */ - DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, - EDA_HOTKEY_CONFIG* aDescList ); + DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager ); protected: @@ -62,7 +58,6 @@ protected: bool TransferDataToWindow() override; private: - PANEL_HOTKEYS_EDITOR* m_hk_list; }; diff --git a/common/dialogs/panel_hotkeys_editor.cpp b/common/dialogs/panel_hotkeys_editor.cpp index 21e0082b95..17236b412a 100644 --- a/common/dialogs/panel_hotkeys_editor.cpp +++ b/common/dialogs/panel_hotkeys_editor.cpp @@ -22,16 +22,14 @@ */ #include <panel_hotkeys_editor.h> -#include <eda_base_frame.h> - +#include <kiway_player.h> #include <wx/srchctrl.h> #include <wx/panel.h> #include <wx/button.h> #include <wx/sizer.h> - #include <widgets/button_row_panel.h> #include <widgets/ui_common.h> - +#include <tool/tool_manager.h> static const wxSize default_dialog_size { 500, 350 }; static const wxSize min_dialog_size { -1, 350 }; @@ -57,17 +55,10 @@ static wxSearchCtrl* CreateTextFilterBox( wxWindow* aParent, const wxString& aDe } -PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, - bool aReadOnly, - EDA_HOTKEY_CONFIG* aHotkeys, - EDA_HOTKEY_CONFIG* aShowHotkeys, - const wxString& aNickname ) : +PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( wxWindow* aWindow, bool aReadOnly ) : wxPanel( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ), - m_frame( aFrame ), m_readOnly( aReadOnly ), - m_hotkeys( aHotkeys ), - m_nickname( aNickname ), - m_hotkeyStore( aShowHotkeys ) + m_hotkeyStore() { const auto margin = KIUI::GetStdMargin(); auto mainSizer = new wxBoxSizer( wxVERTICAL ); @@ -93,8 +84,13 @@ PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aW this->Layout(); // Connect Events - filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED, - &PANEL_HOTKEYS_EDITOR::OnFilterSearch, this ); + filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED, &PANEL_HOTKEYS_EDITOR::OnFilterSearch, this ); +} + + +void PANEL_HOTKEYS_EDITOR::AddHotKeys( TOOL_MANAGER* aToolMgr ) +{ + m_toolManagers.push_back( aToolMgr ); } @@ -116,26 +112,19 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer ) [this]( wxCommandEvent& ){ m_hotkeyListCtrl->ResetAllHotkeys( true ); } + }, + { + wxID_ANY, + _( "Import Hotkeys..." ), + _( "Import hotkey definitions from an external file, replacing the current values" ), + [this]( wxCommandEvent& ){ + // JEY TODO: implement hotkey import.... + /*m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname );*/ + } } }; const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = { - { - wxID_ANY, - _( "Import..." ), - _( "Import hotkey definitions from an external file, replacing the current values" ), - [this]( wxCommandEvent& ){ - m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname ); - } - }, - { - wxID_ANY, - _( "Export..." ), - _( "Export these hotkey definitions to an external file" ), - [this]( wxCommandEvent& ){ - m_frame->ExportHotkeyConfigToFile( m_hotkeys, m_nickname ); - } - }, }; auto btnPanel = std::make_unique<BUTTON_ROW_PANEL>( this, l_btn_defs, r_btn_defs ); @@ -146,6 +135,7 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer ) bool PANEL_HOTKEYS_EDITOR::TransferDataToWindow() { + m_hotkeyStore.Init( m_toolManagers ); return m_hotkeyListCtrl->TransferDataToControl(); } @@ -156,7 +146,8 @@ bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow() return false; // save the hotkeys - m_frame->WriteHotkeyConfig( m_hotkeys ); + for( TOOL_MANAGER* toolMgr : m_toolManagers ) + WriteHotKeyConfig( toolMgr->GetActions() ); return true; } diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index f0c9ec7ee5..c799669e29 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -37,14 +37,15 @@ #include <widgets/paged_dialog.h> #include <bitmaps.h> #include <tool/action_menu.h> +#include <tool/common_control.h> +#include <tool/tool_manager.h> #include <menus_helpers.h> +#include <tool/actions.h> /// The default auto save interval is 10 minutes. #define DEFAULT_AUTO_SAVE_INTERVAL 600 -#define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/" - ///@{ /// \ingroup config @@ -66,10 +67,8 @@ static const wxString entryMaximized = "Maximized"; ///< Nonzero iff frame is m BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame ) - EVT_MENU( wxID_HELP, EDA_BASE_FRAME::GetKicadHelp ) - EVT_MENU( wxID_INDEX, EDA_BASE_FRAME::GetKicadHelp ) - EVT_MENU( ID_HELP_GET_INVOLVED, EDA_BASE_FRAME::GetKicadContribute ) - EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) + EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout ) + EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences ) EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook ) EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuOpen ) @@ -290,30 +289,18 @@ void EDA_BASE_FRAME::ReCreateMenuBar() void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar ) { - wxMenu* helpMenu = new wxMenu; + COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>(); + ACTION_MENU* helpMenu = new ACTION_MENU(); - AddMenuItem( helpMenu, wxID_HELP, - _( "&Help" ), - _( "Open product documentation in a web browser" ), - KiBitmap( online_help_xpm ) ); - - AddMenuItem( helpMenu, wxID_INDEX, - _( "&Getting Started with KiCad" ), - _( "Open \"Getting Started in KiCad\" guide for beginners" ), - KiBitmap( help_xpm ) ); - - // JEY TODO: move to actions... - AddMenuItem( helpMenu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, _( "&List Hotkeys..." ), - _( "Displays current hotkeys table and corresponding commands" ), - KiBitmap( hotkeys_xpm ) ); + helpMenu->SetTool( commonControl ); + helpMenu->Add( ACTIONS::help ); + helpMenu->Add( ACTIONS::gettingStarted ); + helpMenu->Add( ACTIONS::listHotKeys ); + helpMenu->Add( ACTIONS::getInvolved ); + helpMenu->AppendSeparator(); - AddMenuItem( helpMenu, ID_HELP_GET_INVOLVED, _( "Get &Involved" ), - _( "Open \"Contribute to KiCad\" in a web browser" ), - KiBitmap( info_xpm ) ); - - helpMenu->AppendSeparator(); - AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) ); + helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm ); aMenuBar->Append( helpMenu, _( "&Help" ) ); } @@ -517,112 +504,33 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, } -void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) -{ - const SEARCH_STACK& search = sys_search(); - - /* We have to get document for beginners, - * or the full specific doc - * if event id is wxID_INDEX, we want the document for beginners. - * else the specific doc file (its name is in Kiface().GetHelpFileName()) - * The document for beginners is the same for all KiCad utilities - */ - if( event.GetId() == wxID_INDEX ) - { - // List of possible names for Getting Started in KiCad - const wxChar* names[2] = { - wxT( "getting_started_in_kicad" ), - wxT( "Getting_Started_in_KiCad" ) - }; - - wxString helpFile; - // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf" - // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf" - for( unsigned ii = 0; ii < arrayDim( names ); ii++ ) - { - helpFile = SearchHelpFileFullPath( search, names[ii] ); - - if( !helpFile.IsEmpty() ) - break; - } - - if( !helpFile ) - { - wxString msg = wxString::Format( _( - "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] ); - wxMessageBox( msg ); - } - else - { - GetAssociatedDocument( this, helpFile ); - } - - return; - } - - wxString base_name = help_name(); - wxString helpFile = SearchHelpFileFullPath( search, base_name ); - - if( !helpFile ) - { - wxString msg = wxString::Format( _( - "Help file \"%s\" could not be found." ), - GetChars( base_name ) - ); - wxMessageBox( msg ); - } - else - { - GetAssociatedDocument( this, helpFile ); - } -} - - -void EDA_BASE_FRAME::GetKicadContribute( wxCommandEvent& event ) -{ - if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) ) - { - wxString msg; - msg.Printf( _( "Could not launch the default browser.\n" - "For information on how to help the KiCad project, visit %s" ), - URL_GET_INVOLVED ); - wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this ); - } -} - - -void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event ) +void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event ) { void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp ShowAboutDialog( this ); } -bool EDA_BASE_FRAME::ShowPreferences( EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys, - const wxString& aHotkeysNickname ) +void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) { PAGED_DIALOG dlg( this, _( "Preferences" ) ); wxTreebook* book = dlg.GetTreebook(); book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) ); - book->AddPage( new PANEL_HOTKEYS_EDITOR( this, book, false, - aHotkeys, aShowHotkeys, aHotkeysNickname ), _( "Hotkeys" ) ); + + PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( book, false ); + book->AddPage( hotkeysPanel, _( "Hotkeys" ) ); for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i ) { KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false ); if( frame ) - frame->InstallPreferences( &dlg ); + frame->InstallPreferences( &dlg, hotkeysPanel ); } if( dlg.ShowModal() == wxID_OK ) - { dlg.Kiway().CommonSettingsChanged(); - return true; - } - - return false; } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index af7f866018..66bbebccf4 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -86,11 +86,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_auxiliaryToolBar = NULL; m_gridSelectBox = NULL; m_zoomSelectBox = NULL; - m_hotkeysDescrList = NULL; m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; m_galCanvas = NULL; - m_actions = NULL; m_toolDispatcher = NULL; m_messagePanel = NULL; m_currentScreen = NULL; @@ -241,17 +239,6 @@ void EDA_DRAW_FRAME::EraseMsgBox() } -bool EDA_DRAW_FRAME::GetToolToggled( int aToolId ) -{ - // Checks all the toolbars and returns true if the given tool id is toggled. - return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) || - ( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) || - ( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) || - ( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) ) - ); -} - - void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) { // No need to update the grid select box if it doesn't exist or the grid setting change @@ -275,18 +262,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) } -int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, - wxString* aFullFileName ) -{ - int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName ); - - if( GetToolManager() ) - GetToolManager()->UpdateHotKeys(); - - return result; -} - - void EDA_DRAW_FRAME::PrintPage( wxDC* aDC ) { wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); diff --git a/common/hotkey_store.cpp b/common/hotkey_store.cpp index 479d9c67ac..2e5bf2071d 100644 --- a/common/hotkey_store.cpp +++ b/common/hotkey_store.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -22,28 +22,82 @@ */ #include <hotkey_store.h> +#include <tool/tool_manager.h> +#include <tool/tool_action.h> -HOTKEY_STORE::HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys ) + +wxString HOTKEY_STORE::GetAppName( TOOL_ACTION* aAction ) { - for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section ) - { - m_hk_sections.push_back( genSection( *section ) ); - } + wxString name( aAction->GetName() ); + return name.BeforeFirst( '.' ); } -HOTKEY_SECTION HOTKEY_STORE::genSection( EDA_HOTKEY_CONFIG& aSection ) +wxString HOTKEY_STORE::GetSectionName( TOOL_ACTION* aAction ) { - HOTKEY_SECTION generated_section { {}, {}, aSection }; + std::map<wxString, wxString> s_AppNames = { + { wxT( "common" ), _( "Common" ) }, + { wxT( "kicad" ), _( "Kicad Manager" ) }, + { wxT( "eeschema" ), _( "Eeschema" ) }, + { wxT( "pcbnew" ), _( "PcbNew" ) }, + { wxT( "plEditor" ), _( "Page Layout Editor" ) } + }; - generated_section.m_name = wxGetTranslation( *aSection.m_Title ); + wxString appName = GetAppName( aAction ); + + if( s_AppNames.count( appName ) ) + return s_AppNames[ appName ]; + else + return wxT( "XXX" + appName ); +} - for( EDA_HOTKEY** info_ptr = aSection.m_HK_InfoList; *info_ptr; ++info_ptr ) + +HOTKEY_STORE::HOTKEY_STORE() +{ +} + + +void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList ) +{ + m_toolManagers = std::move( aToolManagerList ); + + // Collect all action maps into a single master map. This will re-group everything + // and elimate duplicates + std::map<std::string, TOOL_ACTION*> masterMap; + + for( TOOL_MANAGER* toolMgr : m_toolManagers ) { - generated_section.m_hotkeys.push_back( { **info_ptr, *aSection.m_SectionTag } ); + for( const auto& entry : toolMgr->GetActions() ) + { + // Internal actions probably shouldn't be allowed hotkeys + if( entry.second->GetMenuItem().IsEmpty() ) + continue; + + masterMap[ entry.first ] = entry.second; + } } + + wxString currentApp; + HOTKEY_SECTION* currentSection = nullptr; + HOTKEY* currentHotKey = nullptr; - return generated_section; + for( const auto& entry : masterMap ) + { + wxString thisApp = GetAppName( entry.second ); + + if( thisApp != currentApp ) + { + m_hk_sections.emplace_back( HOTKEY_SECTION() ); + currentApp = thisApp; + currentSection = &m_hk_sections.back(); + currentSection->m_SectionName = GetSectionName( entry.second ); + } + + currentSection->m_HotKeys.emplace_back( HOTKEY() ); + currentHotKey = ¤tSection->m_HotKeys.back(); + currentHotKey->m_Parent = entry.second; + currentHotKey->m_EditKeycode = entry.second->GetHotKey(); + } } @@ -53,102 +107,57 @@ std::vector<HOTKEY_SECTION>& HOTKEY_STORE::GetSections() } -CHANGED_HOTKEY* HOTKEY_STORE::FindHotkey( const wxString& aTag, int aCmdId ) -{ - CHANGED_HOTKEY* found_key = nullptr; - - for( auto& section: m_hk_sections ) - { - if( *section.m_section.m_SectionTag != aTag) - continue; - - for( auto& hotkey: section.m_hotkeys ) - { - auto& curr_hk = hotkey.GetCurrentValue(); - if( curr_hk.m_Idcommand == aCmdId ) - { - found_key = &hotkey; - break; - } - } - } - - return found_key; -} - - void HOTKEY_STORE::SaveAllHotkeys() { - for( auto& section: m_hk_sections ) + for( HOTKEY_SECTION& section: m_hk_sections ) { - for( auto& hotkey: section.m_hotkeys ) - { - hotkey.SaveHotkey(); - } + for( HOTKEY& hotkey: section.m_HotKeys ) + hotkey.m_Parent->SetHotKey( hotkey.m_EditKeycode ); } } void HOTKEY_STORE::ResetAllHotkeysToDefault() { - for( auto& section: m_hk_sections ) + for( HOTKEY_SECTION& section: m_hk_sections ) { - for( auto& hotkey: section.m_hotkeys ) - { - hotkey.GetCurrentValue().ResetKeyCodeToDefault(); - } + for( HOTKEY& hotkey: section.m_HotKeys ) + hotkey.m_EditKeycode = hotkey.m_Parent->GetDefaultHotKey(); } } void HOTKEY_STORE::ResetAllHotkeysToOriginal() { - for( auto& section: m_hk_sections ) + for( HOTKEY_SECTION& section: m_hk_sections ) { - for( auto& hotkey: section.m_hotkeys ) - { - hotkey.GetCurrentValue().m_KeyCode = hotkey.GetOriginalValue().m_KeyCode; - } + for( HOTKEY& hotkey: section.m_HotKeys ) + hotkey.m_EditKeycode = hotkey.m_Parent->GetHotKey(); } } -bool HOTKEY_STORE::CheckKeyConflicts( long aKey, const wxString& aSectionTag, - EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect ) +bool HOTKEY_STORE::CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict ) { - EDA_HOTKEY* conflicting_key = nullptr; - EDA_HOTKEY_CONFIG* conflicting_section = nullptr; + wxString sectionName = GetSectionName( aAction ); - for( auto& section: m_hk_sections ) + for( HOTKEY_SECTION& section: m_hk_sections ) { - const auto& sectionTag = *section.m_section.m_SectionTag; - - if( aSectionTag != g_CommonSectionTag - && sectionTag != g_CommonSectionTag - && sectionTag != aSectionTag ) - { - // This key and its conflict candidate are in orthogonal sections, so skip. + if( section.m_SectionName != sectionName ) continue; - } - - // See if any *current* hotkeys are in conflict - for( auto& hotkey: section.m_hotkeys ) + + for( HOTKEY& hotkey: section.m_HotKeys ) { - auto& curr_hk = hotkey.GetCurrentValue(); - if( aKey == curr_hk.m_KeyCode ) + if( hotkey.m_Parent == aAction ) + continue; + + if( hotkey.m_EditKeycode == aKey ) { - conflicting_key = &curr_hk; - conflicting_section = §ion.m_section; + *aConflict = &hotkey; + return true; } } } - - // Write the outparams - if( aConfKey ) - *aConfKey = conflicting_key; - - if( aConfSect ) - *aConfSect = conflicting_section; - - return conflicting_key == nullptr; + + return false; } \ No newline at end of file diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index cef95dacf5..ba1d616256 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -41,14 +41,12 @@ #include <eda_draw_frame.h> #include <tool/tool_manager.h> - #include "dialogs/dialog_hotkey_list.h" - #include <wx/apptrait.h> #include <wx/stdpaths.h> #include <wx/tokenzr.h> +#include <tool/tool_action.h> -#define HOTKEYS_CONFIG_KEY wxT( "Keys" ) wxString g_CommonSectionTag( wxT( "[common]" ) ); @@ -59,23 +57,8 @@ wxString g_CommonSectionTag( wxT( "[common]" ) ); */ EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) : - m_defaultKeyCode( keycode ), m_KeyCode( keycode ), m_InfoMsg( infomsg ), - m_Idcommand( idcommand ), m_IdMenuEvent( idmenuevent ) -{ -} - - -EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) -{ - m_defaultKeyCode = base->m_defaultKeyCode; // initialize default key code - m_KeyCode = base->m_KeyCode; - m_InfoMsg = base->m_InfoMsg; - m_Idcommand = base->m_Idcommand; - m_IdMenuEvent = base->m_IdMenuEvent; -} - - -EDA_HOTKEY_CLIENT_DATA::~EDA_HOTKEY_CLIENT_DATA() + m_KeyCode( keycode ), m_InfoMsg( infomsg ), m_Idcommand( idcommand ), + m_IdMenuEvent( idmenuevent ) { } @@ -174,16 +157,16 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound ) bool found = false; // Assume keycode of 0 is "unassigned" - if( (aKeycode & GR_KB_CTRL) != 0 ) + if( (aKeycode & MD_CTRL) != 0 ) modifier << MODIFIER_CTRL; - if( (aKeycode & GR_KB_ALT) != 0 ) + if( (aKeycode & MD_ALT) != 0 ) modifier << MODIFIER_ALT; - if( (aKeycode & GR_KB_SHIFT) != 0 ) + if( (aKeycode & MD_SHIFT) != 0 ) modifier << MODIFIER_SHIFT; - aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT ); + aKeycode &= ~( MD_CTRL | MD_ALT | MD_SHIFT ); if( (aKeycode > ' ') && (aKeycode < 0x7F ) ) { @@ -217,58 +200,26 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound ) } -/* - * helper function use in AddHotkeyName to calculate an accelerator string - * In some menus, accelerators do not perform exactly the same action as - * the hotkey that perform a similar action. - * this is usually the case when this action uses the current mouse position - * for instance zoom action is ran from the F1 key or the Zoom menu. - * a zoom uses the mouse position from a hot key and not from the menu - * In this case, the accelerator if Shift+<hotkey> - * But for many keys, the Shift modifier is not usable, and the accelerator is Alt+<hotkey> +/** + * AddHotkeyName + * @param aText - the base text on which to append the hotkey + * @param aHotKey - the hotkey keycode + * @param aStyle - IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) + * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips */ -static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) -{ - if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z')) - // We can use Shift+<key> as accelerator and <key> for hot key - aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey; - else - // We must use Alt+<key> as accelerator and <key> for hot key - aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey; -} - - -/* AddHotkeyName - * Add the key name from the Command id value ( m_Idcommand member value) - * aText = a wxString. returns aText + key name - * aList = pointer to a EDA_HOTKEY list of commands - * aCommandId = Command Id value - * aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) - * IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys) - * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips - * Return a wxString (aTest + key name) if key found or aText without modification - */ -wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList, - int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) +wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle ) { wxString msg = aText; - wxString keyname; - - if( aList ) - keyname = KeyNameFromCommandId( aList, aCommandId ); + wxString keyname = KeyNameFromKeyCode( aHotKey ); if( !keyname.IsEmpty() ) { - switch( aShortCutType ) + switch( aStyle ) { case IS_HOTKEY: msg << wxT( "\t" ) << keyname; break; - case IS_ACCELERATOR: - AddModifierToKey( msg, keyname ); - break; - case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); break; @@ -300,6 +251,7 @@ wxString AddHotkeyName( const wxString& aText, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) { + // JEY TODO: obsolete once 3DViewer and ProjectManager are moved over... wxString msg = aText; wxString keyname; EDA_HOTKEY** list; @@ -319,10 +271,6 @@ wxString AddHotkeyName( const wxString& aText, msg << wxT( "\t" ) << keyname; break; - case IS_ACCELERATOR: - AddModifierToKey( msg, keyname ); - break; - case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); break; @@ -352,6 +300,7 @@ wxString AddHotkeyName( const wxString& aText, */ wxString KeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId ) { + // JEY TODO: obsolete once 3DViewer and ProjectManager are moved over... wxString keyname; for( ; *aList != nullptr; aList++ ) @@ -387,28 +336,28 @@ int KeyCodeFromKeyName( const wxString& keyname ) wxString prefix; int modifier = 0; - while( 1 ) + while( true ) { prefix.Empty(); if( key.StartsWith( MODIFIER_CTRL_BASE ) ) { - modifier |= GR_KB_CTRL; + modifier |= MD_CTRL; prefix = MODIFIER_CTRL_BASE; } else if( key.StartsWith( MODIFIER_CMD_MAC ) ) { - modifier |= GR_KB_CTRL; + modifier |= MD_CTRL; prefix = MODIFIER_CMD_MAC; } else if( key.StartsWith( MODIFIER_ALT ) ) { - modifier |= GR_KB_ALT; + modifier |= MD_ALT; prefix = MODIFIER_ALT; } else if( key.StartsWith( MODIFIER_SHIFT ) ) { - modifier |= GR_KB_SHIFT; + modifier |= MD_SHIFT; prefix = MODIFIER_SHIFT; } else @@ -440,139 +389,104 @@ int KeyCodeFromKeyName( const wxString& keyname ) } -/* DisplayHotkeyList - * Displays the current hotkey list - * aList = a EDA_HOTKEY_CONFIG list(Null terminated) +/* + * DisplayHotkeyList + * Displays the hotkeys registered with the given tool manager. */ -void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList ) +void DisplayHotkeyList( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager ) { - DIALOG_LIST_HOTKEYS dlg( aFrame, aDescList ); + DIALOG_LIST_HOTKEYS dlg( aParent, aToolManager ); dlg.ShowModal(); } -/** - * Function GetDescriptorFromHotkey - * Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function - * @param aKey = key code (ascii value, or wxWidgets value for function keys - * @param aList = pointer to a EDA_HOTKEY list of commands - * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List - */ -EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList ) +int WriteHotKeyConfig( std::map<std::string, TOOL_ACTION*> aActionMap ) { - for( ; *aList != nullptr; aList++ ) - { - EDA_HOTKEY* hk_decr = *aList; + wxFileName fn( "user" ); - if( hk_decr->m_KeyCode == aKey ) - return hk_decr; - } + fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); + fn.SetPath( GetKicadConfigPath() ); - return nullptr; -} - - -EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList ) -{ - for( ; *aList != nullptr; aList++ ) - { - EDA_HOTKEY* hk_decr = *aList; - - if( hk_decr->m_Idcommand == aCommand ) - return hk_decr; - } - - return nullptr; -} - - -int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, - wxString* aFullFileName ) -{ - wxString msg; - wxString keyname, infokey; - FILE* file; - - msg = wxT( "$hotkey list\n" ); - - // Print the current hotkey list - EDA_HOTKEY** list; - - for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ ) - { - if( aDescList->m_Title ) - { - msg += wxT( "# " ); - msg += *aDescList->m_Title; - msg += wxT( "\n" ); - } - - msg += *aDescList->m_SectionTag; - msg += wxT( "\n" ); - - list = aDescList->m_HK_InfoList; - - for( ; *list != nullptr; list++ ) - { - EDA_HOTKEY* hk_decr = *list; - msg += wxT( "shortcut " ); - keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode ); - AddDelimiterString( keyname ); - infokey = hk_decr->m_InfoMsg; - AddDelimiterString( infokey ); - msg += keyname + wxT( ": " ) + infokey + wxT( "\n" ); - } - } - - msg += wxT( "$Endlist\n" ); - - if( aFullFileName ) - file = wxFopen( *aFullFileName, wxT( "wt" ) ); - else - { - wxString configName( ConfigBaseName() ); - if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME ) - configName = EESCHEMA_HOTKEY_NAME; - else if( configName == PCB_EDIT_FRAME_NAME || - configName == FOOTPRINT_EDIT_FRAME_NAME ) - configName = PCBNEW_HOTKEY_NAME; - - wxFileName fn( configName ); - fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); - fn.SetPath( GetKicadConfigPath() ); - file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); - } - - if( file ) - { - wxFputs( msg, file ); - fclose( file ); - } - else - { - msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) ); + if( !wxFile::Exists( fn.GetFullPath() ) ) return 0; + + wxFile file( fn.GetFullPath(), wxFile::OpenMode::read ); + + if( !file.IsOpened() ) // There is a problem to open file + return 0; + + // Read entire hotkey set into map + // + wxString input; + std::map<wxString, int> hotkeys; + + file.ReadAll( &input ); + input.Replace( "\r\n", "\n" ); // Convert Windows files to Unix line-ends + wxStringTokenizer fileTokenizer( input, "\n", wxTOKEN_STRTOK ); + + while( fileTokenizer.HasMoreTokens() ) + { + wxStringTokenizer lineTokenizer( fileTokenizer.GetNextToken(), "\t" ); + + wxString cmdName = lineTokenizer.GetNextToken(); + wxString keyName = lineTokenizer.GetNextToken(); + + if( !cmdName.IsEmpty() ) + hotkeys[ cmdName ] = KeyCodeFromKeyName( keyName ); } + file.Close(); + + // Overlay this app's hotkey definitions onto the map + // + for( const auto& ii : aActionMap ) + { + if( ii.second->GetHotKey() ) + hotkeys[ ii.first ] = ii.second->GetHotKey(); + } + + // Write entire hotkey set + // + file.Open( fn.GetFullPath(), wxFile::OpenMode::write ); + + for( const auto& ii : hotkeys ) + file.Write( wxString::Format( "%s\t%s\n", ii.first, KeyNameFromKeyCode( ii.second ) ) ); + + file.Close(); + return 1; } -int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList, - const bool aDefaultLocation ) +int ReadLegacyHotkeyConfig( const wxString& aAppname, std::map<std::string, int>& aMap ) +{ + // For Eeschema and Pcbnew frames, we read the new combined file. + // For other kifaces, we read the frame-based file + if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME ) + { + return ReadLegacyHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aMap ); + } + else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME ) + { + return ReadLegacyHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aMap ); + } + + return ReadLegacyHotkeyConfigFile( aAppname, aMap ); +} + + +int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string, int>& aMap ) { wxFileName fn( aFilename ); - if( aDefaultLocation ) - { - fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); - fn.SetPath( GetKicadConfigPath() ); - } + fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); + fn.SetPath( GetKicadConfigPath() ); if( !wxFile::Exists( fn.GetFullPath() ) ) return 0; wxFile cfgfile( fn.GetFullPath() ); + if( !cfgfile.IsOpened() ) // There is a problem to open file return 0; @@ -591,43 +505,7 @@ int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* a data.Replace( "\\n", "\n", true ); // parse - ParseHotkeyConfig( data, aDescList, aFilename ); - - // cleanup - cfgfile.Close(); - return 1; -} - - -int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescList ) -{ - // For Eeschema and Pcbnew frames, we read the new combined file. - // For other kifaces, we read the frame-based file - if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME ) - { - return ReadHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aDescList ); - } - else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME ) - { - return ReadHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aDescList ); - } - - return ReadHotkeyConfigFile( aAppname, aDescList ); -} - - -/* Function ParseHotkeyConfig - * the input format is: shortcut "key" "function" - * lines starting by # are ignored (comments) - * lines like [xxx] are tags (example: [common] or [libedit] which identify sections - */ -void ParseHotkeyConfig( const wxString& data, - struct EDA_HOTKEY_CONFIG* aDescList, - const wxString& aAppname ) -{ - // Read the config wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); - EDA_HOTKEY** CurrentHotkeyList = nullptr; while( tokenizer.HasMoreTokens() ) { @@ -636,38 +514,11 @@ void ParseHotkeyConfig( const wxString& data, wxString line_type = lineTokenizer.GetNextToken(); - if( line_type[0] == '#' ) //comment + if( line_type[0] == '#' ) // comment continue; - if( line_type[0] == '[' ) // A tag is found. search infos in list - { - CurrentHotkeyList = nullptr; - EDA_HOTKEY_CONFIG* DList = aDescList; - - for( ; DList->m_HK_InfoList; DList++ ) - { - if( *DList->m_SectionTag == line_type ) - { - CurrentHotkeyList = DList->m_HK_InfoList; - break; - } - } - + if( line_type[0] == '[' ) // tags ignored reading legacy hotkeys continue; - } - - // Do not accept hotkey assignments from hotkey files that don't match the application - if( aAppname == LIB_EDIT_FRAME_NAME && line_type == wxT( "[eeschema]" ) ) - CurrentHotkeyList = nullptr; - - if( aAppname == SCH_EDIT_FRAME_NAME && line_type == wxT( "[libedit]" ) ) - CurrentHotkeyList = nullptr; - - if( aAppname == PCB_EDIT_FRAME_NAME && line_type == wxT( "[footprinteditor]" ) ) - CurrentHotkeyList = nullptr; - - if( aAppname == FOOTPRINT_EDIT_FRAME_NAME && line_type == wxT( "[pcbnew]" ) ) - CurrentHotkeyList = nullptr; if( line_type == wxT( "$Endlist" ) ) break; @@ -675,9 +526,6 @@ void ParseHotkeyConfig( const wxString& data, if( line_type != wxT( "shortcut" ) ) continue; - if( CurrentHotkeyList == nullptr ) - continue; - // Get the key name lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK ); wxString keyname = lineTokenizer.GetNextToken(); @@ -687,22 +535,13 @@ void ParseHotkeyConfig( const wxString& data, // Get the command name wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' ); - // search the hotkey in current hotkey list - for( EDA_HOTKEY** list = CurrentHotkeyList; *list != nullptr; list++ ) - { - EDA_HOTKEY* hk_decr = *list; - - if( hk_decr->m_InfoMsg == fctname ) - { - int keycode = KeyCodeFromKeyName( keyname ); - - if( keycode != KEY_NON_FOUND ) // means the key name is found in list or unassigned - hk_decr->m_KeyCode = keycode; - - break; - } - } + // Add the pair to the map + aMap[ fctname.ToStdString() ] = KeyCodeFromKeyName( keyname ); } + + // cleanup + cfgfile.Close(); + return 1; } @@ -729,8 +568,9 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList, if( filename.IsEmpty() ) return; - ::ReadHotkeyConfigFile( filename, aDescList, false ); - WriteHotkeyConfig( aDescList ); + // JEY TODO: implement import of new hotkeys file.... + //::ReadHotkeyConfigFile( filename, aDescList, false ); + //WriteHotKeyConfig( aDescList ); SetMruPath( wxFileName( filename ).GetPath() ); } @@ -761,7 +601,8 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList, if( filename.IsEmpty() ) return; - WriteHotkeyConfig( aDescList, &filename ); + // JEY TODO: make this whole routine oboslete? + //WriteHotKeyConfig( aDescList, &filename ); SetMruPath( wxFileName( filename ).GetPath() ); } diff --git a/common/tool/action_manager.cpp b/common/tool/action_manager.cpp index a0bfb8afdd..fda2d77493 100644 --- a/common/tool/action_manager.cpp +++ b/common/tool/action_manager.cpp @@ -178,6 +178,12 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const } +const std::map<std::string, TOOL_ACTION*>& ACTION_MANAGER::GetActions() +{ + return m_actionNameIndex; +} + + int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const { std::map<int, int>::const_iterator it = m_hotkeys.find( aAction.GetId() ); @@ -191,13 +197,19 @@ int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const void ACTION_MANAGER::UpdateHotKeys() { + std::map<std::string, int> legacyHotKeyMap; + std::map<std::string, int> userHotKeyMap; + m_actionHotKeys.clear(); m_hotkeys.clear(); + + ReadLegacyHotkeyConfig( m_toolMgr->GetEditFrame()->ConfigBaseName(), legacyHotKeyMap ); + // JEY TODO: read user hotkey config... for( const auto& actionName : m_actionNameIndex ) { TOOL_ACTION* action = actionName.second; - int hotkey = processHotKey( action ); + int hotkey = processHotKey( action, legacyHotKeyMap, userHotKeyMap ); if( hotkey <= 0 ) continue; @@ -218,53 +230,20 @@ void ACTION_MANAGER::UpdateHotKeys() m_actionHotKeys[hotkey].push_back( action ); m_hotkeys[action->GetId()] = hotkey; - } } -int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction ) +int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction, std::map<std::string, int> aLegacyMap, + std::map<std::string, int> aHotKeyMap ) { - int hotkey = aAction->getDefaultHotKey(); - - if( ( hotkey & TOOL_ACTION::LEGACY_HK ) ) - { - hotkey = hotkey & ~TOOL_ACTION::LEGACY_HK; // it leaves only HK_xxx identifier - - auto frame = static_cast<EDA_DRAW_FRAME*>( m_toolMgr->GetEditFrame() ); - EDA_HOTKEY* hk_desc = nullptr; - - if( frame ) - hk_desc = frame->GetHotKeyDescription( hotkey ); - - if( hk_desc ) - { - hotkey = hk_desc->m_KeyCode; - - // Convert modifiers to the ones used by the Tool Framework - if( hotkey & GR_KB_CTRL ) - { - hotkey &= ~GR_KB_CTRL; - hotkey |= MD_CTRL; - } - - if( hotkey & GR_KB_ALT ) - { - hotkey &= ~GR_KB_ALT; - hotkey |= MD_ALT; - } - - if( hotkey & GR_KB_SHIFT ) - { - hotkey &= ~GR_KB_SHIFT; - hotkey |= MD_SHIFT; - } - } - else - { - hotkey = 0; - } - } - - return hotkey; + aAction->m_hotKey = aAction->m_defaultHotKey; + + if( !aAction->m_legacyName.empty() && aLegacyMap.count( aAction->m_legacyName ) ) + aAction->m_hotKey = aLegacyMap[ aAction->m_legacyName ]; + + if( aHotKeyMap.count( aAction->m_name ) ) + aAction->m_hotKey = aHotKeyMap[ aAction->m_name ]; + + return aAction->m_hotKey; } diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 5fe3ea5dc4..1d45512d8b 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -1,415 +1,564 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 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 2 + * 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 here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <fctsys.h> #include <tool/actions.h> -#include <hotkeys.h> #include <bitmaps.h> // These members are static in class ACTIONS: Build them here: TOOL_ACTION ACTIONS::doNew( "common.Control.new", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_NEW ), + AS_GLOBAL, + MD_CTRL + 'N', LEGACY_HK_NAME( "New" ), _( "New..." ), _( "Create a new document in the editor" ), new_generic_xpm ); TOOL_ACTION ACTIONS::newLibrary( "common.Control.newLibrary", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "New Library..." ), _( "Create a new library folder" ), new_generic_xpm ); TOOL_ACTION ACTIONS::addLibrary( "common.Control.addLibrary", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Add Library..." ), _( "Add an existing library folder" ), add_library_xpm ); TOOL_ACTION ACTIONS::open( "common.Control.open", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_OPEN ), + AS_GLOBAL, + MD_CTRL + 'O', LEGACY_HK_NAME( "Open" ), _( "Open..." ), _( "Open existing document" ), directory_xpm ); TOOL_ACTION ACTIONS::save( "common.Control.save", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SAVE ), + AS_GLOBAL, + MD_CTRL + 'S', LEGACY_HK_NAME( "Save" ), _( "Save" ), _( "Save changes" ), save_xpm ); TOOL_ACTION ACTIONS::saveAs( "common.Control.saveAs", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SAVEAS ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'S', LEGACY_HK_NAME( "Save As" ), _( "Save As..." ), _( "Save current document to another location" ), save_as_xpm ); TOOL_ACTION ACTIONS::saveCopyAs( "common.Control.saveCopyAs", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Save Copy As..." ), _( "Save a copy of the current document to another location" ), save_as_xpm ); TOOL_ACTION ACTIONS::saveAll( "common.Control.saveAll", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Save All" ), _( "Save all changes" ), save_xpm ); TOOL_ACTION ACTIONS::revert( "common.Control.revert", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Revert" ), _( "Throw away changes" ), undo_xpm ); TOOL_ACTION ACTIONS::pageSettings( "common.Control.pageSettings", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Page Settings..." ), _( "Settings for paper size and frame references" ), sheetset_xpm ); TOOL_ACTION ACTIONS::print( "common.Control.print", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_PRINT ), + AS_GLOBAL, + MD_CTRL + 'P', LEGACY_HK_NAME( "Print" ), _( "Print..." ), _( "Print" ), print_button_xpm ); TOOL_ACTION ACTIONS::plot( "common.Control.plot", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Plot..." ), _( "Plot" ), plot_xpm ); TOOL_ACTION ACTIONS::quit( "common.Control.quit", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", // Not currently in use due to wxWidgets crankiness _( "Quit" ), _( "Close the current editor" ), exit_xpm ); // Generic Edit Actions TOOL_ACTION ACTIONS::cancelInteractive( "common.Interactive.cancel", - AS_GLOBAL, 0, // ESC key is handled in the dispatcher + AS_GLOBAL, + 0, "", // ESC key is handled in the dispatcher _( "Cancel" ), _( "Cancel current tool" ), cancel_xpm, AF_NONE ); TOOL_ACTION ACTIONS::updateMenu( "common.Interactive.updateMenu", - AS_GLOBAL, 0, "", "" ); // This is an internal event + AS_GLOBAL ); TOOL_ACTION ACTIONS::undo( "common.Interactive.undo", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UNDO ), + AS_GLOBAL, + MD_CTRL + 'Z', LEGACY_HK_NAME( "Undo" ), _( "Undo" ), _( "Undo last edit" ), undo_xpm ); TOOL_ACTION ACTIONS::redo( "common.Interactive.redo", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_REDO ), + AS_GLOBAL, +#if defined( __WXMAC__ ) + MD_SHIFT + MD_CTRL + 'Z', +#else + MD_CTRL + 'Y', +#endif + LEGACY_HK_NAME( "Redo" ), _( "Redo" ), _( "Redo last edit" ), redo_xpm ); TOOL_ACTION ACTIONS::cut( "common.Interactive.cut", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CUT ), + AS_GLOBAL, + MD_CTRL + 'X', LEGACY_HK_NAME( "Cut" ), _( "Cut" ), _( "Cut selected item(s) to clipboard" ), cut_xpm ); TOOL_ACTION ACTIONS::copy( "common.Interactive.copy", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_COPY ), + AS_GLOBAL, + MD_CTRL + 'C', LEGACY_HK_NAME( "Copy" ), _( "Copy" ), _( "Copy selected item(s) to clipboard" ), copy_xpm ); TOOL_ACTION ACTIONS::paste( "common.Interactive.paste", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_PASTE ), + AS_GLOBAL, + MD_CTRL + 'V', LEGACY_HK_NAME( "Paste" ), _( "Paste" ), _( "Paste clipboard into schematic" ), paste_xpm ); TOOL_ACTION ACTIONS::duplicate( "common.Interactive.duplicate", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ), + AS_GLOBAL, + MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate" ), _( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm ); TOOL_ACTION ACTIONS::doDelete( "common.Interactive.delete", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ), + AS_GLOBAL, + WXK_DELETE, LEGACY_HK_NAME( "Delete Item" ), _( "Delete" ), _( "Deletes selected item(s)" ), delete_xpm ); TOOL_ACTION ACTIONS::activatePointEditor( "common.Control.activatePointEditor", - AS_GLOBAL, 0, "", "" ); // This is an internal event + AS_GLOBAL ); TOOL_ACTION ACTIONS::find( "common.Interactive.find", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FIND ), + AS_GLOBAL, + MD_CTRL + 'F', LEGACY_HK_NAME( "Find" ), _( "Find" ), _( "Find text" ), find_xpm ); TOOL_ACTION ACTIONS::findAndReplace( "common.Interactive.findAndReplace", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_REPLACE ), + AS_GLOBAL, + MD_CTRL + MD_ALT + 'F', LEGACY_HK_NAME( "Find and Replace" ), _( "Find and Replace" ), _( "Find and replace text" ), find_replace_xpm ); TOOL_ACTION ACTIONS::findNext( "common.Interactive.findNext", - AS_GLOBAL, 0, + AS_GLOBAL, + WXK_F5, LEGACY_HK_NAME( "Find Next" ), _( "Find Next" ), _( "Find next match" ), find_xpm ); TOOL_ACTION ACTIONS::findNextMarker( "common.Interactive.findNextMarker", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FIND_NEXT_MARKER ), + AS_GLOBAL, + MD_SHIFT + WXK_F5, LEGACY_HK_NAME( "Find Next Marker" ), _( "Find Next Marker" ), "", find_xpm ); TOOL_ACTION ACTIONS::replaceAndFindNext( "common.Interactive.replaceAndFindNext", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Replace and Find Next" ), _( "Replace current match and find next" ), find_replace_xpm ); TOOL_ACTION ACTIONS::replaceAll( "common.Interactive.replaceAll", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Replace All" ), _( "Replace all matches" ), find_replace_xpm ); TOOL_ACTION ACTIONS::updateFind( "common.Control.updateFind", - AS_GLOBAL, 0, "", "" ); // This is an internal event + AS_GLOBAL ); // View Controls TOOL_ACTION ACTIONS::zoomRedraw( "common.Control.zoomRedraw", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_REDRAW ), + AS_GLOBAL, +#if defined( __WXMAC__ ) + MD_CTRL + 'R', +#else + WXK_F3, +#endif + LEGACY_HK_NAME( "Zoom Redraw" ), _( "Refresh" ), "", zoom_redraw_xpm ); +TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen", + AS_GLOBAL, +#if defined( __WXMAC__ ) + MD_CTRL + '0', +#else + WXK_HOME, +#endif + LEGACY_HK_NAME( "Zoom Auto" ), + _( "Zoom to Fit" ), "", + zoom_fit_in_page_xpm ); + TOOL_ACTION ACTIONS::zoomIn( "common.Control.zoomIn", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_IN ), + AS_GLOBAL, +#if defined( __WXMAC__ ) + MD_CTRL + '+', +#else + WXK_F1, +#endif + LEGACY_HK_NAME( "Zoom In" ), _( "Zoom In" ), "", zoom_in_xpm ); TOOL_ACTION ACTIONS::zoomOut( "common.Control.zoomOut", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_OUT ), + AS_GLOBAL, +#if defined( __WXMAC__ ) + MD_CTRL + '-', +#else + WXK_F2, +#endif + LEGACY_HK_NAME( "Zoom Out" ), _( "Zoom Out" ), "", zoom_out_xpm ); TOOL_ACTION ACTIONS::zoomInCenter( "common.Control.zoomInCenter", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Zoom In" ), "", zoom_in_xpm ); TOOL_ACTION ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter", - AS_GLOBAL, 0, + AS_GLOBAL, + 0, "", _( "Zoom Out" ), "", zoom_out_xpm ); TOOL_ACTION ACTIONS::zoomCenter( "common.Control.zoomCenter", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_CENTER ), + AS_GLOBAL, + WXK_F4, LEGACY_HK_NAME( "Zoom Center" ), _( "Center" ), "", zoom_center_on_screen_xpm ); -TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_AUTO ), - _( "Zoom to Fit" ), "", - zoom_fit_in_page_xpm ); - TOOL_ACTION ACTIONS::zoomTool( "common.Control.zoomTool", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_SELECTION ), + AS_GLOBAL, + MD_CTRL + WXK_F5, LEGACY_HK_NAME( "Zoom to Selection" ), _( "Zoom to Selection" ), "", zoom_area_xpm, AF_ACTIVATE ); TOOL_ACTION ACTIONS::zoomPreset( "common.Control.zoomPreset", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION ACTIONS::centerContents( "common.Control.centerContents", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); // Cursor control TOOL_ACTION ACTIONS::cursorUp( "common.Control.cursorUp", - AS_GLOBAL, WXK_UP, - "", "", NULL, AF_NONE, (void*) CURSOR_UP ); + AS_GLOBAL, + WXK_UP, "", + "", "", + nullptr, AF_NONE, (void*) CURSOR_UP ); TOOL_ACTION ACTIONS::cursorDown( "common.Control.cursorDown", - AS_GLOBAL, WXK_DOWN, - "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); + AS_GLOBAL, + WXK_DOWN, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_DOWN ); TOOL_ACTION ACTIONS::cursorLeft( "common.Control.cursorLeft", - AS_GLOBAL, WXK_LEFT, - "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); + AS_GLOBAL, + WXK_LEFT, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_LEFT ); TOOL_ACTION ACTIONS::cursorRight( "common.Control.cursorRight", - AS_GLOBAL, WXK_RIGHT, - "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); + AS_GLOBAL, + WXK_RIGHT, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_RIGHT ); TOOL_ACTION ACTIONS::cursorUpFast( "common.Control.cursorUpFast", - AS_GLOBAL, MD_CTRL + WXK_UP, - "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); + AS_GLOBAL, + MD_CTRL + WXK_UP, "", + "", "", + nullptr, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); TOOL_ACTION ACTIONS::cursorDownFast( "common.Control.cursorDownFast", - AS_GLOBAL, MD_CTRL + WXK_DOWN, - "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); + AS_GLOBAL, + MD_CTRL + WXK_DOWN, "", + "", "" , + nullptr, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); TOOL_ACTION ACTIONS::cursorLeftFast( "common.Control.cursorLeftFast", - AS_GLOBAL, MD_CTRL + WXK_LEFT, - "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); + AS_GLOBAL, + MD_CTRL + WXK_LEFT, "", + "", "" , + nullptr, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); TOOL_ACTION ACTIONS::cursorRightFast( "common.Control.cursorRightFast", - AS_GLOBAL, MD_CTRL + WXK_RIGHT, - "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); - + AS_GLOBAL, + MD_CTRL + WXK_RIGHT, "", + "", "" , + nullptr, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); TOOL_ACTION ACTIONS::cursorClick( "common.Control.cursorClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_CLICK ); + AS_GLOBAL, + WXK_RETURN, LEGACY_HK_NAME( "Mouse Left Click" ), + "", "", + nullptr, AF_NONE, (void*) CURSOR_CLICK ); TOOL_ACTION ACTIONS::cursorDblClick( "common.Control.cursorDblClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_DCLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK ); + AS_GLOBAL, + WXK_END, LEGACY_HK_NAME( "Mouse Left Double Click" ), + "", "", + nullptr, AF_NONE, (void*) CURSOR_DBL_CLICK ); TOOL_ACTION ACTIONS::panUp( "common.Control.panUp", - AS_GLOBAL, MD_SHIFT + WXK_UP, - "", "", NULL, AF_NONE, (void*) CURSOR_UP ); + AS_GLOBAL, + MD_SHIFT + WXK_UP, "", + "", "", + nullptr, AF_NONE, (void*) CURSOR_UP ); TOOL_ACTION ACTIONS::panDown( "common.Control.panDown", - AS_GLOBAL, MD_SHIFT + WXK_DOWN, - "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); + AS_GLOBAL, + MD_SHIFT + WXK_DOWN, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_DOWN ); TOOL_ACTION ACTIONS::panLeft( "common.Control.panLeft", - AS_GLOBAL, MD_SHIFT + WXK_LEFT, - "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); + AS_GLOBAL, + MD_SHIFT + WXK_LEFT, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_LEFT ); TOOL_ACTION ACTIONS::panRight( "common.Control.panRight", - AS_GLOBAL, MD_SHIFT + WXK_RIGHT, - "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); + AS_GLOBAL, + MD_SHIFT + WXK_RIGHT, "", + "", "" , + nullptr, AF_NONE, (void*) CURSOR_RIGHT ); // Grid control TOOL_ACTION ACTIONS::gridFast1( "common.Control.gridFast1", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID1 ), + AS_GLOBAL, + MD_ALT + '1', LEGACY_HK_NAME( "Switch Grid To Fast Grid1" ), "", "" ); TOOL_ACTION ACTIONS::gridFast2( "common.Control.gridFast2", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID2 ), + AS_GLOBAL, + MD_ALT + '2', LEGACY_HK_NAME( "Switch Grid To Fast Grid2" ), "", "" ); TOOL_ACTION ACTIONS::gridNext( "common.Control.gridNext", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_NEXT ), + AS_GLOBAL, + 'N', LEGACY_HK_NAME( "Switch Grid To Next" ), "", "" ); TOOL_ACTION ACTIONS::gridPrev( "common.Control.gridPrev", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_PREVIOUS ), + AS_GLOBAL, MD_SHIFT + 'N', LEGACY_HK_NAME( "Switch Grid To Previous" ), "", "" ); TOOL_ACTION ACTIONS::gridSetOrigin( "common.Control.gridSetOrigin", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SET_GRID_ORIGIN ), + AS_GLOBAL, + 'S', LEGACY_HK_NAME( "Set Grid Origin" ), _( "Grid Origin" ), _( "Set the grid origin point" ), grid_select_axis_xpm ); TOOL_ACTION ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_GRID_ORIGIN ), + AS_GLOBAL, + 'Z', LEGACY_HK_NAME( "Reset Grid Origin" ), "", "" ); TOOL_ACTION ACTIONS::gridPreset( "common.Control.gridPreset", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION ACTIONS::toggleGrid( "common.Control.toggleGrid", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Grid" ), _( "Display grid dots or lines in the edit window" ), grid_xpm ); TOOL_ACTION ACTIONS::gridProperties( "common.Control.gridProperties", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Grid Properties..." ), _( "Set grid dimensions" ), grid_select_xpm ); TOOL_ACTION ACTIONS::imperialUnits( "common.Control.imperialUnits", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Imperial" ), _( "Use inches and mils" ), unit_inch_xpm ); TOOL_ACTION ACTIONS::metricUnits( "common.Control.metricUnits", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Metric" ), _( "Use millimeters" ), unit_mm_xpm ); TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ), + AS_GLOBAL, + MD_CTRL + 'U', LEGACY_HK_NAME( "Switch Units" ), _( "Switch units" ), _( "Switch between inches and millimeters" ), unit_mm_xpm ); TOOL_ACTION ACTIONS::togglePolarCoords( "common.Control.togglePolarCoords", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Polar Coordinates" ), _( "Switch between polar and cartesian coordinate systems" ), polar_coord_xpm ); TOOL_ACTION ACTIONS::resetLocalCoords( "common.Control.resetLocalCoords", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ), + AS_GLOBAL, + ' ', LEGACY_HK_NAME( "Reset Local Coordinates" ), "", "" ); TOOL_ACTION ACTIONS::toggleCursor( "common.Control.toggleCursor", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_TOGGLE_CURSOR ), + AS_GLOBAL, + MD_CTRL + MD_SHIFT + 'X', LEGACY_HK_NAME( "Toggle Cursor Display (Modern Toolset only)" ), _( "Always Show Cursor" ), _( "Display crosshairs even in selection tool" ), cursor_xpm ); TOOL_ACTION ACTIONS::toggleCursorStyle( "common.Control.toggleCursorStyle", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Full-Window Crosshairs" ), _( "Switch display of full-window crosshairs" ), cursor_shape_xpm ); TOOL_ACTION ACTIONS::highContrastMode( "common.Control.highContrastMode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_HIGHCONTRAST_MODE ), + AS_GLOBAL, + MD_CTRL + 'H', LEGACY_HK_NAME( "Toggle High Contrast Mode" ), _( "High Contrast Mode" ), _( "Use high contrast display mode" ), contrast_mode_xpm ); -TOOL_ACTION ACTIONS::highContrastInc( "common.Control.highContrastInc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHCONTRAST_INC ), - "", "" ); - -TOOL_ACTION ACTIONS::highContrastDec( "common.Control.highContrastDec", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHCONTRAST_DEC ), - "", "" ); - TOOL_ACTION ACTIONS::selectionTool( "common.InteractiveSelection.selectionTool", - AS_GLOBAL, 0, _( "Select item(s)" ), "", + AS_GLOBAL, 0, "", + _( "Select item(s)" ), "", cursor_xpm, AF_ACTIVATE ); TOOL_ACTION ACTIONS::measureTool( "common.InteractiveEdit.measureTool", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ), + AS_GLOBAL, + MD_CTRL + MD_SHIFT + 'M', LEGACY_HK_NAME( "Measure Distance (Modern Toolset only)" ), _( "Measure Tool" ), _( "Interactively measure distance between points" ), measurement_xpm, AF_ACTIVATE ); TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_3D_VIEWER ), + AS_GLOBAL, + MD_ALT + '3', LEGACY_HK_NAME( "3D Viewer" ), _( "3D Viewer" ), _( "Show 3D viewer window" ), three_d_xpm ); TOOL_ACTION ACTIONS::showSymbolBrowser( "common.Control.showSymbolBrowser", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Symbol Library Browser" ), _( "Browse symbol libraries" ), library_browse_xpm ); TOOL_ACTION ACTIONS::showSymbolEditor( "common.Control.showSymbolEditor", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Symbol Editor" ), _( "Create, delete and edit symbols" ), libedit_xpm ); TOOL_ACTION ACTIONS::showFootprintBrowser( "common.Control.showFootprintBrowser", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Footprint Library Browser" ), _( "Browse footprint libraries" ), modview_icon_xpm ); TOOL_ACTION ACTIONS::showFootprintEditor( "common.Control.showFootprintEditor", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Footprint Editor" ), _( "Create, delete and edit footprints" ), module_editor_xpm ); TOOL_ACTION ACTIONS::updatePcbFromSchematic( "common.Control.updatePcbFromSchematic", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UPDATE_PCB_FROM_SCH ), + AS_GLOBAL, + WXK_F8, LEGACY_HK_NAME( "Update PCB from Schematic" ), _( "Update PCB from Schematic..." ), _( "Push changes from schematic to PCB" ), update_pcb_from_sch_xpm ); -TOOL_ACTION ACTIONS::configurePaths( "common.Control.configurePaths", - AS_GLOBAL, 0, - _( "Configure Paths..." ), _( "Edit path configuration environment variables" ), - path_xpm ); - -TOOL_ACTION ACTIONS::showSymbolLibTable( "common.Control.showSymbolLibTable", - AS_GLOBAL, 0, - _( "Manage Symbol Libraries..." ), - _( "Edit the global and project symbol library lists" ), - library_table_xpm ); - -TOOL_ACTION ACTIONS::showFootprintLibTable( "common.Control.showFootprintLibTable", - AS_GLOBAL, 0, - _( "Manage Footprint Libraries..." ), - _( "Edit the global and project footprint library lists" ), - library_table_xpm ); - TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_OPENGL ), + AS_GLOBAL, +#ifdef __WXMAC__ + MD_ALT + WXK_F11, +#else + WXK_F11, +#endif + LEGACY_HK_NAME( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), _( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ), tools_xpm ); TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_CAIRO ), + AS_GLOBAL, +#ifdef __WXMAC__ + MD_ALT + WXK_F12, +#else + WXK_F12, +#endif + LEGACY_HK_NAME( "Switch to Modern Toolset with software graphics (fall-back)" ), _( "Standard Graphics" ), _( "Use software graphics (fall-back)" ), tools_xpm ); +TOOL_ACTION ACTIONS::configurePaths( "common.SuiteControl.configurePaths", + AS_GLOBAL, 0, "", + _( "Configure Paths..." ), _( "Edit path configuration environment variables" ), + path_xpm ); + +TOOL_ACTION ACTIONS::showSymbolLibTable( "common.SuiteControl.showSymbolLibTable", + AS_GLOBAL, 0, "", + _( "Manage Symbol Libraries..." ), + _( "Edit the global and project symbol library lists" ), + library_table_xpm ); + +TOOL_ACTION ACTIONS::showFootprintLibTable( "common.SuiteControl.showFootprintLibTable", + AS_GLOBAL, 0, "", + _( "Manage Footprint Libraries..." ), + _( "Edit the global and project footprint library lists" ), + library_table_xpm ); + +TOOL_ACTION ACTIONS::gettingStarted( "common.SuiteControl.gettingStarted", + AS_GLOBAL, 0, "", + _( "Getting Started with KiCad" ), + _( "Open \"Getting Started in KiCad\" guide for beginners" ), + help_xpm ); + +TOOL_ACTION ACTIONS::help( "common.SuiteControl.help", + AS_GLOBAL, 0, "", + _( "Help" ), + _( "Open product documentation in a web browser" ), + online_help_xpm ); + +TOOL_ACTION ACTIONS::listHotKeys( "common.SuiteControl.listHotKeys", + AS_GLOBAL, + MD_CTRL + WXK_F1, LEGACY_HK_NAME( "List Hotkeys" ), + _( "List Hotkeys..." ), + _( "Displays current hotkeys table and corresponding commands" ), + hotkeys_xpm ); + +TOOL_ACTION ACTIONS::getInvolved( "common.SuiteControl.getInvolved", + AS_GLOBAL, 0, "", + _( "Get Involved" ), + _( "Open \"Contribute to KiCad\" in a web browser" ), + info_xpm ); + // System-wide selection Events diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp new file mode 100644 index 0000000000..c6438842ad --- /dev/null +++ b/common/tool/common_control.cpp @@ -0,0 +1,201 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2014-2016 CERN + * @author Maciej Suminski <maciej.suminski@cern.ch> + * + * 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 2 + * 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 here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <bitmaps.h> +#include <tool/actions.h> +#include <tool/tool_manager.h> +#include <eda_draw_frame.h> +#include <class_draw_panel_gal.h> +#include <view/view.h> +#include <view/view_controls.h> +#include <gal/graphics_abstraction_layer.h> +#include <base_screen.h> +#include <tool/common_control.h> +#include <id.h> +#include <project.h> +#include <kiface_i.h> +#include <dialog_configure_paths.h> +#include <eda_doc.h> + +#define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/" + + +void COMMON_CONTROL::Reset( RESET_REASON aReason ) +{ + m_frame = getEditFrame<EDA_BASE_FRAME>(); +} + + +int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent ) +{ + KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB ); + kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() ); + return 0; +} + + +int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent ) +{ + if( aEvent.IsAction( &ACTIONS::showSymbolLibTable ) ) + { + KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH ); + kiface->CreateWindow( m_frame, DIALOG_SCH_LIBRARY_TABLE, &m_frame->Kiway() ); + } + else if( aEvent.IsAction( &ACTIONS::showFootprintLibTable ) ) + { + KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB ); + kiface->CreateWindow( m_frame, DIALOG_PCB_LIBRARY_TABLE, &m_frame->Kiway() ); + } + + return 0; +} + + +int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent ) +{ + FRAME_T playerType = FRAME_SCH_VIEWER; + + if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) ) + playerType = FRAME_SCH_VIEWER; + else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) ) + playerType = FRAME_SCH_LIB_EDITOR; + else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) ) + playerType = FRAME_PCB_MODULE_VIEWER; + else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) ) + playerType = FRAME_PCB_MODULE_EDITOR; + else + wxFAIL_MSG( "ShowPlayer(): unexpected request" ); + + KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true ); + + // Needed on Windows, other platforms do not use it, but it creates no issue + if( editor->IsIconized() ) + editor->Iconize( false ); + + editor->Raise(); + + // Raising the window does not set the focus on Linux. This should work on + // any platform. + if( wxWindow::FindFocus() != editor ) + editor->SetFocus(); + + return 0; +} + + +int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) +{ + const SEARCH_STACK& search = m_frame->sys_search(); + wxString helpFile; + wxString msg; + + /* We have to get document for beginners, + * or the full specific doc + * if event id is wxID_INDEX, we want the document for beginners. + * else the specific doc file (its name is in Kiface().GetHelpFileName()) + * The document for beginners is the same for all KiCad utilities + */ + if( aEvent.IsAction( &ACTIONS::gettingStarted ) ) + { + // List of possible names for Getting Started in KiCad + const wxChar* names[2] = { + wxT( "getting_started_in_kicad" ), + wxT( "Getting_Started_in_KiCad" ) + }; + + // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf" + // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf" + for( auto& name : names ) + { + helpFile = SearchHelpFileFullPath( search, name ); + + if( !helpFile.IsEmpty() ) + break; + } + + if( !helpFile ) + { + msg = wxString::Format( _( "Html or pdf help file \n%s\nor\n%s could not be found." ), + names[0], names[1] ); + wxMessageBox( msg ); + return -1; + } + } + else + { + wxString base_name = m_frame->help_name(); + + helpFile = SearchHelpFileFullPath( search, base_name ); + + if( !helpFile ) + { + msg = wxString::Format( _( "Help file \"%s\" could not be found." ), base_name ); + wxMessageBox( msg ); + return -1; + } + } + + GetAssociatedDocument( m_frame, helpFile ); + return 0; +} + + +int COMMON_CONTROL::ListHotKeys( const TOOL_EVENT& aEvent ) +{ + DisplayHotkeyList( m_frame, m_toolMgr ); + return 0; +} + + +int COMMON_CONTROL::GetInvolved( const TOOL_EVENT& aEvent ) +{ + if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) ) + { + wxString msg; + msg.Printf( _( "Could not launch the default browser.\n" + "For information on how to help the KiCad project, visit %s" ), + URL_GET_INVOLVED ); + wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, m_frame ); + } + return 0; +} + + +void COMMON_CONTROL::setTransitions() +{ + Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() ); + Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() ); + Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() ); + Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() ); + Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() ); + Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() ); + Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() ); + + Go( &COMMON_CONTROL::ShowHelp, ACTIONS::gettingStarted.MakeEvent() ); + Go( &COMMON_CONTROL::ShowHelp, ACTIONS::help.MakeEvent() ); + Go( &COMMON_CONTROL::ListHotKeys, ACTIONS::listHotKeys.MakeEvent() ); + Go( &COMMON_CONTROL::GetInvolved, ACTIONS::getInvolved.MakeEvent() ); +} + + diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 9086927c55..df6e3cdd4e 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -31,7 +31,6 @@ #include <view/view_controls.h> #include <gal/graphics_abstraction_layer.h> #include <base_screen.h> -#include <hotkeys.h> #include <tool/common_tools.h> #include <id.h> #include <project.h> @@ -494,31 +493,6 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent ) } -int COMMON_TOOLS::ConfigurePaths( const TOOL_EVENT& aEvent ) -{ - KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB ); - kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() ); - return 0; -} - - -int COMMON_TOOLS::ShowLibraryTable( const TOOL_EVENT& aEvent ) -{ - if( aEvent.IsAction( &ACTIONS::showSymbolLibTable ) ) - { - KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH ); - kiface->CreateWindow( m_frame, DIALOG_SCH_LIBRARY_TABLE, &m_frame->Kiway() ); - } - else if( aEvent.IsAction( &ACTIONS::showFootprintLibTable ) ) - { - KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB ); - kiface->CreateWindow( m_frame, DIALOG_PCB_LIBRARY_TABLE, &m_frame->Kiway() ); - } - - return 0; -} - - int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent ) { if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) ) @@ -532,38 +506,6 @@ int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent ) } -int COMMON_TOOLS::ShowPlayer( const TOOL_EVENT& aEvent ) -{ - FRAME_T playerType = FRAME_SCH_VIEWER; - - if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) ) - playerType = FRAME_SCH_VIEWER; - else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) ) - playerType = FRAME_SCH_LIB_EDITOR; - else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) ) - playerType = FRAME_PCB_MODULE_VIEWER; - else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) ) - playerType = FRAME_PCB_MODULE_EDITOR; - else - wxFAIL_MSG( "ShowPlayer(): unexpected request" ); - - KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true ); - - // Needed on Windows, other platforms do not use it, but it creates no issue - if( editor->IsIconized() ) - editor->Iconize( false ); - - editor->Raise(); - - // Raising the window does not set the focus on Linux. This should work on - // any platform. - if( wxWindow::FindFocus() != editor ) - editor->SetFocus(); - - return 0; -} - - void COMMON_TOOLS::setTransitions() { // Cursor control @@ -594,33 +536,27 @@ void COMMON_TOOLS::setTransitions() Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() ); Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() ); Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() ); - Go( &COMMON_TOOLS::CenterContents, ACTIONS::centerContents.MakeEvent() ); + // Grid control Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() ); Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() ); Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() ); Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() ); Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() ); + // Units and coordinates Go( &COMMON_TOOLS::ImperialUnits, ACTIONS::imperialUnits.MakeEvent() ); Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() ); Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() ); Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() ); Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() ); + // Misc Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() ); Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() ); - - Go( &COMMON_TOOLS::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() ); - Go( &COMMON_TOOLS::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() ); - Go( &COMMON_TOOLS::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() ); Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::acceleratedGraphics.MakeEvent() ); Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::standardGraphics.MakeEvent() ); - Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() ); - Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() ); - Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() ); - Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() ); } diff --git a/common/tool/tool_action.cpp b/common/tool/tool_action.cpp index 8693bcdd07..d0f3ad129b 100644 --- a/common/tool/tool_action.cpp +++ b/common/tool/tool_action.cpp @@ -28,11 +28,19 @@ #include <algorithm> TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope, - int aDefaultHotKey, const wxString& aMenuItem, const wxString& aMenuDesc, - const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) : - m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ), - m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ), - m_icon( aIcon ), m_id( -1 ), m_flags( aFlags ), m_param( aParam ) + int aDefaultHotKey, const std::string& aLegacyHotKeyName, + const wxString& aMenuText, const wxString& aTooltip, + const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) : + m_name( aName ), + m_scope( aScope ), + m_defaultHotKey( aDefaultHotKey ), + m_legacyName( aLegacyHotKeyName ), + m_menuText( aMenuText ), + m_tooltip( aTooltip ), + m_icon( aIcon ), + m_id( -1 ), + m_flags( aFlags ), + m_param( aParam ) { ACTION_MANAGER::GetActionList().push_back( this ); } diff --git a/common/tool/tool_base.cpp b/common/tool/tool_base.cpp index 828b919add..3f7c6e4aec 100644 --- a/common/tool/tool_base.cpp +++ b/common/tool/tool_base.cpp @@ -45,7 +45,7 @@ KIGFX::VIEW_CONTROLS* TOOL_BASE::getViewControls() const } -wxWindow* TOOL_BASE::getEditFrameInt() const +EDA_BASE_FRAME* TOOL_BASE::getEditFrameInt() const { return m_toolMgr->GetEditFrame(); } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 3ee4a8a94f..43cb53a8e3 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -26,7 +26,6 @@ #include <map> #include <stack> #include <algorithm> - #include <core/optional.h> #include <wx/event.h> @@ -311,6 +310,12 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara } +const std::map<std::string, TOOL_ACTION*>& TOOL_MANAGER::GetActions() +{ + return m_actionMgr->GetActions(); +} + + int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) { return m_actionMgr->GetHotKey( aAction ); @@ -464,6 +469,8 @@ void TOOL_MANAGER::InitTools() } } + m_actionMgr->UpdateHotKeys(); + ResetTools( TOOL_BASE::RUN ); } @@ -863,7 +870,6 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView, m_view = aView; m_viewControls = aViewControls; m_frame = aFrame; - m_actionMgr->UpdateHotKeys(); } diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index abd7e0eb1c..a81e607bd8 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -46,15 +46,6 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason ) int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) { - // This method is called both when the zoom tool is activated (on) or deactivated (off) - wxMenuBar* menu = m_frame->GetMenuBar(); - - bool zoom_tool_is_on = m_frame->GetToolToggled( ID_ZOOM_SELECTION ) || - ( menu && menu->IsChecked( ID_ZOOM_SELECTION ) ); - - if( !zoom_tool_is_on ) // This is a tool deselection: do nothing - return 0; - m_frame->SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); while( auto evt = Wait() ) diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index aed93cbbd4..c0e6d85237 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com> - * Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2019 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 @@ -23,11 +23,9 @@ */ #include <cctype> - #include <widgets/widget_hotkey_list.h> - #include <wx/statline.h> - +#include <tool/tool_action.h> #include <eda_draw_frame.h> #include <dialog_shim.h> @@ -59,14 +57,14 @@ enum ID_WHKL_MENU_IDS */ class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData { - CHANGED_HOTKEY& m_changed_hotkey; + HOTKEY& m_changed_hotkey; public: - WIDGET_HOTKEY_CLIENT_DATA( CHANGED_HOTKEY& aChangedHotkey ) + WIDGET_HOTKEY_CLIENT_DATA( HOTKEY& aChangedHotkey ) : m_changed_hotkey( aChangedHotkey ) {} - CHANGED_HOTKEY& GetChangedHotkey() { return m_changed_hotkey; } + HOTKEY& GetChangedHotkey() { return m_changed_hotkey; } }; @@ -245,17 +243,17 @@ public: * * @return true on match (or if filter is disabled) */ - bool FilterMatches( const EDA_HOTKEY& aHotkey ) const + bool FilterMatches( const HOTKEY& aHotkey ) const { if( !m_valid ) return true; // Match in the (translated) filter string - const auto normedInfo = wxGetTranslation( aHotkey.m_InfoMsg ).Upper(); + const auto normedInfo = wxGetTranslation( aHotkey.m_Parent->GetMenuItem() ).Upper(); if( normedInfo.Contains( m_normalised_filter_str ) ) return true; - const wxString keyName = KeyNameFromKeyCode( aHotkey.m_KeyCode ); + const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode ); if( keyName.Upper().Contains( m_normalised_filter_str ) ) return true; @@ -275,25 +273,11 @@ WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetHKClientData( wxTreeListItem a { wxClientData* data = GetItemData( aItem ); - if( !data ) - { - return NULL; - } - else - { + if( data ) return static_cast<WIDGET_HOTKEY_CLIENT_DATA*>( data ); - } } - else - { - return NULL; - } -} - -WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetSelHKClientData() -{ - return GetHKClientData( GetSelection() ); + return nullptr; } @@ -318,15 +302,17 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData() if( hkdata ) { const auto& changed_hk = hkdata->GetChangedHotkey(); - const EDA_HOTKEY& hk = changed_hk.GetCurrentValue(); - - wxString key_text = KeyNameFromKeyCode( hk.m_KeyCode ); + wxString label = changed_hk.m_Parent->GetMenuItem(); + wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode ); + if( label.IsEmpty() ) + label = changed_hk.m_Parent->GetName(); + // mark unsaved changes - if( changed_hk.HasUnsavedChange() ) + if( changed_hk.m_EditKeycode != changed_hk.m_Parent->GetHotKey() ) key_text += " *"; - SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) ); + SetItemText( i, 0, label ); SetItemText( i, 1, key_text); } } @@ -337,23 +323,16 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData() } -void WIDGET_HOTKEY_LIST::changeHotkey( CHANGED_HOTKEY& aHotkey, long aKey ) +void WIDGET_HOTKEY_LIST::changeHotkey( HOTKEY& aHotkey, long aKey ) { // See if this key code is handled in hotkeys names list bool exists; KeyNameFromKeyCode( aKey, &exists ); - auto& curr_hk = aHotkey.GetCurrentValue(); - - if( exists && curr_hk.m_KeyCode != aKey ) + if( exists && aHotkey.m_EditKeycode != aKey ) { - const auto& tag = aHotkey.GetSectionTag(); - bool can_update = ResolveKeyConflicts( aKey, tag ); - - if( can_update ) - { - curr_hk.m_KeyCode = aKey; - } + if( ResolveKeyConflicts( aHotkey.m_Parent, aKey ) ) + aHotkey.m_EditKeycode = aKey; } } @@ -387,9 +366,8 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem ) return; auto& changed_hk = hkdata->GetChangedHotkey(); - const auto& orig_hk = changed_hk.GetOriginalValue(); - changeHotkey( changed_hk, orig_hk.m_KeyCode ); + changeHotkey( changed_hk, changed_hk.m_Parent->GetHotKey() ); UpdateFromClientData(); } @@ -403,7 +381,7 @@ void WIDGET_HOTKEY_LIST::ResetItemToDefault( wxTreeListItem aItem ) auto& changed_hk = hkdata->GetChangedHotkey(); - changeHotkey( changed_hk, changed_hk.GetCurrentValue().GetDefaultKeyCode() ); + changeHotkey( changed_hk, changed_hk.m_Parent->GetDefaultHotKey() ); UpdateFromClientData(); } @@ -469,45 +447,38 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent ) } -bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectionTag ) +bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey ) { - EDA_HOTKEY* conflicting_key = nullptr; - EDA_HOTKEY_CONFIG* conflicting_section = nullptr; + HOTKEY* conflictingHotKey = nullptr; - m_hk_store.CheckKeyConflicts( aKey, aSectionTag, &conflicting_key, &conflicting_section ); + m_hk_store.CheckKeyConflicts( aAction, aKey, &conflictingHotKey ); - if( conflicting_key != nullptr ) - { - wxString info = wxGetTranslation( conflicting_key->m_InfoMsg ); - wxString msg = wxString::Format( - _( "\"%s\" is already assigned to \"%s\" in section \"%s\". Are you sure you want " - "to change its assignment?" ), - KeyNameFromKeyCode( aKey ), GetChars( info ), - *(conflicting_section->m_Title) ); - - wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT ); - - if( dlg.ShowModal() == wxID_YES ) - { - // Reset the other hotkey - conflicting_key->m_KeyCode = 0; - UpdateFromClientData(); - return true; - } - else - { - return false; - } - } - else + if( !conflictingHotKey ) + return true; + + TOOL_ACTION* conflictingAction = conflictingHotKey->m_Parent; + wxString msg = wxString::Format( _( "\"%s\" is already assigned to \"%s\" in section \"%s\". " + "Are you sure you want to change its assignment?" ), + KeyNameFromKeyCode( aKey ), + conflictingAction->GetMenuItem(), + HOTKEY_STORE::GetSectionName( conflictingAction ) ); + + wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT ); + + if( dlg.ShowModal() == wxID_YES ) { + // Reset the other hotkey + conflictingHotKey->m_EditKeycode = 0; + UpdateFromClientData(); return true; } + + return false; } WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore, - bool aReadOnly ) + bool aReadOnly ) : TWO_COLUMN_TREE_LIST( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ), m_hk_store( aHotkeyStore ), m_readOnly( aReadOnly ) @@ -573,14 +544,14 @@ void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr ) HOTKEY_FILTER filter( aFilterStr ); - for( auto& section: m_hk_store.GetSections() ) + for( HOTKEY_SECTION& section: m_hk_store.GetSections() ) { // Create parent tree item - wxTreeListItem parent = AppendItem( GetRootItem(), section.m_name ); + wxTreeListItem parent = AppendItem( GetRootItem(), section.m_SectionName ); - for( auto& hotkey: section.m_hotkeys ) + for( HOTKEY& hotkey: section.m_HotKeys ) { - if( filter.FilterMatches( hotkey.GetCurrentValue() ) ) + if( filter.FilterMatches( hotkey ) ) { wxTreeListItem item = AppendItem( parent, wxEmptyString ); SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) ); diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index c088f4e956..56b3716bd0 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -23,10 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file cvpcb_mainframe.cpp - */ - #include <fctsys.h> #include <build_version.h> #include <kiway_express.h> @@ -48,7 +44,7 @@ #include <invoke_pcb_dialog.h> #include <display_footprints_frame.h> #include <cvpcb_id.h> - +#include <tool/action_toolbar.h> #include <cvpcb_mainframe.h> wxSize const FRAME_MIN_SIZE_DU( 350, 250 ); @@ -65,7 +61,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER ) // Menu events EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::OnSaveAndContinue ) EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit ) - EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths ) EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList ) // Toolbar events diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 1323760b14..d74edae477 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -25,8 +25,6 @@ #include <fctsys.h> #include <common.h> -#include <gal/graphics_abstraction_layer.h> -#include <class_draw_panel_gal.h> #include <pcb_draw_panel_gal.h> #include <confirm.h> #include <macros.h> @@ -36,7 +34,6 @@ #include <lib_id.h> #include <fp_lib_table.h> #include <eda_dockart.h> -#include <io_mgr.h> #include <class_module.h> #include <class_board.h> #include <pcb_painter.h> @@ -44,10 +41,10 @@ #include <display_footprints_frame.h> #include <cvpcb_id.h> #include <listboxes.h> -#include <3d_viewer/eda_3d_viewer.h> #include <view/view.h> #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/cvpcb_actions.h> diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index 8a9e405442..e87c90b2fc 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -102,9 +102,6 @@ public: void InstallOptionsDisplay( wxCommandEvent& event ); MODULE* Get_Module( const wxString& CmpName ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override { return NULL; } - /* SaveCopyInUndoList() virtual * currently: do nothing in CvPcb. * but but be defined because it is a pure virtual in PCB_BASE_FRAME diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index daeb1de829..5e53b78d0f 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -55,6 +55,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() wxMenu* preferencesMenu = new wxMenu; // Path configuration edit dialog. + // JEY TODO: fix these.... AddMenuItem( preferencesMenu, ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ), diff --git a/cvpcb/tools/cvpcb_selection_tool.cpp b/cvpcb/tools/cvpcb_selection_tool.cpp index c7d7d7c095..630302d56f 100644 --- a/cvpcb/tools/cvpcb_selection_tool.cpp +++ b/cvpcb/tools/cvpcb_selection_tool.cpp @@ -20,10 +20,8 @@ #include <limits> #include <functional> using namespace std::placeholders; - #include <class_draw_panel_gal.h> #include <view/view.h> -#include <hotkeys.h> #include <bitmaps.h> #include <tool/tool_event.h> #include <tool/tool_manager.h> @@ -34,7 +32,7 @@ using namespace std::placeholders; TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index a777b7c002..bf831a7549 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -31,7 +31,6 @@ include_directories( ${INC_AFTER} ) - set( EESCHEMA_DLGS dialogs/dialog_annotate.cpp dialogs/dialog_annotate_base.cpp @@ -153,7 +152,6 @@ set( EESCHEMA_SRCS generate_alias_info.cpp getpart.cpp hierarch.cpp - ee_hotkeys.cpp lib_arc.cpp lib_bezier.cpp lib_circle.cpp diff --git a/eeschema/ee_hotkeys.cpp b/eeschema/ee_hotkeys.cpp deleted file mode 100644 index 5f22fe09ab..0000000000 --- a/eeschema/ee_hotkeys.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net> - * Copyright (C) 2004-2019 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <fctsys.h> -#include <id.h> -#include <eeschema_id.h> -#include <ee_hotkeys.h> -#include <sch_edit_frame.h> -#include <sch_draw_panel.h> - -#include <general.h> -#include <lib_edit_frame.h> -#include <viewlib_frame.h> -#include <class_libentry.h> -#include <sch_junction.h> -#include <sch_line.h> -#include <sch_component.h> -#include <sch_sheet.h> - -#include <dialogs/dialog_schematic_find.h> -#include <tool/tool_manager.h> -#include <tools/ee_selection_tool.h> -#include <tools/ee_actions.h> - -// Remark: the hotkey message info is used as keyword in hotkey config files and -// as comments in help windows, therefore translated only when displayed -// they are marked _HKI to be extracted by translation tools -// See hotkeys_basic.h for more info - - -/* How to add a new hotkey: - * add a new id in the enum hotkey_id_command like MY_NEW_ID_FUNCTION (see - * hotkeys.h). - * add a new EDA_HOTKEY entry like: - * static EDA_HOTKEY HkMyNewEntry(_HKI("Command Label"), MY_NEW_ID_FUNCTION, - * default key value); - * _HKI("Command Label") is the name used in hotkey list display, and the - * identifier in the hotkey list file - * MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in - * OnHotKey() function. - * default key value is the default hotkey for this command. Can be overridden - * by the user hotkey list file - * add the HkMyNewEntry pointer in the schematic_Hotkey_List list or the - * libEdit_Hotkey_List list or common_Hotkey_List if the same command is - * added both in Eeschema and libedit) - * Add the new code in the switch in OnHotKey() function. - * when the variable itemInEdit is true, an item is currently edited. - * This can be useful if the new function cannot be executed while an item is - * currently being edited - * ( For example, one cannot start a new wire when a component is moving.) - * - * Note: If an hotkey is a special key be sure the corresponding wxWidget - * keycode (WXK_XXXX) is handled in the hotkey_name_descr - * s_Hotkey_Name_List list (see hotkeys_basic.cpp) and see this list - * for some ascii keys (space ...) - * - * Key modifier are: GR_KB_CTRL GR_KB_ALT - */ - - -// Common commands - -// Fit on Screen -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomAuto( _HKI( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME ); -#else -static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0' ); -#endif - -static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); - -// Refresh Screen -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); -#else -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL + 'R' ); -#endif - -// Zoom In -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -#else -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+' ); -#endif - -// Zoom Out -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); -#else -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' ); -#endif - -static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL ); - -static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); -static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), HK_PREFERENCES, GR_KB_CTRL + ',', - wxID_PREFERENCES ); -static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkLeaveSheet( _HKI( "Leave Sheet" ), HK_LEAVE_SHEET, GR_KB_ALT + WXK_BACK ); - -static EDA_HOTKEY HkSwitchGridToNext( _HKI( "Switch Grid To Next" ), - HK_SWITCH_GRID_TO_NEXT, 'N' ); -static EDA_HOTKEY HkSwitchGridToPrevious( _HKI( "Switch Grid To Previous" ), - HK_SWITCH_GRID_TO_PREVIOUS, 'N' + GR_KB_SHIFT ); - -// mouse click command: -static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, - ID_MOUSE_CLICK ); -static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END, - ID_MOUSE_DOUBLECLICK ); - -// Schematic editor -static EDA_HOTKEY HkBeginWire( _HKI( "Begin Wire" ), HK_BEGIN_WIRE, 'W' ); -static EDA_HOTKEY HkBeginBus( _HKI( "Begin Bus" ), HK_BEGIN_BUS, 'B' ); -static EDA_HOTKEY HkEndLineWireBus( _HKI( "End Line Wire Bus" ), HK_END_CURR_LINEWIREBUS, 'K' ); - -static EDA_HOTKEY HkAddLabel( _HKI( "Add Label" ), HK_ADD_LABEL, 'L' ); -static EDA_HOTKEY HkAddHierarchicalLabel( _HKI( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H' ); -static EDA_HOTKEY HkAddGlobalLabel( _HKI( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'H' ); -static EDA_HOTKEY HkAddJunction( _HKI( "Add Junction" ), HK_ADD_JUNCTION, 'J' ); -static EDA_HOTKEY HkAddComponent( _HKI( "Add Symbol" ), HK_ADD_NEW_COMPONENT, 'A' ); -static EDA_HOTKEY HkAddPower( _HKI( "Add Power" ), HK_ADD_NEW_POWER, 'P' ); -static EDA_HOTKEY HkAddNoConn( _HKI( "Add No Connect Flag" ), HK_ADD_NOCONN_FLAG, 'Q' ); -static EDA_HOTKEY HkAddHierSheet( _HKI( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S' ); -static EDA_HOTKEY HkAddBusEntry( _HKI( "Add Bus Entry" ), HK_ADD_BUS_ENTRY, '/' ); -static EDA_HOTKEY HkAddWireEntry( _HKI( "Add Wire Entry" ), HK_ADD_WIRE_ENTRY, 'Z' ); -static EDA_HOTKEY HkAddGraphicPolyLine( _HKI( "Add Graphic PolyLine" ), HK_ADD_GRAPHIC_POLYLINE, 'I' ); -static EDA_HOTKEY HkAddGraphicText( _HKI( "Add Graphic Text" ), HK_ADD_GRAPHIC_TEXT, 'T' ); -static EDA_HOTKEY HkMirrorY( _HKI( "Mirror Y" ), HK_MIRROR_Y, 'Y' ); -static EDA_HOTKEY HkMirrorX( _HKI( "Mirror X" ), HK_MIRROR_X, 'X' ); -static EDA_HOTKEY HkRotate( _HKI( "Rotate Item" ), HK_ROTATE, 'R' ); -static EDA_HOTKEY HkEdit( _HKI( "Edit Item" ), HK_EDIT, 'E' ); -static EDA_HOTKEY HkEditValue( _HKI( "Edit Symbol Value" ), HK_EDIT_COMPONENT_VALUE, 'V' ); -static EDA_HOTKEY HkEditReference( _HKI( "Edit Symbol Reference" ), HK_EDIT_COMPONENT_REFERENCE, 'U' ); -static EDA_HOTKEY HkEditFootprint( _HKI( "Edit Symbol Footprint" ), HK_EDIT_COMPONENT_FOOTPRINT, 'F' ); -static EDA_HOTKEY HkShowDatasheet( _HKI( "Show Datasheet" ), HK_SHOW_DATASHEET, 'D' ); -static EDA_HOTKEY HkEditWithLibedit( _HKI( "Edit with Symbol Editor" ), HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL ); - -static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL ); - -static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE, 'M' ); -static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G' ); -static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT ); -static EDA_HOTKEY HkDelete( _HKI( "Delete Item" ), HK_DELETE, WXK_DELETE ); - -static EDA_HOTKEY HkFind( _HKI( "Find" ), HK_FIND, 'F' + GR_KB_CTRL ); -static EDA_HOTKEY HkReplace( _HKI( "Find and Replace" ), HK_REPLACE, 'F' + GR_KB_CTRL + GR_KB_ALT ); - -static EDA_HOTKEY HkFindNextItem( _HKI( "Find Next" ), HK_FIND_NEXT, WXK_F5 ); -static EDA_HOTKEY HkFindNextMarker( _HKI( "Find Next Marker" ), HK_FIND_NEXT_MARKER, WXK_F5 + GR_KB_SHIFT ); -static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION, GR_KB_CTRL + WXK_F5, - ID_ZOOM_SELECTION ); - -// Special keys for library editor: -static EDA_HOTKEY HkCreatePin( _HKI( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' ); -static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); - -// Autoplace fields -static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O' ); - -static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UPDATE_PCB_FROM_SCH, WXK_F8 ); - -// Selection -static EDA_HOTKEY HkSelectNode( _HKI( "Select Node" ), HK_SELECT_NODE, GR_KB_ALT + '3' ); -static EDA_HOTKEY HkSelectConnection( _HKI( "Select Connection" ), HK_SELECT_CONNECTION, GR_KB_ALT + '4' ); - -// Higtlight connection -static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Net" ), ID_HOTKEY_HIGHLIGHT, 'B' + GR_KB_CTRL ); - -static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold from Bus" ), HK_UNFOLD_BUS, 'C', ID_SCH_UNFOLD_BUS ); - -// Common: hotkeys_basic.h -static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', wxID_NEW ); -static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O', wxID_OPEN ); -static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S', wxID_SAVE ); -static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_SHIFTCTRL + 'S', wxID_SAVEAS ); -static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P', wxID_PRINT ); - -static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z' ); - -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y' ); -#else -static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_SHIFTCTRL + 'Z' ); -#endif - -static EDA_HOTKEY HkCut( _HKI( "Cut" ), HK_CUT, GR_KB_CTRL + 'X' ); -static EDA_HOTKEY HkCopy( _HKI( "Copy" ), HK_COPY, GR_KB_CTRL + 'C' ); -static EDA_HOTKEY HkPaste( _HKI( "Paste" ), HK_PASTE, GR_KB_CTRL + 'V' ); - -static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), - HK_CANVAS_OPENGL, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F11, ID_MENU_CANVAS_OPENGL ); -static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ), - HK_CANVAS_CAIRO, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F12, ID_MENU_CANVAS_CAIRO ); - -// List of common hotkey descriptors -static EDA_HOTKEY* common_Hotkey_List[] = -{ - &HkNew, &HkOpen, &HkSave, &HkSaveAs, &HkPrint, - &HkUndo, &HkRedo, - &HkCut, &HkCopy, &HkPaste, - &HkFind, &HkReplace, - &HkHelp, - &HkPreferences, - &HkZoomIn, - &HkZoomOut, - &HkZoomRedraw, - &HkZoomCenter, - &HkZoomAuto, - &HkZoomSelection, - &HkSwitchUnits, - &HkResetLocalCoord, - &HkSwitchGridToNext, - &HkSwitchGridToPrevious, - &HkEdit, - &HkDuplicateItem, - &HkDelete, - &HkRotate, - &HkDrag, - &HkMove, - &HkMirrorX, - &HkMirrorY, - &HkMouseLeftClick, - &HkMouseLeftDClick, - NULL -}; - -// List of common hotkey descriptors, for the library viewer -static EDA_HOTKEY* common_basic_Hotkey_List[] = -{ - &HkCut, &HkCopy, &HkPaste, - &HkHelp, - &HkZoomIn, - &HkZoomOut, - &HkZoomRedraw, - &HkZoomCenter, - &HkZoomAuto, - &HkResetLocalCoord, - &HkEdit, - &HkDuplicateItem, - &HkDelete, - &HkRotate, - &HkMove, - &HkMirrorX, - &HkMirrorY, - &HkMouseLeftClick, - &HkMouseLeftDClick, - NULL -}; - -// List of hotkey descriptors for schematic -static EDA_HOTKEY* schematic_Hotkey_List[] = -{ - &HkFindNextItem, - &HkFindNextMarker, - &HkInsert, - &HkAddComponent, - &HkAddPower, - &HkEditValue, - &HkEditReference, - &HkEditFootprint, - &HkShowDatasheet, - &HkEditWithLibedit, - &HkSelectNode, - &HkSelectConnection, - &HkBeginWire, - &HkBeginBus, - &HkEndLineWireBus, - &HkAddLabel, - &HkAddHierarchicalLabel, - &HkAddGlobalLabel, - &HkAddJunction, - &HkAddNoConn, - &HkAddHierSheet, - &HkAddWireEntry, - &HkAddBusEntry, - &HkAddGraphicPolyLine, - &HkAddGraphicText, - &HkUpdatePcbFromSch, - &HkAutoplaceFields, - &HkLeaveSheet, - &HkHighlightConnection, - &HkUnfoldBus, - &HkCanvasCairo, - &HkCanvasOpenGL, - NULL -}; - -// List of hotkey descriptors for library editor -static EDA_HOTKEY* libEdit_Hotkey_List[] = -{ - &HkCreatePin, - &HkInsertPin, - &HkShowDatasheet, - NULL -}; - -// List of hotkey descriptors for library viewer (currently empty) -static EDA_HOTKEY* viewlib_Hotkey_List[] = -{ - NULL -}; - -// Keyword Identifiers (tags) in key code configuration file (section names) -// (.m_SectionTag member of a EDA_HOTKEY_CONFIG) -static wxString schematicSectionTag( wxT( "[eeschema]" ) ); -static wxString libEditSectionTag( wxT( "[libedit]" ) ); - -// Titles for hotkey editor and hotkey display -static wxString commonSectionTitle( _HKI( "Common" ) ); -static wxString schematicSectionTitle( _HKI( "Schematic Editor" ) ); -static wxString libEditSectionTitle( _HKI( "Library Editor" ) ); - -// list of sections and corresponding hotkey list for Eeschema (used to create -// an hotkey config file) -struct EDA_HOTKEY_CONFIG g_Eeschema_Hotkeys_Descr[] = -{ - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &schematicSectionTag, schematic_Hotkey_List, &schematicSectionTitle }, - { &libEditSectionTag, libEdit_Hotkey_List, &libEditSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the schematic editor -// (used to list current hotkeys) -struct EDA_HOTKEY_CONFIG g_Schematic_Hotkeys_Descr[] = -{ - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &schematicSectionTag, schematic_Hotkey_List, &schematicSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the component editor -// (used to list current hotkeys) -struct EDA_HOTKEY_CONFIG g_Libedit_Hotkeys_Descr[] = -{ - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &libEditSectionTag, libEdit_Hotkey_List, &libEditSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the component browser -// (used to list current hotkeys) -struct EDA_HOTKEY_CONFIG g_Viewlib_Hotkeys_Descr[] = -{ - { &g_CommonSectionTag, common_basic_Hotkey_List, &commonSectionTitle }, - { NULL, NULL, NULL } -}; - - -EDA_HOTKEY* SCH_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, schematic_Hotkey_List ); - - return HK_Descr; -} - - -EDA_HOTKEY* LIB_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, libEdit_Hotkey_List ); - - return HK_Descr; -} - - -EDA_HOTKEY* LIB_VIEW_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, viewlib_Hotkey_List ); - - return HK_Descr; -} - - diff --git a/eeschema/ee_hotkeys.h b/eeschema/ee_hotkeys.h deleted file mode 100644 index 7d52f25e7c..0000000000 --- a/eeschema/ee_hotkeys.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014-2017 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * eeschema/hotkeys.h - */ -#ifndef EESCHEMA_KOTKEYS_H_ -#define EESCHEMA_KOTKEYS_H_ - -#include <hotkeys_basic.h> - -// List of hot keys id. -// see also enum common_hotkey_id_command in hotkeys_basic.h -// for shared hotkeys id -enum hotkey_id_command { - HK_REPEAT_LAST = HK_COMMON_END, - HK_LIBEDIT_CREATE_PIN, - HK_SHOW_DATASHEET, - HK_ROTATE, - HK_EDIT, - HK_EDIT_COMPONENT_VALUE, - HK_EDIT_COMPONENT_REFERENCE, - HK_EDIT_COMPONENT_FOOTPRINT, - HK_EDIT_COMPONENT_WITH_LIBEDIT, - HK_MIRROR_X, - HK_MIRROR_Y, - HK_MOVE, - HK_DRAG, - HK_SELECT_NODE, - HK_SELECT_CONNECTION, - HK_ADD_NEW_COMPONENT, - HK_ADD_NEW_POWER, - HK_BEGIN_WIRE, - HK_BEGIN_BUS, - HK_UNFOLD_BUS, - HK_END_CURR_LINEWIREBUS, - HK_ADD_WIRE_ENTRY, - HK_ADD_BUS_ENTRY, - HK_ADD_LABEL, - HK_ADD_HLABEL, - HK_ADD_GLABEL, - HK_ADD_JUNCTION, - HK_ADD_HIER_SHEET, - HK_ADD_GRAPHIC_TEXT, - HK_ADD_GRAPHIC_POLYLINE, - HK_ADD_NOCONN_FLAG, - HK_LEAVE_SHEET, - HK_AUTOPLACE_FIELDS, - HK_SELECT_ITEMS_ON_PCB, - HK_CANVAS_OPENGL, - HK_CANVAS_CAIRO, -}; - -// List of hotkey descriptors for Eeschema -extern struct EDA_HOTKEY_CONFIG g_Eeschema_Hotkeys_Descr[]; - -// List of hotkey descriptors for the schematic editor only -extern struct EDA_HOTKEY_CONFIG g_Schematic_Hotkeys_Descr[]; - -// List of hotkey descriptors for the lib editor only -extern struct EDA_HOTKEY_CONFIG g_Libedit_Hotkeys_Descr[]; - -// List of hotkey descriptors for the lib browser only -extern struct EDA_HOTKEY_CONFIG g_Viewlib_Hotkeys_Descr[]; - -#endif // EESCHEMA_KOTKEYS_H_ diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index cf083a9f55..3bd373d7c2 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -33,16 +33,13 @@ #include <lib_edit_frame.h> #include <viewlib_frame.h> #include <eda_text.h> - #include <general.h> #include <class_libentry.h> -#include <ee_hotkeys.h> #include <transform.h> #include <wildcards_and_files_ext.h> #include <symbol_lib_table.h> #include <dialogs/dialog_global_sym_lib_table_config.h> #include <dialogs/panel_sym_lib_table.h> - #include <kiway.h> #include <sim/sim_plot_frame.h> @@ -245,10 +242,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) SetLayerColor( COLOR4D::WHITE, LAYER_SCHEMATIC_BACKGROUND ); SetLayerColor( COLOR4D::BLACK, LAYER_SCHEMATIC_CURSOR ); - // Must be called before creating the main frame in order to - // display the real hotkeys in menus or tool tips - ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Eeschema_Hotkeys_Descr ); - wxConfigLoadSetups( KifaceSettings(), cfg_params() ); wxFileName fn = SYMBOL_LIB_TABLE::GetGlobalTableFileName(); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index c6a2c199b1..f5837be9e8 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -36,7 +36,6 @@ #include <invoke_sch_dialog.h> #include <lib_edit_frame.h> #include <eeschema_config.h> -#include <ee_hotkeys.h> #include <ws_draw_item.h> #include <ws_data_model.h> #include <class_library.h> @@ -48,6 +47,7 @@ #include <dialogs/panel_eeschema_settings.h> #include <dialogs/panel_eeschema_display_options.h> #include <dialogs/panel_libedit_display_options.h> +#include <panel_hotkeys_editor.h> #include <widgets/widget_eeschema_color_config.h> #include <widgets/symbol_tree_pane.h> #include <dialogs/panel_libedit_settings.h> @@ -128,23 +128,6 @@ COLOR4D GetInvisibleItemColor() } -void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) -{ - int id = event.GetId(); - - switch( id ) - { - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - // Display current hotkey list for LibEdit. - DisplayHotkeyList( this, g_Libedit_Hotkeys_Descr ); - break; - - default: - DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Config error" ) ); - } -} - - void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); @@ -152,6 +135,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) switch( id ) { + // JEY TODO: are these still active? case ID_CONFIG_SAVE: SaveProjectSettings( true ); break; @@ -183,28 +167,14 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) } break; - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - // Display current hotkey list for eeschema. - DisplayHotkeyList( this, g_Schematic_Hotkeys_Descr ); - break; - default: DisplayError( this, wxT( "SCH_EDIT_FRAME::Process_Config error" ) ); } } -void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) -{ - if( ShowPreferences( g_Eeschema_Hotkeys_Descr, g_Schematic_Hotkeys_Descr, wxT( "eeschema" ) ) ) - { - SaveSettings( config() ); // save values shared by eeschema applications. - GetGalCanvas()->Refresh( true ); - } -} - - -void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) +void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { wxTreebook* book = aParent->GetTreebook(); @@ -212,6 +182,8 @@ void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) book->AddSubPage( new PANEL_EESCHEMA_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); book->AddSubPage( new PANEL_EESCHEMA_COLOR_CONFIG( this, book ), _( "Colors" ) ); book->AddSubPage( new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( this, book ), _( "Field Name Templates" ) ); + + aHotkeysPanel->AddHotKeys( GetToolManager() ); } @@ -411,7 +383,6 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) long tmp; - ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Schematic_Hotkeys_Descr ); wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); SetDefaultBusThickness( (int) aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); @@ -548,8 +519,6 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - ReadHotkeyConfig( LIB_EDIT_FRAME_NAME, g_Libedit_Hotkeys_Descr ); - SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SetDefaultPinLength( (int) aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ); m_textPinNumDefaultSize = (int) aCfg->Read( defaultPinNumSizeEntry, DEFAULTPINNUMSIZE ); @@ -608,22 +577,15 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) } -void LIB_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) -{ - if( ShowPreferences( g_Eeschema_Hotkeys_Descr, g_Libedit_Hotkeys_Descr, wxT( "eeschema" ) ) ) - { - SaveSettings( config() ); // save values shared by eeschema applications. - GetGalCanvas()->Refresh( true ); - } -} - - -void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) +void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { wxTreebook* book = aParent->GetTreebook(); book->AddPage( new PANEL_LIBEDIT_SETTINGS( this, book ), _( "Symbol Editor" ) ); book->AddSubPage( new PANEL_LIBEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); + + aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index eea0723c7b..3043b1c423 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -43,12 +43,13 @@ #include <widgets/symbol_tree_pane.h> #include <widgets/lib_tree.h> #include <symbol_lib_table.h> -#include <ee_hotkeys.h> #include <eeschema_config.h> #include <wildcards_and_files_ext.h> #include <wx/progdlg.h> #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/ee_actions.h> @@ -98,10 +99,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) - EVT_MENU( wxID_PREFERENCES, LIB_EDIT_FRAME::OnPreferencesOptions ) - - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_EDIT_FRAME::Process_Config ) - // Update user interface elements. EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) @@ -116,7 +113,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetShowDeMorgan( false ); m_DrawSpecificConvert = true; m_DrawSpecificUnit = false; - m_hotkeysDescrList = g_Libedit_Hotkeys_Descr; m_SyncPinEdit = false; m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN; SetShowElectricalType( true ); @@ -230,6 +226,7 @@ void LIB_EDIT_FRAME::setupTools() m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); @@ -759,6 +756,7 @@ void LIB_EDIT_FRAME::CommonSettingsChanged() void LIB_EDIT_FRAME::ShowChangedLanguage() { + // JEY TODO: push this down into EDA_BASE_FRAME... // call my base class SCH_BASE_FRAME::ShowChangedLanguage(); diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 40b491b6c5..1880ae0345 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -177,9 +177,6 @@ public: void ReCreateMenuBar() override; - void OnPreferencesOptions( wxCommandEvent& event ); - void Process_Config( wxCommandEvent& event ); - /** * Pin editing (add, delete, move...) can be synchronized between units * when units are interchangeable because in this case similar pins are expected @@ -268,9 +265,6 @@ public: void ReCreateOptToolbar(); double BestZoom() override; // Returns the best zoom - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; @@ -449,7 +443,7 @@ public: /** * Allows Libedit to install its preferences panel into the preferences dialog. */ - void InstallPreferences( PAGED_DIALOG* aParent ) override; + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; /** * Called after the preferences dialog is run. diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index e7dc8f06e7..7ca28cb5bf 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -31,7 +31,6 @@ #include <tools/ee_selection_tool.h> #include <lib_manager.h> #include "eeschema_id.h" -#include "ee_hotkeys.h" #include "lib_edit_frame.h" @@ -211,7 +210,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AddItem( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, EE_CONDITIONS::ShowAlways ); diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 6ff5a48afc..64aa0274b7 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -24,14 +24,13 @@ */ #include <fctsys.h> -#include <ee_hotkeys.h> #include <eeschema_id.h> -#include <tool/action_toolbar.h> #include <general.h> #include <lib_edit_frame.h> #include <dialog_helpers.h> #include <bitmaps.h> #include <lib_manager.h> +#include <tool/action_toolbar.h> #include <tools/ee_actions.h> #ifdef __UNIX__ @@ -117,6 +116,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->AddControl( m_partSelectBox ); KiScaledSeparator( m_mainToolBar, this ); + // JEY TODO: move to an action.... m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString, KiScaledBitmap( pin2pin_xpm, this ), _( "Synchronized pin edit mode\n" diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index ee61d08507..b81073d238 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -23,7 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - #include <kiface_i.h> #include <menus_helpers.h> #include <pgm_base.h> @@ -32,7 +31,6 @@ #include <tools/ee_selection_tool.h> #include <tools/ee_actions.h> #include "eeschema_id.h" -#include "ee_hotkeys.h" #include "sch_edit_frame.h" class CONDITIONAL_MENU; @@ -311,7 +309,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AddItem( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), g_Eeschema_Hotkeys_Descr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, EE_CONDITIONS::ShowAlways ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index e14d082292..c7e33ed7f3 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -46,7 +46,6 @@ #include <reporter.h> #include <lib_edit_frame.h> #include <viewlib_frame.h> -#include <ee_hotkeys.h> #include <eeschema_config.h> #include <sch_sheet.h> #include <sim/sim_plot_frame.h> @@ -56,6 +55,8 @@ #include <view/view.h> #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/ee_actions.h> @@ -225,9 +226,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config ) - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, SCH_EDIT_FRAME::Process_Config ) - - EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions ) EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject ) EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols ) @@ -254,7 +252,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_printMonochrome = true; m_printSheetReference = true; SetShowPageLimits( true ); - m_hotkeysDescrList = g_Schematic_Hotkeys_Descr; m_undoItem = NULL; m_hasAutoSave = true; m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs @@ -345,6 +342,7 @@ void SCH_EDIT_FRAME::setupTools() m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 259bb7c844..eb685cfd3c 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -305,9 +305,6 @@ public: void ReCreateOptToolbar(); void ReCreateMenuBar() override; - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - /** * Must be called after a schematic change in order to set the "modify" flag of the * current screen and update the date in frame reference. @@ -765,11 +762,6 @@ private: void OnAppendProject( wxCommandEvent& event ); void OnImportProject( wxCommandEvent& event ); - // a helper function to run the dialog that allows to rename the symbol library Id of - // groups of components, for instance after a symbol has moved from a library to - // another library - void OnPreferencesOptions( wxCommandEvent& event ); - /** * Set the main window title bar text. * @@ -1096,7 +1088,7 @@ public: /** * Allows Eeschema to install its preferences panels into the preferences dialog. */ - void InstallPreferences( PAGED_DIALOG* aParent ) override; + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; /** * Called after the preferences dialog is run. diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index 4dc8362b66..9a72decfd7 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -20,15 +20,13 @@ */ -#include <dialog_helpers.h> #include <macros.h> -#include <menus_helpers.h> - #include "class_library.h" #include "eeschema_id.h" #include "general.h" #include "viewlib_frame.h" #include <symbol_lib_table.h> +#include <tool/action_toolbar.h> #include <tool/conditional_menu.h> #include <tool/tool_manager.h> #include <tools/ee_actions.h> @@ -104,12 +102,13 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() //-- File menu ----------------------------------------------------------- // - wxMenu* fileMenu = new wxMenu; + CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, libControl ); + + fileMenu->AddItem( wxID_EXIT, _( "Close" ), _( "Close footprint viewer" ), + exit_xpm, EE_CONDITIONS::ShowAlways ); + + fileMenu->Resolve(); - AddMenuItem( fileMenu, wxID_EXIT, - _( "Cl&ose" ), - _( "Close schematic symbol viewer" ), - KiBitmap( exit_xpm ) ); //-- View menu ----------------------------------------------------------- // diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 5d0d46a56d..9c45882d6f 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -205,7 +205,10 @@ public: static TOOL_ACTION highlightNetCursor; ///> @copydoc COMMON_ACTIONS::TranslateLegacyId() - virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); } + virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override + { + return OPT<TOOL_EVENT>(); + } }; diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 51a1fdda67..bf93dc1d6a 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -26,7 +26,6 @@ #include <sch_marker.h> #include <id.h> #include <kiway.h> -#include <ee_hotkeys.h> #include <confirm.h> #include <tool/conditional_menu.h> #include <tool/selection_conditions.h> @@ -47,22 +46,23 @@ #include <dialogs/dialog_display_info_HTML_base.h> TOOL_ACTION EE_ACTIONS::runERC( "eeschame.InspectionTool.runERC", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Electrical Rules &Checker" ), _( "Perform electrical rules check" ), erc_xpm ); TOOL_ACTION EE_ACTIONS::runSimulation( "eeschema.EditorControl.runSimulation", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Simulator..." ), _( "Simulate circuit in SPICE" ), simulator_xpm ); TOOL_ACTION EE_ACTIONS::showDatasheet( "eeschema.InspectionTool.showDatasheet", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SHOW_DATASHEET ), + AS_GLOBAL, + 'D', LEGACY_HK_NAME( "Show Datasheet" ), _( "Show Datasheet" ), _( "Opens the datasheet in a browser" ), datasheet_xpm ); TOOL_ACTION EE_ACTIONS::showMarkerInfo( "eeschema.InspectionTool.showMarkerInfo", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Marker Info" ), _( "Display the marker's info in a dialog" ), info_xpm ); diff --git a/eeschema/tools/ee_picker_tool.cpp b/eeschema/tools/ee_picker_tool.cpp index 6d91b9e5cb..5023a2e6fc 100644 --- a/eeschema/tools/ee_picker_tool.cpp +++ b/eeschema/tools/ee_picker_tool.cpp @@ -27,11 +27,12 @@ #include <tool/tool_manager.h> #include <sch_base_frame.h> -TOOL_ACTION EE_ACTIONS::pickerTool( "eeschema.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); +TOOL_ACTION EE_ACTIONS::pickerTool( "eeschema.InteractivePicker.activate", + AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE ); EE_PICKER_TOOL::EE_PICKER_TOOL() - : EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.Picker" ) + : EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InteractivePicker" ) { resetPicker(); } diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 4bcf9fd791..b1cb694604 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -48,12 +48,14 @@ using namespace std::placeholders; // Point editor TOOL_ACTION EE_ACTIONS::pointEditorAddCorner( "eeschema.PointEditor.addCorner", - AS_GLOBAL, 0, - _( "Create Corner" ), _( "Create a corner" ), add_corner_xpm ); + AS_GLOBAL, 0, "", + _( "Create Corner" ), _( "Create a corner" ), + add_corner_xpm ); TOOL_ACTION EE_ACTIONS::pointEditorRemoveCorner( "eeschema.PointEditor.removeCorner", - AS_GLOBAL, 0, - _( "Remove Corner" ), _( "Remove corner" ), delete_xpm ); + AS_GLOBAL, 0, "", + _( "Remove Corner" ), _( "Remove corner" ), + delete_xpm ); // Few constants to avoid using bare numbers for point indices diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index d198a1e0b2..b70792479f 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -44,38 +44,39 @@ #include <painter.h> #include <eeschema_id.h> #include <menus_helpers.h> -#include <ee_hotkeys.h> // Selection tool actions TOOL_ACTION EE_ACTIONS::selectionActivate( "eeschema.InteractiveSelection", - AS_GLOBAL, 0, "", "", // No description, not shown anywhere + AS_GLOBAL, 0, "", "", "", // No description, not shown anywhere nullptr, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::selectNode( "eeschema.InteractiveSelection.SelectNode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_NODE ), + AS_GLOBAL, + MD_ALT + '3', LEGACY_HK_NAME( "Select Node" ), _( "Select Node" ), _( "Select a connection item under the cursor" ) ); TOOL_ACTION EE_ACTIONS::selectConnection( "eeschema.InteractiveSelection.SelectConnection", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_CONNECTION ), + AS_GLOBAL, + MD_ALT + '4', LEGACY_HK_NAME( "Select Connection" ), _( "Select Connection" ), _( "Select a complete connection" ) ); TOOL_ACTION EE_ACTIONS::selectionMenu( "eeschema.InteractiveSelection.SelectionMenu", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::addItemToSel( "eeschema.InteractiveSelection.AddItemToSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::addItemsToSel( "eeschema.InteractiveSelection.AddItemsToSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::removeItemFromSel( "eeschema.InteractiveSelection.RemoveItemFromSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::removeItemsFromSel( "eeschema.InteractiveSelection.RemoveItemsFromSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::clearSelection( "eeschema.InteractiveSelection.ClearSelection", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); SELECTION_CONDITION EE_CONDITIONS::Empty = [] (const SELECTION& aSelection ) diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index 9165ef02e3..c986d07b15 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -32,58 +32,58 @@ TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.SymbolLibraryControl.newSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "New Symbol..." ), _( "Create a new symbol" ), new_component_xpm ); TOOL_ACTION EE_ACTIONS::editSymbol( "eeschema.SymbolLibraryControl.editSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ), edit_xpm ); TOOL_ACTION EE_ACTIONS::duplicateSymbol( "eeschema.SymbolLibraryControl.duplicateSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Duplicate Symbol" ), _( "Make a copy of the selected symbol" ), duplicate_xpm ); TOOL_ACTION EE_ACTIONS::deleteSymbol( "eeschema.SymbolLibraryControl.deleteSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Delete Symbol" ), _( "Remove the selected symbol from its library" ), delete_xpm ); TOOL_ACTION EE_ACTIONS::cutSymbol( "eeschema.SymbolLibraryControl.cutSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Cut Symbol" ), "", cut_xpm ); TOOL_ACTION EE_ACTIONS::copySymbol( "eeschema.SymbolLibraryControl.copySymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Copy Symbol" ), "", copy_xpm ); TOOL_ACTION EE_ACTIONS::pasteSymbol( "eeschema.SymbolLibraryControl.pasteSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Paste Symbol" ), "", paste_xpm ); TOOL_ACTION EE_ACTIONS::importSymbol( "eeschema.SymbolLibraryControl.importSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Import Symbol..." ), _( "Import a symbol to the current library" ), import_part_xpm ); TOOL_ACTION EE_ACTIONS::exportSymbol( "eeschema.SymbolLibraryControl.exportSymbol", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Export Symbol..." ), _( "Export a symbol to a new library file" ), export_part_xpm ); TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ), pin_show_etype_xpm ); TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showComponentTree", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Symbol Tree" ), "", search_tree_xpm ); diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 109064d6ba..a83d720ea7 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -36,7 +36,6 @@ #include <tools/ee_selection_tool.h> #include <tools/lib_drawing_tools.h> #include <tools/lib_pin_tool.h> -#include <ee_hotkeys.h> #include <class_libentry.h> #include <bitmaps.h> #include <lib_text.h> @@ -48,42 +47,44 @@ // Drawing tool actions TOOL_ACTION EE_ACTIONS::placeSymbolPin( "libedit.InteractiveDrawing.placeSymbolPin", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LIBEDIT_CREATE_PIN ), + AS_GLOBAL, + 'P', LEGACY_HK_NAME( "Create Pin" ), _( "Add Pin" ), _( "Add a pin" ), pin_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeSymbolText( "libedit.InteractiveDrawing.placeSymbolText", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Text" ), _( "Add a text item" ), text_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawSymbolRectangle( "libedit.InteractiveDrawing.drawSymbolRectangle", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Rectangle" ), _( "Add a rectangle" ), add_rectangle_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawSymbolCircle( "libedit.InteractiveDrawing.drawSymbolCircle", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Circle" ), _( "Add a circle" ), add_circle_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawSymbolArc( "libedit.InteractiveDrawing.drawSymbolArc", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Arc" ), _( "Add an arc" ), add_arc_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawSymbolLines( "libedit.InteractiveDrawing.drawSymbolLines", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Lines" ), _( "Add connected graphic lines" ), add_graphical_segments_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeSymbolAnchor( "libedit.InteractiveDrawing.placeSymbolAnchor", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Move Symbol Anchor" ), _( "Specify a new location for the symbol anchor" ), anchor_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::finishDrawing( "libedit.InteractiveDrawing.finishDrawing", - AS_GLOBAL, 0, _( "Finish Drawing" ), _( "Finish drawing shape" ), + AS_GLOBAL, 0, "", + _( "Finish Drawing" ), _( "Finish drawing shape" ), checked_ok_xpm, AF_NONE ); diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index 2b60477cc8..6f55437bfc 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -28,7 +28,6 @@ #include <tools/lib_drawing_tools.h> #include <tools/lib_move_tool.h> #include <ee_actions.h> -#include <ee_hotkeys.h> #include <bitmaps.h> #include <confirm.h> #include <base_struct.h> diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index 2c02c8fc75..c03148f6c5 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -24,7 +24,6 @@ #include <tool/tool_manager.h> #include <tools/ee_selection_tool.h> #include <ee_actions.h> -#include <ee_hotkeys.h> #include <view/view.h> #include <bitmaps.h> #include <base_struct.h> diff --git a/eeschema/tools/lib_pin_tool.cpp b/eeschema/tools/lib_pin_tool.cpp index 46c656a247..3ea55030d6 100644 --- a/eeschema/tools/lib_pin_tool.cpp +++ b/eeschema/tools/lib_pin_tool.cpp @@ -34,15 +34,18 @@ TOOL_ACTION EE_ACTIONS::pushPinLength( "libedit.PinEditing.pushPinLength", - AS_GLOBAL, 0, _( "Push Pin Length" ), _( "Copy pin length to other pins in symbol" ), + AS_GLOBAL, 0, "", + _( "Push Pin Length" ), _( "Copy pin length to other pins in symbol" ), pin_size_to_xpm ); TOOL_ACTION EE_ACTIONS::pushPinNameSize( "libedit.PinEditing.pushPinNameSize", - AS_GLOBAL, 0, _( "Push Pin Name Size" ), _( "Copy pin name size to other pins in symbol" ), + AS_GLOBAL, 0, "", + _( "Push Pin Name Size" ), _( "Copy pin name size to other pins in symbol" ), pin_size_to_xpm ); TOOL_ACTION EE_ACTIONS::pushPinNumSize( "libedit.PinEditing.pushPinNumSize", - AS_GLOBAL, 0, _( "Push Pin Number Size" ), _( "Copy pin number size to other pins in symbol" ), + AS_GLOBAL, 0, "", + _( "Push Pin Number Size" ), _( "Copy pin number size to other pins in symbol" ), pin_size_to_xpm ); diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 515f7a900f..3e78a55672 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -36,7 +36,6 @@ #include <view/view_controls.h> #include <view/view.h> #include <tool/tool_manager.h> -#include <ee_hotkeys.h> #include <sch_component.h> #include <sch_no_connect.h> #include <sch_line.h> @@ -50,98 +49,119 @@ // Drawing tool actions TOOL_ACTION EE_ACTIONS::placeSymbol( "eeschema.InteractiveDrawing.placeSymbol", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_COMPONENT ), + AS_GLOBAL, + 'A', LEGACY_HK_NAME( "Add Symbol" ), _( "Add Symbol" ), _( "Add a symbol" ), add_component_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placePower( "eeschema.InteractiveDrawing.placePowerPort", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_POWER ), + AS_GLOBAL, + 'P', LEGACY_HK_NAME( "Add Power" ), _( "Add Power" ), _( "Add a power port" ), add_power_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeNoConnect( "eeschema.InteractiveDrawing.placeNoConnect", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NOCONN_FLAG ), + AS_GLOBAL, + 'Q', LEGACY_HK_NAME( "Add No Connect Flag" ), _( "Add No Connect Flag" ), _( "Add a no-connection flag" ), noconn_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeJunction( "eeschema.InteractiveDrawing.placeJunction", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_JUNCTION ), + AS_GLOBAL, + 'J', LEGACY_HK_NAME( "Add Junction" ), _( "Add Junction" ), _( "Add a junction" ), add_junction_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeBusWireEntry( "eeschema.InteractiveDrawing.placeBusWireEntry", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_WIRE_ENTRY ), + AS_GLOBAL, + 'Z', LEGACY_HK_NAME( "Add Wire Entry" ), _( "Add Wire to Bus Entry" ), _( "Add a wire entry to a bus" ), add_line2bus_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeBusBusEntry( "eeschema.InteractiveDrawing.placeBusBusEntry", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_BUS_ENTRY ), + AS_GLOBAL, + '/', LEGACY_HK_NAME( "Add Bus Entry" ), _( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ), add_bus2bus_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_LABEL ), + AS_GLOBAL, + 'L', LEGACY_HK_NAME( "Add Label" ), _( "Add Label" ), _( "Add a net label" ), add_line_label_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeHierarchicalLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_HLABEL ), + AS_GLOBAL, + 'H', LEGACY_HK_NAME( "Add Hierarchical Label" ), _( "Add Hierarchical Label" ), _( "Add a hierarchical sheet label" ), add_hierarchical_label_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_HIER_SHEET ), + AS_GLOBAL, + 'S', LEGACY_HK_NAME( "Add Sheet" ), _( "Add Sheet" ), _( "Add a hierarchical sheet" ), add_hierarchical_subsheet_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeSheetPin( "eeschema.InteractiveDrawing.placeSheetPin", - AS_GLOBAL, 0, _( "Add Sheet Pin" ), _( "Add a sheet pin" ), + AS_GLOBAL, 0, "", + _( "Add Sheet Pin" ), _( "Add a sheet pin" ), add_hierar_pin_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin", - AS_GLOBAL, 0, _( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ), + AS_GLOBAL, 0, "", + _( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ), import_hierarchical_label_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GLABEL ), + AS_GLOBAL, + MD_CTRL + 'H', LEGACY_HK_NAME( "Add Global Label" ), _( "Add Global Label" ), _( "Add a global label" ), add_glabel_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GRAPHIC_TEXT ), + AS_GLOBAL, + 'T', LEGACY_HK_NAME( "Add Graphic Text" ), _( "Add Text" ), _( "Add text" ), text_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage", - AS_GLOBAL, 0, _( "Add Image" ), _( "Add bitmap image" ), + AS_GLOBAL, 0, "", + _( "Add Image" ), _( "Add bitmap image" ), image_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::finishSheet( "eeschema.InteractiveDrawing.finishSheet", - AS_GLOBAL, 0, _( "Finish Sheet" ), _( "Finish drawing sheet" ), + AS_GLOBAL, 0, "", + _( "Finish Sheet" ), _( "Finish drawing sheet" ), checked_ok_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addJunction( "eeschema.InteractiveEditing.addJunction", - AS_GLOBAL, 0, _( "Add Junction" ), _( "Add a wire or bus junction" ), + AS_GLOBAL, 0, "", + _( "Add Junction" ), _( "Add a wire or bus junction" ), add_junction_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addLabel( "eeschema.InteractiveEditing.addLabel", - AS_GLOBAL, 0, _( "Add Label" ), _( "Add a label to a wire or bus" ), + AS_GLOBAL, 0, "", + _( "Add Label" ), _( "Add a label to a wire or bus" ), add_line_label_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addGlobalLabel( "eeschema.InteractiveEditing.addGlobalLabel", - AS_GLOBAL, 0, _( "Add Global Label" ), _( "Add a global label to a wire or bus" ), + AS_GLOBAL, 0, "", + _( "Add Global Label" ), _( "Add a global label to a wire or bus" ), add_glabel_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addHierLabel( "eeschema.InteractiveEditing.addHierLabel", - AS_GLOBAL, 0, _( "Add Hierarchical Label" ), _( "Add a hierarchical label to a wire or bus" ), + AS_GLOBAL, 0, "", + _( "Add Hierarchical Label" ), _( "Add a hierarchical label to a wire or bus" ), add_hierarchical_label_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addSheetPin( "eeschema.InteractiveEditing.addSheetPin", - AS_GLOBAL, 0, _( "Add Sheet Pin" ), _( "Add a sheet pin to the selected sheet" ), + AS_GLOBAL, 0, "", + _( "Add Sheet Pin" ), _( "Add a sheet pin to the selected sheet" ), add_hierarchical_label_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::addImportedSheetPin( "eeschema.InteractiveEditing.addImportedSheetPin", - AS_GLOBAL, 0, _( "Add Imported Sheet Pin" ), _( "Add an imported sheet pin" ), + AS_GLOBAL, 0, "", + _( "Add Imported Sheet Pin" ), _( "Add an imported sheet pin" ), add_hierarchical_label_xpm, AF_NONE ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index de8b165628..8d27c1609e 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -28,7 +28,6 @@ #include <tools/ee_picker_tool.h> #include <tools/sch_move_tool.h> #include <ee_actions.h> -#include <ee_hotkeys.h> #include <bitmaps.h> #include <confirm.h> #include <eda_doc.h> @@ -51,132 +50,141 @@ TOOL_ACTION EE_ACTIONS::repeatDrawItem( "eeschema.InteractiveEdit.repeatDrawItem", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_REPEAT_LAST ), + AS_GLOBAL, + WXK_INSERT, LEGACY_HK_NAME( "Repeat Last Item" ), _( "Repeat Last Item" ), _( "Duplicates the last drawn item" ), nullptr ); TOOL_ACTION EE_ACTIONS::rotateCW( "eeschema.InteractiveEdit.rotateCW", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ), rotate_cw_xpm ); TOOL_ACTION EE_ACTIONS::rotateCCW( "eeschema.InteractiveEdit.rotateCCW", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE ), + AS_GLOBAL, + 'R', LEGACY_HK_NAME( "Rotate Item" ), _( "Rotate" ), _( "Rotates selected item(s) counter-clockwise" ), rotate_ccw_xpm ); TOOL_ACTION EE_ACTIONS::mirrorX( "eeschema.InteractiveEdit.mirrorX", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MIRROR_X ), + AS_GLOBAL, + 'X', LEGACY_HK_NAME( "Mirror X" ), _( "Mirror Around Horizontal Axis" ), _( "Flips selected item(s) from top to bottom" ), mirror_v_xpm ); TOOL_ACTION EE_ACTIONS::mirrorY( "eeschema.InteractiveEdit.mirrorY", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MIRROR_Y ), + AS_GLOBAL, + 'Y', LEGACY_HK_NAME( "Mirror Y" ), _( "Mirror Around Vertical Axis" ), _( "Flips selected item(s) from left to right" ), mirror_h_xpm ); TOOL_ACTION EE_ACTIONS::properties( "eeschema.InteractiveEdit.properties", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT ), + AS_GLOBAL, + 'E', LEGACY_HK_NAME( "Edit Item" ), _( "Properties..." ), _( "Displays item properties dialog" ), edit_xpm ); TOOL_ACTION EE_ACTIONS::editReference( "eeschema.InteractiveEdit.editReference", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_REFERENCE ), + AS_GLOBAL, + 'U', LEGACY_HK_NAME( "Edit Symbol Reference" ), _( "Edit Reference..." ), _( "Displays reference field dialog" ), edit_comp_ref_xpm ); TOOL_ACTION EE_ACTIONS::editValue( "eeschema.InteractiveEdit.editValue", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_VALUE ), + AS_GLOBAL, + 'V', LEGACY_HK_NAME( "Edit Symbol Value" ), _( "Edit Value..." ), _( "Displays value field dialog" ), edit_comp_value_xpm ); TOOL_ACTION EE_ACTIONS::editFootprint( "eeschema.InteractiveEdit.editFootprint", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_FOOTPRINT ), + AS_GLOBAL, + 'F', LEGACY_HK_NAME( "Edit Symbol Footprint" ), _( "Edit Footprint..." ), _( "Displays footprint field dialog" ), edit_comp_footprint_xpm ); TOOL_ACTION EE_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFields", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_AUTOPLACE_FIELDS ), + AS_GLOBAL, + 'O', LEGACY_HK_NAME( "Autoplace Fields" ), _( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ), autoplace_fields_xpm ); TOOL_ACTION EE_ACTIONS::updateFieldsFromLibrary( "eeschema.InteractiveEdit.updateFieldsFromLibrary", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Update Fields from Library..." ), _( "Sets symbol fields to original library values" ), update_fields_xpm ); TOOL_ACTION EE_ACTIONS::toggleDeMorgan( "eeschema.InteractiveEdit.toggleDeMorgan", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ), morgan2_xpm ); TOOL_ACTION EE_ACTIONS::showDeMorganStandard( "eeschema.InteractiveEdit.showDeMorganStandard", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "DeMorgan Standard" ), _( "Switch to standard DeMorgan representation" ), morgan1_xpm ); TOOL_ACTION EE_ACTIONS::showDeMorganAlternate( "eeschema.InteractiveEdit.showDeMorganAlternate", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "DeMorgan Alternate" ), _( "Switch to alternate DeMorgan representation" ), morgan2_xpm ); TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ), change_entry_orient_xpm ); TOOL_ACTION EE_ACTIONS::toShapeBackslash( "eeschema.InteractiveEdit.toShapeBackslash", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Set Bus Entry Shape \\" ), _( "Change the bus entry shape to \\" ), change_entry_orient_xpm ); TOOL_ACTION EE_ACTIONS::toLabel( "eeschema.InteractiveEdit.toLabel", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change to Label" ), _( "Change existing item to a label" ), add_line_label_xpm ); TOOL_ACTION EE_ACTIONS::toHLabel( "eeschema.InteractiveEdit.toHLabel", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change to Hierarchical Label" ), _( "Change existing item to a hierarchical label" ), add_hierarchical_label_xpm ); TOOL_ACTION EE_ACTIONS::toGLabel( "eeschema.InteractiveEdit.toGLabel", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change to Global Label" ), _( "Change existing item to a global label" ), add_glabel_xpm ); TOOL_ACTION EE_ACTIONS::toText( "eeschema.InteractiveEdit.toText", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change to Text" ), _( "Change existing item to a text comment" ), text_xpm ); TOOL_ACTION EE_ACTIONS::cleanupSheetPins( "eeschema.InteractiveEdit.cleanupSheetPins", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Cleanup Sheet Pins" ), _( "Delete unreferenced sheet pins" ), nullptr ); TOOL_ACTION EE_ACTIONS::symbolProperties( "eeschema.InteractiveEdit.symbolProperties", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Symbol Properties..." ), _( "Displays symbol properties dialog" ), part_properties_xpm ); TOOL_ACTION EE_ACTIONS::pinTable( "eeschema.InteractiveEdit.pinTable", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Pin Table..." ), _( "Displays pin table for bulk editing of pins" ), pin_table_xpm ); TOOL_ACTION EE_ACTIONS::deleteItemCursor( "eeschema.InteractiveEdit.deleteTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Delete Items" ), _( "Delete clicked items" ), delete_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::breakWire( "eeschema.InteractiveEdit.breakWire", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Break Wire" ), _( "Divide a wire into segments which can be dragged independently" ), break_line_xpm ); TOOL_ACTION EE_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Break Bus" ), _( "Divide a bus into segments which can be dragged independently" ), break_line_xpm ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index b2a48b1787..add336d319 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -34,10 +34,10 @@ #include <tools/ee_actions.h> #include <tools/ee_picker_tool.h> #include <tools/sch_editor_control.h> +#include <tools/ee_selection.h> #include <tools/ee_selection_tool.h> #include <tools/sch_drawing_tools.h> #include <tools/sch_wire_bus_tool.h> -#include <ee_hotkeys.h> #include <advanced_config.h> #include <simulation_cursors.h> #include <sim/sim_plot_frame.h> @@ -52,97 +52,99 @@ #include <invoke_sch_dialog.h> TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview", - AS_GLOBAL, 0, "", "" ); + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::simProbe( "eeschema.Simulation.probe", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add a simulator probe" ), "" ); TOOL_ACTION EE_ACTIONS::simTune( "eeschema.Simulation.tune", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Select a value to be tuned" ), "" ); TOOL_ACTION EE_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet", - AS_GLOBAL, 0, "", "" ); + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::clearHighlight( "eeschema.EditorControl.clearHighlight", - AS_GLOBAL, 0, "", "" ); + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::updateNetHighlighting( "eeschema.EditorControl.updateNetHighlighting", - AS_GLOBAL, 0, "", "" ); + AS_GLOBAL ); TOOL_ACTION EE_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Nets" ), _( "Highlight wires and pins of a net" ), net_highlight_schematic_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::editWithLibEdit( "eeschema.EditorControl.editWithSymbolEditor", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_WITH_LIBEDIT ), + AS_GLOBAL, + MD_CTRL + 'E', LEGACY_HK_NAME( "Edit with Symbol Editor" ), _( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ), libedit_xpm ); TOOL_ACTION EE_ACTIONS::editSymbolFields( "eeschema.EditorControl.editSymbolFields", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Symbol Fields..." ), _( "Bulk-edit fields of all symbols in schematic" ), spreadsheet_xpm ); TOOL_ACTION EE_ACTIONS::editSymbolLibraryLinks( "eeschema.EditorControl.editSymbolLibraryLinks", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Symbol Library Links..." ), _( "Edit links between schematic and library symbols" ), edit_cmp_symb_links_xpm ); TOOL_ACTION EE_ACTIONS::assignFootprints( "eeschema.EditorControl.assignFootprints", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Assign Footprints..." ), _( "Run Cvpcb" ), cvpcb_xpm ); TOOL_ACTION EE_ACTIONS::annotate( "eeschema.EditorControl.annotate", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Annotate Schematic..." ), _( "Fill in schematic symbol reference designators" ), annotate_xpm ); TOOL_ACTION EE_ACTIONS::showBusManager( "eeschema.EditorControl.showBusManager", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Bus Definitions..." ), _( "Manage bus definitions" ), bus_definition_tool_xpm ); TOOL_ACTION EE_ACTIONS::showPcbNew( "eeschema.EditorControl.showPcbNew", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Open PCB Editor" ), _( "Run Pcbnew" ), pcbnew_xpm ); TOOL_ACTION EE_ACTIONS::generateBOM( "eeschema.EditorControl.generateBOM", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Generate BOM..." ), _( "Generate a bill of materials for the current schematic" ), bom_xpm ); TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ), enter_sheet_xpm ); TOOL_ACTION EE_ACTIONS::leaveSheet( "eeschema.EditorControl.leaveSheet", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEAVE_SHEET ), + AS_GLOBAL, + MD_ALT + WXK_BACK, LEGACY_HK_NAME( "Leave Sheet" ), _( "Leave Sheet" ), _( "Display the parent sheet in the Eeschema window" ), leave_sheet_xpm ); TOOL_ACTION EE_ACTIONS::navigateHierarchy( "eeschema.EditorControl.navigateHierarchy", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Hierarchy Navigator" ), "", hierarchy_nav_xpm ); TOOL_ACTION EE_ACTIONS::explicitCrossProbe( "eeschema.EditorControl.explicitCrossProbe", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_ITEMS_ON_PCB ), + AS_GLOBAL, 0, "", _( "Highlight on PCB" ), _( "Highlight corresponding items in PCBNew" ), select_same_sheet_xpm ); TOOL_ACTION EE_ACTIONS::toggleHiddenPins( "eeschema.EditorControl.showHiddenPins", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Hidden Pins" ), "", hidden_pin_xpm ); TOOL_ACTION EE_ACTIONS::toggleForceHV( "eeschema.EditorControl.forceHVLines", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Force H/V Wires and Busses" ), "", lines90_xpm ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index b64571860b..a347327b59 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -25,7 +25,6 @@ #include <tools/ee_selection_tool.h> #include <tools/sch_wire_bus_tool.h> #include <ee_actions.h> -#include <ee_hotkeys.h> #include <bitmaps.h> #include <base_struct.h> #include <sch_item.h> @@ -39,15 +38,17 @@ TOOL_ACTION EE_ACTIONS::move( "eeschema.InteractiveEdit.move", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE ), + AS_GLOBAL, + 'M', LEGACY_HK_NAME( "Move Item" ), _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drag( "eeschema.InteractiveEdit.drag", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG ), + AS_GLOBAL, + 'G', LEGACY_HK_NAME( "Drag Item" ), _( "Drag" ), _( "Drags the selected item(s)" ), move_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::moveActivate( "eeschema.InteractiveMove", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Move Activate" ), "", move_xpm, AF_ACTIVATE ); diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index 4f27f33928..b9f62d2659 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -35,7 +35,6 @@ #include <view/view_controls.h> #include <view/view.h> #include <tool/tool_manager.h> -#include <ee_hotkeys.h> #include <sch_junction.h> #include <sch_line.h> #include <sch_bus_entry.h> @@ -44,54 +43,63 @@ #include <advanced_config.h> TOOL_ACTION EE_ACTIONS::startWire( "eeschema.WireBusDrawing.startWire", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Start Wire" ), _( "Start drawing a wire" ), add_line_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawWire( "eeschema.WireBusDrawing.drawWires", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ), + AS_GLOBAL, + 'W', LEGACY_HK_NAME( "Begin Wire" ), _( "Add Wire" ), _( "Add a wire" ), add_line_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::startBus( "eeschema.WireBusDrawing.startBus", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Start Bus" ), _( "Start drawing a bus" ), add_bus_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawBus( "eeschema.WireBusDrawing.drawBusses", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_BUS ), + AS_GLOBAL, + 'B', LEGACY_HK_NAME( "Begin Bus" ), _( "Add Bus" ), _( "Add a bus" ), add_bus_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::unfoldBus( "eeschema.WireBusDrawing.unfoldBus", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UNFOLD_BUS ), + AS_GLOBAL, + 'C', LEGACY_HK_NAME( "Unfold from Bus" ), _( "Unfold from Bus" ), _( "Break a wire out of a bus" ), nullptr, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::startLines( "eeschema.WireBusDrawing.startLines", - AS_GLOBAL, 0, _( "Begin Lines" ), _( "Start drawing connected graphic lines" ), + AS_GLOBAL, 0, "", + _( "Begin Lines" ), _( "Start drawing connected graphic lines" ), add_line_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::drawLines( "eeschema.WireBusDrawing.drawLines", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GRAPHIC_POLYLINE ), + AS_GLOBAL, + 'I', LEGACY_HK_NAME( "Add Graphic PolyLine" ), _( "Add Lines" ), _( "Add connected graphic lines" ), add_dashed_line_xpm, AF_ACTIVATE ); TOOL_ACTION EE_ACTIONS::finishLineWireOrBus( "eeschema.WireBusDrawing.finishLineWireOrBus", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_END_CURR_LINEWIREBUS ), + AS_GLOBAL, + 'K', LEGACY_HK_NAME( "End Line Wire Bus" ), _( "Finish Wire or Bus" ), _( "Complete drawing at current segment" ), checked_ok_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::finishWire( "eeschema.WireBusDrawing.finishWire", - AS_GLOBAL, 0, _( "Finish Wire" ), _( "Complete wire with current segment" ), + AS_GLOBAL, 0, "", + _( "Finish Wire" ), _( "Complete wire with current segment" ), checked_ok_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::finishBus( "eeschema.WireBusDrawing.finishBus", - AS_GLOBAL, 0, _( "Finish Bus" ), _( "Complete bus with current segment" ), + AS_GLOBAL, 0, "", + _( "Finish Bus" ), _( "Complete bus with current segment" ), checked_ok_xpm, AF_NONE ); TOOL_ACTION EE_ACTIONS::finishLine( "eeschema.WireBusDrawing.finishLine", - AS_GLOBAL, 0, _( "Finish Lines" ), _( "Complete connected lines with current segment" ), + AS_GLOBAL, 0, "", + _( "Finish Lines" ), _( "Complete connected lines with current segment" ), checked_ok_xpm, AF_NONE ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 43f4de8f63..11934eabdc 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -36,7 +36,6 @@ #include <general.h> #include <viewlib_frame.h> #include <symbol_lib_table.h> -#include <ee_hotkeys.h> #include <dialog_helpers.h> #include <class_libentry.h> #include <class_library.h> @@ -44,6 +43,7 @@ #include <sch_painter.h> #include <confirm.h> #include <tool/tool_manager.h> +#include <tool/action_toolbar.h> #include <tool/tool_dispatcher.h> #include <tools/ee_actions.h> #include <tool/common_tools.h> @@ -84,7 +84,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer ) EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_VIEW_FRAME::OnDisplayHotkeyList ) EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice ) @@ -121,7 +120,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) ); SetIcon( icon ); - m_hotkeysDescrList = g_Viewlib_Hotkeys_Descr; m_libListWidth = 200; m_cmpListWidth = 300; m_listPowerCmpOnly = false; @@ -799,8 +797,3 @@ void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent ) } } - -void LIB_VIEW_FRAME::OnDisplayHotkeyList( wxCommandEvent& event ) -{ - DisplayHotkeyList( this, g_Viewlib_Hotkeys_Descr ); -} diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 12fc69a1a0..6ec95bb995 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -96,14 +96,6 @@ public: void OnSetRelativeOffset( wxCommandEvent& event ); void OnSelectSymbol( wxCommandEvent& aEvent ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - - /** - * Displays the hotkey dialog - */ - void OnDisplayHotkeyList( wxCommandEvent& event ); - void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 1f4ed4b2b4..ce02aad723 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -47,7 +47,6 @@ set( GERBVIEW_SRCS files.cpp gerbview_config.cpp gerbview_frame.cpp - hotkeys.cpp json11.cpp job_file_reader.cpp locate.cpp diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 49fb11362a..820dcf9a8e 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -74,11 +74,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit ) - // menu Preferences - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, GERBVIEW_FRAME::Process_Config ) - - EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::Process_Config ) - // menu Postprocess EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions ) EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::OnShowGerberSourceFile ) @@ -126,7 +121,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); GERBVIEW_SELECTION_TOOL* selTool = GetToolManager()->GetTool<GERBVIEW_SELECTION_TOOL>(); - SELECTION& selection = selTool->GetSelection(); + GERBVIEW_SELECTION& selection = selTool->GetSelection(); GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) selection.Front(); switch( id ) diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index dbeb05bb3b..bb97f5ddf8 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -30,7 +30,6 @@ #include <kiface_i.h> #include <pgm_base.h> #include <gerbview.h> -#include <hotkeys.h> #include <gerbview_frame.h> const wxChar* g_GerberPageSizeList[] = @@ -123,11 +122,6 @@ PGM_BASE& Pgm() bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) { start_common( aCtlBits ); - - // Must be called before creating the main frame in order to - // display the real hotkeys in menus or tool tips - ReadHotkeyConfig( GERBVIEW_FRAME_NAME, GerbviewHotkeysDescr ); - return true; } diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 19017339c3..5f818aa5be 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -28,39 +28,21 @@ #include <common.h> #include <config_params.h> #include <gerbview_frame.h> -#include <hotkeys.h> #include <widgets/paged_dialog.h> #include <dialogs/panel_gerbview_settings.h> #include <dialogs/panel_gerbview_display_options.h> - -void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event ) -{ - int id = event.GetId(); - - switch( id ) - { - case wxID_PREFERENCES: - ShowPreferences( GerbviewHotkeysDescr, GerbviewHotkeysDescr, wxT( "gerbview" ) ); - break; - - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - // Display current hotkey list for GerbView. - DisplayHotkeyList( this, GerbviewHotkeysDescr ); - break; - - default: - wxMessageBox( wxT( "GERBVIEW_FRAME::Process_Config error" ) ); - break; - } -} +#include <panel_hotkeys_editor.h> -void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) +void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { wxTreebook* book = aParent->GetTreebook(); book->AddPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Gerbview" ) ); book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); + + aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index d2c7d22e77..7aca95c1c7 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -30,21 +30,20 @@ #include <bitmaps.h> #include <wildcards_and_files_ext.h> #include <eda_dockart.h> - #include <gerbview.h> #include <gerbview_frame.h> #include <gerbview_id.h> -#include <hotkeys.h> #include <gerber_file_image.h> #include <gerber_file_image_list.h> #include <dialog_helpers.h> #include <DCodeSelectionbox.h> #include <gerbview_layer_widget.h> - #include <gerbview_draw_panel_gal.h> #include <gal/graphics_abstraction_layer.h> #include <tool/tool_manager.h> +#include <tool/action_toolbar.h> #include <tool/tool_dispatcher.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/gerbview_actions.h> @@ -81,7 +80,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_showAxis = true; // true to show X and Y axis on screen m_showBorderAndTitleBlock = false; // true for reference drawings. - m_hotkeysDescrList = GerbviewHotkeysDescr; m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_SelComponentBox = nullptr; @@ -1139,6 +1137,7 @@ void GERBVIEW_FRAME::setupTools() m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new GERBVIEW_SELECTION_TOOL ); m_toolManager->RegisterTool( new GERBVIEW_CONTROL ); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 2e9a4d002e..cd2217cffb 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -450,13 +450,8 @@ public: */ void OnQuit( wxCommandEvent& event ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - GERBER_DRAW_ITEM* Locate( const wxPoint& aPosition, int typeloc ); - void Process_Config( wxCommandEvent& event ); - void OnUpdateDrawMode( wxUpdateUIEvent& aEvent ); void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ); void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); @@ -590,7 +585,7 @@ public: /** * Allows Gerbview to install its preferences panels into the preferences dialog. */ - void InstallPreferences( PAGED_DIALOG* aParent ) override; + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; /** * Called after the preferences dialog is run. diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp deleted file mode 100644 index 90bcb8abfd..0000000000 --- a/gerbview/hotkeys.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <fctsys.h> -#include <common.h> -#include <gerbview_id.h> -#include <gerbview.h> -#include <gerbview_frame.h> -#include <gerbview_layer_widget.h> -#include <hotkeys.h> - - -/* How to add a new hotkey: - * add a new id in the enum hotkey_id_command like MY_NEW_ID_FUNCTION. - * add a new EDA_HOTKEY entry like: - * static EDA_HOTKEY HkMyNewEntry(wxT("Command Label"), MY_NEW_ID_FUNCTION, default key value); - * "Command Label" is the name used in hotkey list display, and the identifier in the - * hotkey list file MY_NEW_ID_FUNCTION is an equivalent id function used in the switch - * in OnHotKey() function. default key value is the default hotkey for this command. - * Can be overrided by the user hotkey list file add the HkMyNewEntry pointer in the - * s_board_edit_Hotkey_List list ( or/and the s_module_edit_Hotkey_List list) Add the - * new code in the switch in OnHotKey() function. when the variable PopupOn is true, - * an item is currently edited. This can be usefull if the new function cannot be - * executed while an item is currently being edited - * ( For example, one cannot start a new wire when a component is moving.) - * - * Note: If an hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX) - * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp) - * and see this list for some ascii keys (space ...) - */ - -// local variables -// Hotkey list: -static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); -static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), - HK_ZOOM_SELECTION, GR_KB_CTRL + WXK_F5 ); -static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), - HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES ); -static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); -static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); -static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkSwitchHighContrastMode( _HKI( "Toggle High Contrast Mode" ), - HK_SWITCH_HIGHCONTRAST_MODE, 'H' + GR_KB_CTRL ); - -static EDA_HOTKEY HkLinesDisplayMode( _HKI( "Gbr Lines Display Mode" ), - HK_GBR_LINES_DISPLAY_MODE, 'L' ); -static EDA_HOTKEY HkFlashedDisplayMode( _HKI( "Gbr Flashed Display Mode" ), - HK_GBR_FLASHED_DISPLAY_MODE, 'F' ); -static EDA_HOTKEY HkPolygonDisplayMode( _HKI( "Gbr Polygons Display Mode" ), - HK_GBR_POLYGON_DISPLAY_MODE, 'P' ); -static EDA_HOTKEY HkNegativeObjDisplayMode( _HKI( "Gbr Negative Obj Display Mode" ), - HK_GBR_NEGATIVE_DISPLAY_ONOFF, 'N' ); -static EDA_HOTKEY HkDCodesDisplayMode( _HKI( "DCodes Display Mode" ), - HK_GBR_DCODE_DISPLAY_ONOFF, 'D' ); - -static EDA_HOTKEY HkSwitch2NextCopperLayer( _HKI( "Switch to Next Layer" ), - HK_SWITCH_LAYER_TO_NEXT, '+' ); -static EDA_HOTKEY HkSwitch2PreviousCopperLayer( _HKI( "Switch to Previous Layer" ), - HK_SWITCH_LAYER_TO_PREVIOUS, '-' ); - -static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), - HK_CANVAS_OPENGL, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F11 ); -static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ), - HK_CANVAS_CAIRO, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F12 ); - -static EDA_HOTKEY HkMeasureTool( _HKI( "Measure Distance (Modern Toolset only)" ), - HK_MEASURE_TOOL, 'M' + GR_KB_SHIFTCTRL ); - -// List of common hotkey descriptors -EDA_HOTKEY* gerbviewHotkeyList[] = { - &HkHelp, &HkPreferences, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkZoomAuto, &HkZoomSelection, &HkSwitchUnits, &HkResetLocalCoord, - &HkLinesDisplayMode, &HkFlashedDisplayMode, &HkPolygonDisplayMode, - &HkDCodesDisplayMode, &HkNegativeObjDisplayMode, - &HkSwitchHighContrastMode, - &HkSwitch2NextCopperLayer, - &HkSwitch2PreviousCopperLayer, - &HkCanvasOpenGL, - &HkCanvasCairo, - &HkMeasureTool, - NULL -}; - - -// list of sections and corresponding hotkey list for GerbView (used to create an hotkey -// config file) -static wxString gerbviewSectionTag( wxT( "[gerbview]" ) ); -static wxString gerbviewSectionTitle( _HKI( "Gerbview Hotkeys" ) ); - -struct EDA_HOTKEY_CONFIG GerbviewHotkeysDescr[] = -{ - { &gerbviewSectionTag, gerbviewHotkeyList, &gerbviewSectionTitle }, - { NULL, NULL, NULL } -}; - - -EDA_HOTKEY* GERBVIEW_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, gerbviewHotkeyList ); - - return HK_Descr; -} - - diff --git a/gerbview/hotkeys.h b/gerbview/hotkeys.h deleted file mode 100644 index 7294f0cca5..0000000000 --- a/gerbview/hotkeys.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * gerbview/hotkeys.h - */ - -#ifndef GERBVIEW_KOTKEYS_H_ -#define GERBVIEW_KOTKEYS_H_ - -#include <hotkeys_basic.h> - -// List of hot keys id. -// see also enum common_hotkey_id_command in hotkeys_basic.h -// for shared hotkeys id -enum hotkey_id_command { - HK_GBR_LINES_DISPLAY_MODE = HK_COMMON_END, - HK_GBR_FLASHED_DISPLAY_MODE, - HK_GBR_POLYGON_DISPLAY_MODE, - HK_GBR_NEGATIVE_DISPLAY_ONOFF, - HK_GBR_DCODE_DISPLAY_ONOFF, - HK_SWITCH_HIGHCONTRAST_MODE, - HK_SWITCH_LAYER_TO_NEXT, - HK_SWITCH_LAYER_TO_PREVIOUS, - HK_CANVAS_OPENGL, - HK_CANVAS_CAIRO -}; - -// List of hotkey descriptors for GerbView. -extern struct EDA_HOTKEY_CONFIG GerbviewHotkeysDescr[]; - -#endif // GERBVIEW_KOTKEYS_H_ diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 1338c99280..6bbc058805 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -28,7 +28,6 @@ #include <kiface_i.h> #include <pgm_base.h> #include "gerbview_id.h" -#include "hotkeys.h" #include <menus_helpers.h> #include <tool/actions.h> #include <tool/tool_manager.h> @@ -250,7 +249,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() CONDITIONAL_MENU* preferencesMenu = new CONDITIONAL_MENU( false, selTool ); preferencesMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), GerbviewHotkeysDescr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, SELECTION_CONDITIONS::ShowAlways ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index b8fd0f0228..dc28857381 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -26,7 +26,6 @@ #include <gerbview_frame.h> #include <bitmaps.h> #include <gerbview_id.h> -#include <hotkeys.h> #include <gerber_file_image.h> #include <gerber_file_image_list.h> #include <gbr_layer_box_selector.h> @@ -36,6 +35,7 @@ #include <kicad_string.h> #include <wx/wupdlock.h> #include <tool/actions.h> +#include <tool/action_toolbar.h> #include <tools/gerbview_actions.h> void GERBVIEW_FRAME::ReCreateHToolbar( void ) diff --git a/gerbview/tools/gerbview_actions.h b/gerbview/tools/gerbview_actions.h index 1383d364bb..41b99373e5 100644 --- a/gerbview/tools/gerbview_actions.h +++ b/gerbview/tools/gerbview_actions.h @@ -70,9 +70,6 @@ public: static TOOL_ACTION layerChanged; // notification - // Miscellaneous - static TOOL_ACTION showHelp; - // Highlighting static TOOL_ACTION highlightClear; static TOOL_ACTION highlightNet; diff --git a/gerbview/tools/gerbview_control.cpp b/gerbview/tools/gerbview_control.cpp index acd9b6e2d6..2bcaa56dd4 100644 --- a/gerbview/tools/gerbview_control.cpp +++ b/gerbview/tools/gerbview_control.cpp @@ -23,86 +23,82 @@ #include <gerbview_frame.h> #include <tool/tool_manager.h> #include <menus_helpers.h> -#include <hotkeys.h> - #include "gerbview_actions.h" #include "gerbview_control.h" #include "gerbview_selection_tool.h" TOOL_ACTION GERBVIEW_ACTIONS::layerChanged( "gerbview.Control.layerChanged", - AS_GLOBAL, 0, - "", "", - NULL, AF_NOTIFY ); + AS_GLOBAL, 0, "", "", "", + nullptr, AF_NOTIFY ); TOOL_ACTION GERBVIEW_ACTIONS::highlightClear( "gerbview.Control.highlightClear", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Clear Highlight" ), "", highlight_remove_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::highlightNet( "gerbview.Control.highlightNet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Net" ), "", general_ratsnest_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::highlightComponent( "gerbview.Control.highlightComponent", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Component" ), "", file_footprint_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::highlightAttribute( "gerbview.Control.highlightAttribute", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Attribute" ), "", flag_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::layerNext( "gerbview.Control.layerNext", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_NEXT ), + AS_GLOBAL, + '+', LEGACY_HK_NAME( "Switch to Next Layer" ), "", "" ); TOOL_ACTION GERBVIEW_ACTIONS::layerPrev( "gerbview.Control.layerPrev", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_PREVIOUS ), + AS_GLOBAL, + '-', LEGACY_HK_NAME( "Switch to Previous Layer" ), "", "" ); TOOL_ACTION GERBVIEW_ACTIONS::linesDisplayOutlines( "gerbview.Control.linesDisplayOutlines", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_LINES_DISPLAY_MODE ), + AS_GLOBAL, + 'L', LEGACY_HK_NAME( "Gbr Lines Display Mode" ), _( "Sketch Lines" ), _( "Show lines in outline mode" ), showtrack_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::flashedDisplayOutlines( "gerbview.Control.flashedDisplayOutlines", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_FLASHED_DISPLAY_MODE ), + AS_GLOBAL, + 'F', LEGACY_HK_NAME( "Gbr Flashed Display Mode" ), _( "Sketch Flashed Items" ), _( "Show flashed items in outline mode" ), pad_sketch_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::polygonsDisplayOutlines( "gerbview.Control.polygonsDisplayOutlines", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_POLYGON_DISPLAY_MODE ), + AS_GLOBAL, + 'P', LEGACY_HK_NAME( "Gbr Polygons Display Mode" ), _( "Sketch Polygons" ), _( "Show polygons in outline mode" ), opt_show_polygon_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::negativeObjectDisplay( "gerbview.Control.negativeObjectDisplay", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_NEGATIVE_DISPLAY_ONOFF ), + AS_GLOBAL, + 'N', LEGACY_HK_NAME( "Gbr Negative Obj Display Mode" ), _( "Ghost Negative Objects" ), _( "Show negative objects in ghost color" ), gerbview_show_negative_objects_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::dcodeDisplay( "gerbview.Control.dcodeDisplay", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_DCODE_DISPLAY_ONOFF ), + AS_GLOBAL, + 'D', LEGACY_HK_NAME( "DCodes Display Mode" ), _( "Show DCodes" ), _( "Show dcode number" ), show_dcodenumber_xpm ); TOOL_ACTION GERBVIEW_ACTIONS::toggleDiffMode( "gerbview.Control.toggleDiffMode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_DCODE_DISPLAY_ONOFF ), + AS_GLOBAL, 0, "", _( "Show in Differential Mode" ), _( "Show layers in diff (compare) mode" ), gbr_select_mode2_xpm ); -TOOL_ACTION GERBVIEW_ACTIONS::showHelp( "gerbview.Control.showHelp", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ), - "", "" ); - GERBVIEW_CONTROL::GERBVIEW_CONTROL() : - TOOL_INTERACTIVE( "gerbview.Control" ), m_frame( NULL ) -{ -} - - -GERBVIEW_CONTROL::~GERBVIEW_CONTROL() + TOOL_INTERACTIVE( "gerbview.Control" ), + m_frame( nullptr ) { } @@ -117,7 +113,7 @@ int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent ) { auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( getView()->GetPainter() )->GetSettings(); const auto& selection = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection(); - GERBER_DRAW_ITEM* item = NULL; + GERBER_DRAW_ITEM* item = nullptr; if( selection.Size() == 1 ) { @@ -235,14 +231,6 @@ int GERBVIEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent ) } -int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) -{ - DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() ); - - return 0; -} - - int GERBVIEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) { GERBVIEW_SELECTION_TOOL* selTool = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>(); @@ -285,8 +273,6 @@ void GERBVIEW_CONTROL::setTransitions() Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastMode.MakeEvent() ); Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::toggleDiffMode.MakeEvent() ); - Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() ); - Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent ); Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent ); Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent ); diff --git a/gerbview/tools/gerbview_control.h b/gerbview/tools/gerbview_control.h index 03b09e6004..aafa023110 100644 --- a/gerbview/tools/gerbview_control.h +++ b/gerbview/tools/gerbview_control.h @@ -34,7 +34,7 @@ class GERBVIEW_CONTROL : public TOOL_INTERACTIVE { public: GERBVIEW_CONTROL(); - ~GERBVIEW_CONTROL(); + ~GERBVIEW_CONTROL() override { } /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; @@ -58,7 +58,6 @@ public: // Miscellaneous int SwitchUnits( const TOOL_EVENT& aEvent ); - int ShowHelp( const TOOL_EVENT& aEvent ); int UpdateMessagePanel( const TOOL_EVENT& aEvent ); int Print( const TOOL_EVENT& aEvent ); diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index 77d12eea14..1c991bad6a 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -31,8 +31,6 @@ using namespace std::placeholders; #include <view/view_group.h> #include <painter.h> #include <bitmaps.h> -#include <hotkeys.h> - #include <tool/tool_event.h> #include <tool/tool_manager.h> #include <preview_items/bright_box.h> @@ -45,24 +43,20 @@ using namespace std::placeholders; // Selection tool actions TOOL_ACTION GERBVIEW_ACTIONS::selectionActivate( "gerbview.InteractiveSelection", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere TOOL_ACTION GERBVIEW_ACTIONS::selectionCursor( "gerbview.InteractiveSelection.Cursor", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION GERBVIEW_ACTIONS::selectItem( "gerbview.InteractiveSelection.SelectItem", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION GERBVIEW_ACTIONS::unselectItem( "gerbview.InteractiveSelection.UnselectItem", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION GERBVIEW_ACTIONS::selectionClear( "gerbview.InteractiveSelection.Clear", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); class HIGHLIGHT_MENU: public ACTION_MENU diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index e8ceb31398..942abd7753 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -45,8 +45,7 @@ #include <common.h> #include <layers_id_colors_and_visibility.h> #include <frame_type.h> -#include "hotkeys_basic.h" -#include <tool/action_toolbar.h> +#include <hotkeys_basic.h> #include <kiway_holder.h> // Option for main frames @@ -72,6 +71,7 @@ class TOOL_DISPATCHER; class ACTIONS; class PAGED_DIALOG; class DIALOG_EDIT_LIBRARY_TABLES; +class PANEL_HOTKEYS_EDITOR; enum id_librarytype { @@ -123,6 +123,7 @@ protected: // and to name some config files (legacy hotkey files) TOOL_MANAGER* m_toolManager; + ACTIONS* m_actions; bool m_hasAutoSave; bool m_autoSaveState; @@ -173,15 +174,6 @@ protected: */ virtual bool doAutoSave(); - /** - * Return a SEARCH_STACK pertaining to entire program. - * - * This is overloaded in #KICAD_MANAGER_FRAME - */ - virtual const SEARCH_STACK& sys_search(); - - virtual wxString help_name(); - /** * Called when when the units setting has changed to allow for any derived classes * to handle refreshing and controls that have units based measurements in them. The @@ -246,14 +238,17 @@ public: bool IsType( FRAME_T aType ) const { return m_Ident == aType; } - void GetKicadHelp( wxCommandEvent& event ); + /** + * Return a SEARCH_STACK pertaining to entire program. + * + * This is overloaded in #KICAD_MANAGER_FRAME + */ + virtual const SEARCH_STACK& sys_search(); - void GetKicadContribute( wxCommandEvent& event ); + virtual wxString help_name(); - void GetKicadAbout( wxCommandEvent& event ); - - bool ShowPreferences( EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys, - const wxString& aHotkeysNickname ); + void OnKicadAbout( wxCommandEvent& event ); + void OnPreferences( wxCommandEvent& event ); void PrintMsg( const wxString& text ); @@ -268,7 +263,7 @@ public: * Allow a frame to load its preference panels (if any) into the preferences dialog. * @param aParent a paged dialog into which the preference panels should be installed */ - virtual void InstallPreferences( PAGED_DIALOG* aParent ) { } + virtual void InstallPreferences( PAGED_DIALOG* , PANEL_HOTKEYS_EDITOR* ) { } /** * Load common frame parameters from a configuration file. @@ -300,7 +295,6 @@ public: return baseCfgName; } - /** * Save changes to the project settings to the project (.pro) file. * @@ -312,20 +306,6 @@ public: // Read/Save and Import/export hotkeys config - /** - * Store the current hotkey list - * - * The hotkey list is stored using the standard wxConfig mechanism or a file. - * - * @param aDescList = pointer to the current hotkey list. - * @param aFullFileName = a wxString pointer to a full file name. - * if NULL, use the standard wxConfig mechanism (default) - * the output format is: shortcut "key" "function" - * lines starting with # are comments - */ - virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, - wxString* aFullFileName = NULL ); - /** * Prompt the user for an old hotkey file to read, and read it. * diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 53f226c267..f695eb9216 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -98,8 +98,6 @@ protected: std::unique_ptr<wxSingleInstanceChecker> m_file_checker; ///< prevents opening same file multiple times. - EDA_HOTKEY_CONFIG* m_hotkeysDescrList; - int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid // 0 is for the grid corresponding to // a wxCommand ID = ID_POPUP_GRID_LEVEL_1000. @@ -116,7 +114,6 @@ protected: bool m_PolarCoords; //< for those frames that support polar coordinates TOOL_DISPATCHER* m_toolDispatcher; - ACTIONS* m_actions; /// Tool ID of previously active draw tool bar button. int m_lastDrawToolId; @@ -351,22 +348,6 @@ public: */ virtual void ExecuteRemoteCommand( const char* cmdline ){} - ///> @copydoc EDA_BASE_FRAME::WriteHotkeyConfig - int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL ) override; - - /** - * Return a structure containing currently used hotkey mapping. - */ - EDA_HOTKEY_CONFIG* GetHotkeyConfig() const { return m_hotkeysDescrList; } - - /** - * Search lists of hot key identifiers (HK_xxx) used in the frame to find a matching - * hot key descriptor. - * @param aCommand is the hot key identifier. - * @return Hot key descriptor or NULL if none found. - */ - virtual EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const = 0; - /** * Return a human readable value which can be displayed as zoom * level indicator in dialogs. @@ -389,20 +370,6 @@ public: virtual void ReCreateVToolbar() = 0; virtual void ReCreateAuxiliaryToolbar() { } - // Toolbar accessors - ACTION_TOOLBAR* GetMainToolBar() const { return m_mainToolBar; } - ACTION_TOOLBAR* GetOptionsToolBar() const { return m_optionsToolBar; } - ACTION_TOOLBAR* GetDrawToolBar() const { return m_drawToolBar; } - ACTION_TOOLBAR* GetAuxiliaryToolBar() const { return m_auxiliaryToolBar; } - - /** - * Checks all the toolbars and returns true if the given tool id is toggled. - * - * This is needed because GerbView and Pcbnew can put some of the same tools in - * different toolbars. - */ - bool GetToolToggled( int aToolId ); - /** * Set the tool command ID to \a aId and sets the cursor to \a aCursor. * diff --git a/include/hotkey_store.h b/include/hotkey_store.h index fd5b5ec908..76182fbca0 100644 --- a/include/hotkey_store.h +++ b/include/hotkey_store.h @@ -21,98 +21,25 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file hotkey_store.h - */ - #ifndef HOTKEY_STORE__H #define HOTKEY_STORE__H - #include <hotkeys_basic.h> +class TOOL_MANAGER; -/** - * Class that manages a hotkey that can be changed, reset to its - * old value, a default or saved. - */ -class CHANGED_HOTKEY + +struct HOTKEY { -public: - CHANGED_HOTKEY( EDA_HOTKEY& aHotkey, const wxString& aTag ): - m_orig( aHotkey ), - m_changed( aHotkey ), - m_tag( aTag ) - {} - - EDA_HOTKEY& GetCurrentValue() - { - return m_changed; - } - - const EDA_HOTKEY& GetCurrentValue() const - { - return m_changed; - } - - /** - * Gets the original value of the hotkey. This is what the hotkey used - * to be, and what it would be set to if reset. - * - * @return reference to the original hotkey. - */ - const EDA_HOTKEY& GetOriginalValue() const - { - return m_orig; - } - - /** - * Save changed hotkey to the original location. - */ - void SaveHotkey() - { - m_orig = m_changed; - } - - /** - * @brief Return true if the hotkey doesn't match the original (i.e. it - * has been changed) - */ - bool HasUnsavedChange() const - { - return m_orig.m_KeyCode != m_changed.m_KeyCode; - } - - const wxString& GetSectionTag() const - { - return m_tag; - } - -private: - // Reference to an "original" hotkey config - EDA_HOTKEY& m_orig; - - // A separate changeable config - EDA_HOTKEY m_changed; - - // The hotkey section tag, used to spot conflicts - const wxString& m_tag; - + TOOL_ACTION* m_Parent; + int m_EditKeycode; }; -/** - * Associates a set of hotkeys (a section) with a display name and the hotkeys - */ + struct HOTKEY_SECTION { - // The displayed, translated, name of the section - wxString m_name; - - // List of update-able hotkey data for this section - std::vector<CHANGED_HOTKEY> m_hotkeys; - - // Back reference to the underlying hotkey data of this section - EDA_HOTKEY_CONFIG& m_section; + wxString m_SectionName; // The displayed, translated, name of the section + std::vector<HOTKEY> m_HotKeys; }; @@ -124,26 +51,22 @@ class HOTKEY_STORE { public: - using SECTION_LIST = std::vector<HOTKEY_SECTION>; - /** * Construct a HOTKEY_STORE from a list of hotkey sections * * @param aHotkeys the hotkey configs that will be managed by this store. */ - HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys ); + HOTKEY_STORE(); + + void Init( std::vector<TOOL_MANAGER*> aToolManagerList ); + + static wxString GetAppName( TOOL_ACTION* aAction ); + static wxString GetSectionName( TOOL_ACTION* aAction ); /** * Get the list of sections managed by this store */ - SECTION_LIST& GetSections(); - - - /** - * Find a hotkey with the given command ID and in the given section - * @return pointer to the hotkey if found. - */ - CHANGED_HOTKEY* FindHotkey( const wxString& aTag, int aCmdId ); + std::vector<HOTKEY_SECTION>& GetSections(); /** * Persist all changes to hotkeys in the store to the underlying @@ -164,24 +87,16 @@ public: /** * Check whether the given key conflicts with anything in this store. * + * @param aAction - the action the key is proposed to be assigned to. Only conflicts + * within the same section will be flagged. * @param aKey - key to check - * @param aSectionTag - section tag into which the key is proposed to be installed - * @param aConfKey - if not NULL, outparam getting the key this one conflicts with - * @param aConfSect - if not NULL, outparam getting the section this one conflicts with + * @param aConflict - outparam getting the section this one conflicts with */ - bool CheckKeyConflicts( long aKey, const wxString& aSectionTag, - EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect ); + bool CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict ); private: - - /** - * Generate a HOTKEY_SECTION for a single section - * described by an EDA_HOTKEY_CONFIG - */ - HOTKEY_SECTION genSection( EDA_HOTKEY_CONFIG& aSection ); - - // Internal data for every hotkey passed in - SECTION_LIST m_hk_sections; + std::vector<TOOL_MANAGER*> m_toolManagers; + std::vector<HOTKEY_SECTION> m_hk_sections; }; #endif // HOTKEY_STORE__H \ No newline at end of file diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index a52caa1ac3..f283068083 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -21,14 +21,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file hotkeys_basic.h - * @brief Some functions to handle hotkeys in KiCad - */ - #ifndef HOTKEYS_BASIC_H #define HOTKEYS_BASIC_H +#include <map> #include <common.h> #define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" ) @@ -43,6 +39,8 @@ // strings to translate #include <i18n_utility.h> // _HKI definition +class TOOL_ACTION; +class TOOL_MANAGER; class EDA_BASE_FRAME; @@ -58,9 +56,6 @@ extern wxString g_CommonSectionTag; */ class EDA_HOTKEY { -private: - int m_defaultKeyCode; // Key code assigned upon object construction, to be used as default value - public: int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key wxString m_InfoMsg; // info message. @@ -69,13 +64,6 @@ public: public: EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 ); - EDA_HOTKEY( const EDA_HOTKEY* base); - void ResetKeyCodeToDefault() { m_KeyCode = m_defaultKeyCode; } - - int GetDefaultKeyCode() const - { - return m_defaultKeyCode; - } }; @@ -94,39 +82,12 @@ public: struct EDA_HOTKEY_CONFIG { public: - wxString* m_SectionTag; // The configuration file section name. - EDA_HOTKEY** m_HK_InfoList; // List of EDA_HOTKEY pointers - wxString* m_Title; // Title displayed in hotkey editor and used as comment in file + wxString* m_SectionTag; // The configuration file section name. + EDA_HOTKEY** m_HK_InfoList; // List of EDA_HOTKEY pointers + wxString* m_Title; // Title displayed in hotkey editor and used as comment in file }; -/** - * Class EDA_HOTKEY_CLIENT_DATA - * provides client data member for hotkeys to include in command events generated - * by the hot key. - */ -class EDA_HOTKEY_CLIENT_DATA : public wxClientData -{ - //< Logical position of the mouse cursor when the hot key was pressed. - wxPoint m_position; - -public: - EDA_HOTKEY_CLIENT_DATA( const wxPoint& aPosition = wxDefaultPosition ) : - m_position( aPosition ) {} - - ~EDA_HOTKEY_CLIENT_DATA(); - - void SetPosition( const wxPoint& aPosition ) { m_position = aPosition; } - - wxPoint GetPosition() { return m_position; } -}; - - -/* Functions: - */ -void AddHotkeyConfigMenu( wxMenu* menu ); -void HandleHotkeyConfigMenuSelection( EDA_BASE_FRAME* frame, int id ); - /** * Function KeyNameFromKeyCode * return the key name from the key code @@ -136,7 +97,7 @@ void HandleHotkeyConfigMenuSelection( EDA_BASE_FRAME* frame, int id ); * @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default) * @return the key name in a wxString */ -wxString KeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL ); +wxString KeyNameFromKeyCode( int aKeycode, bool * aIsFound = nullptr ); /** * Function KeyNameFromCommandId @@ -147,17 +108,6 @@ wxString KeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL ); */ wxString KeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId ); -/** - - * Function KeyCodeFromKeyName - * return the key code from its key name - * Only some wxWidgets key values are handled for function key - * @param keyname = wxString key name to find in s_Hotkey_Name_List[], - * like F2 or space or an usual (ascii) char. - * @return the key code - */ -int KeyCodeFromKeyName( const wxString& keyname ); - /** * An helper enum for AddHotkeyName function * In menus we can add a hot key, or an accelerator , or sometimes just a comment @@ -169,21 +119,18 @@ int KeyCodeFromKeyName( const wxString& keyname ); enum HOTKEY_ACTION_TYPE { IS_HOTKEY, - IS_ACCELERATOR, IS_COMMENT }; /** - * Function AddHotkeyName - * Add the key name from the Command id value ( m_Idcommand member value) - * @param aText = a wxString. returns aText + key name - * @param aList = pointer to a EDA_HOTKEY list of commands - * @param aCommandId = Command Id value - * @param aShortCutType The #HOTKEY_ACTION_TYPE of the shortcut. - * @return a wxString (aTest + key name) if key found or aText without modification + * AddHotkeyName + * @param aText - the base text on which to append the hotkey + * @param aHotKey - the hotkey keycode + * @param aStyle - IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) + * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips */ -wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList, int aCommandId, - HOTKEY_ACTION_TYPE aShortCutType = IS_HOTKEY); +wxString AddHotkeyName( const wxString& aText, int aHotKey, + HOTKEY_ACTION_TYPE aStyle = IS_HOTKEY); /** * Function AddHotkeyName @@ -203,101 +150,33 @@ wxString AddHotkeyName( const wxString& aText, * Function DisplayHotkeyList * Displays the current hotkey list * @param aFrame = current active frame - * @param aList = pointer to a EDA_HOTKEY_CONFIG list (Null terminated) + * @param aToolMgr = the tool manager holding the registered actions from which the hotkeys + * will be harvested */ -void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aList ); +void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, TOOL_MANAGER* aToolMgr ); /** - * Function GetDescriptorFromHotkey - * Returns a EDA_HOTKEY* pointer from a key code for OnHotKey() function - * @param aKey = key code (ascii value, or wxWidgets value for function keys - * @param aList = pointer to a EDA_HOTKEY list of commands - * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List + * Function WriteHotKeyConfig + * Updates the hotkeys config file with the hotkeys from the given actions map. */ -EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList ); +int WriteHotKeyConfig( std::map<std::string, TOOL_ACTION*> aActionMap ); /** - * Function GetDescriptorFromCommand - * Returns a EDA_HOTKEY* pointer from a hot key identifier. - * @param aCommand = hot key identifier (@see hotkeys.h) - * @param aList = pointer to a EDA_HOTKEY list of commands - * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List - */ -EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList ); - -/** - * Function ReadHotkeyConfig + * Function ReadLegacyHotkeyConfigFile * Read hotkey configuration for a given app, * possibly before the frame for that app has been created * @param aFilename = the filename to save the hotkeys as - * @param aDescList = the hotkey data - * @param aDefaultLocation = if true, add hotkey path and extension to aFilename + * @param aMap The list of keycodes mapped by legacy property names * @return 1 on success, 0 on failure */ -int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList, - const bool aDefaultLocation = true ); +int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string, int>& aMap ); /** - * Function ReadHotkeyConfig + * Function ReadLegacyHotkeyConfig * Read configuration data and fill the current hotkey list with hotkeys * @param aAppname = the value of the app's m_FrameName - * @param aDescList = current hotkey list descr. to initialize. + * @param aMap The list of keycodes mapped by legacy property names */ -int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescList ); - -/** - * Function ParseHotkeyConfig - * Translates hotkey string data into application hotkeys - * @param data The string of data read from the configuration files - * @param aDescList The list of hotkeys to update - * @param aAppname The application interface requesting hotkey updates or empty for all - */ -void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescList, - const wxString& aAppname ); - - -// common hotkeys event id -// these hotkey ID are used in many files, so they are define here only once. -enum common_hotkey_id_command { - HK_NOT_FOUND = 0, - HK_NEW, - HK_OPEN, - HK_SAVE, - HK_SAVEAS, - HK_PRINT, - HK_UNDO, - HK_REDO, - HK_CUT, - HK_COPY, - HK_PASTE, - HK_DUPLICATE, - HK_DELETE, - HK_FIND, - HK_FIND_NEXT, - HK_FIND_NEXT_MARKER, - HK_REPLACE, - HK_RESET_LOCAL_COORD, - HK_SET_GRID_ORIGIN, - HK_RESET_GRID_ORIGIN, - HK_SWITCH_GRID_TO_FASTGRID1, - HK_SWITCH_GRID_TO_FASTGRID2, - HK_SWITCH_GRID_TO_NEXT, - HK_SWITCH_GRID_TO_PREVIOUS, - HK_SWITCH_UNITS, - HK_HELP, - HK_ZOOM_IN, - HK_ZOOM_OUT, - HK_ZOOM_REDRAW, - HK_ZOOM_CENTER, - HK_ZOOM_AUTO, - HK_ZOOM_SELECTION, - HK_LEFT_CLICK, - HK_LEFT_DCLICK, - HK_PREFERENCES, - HK_TOGGLE_CURSOR, - HK_MEASURE_TOOL, - HK_UPDATE_PCB_FROM_SCH, - HK_COMMON_END -}; +int ReadLegacyHotkeyConfig( const wxString& aAppname, std::map<std::string, int>& aMap ); #endif // HOTKEYS_BASIC_H diff --git a/include/panel_hotkeys_editor.h b/include/panel_hotkeys_editor.h index 91e40df905..4951eb1406 100644 --- a/include/panel_hotkeys_editor.h +++ b/include/panel_hotkeys_editor.h @@ -34,24 +34,23 @@ class wxPanel; class wxSizer; +class TOOL_MANAGER; class PANEL_HOTKEYS_EDITOR : public wxPanel { protected: - EDA_BASE_FRAME* m_frame; - bool m_readOnly; - struct EDA_HOTKEY_CONFIG* m_hotkeys; - wxString m_nickname; + bool m_readOnly; + std::vector<TOOL_MANAGER*> m_toolManagers; - HOTKEY_STORE m_hotkeyStore; - WIDGET_HOTKEY_LIST* m_hotkeyListCtrl; + HOTKEY_STORE m_hotkeyStore; + WIDGET_HOTKEY_LIST* m_hotkeyListCtrl; public: - PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, bool aReadOnly, - EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys, - const wxString& aNickname ); + PANEL_HOTKEYS_EDITOR( wxWindow* aWindow, bool aReadOnly ); + void AddHotKeys( TOOL_MANAGER* aToolMgr ); + bool TransferDataToWindow() override; bool TransferDataFromWindow() override; diff --git a/include/pgm_base.h b/include/pgm_base.h index 4aba77bb30..dd056043ba 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -63,9 +63,6 @@ class wxApp; class wxMenu; class wxWindow; -class FILENAME_RESOLVER; -class EDA_DRAW_FRAME; - class FILE_HISTORY : public wxFileHistory { diff --git a/include/tool/action_manager.h b/include/tool/action_manager.h index 63649b8272..e6f9b8841c 100644 --- a/include/tool/action_manager.h +++ b/include/tool/action_manager.h @@ -74,6 +74,11 @@ public: */ static int MakeActionId( const std::string& aActionName ); + /** + * Get a list of currently-registered actions mapped by their name. + */ + const std::map<std::string, TOOL_ACTION*>& GetActions(); + /** * Function FindAction() * Finds an action with a given name (if there is one available). @@ -98,7 +103,7 @@ public: int GetHotKey( const TOOL_ACTION& aAction ) const; /** - * Function UpdateHotKeys() + * Function ReadHotKeyConfig() * Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot Key Editor settings. */ void UpdateHotKeys(); @@ -117,9 +122,10 @@ public: } private: - ///> Resolves a reference to legacy hot key settings to a particular hot key. - ///> @param aAction is the action to be resolved. - int processHotKey( TOOL_ACTION* aAction ); + // Resolves a hotkey by applying legacy and current settings over the action's + // default hotkey. + int processHotKey( TOOL_ACTION* aAction, std::map<std::string, int> aLegacyMap, + std::map<std::string, int> aHotKeyMap ); ///> Tool manager needed to run actions TOOL_MANAGER* m_toolMgr; diff --git a/include/tool/actions.h b/include/tool/actions.h index da0dfed50d..6218065d37 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -32,6 +32,8 @@ class TOOL_EVENT; class TOOL_MANAGER; +#define LEGACY_HK_NAME( x ) x + /** * Class ACTIONS * @@ -94,8 +96,6 @@ public: static TOOL_ACTION toggleCursor; static TOOL_ACTION toggleCursorStyle; static TOOL_ACTION highContrastMode; - static TOOL_ACTION highContrastInc; - static TOOL_ACTION highContrastDec; /// Cursor control with keyboard static TOOL_ACTION cursorUp; @@ -146,11 +146,17 @@ public: static TOOL_ACTION showFootprintBrowser; static TOOL_ACTION showFootprintEditor; static TOOL_ACTION updatePcbFromSchematic; + static TOOL_ACTION acceleratedGraphics; + static TOOL_ACTION standardGraphics; + + // Suite static TOOL_ACTION configurePaths; static TOOL_ACTION showSymbolLibTable; static TOOL_ACTION showFootprintLibTable; - static TOOL_ACTION acceleratedGraphics; - static TOOL_ACTION standardGraphics; + static TOOL_ACTION gettingStarted; + static TOOL_ACTION help; + static TOOL_ACTION listHotKeys; + static TOOL_ACTION getInvolved; /** * Function TranslateLegacyId() diff --git a/include/tool/common_control.h b/include/tool/common_control.h new file mode 100644 index 0000000000..e0097e42cb --- /dev/null +++ b/include/tool/common_control.h @@ -0,0 +1,67 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 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 2 + * 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 here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef COMMON_CONTROL_H +#define COMMON_CONTROL_H + +#include <tool/tool_interactive.h> + +class EDA_BASE_FRAME; + +/** + * Class COMMON_CONTROL + * + * Handles actions that are shared between different applications + */ + +class COMMON_CONTROL : public TOOL_INTERACTIVE +{ +public: + COMMON_CONTROL() : + TOOL_INTERACTIVE( "common.SuiteControl" ), + m_frame( nullptr ) + { } + + ~COMMON_CONTROL() override { } + + /// @copydoc TOOL_BASE::Reset() + void Reset( RESET_REASON aReason ) override; + + int ConfigurePaths( const TOOL_EVENT& aEvent ); + int ShowLibraryTable( const TOOL_EVENT& aEvent ); + + int ShowPlayer( const TOOL_EVENT& aEvent ); + + int ShowHelp( const TOOL_EVENT& aEvent ); + int ListHotKeys( const TOOL_EVENT& aEvent ); + int GetInvolved( const TOOL_EVENT& aEvent ); + + ///> Sets up handlers for various events. + void setTransitions() override; + +private: + ///> Pointer to the currently used edit frame. + EDA_BASE_FRAME* m_frame; +}; + +#endif diff --git a/include/tool/common_tools.h b/include/tool/common_tools.h index 4691669df6..32e9e1009d 100644 --- a/include/tool/common_tools.h +++ b/include/tool/common_tools.h @@ -40,10 +40,10 @@ class COMMON_TOOLS : public TOOL_INTERACTIVE public: COMMON_TOOLS() : TOOL_INTERACTIVE( "common.Control" ), - m_frame( NULL ) + m_frame( nullptr ) { } - virtual ~COMMON_TOOLS() { } + ~COMMON_TOOLS() override { } /// @copydoc TOOL_BASE::Reset() void Reset( RESET_REASON aReason ) override; @@ -79,12 +79,8 @@ public: int ToggleGrid( const TOOL_EVENT& aEvent ); int GridProperties( const TOOL_EVENT& aEvent ); - int ConfigurePaths( const TOOL_EVENT& aEvent ); - int ShowLibraryTable( const TOOL_EVENT& aEvent ); int SwitchCanvas( const TOOL_EVENT& aEvent ); - int ShowPlayer( const TOOL_EVENT& aEvent ); - ///> Sets up handlers for various events. void setTransitions() override; diff --git a/include/tool/selection_conditions.h b/include/tool/selection_conditions.h index c54102ab5e..7cffb8d8e1 100644 --- a/include/tool/selection_conditions.h +++ b/include/tool/selection_conditions.h @@ -28,7 +28,6 @@ #include <functional> #include <core/typeinfo.h> #include <vector> - #include <tool/selection.h> ///> Functor type that checks a specific condition for selected items. diff --git a/include/tool/tool_action.h b/include/tool/tool_action.h index 84796f15a2..31eb5dc5e3 100644 --- a/include/tool/tool_action.h +++ b/include/tool/tool_action.h @@ -47,9 +47,10 @@ class TOOL_ACTION { public: TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT, - int aDefaultHotKey = 0, const wxString& aMenuItem = wxEmptyString, - const wxString& aMenuDesc = wxEmptyString, const BITMAP_OPAQUE* aIcon = NULL, - TOOL_ACTION_FLAGS aFlags = AF_NONE, void* aParam = NULL ); + int aDefaultHotKey = 0, const std::string& aLegacyHotKeyName = "", + const wxString& aMenuText = wxEmptyString, const wxString& aTooltip = wxEmptyString, + const BITMAP_OPAQUE* aIcon = nullptr, TOOL_ACTION_FLAGS aFlags = AF_NONE, + void* aParam = nullptr ); ~TOOL_ACTION(); @@ -66,15 +67,25 @@ public: /** * Function GetName() * Returns name of the action. It is the same one that is contained in TOOL_EVENT that is - * sent by activating the TOOL_ACTION. + * sent by activating the TOOL_ACTION. Convention is "app.tool.actionName". * * @return Name of the action. */ - const std::string& GetName() const - { - return m_name; - } - + const std::string& GetName() const { return m_name; } + + /** + * Function GetDefaultHotKey() + * Returns the default hotkey (if any) for the action. + */ + int GetDefaultHotKey() const { return m_defaultHotKey; } + + /** + * Function GetHotKey() + * Returns the hotkey keycode which initiates the action. + */ + int GetHotKey() const { return m_hotKey; } + void SetHotKey( int aKeycode ) { m_hotKey = aKeycode; } + /** * Function GetId() * Returns the unique id of the TOOL_ACTION object. It is valid only after registering the @@ -82,10 +93,7 @@ public: * * @return The unique identification number. If the number is negative, then it is not valid. */ - int GetId() const - { - return m_id; - } + int GetId() const { return m_id; } /** * Function MakeEvent() @@ -102,30 +110,13 @@ public: return TOOL_EVENT( TC_COMMAND, TA_ACTION, m_name, m_scope, m_param ); } - const wxString& GetMenuItem() const - { - return m_menuItem; - } + const wxString& GetMenuItem() const { return m_menuText; } + void SetMenuItem( const wxString& aItem ) { m_menuText = aItem; } - void SetMenuItem( const wxString& aItem ) - { - m_menuItem = aItem; - } + const wxString& GetDescription() const { return m_tooltip; } + void SetDescription( const wxString& aDescription ) { m_tooltip = aDescription; } - const wxString& GetDescription() const - { - return m_menuDescription; - } - - void SetDescription( const wxString& aDescription ) - { - m_menuDescription = aDescription; - } - - TOOL_ACTION_SCOPE GetScope() const - { - return m_scope; - } + TOOL_ACTION_SCOPE GetScope() const { return m_scope; } /** * Returns name of the tool associated with the action. It is basically the action name @@ -158,57 +149,26 @@ public: return m_icon; } - /** - * Creates a hot key code that refers to a legacy hot key setting, instead of a particular key. - * @param aHotKey is an ID of hot key to be referred (see hotkeys.h). - */ - inline static int LegacyHotKey( int aHotKey ) - { - assert( ( aHotKey & LEGACY_HK ) == 0 ); - - return aHotKey | LEGACY_HK; - } - private: friend class ACTION_MANAGER; - /// Returns the hot key assigned in the object definition. It may refer to a legacy hot key setting - /// (if LEGACY_HK flag is set). - int getDefaultHotKey() - { - return m_defaultHotKey; - } + /// Name of the action (convention is "app.tool.actionName") + std::string m_name; + TOOL_ACTION_SCOPE m_scope; - /// Name of the action (convention is: app.[tool.]action.name) - std::string m_name; + const int m_defaultHotKey; // Default hot key + int m_hotKey; // The curret hotkey (post-user-settings-application) + const std::string m_legacyName; // Name for reading legacy hotkey settings - /// Scope of the action - TOOL_ACTION_SCOPE m_scope; + wxString m_menuText; + wxString m_tooltip; + const BITMAP_OPAQUE* m_icon; // Icon for the menu entry - /// Default hot key that activates the action. - const int m_defaultHotKey; + int m_id; // Unique ID for maps. Assigned by ACTION_MANAGER. - /// Menu entry text - wxString m_menuItem; + TOOL_ACTION_FLAGS m_flags; + void* m_param; // Generic parameter - /// Pop-up help - wxString m_menuDescription; - - // Icon for menu entry - const BITMAP_OPAQUE* m_icon; - - /// Unique ID for fast matching. Assigned by ACTION_MANAGER. - int m_id; - - /// Action flags - TOOL_ACTION_FLAGS m_flags; - - /// Generic parameter - void* m_param; - - /// Flag to determine the hot key settings is not a particular key, but a reference to legacy - /// hot key setting. - static const int LEGACY_HK = 0x800000; }; #endif diff --git a/include/tool/tool_base.h b/include/tool/tool_base.h index a8a5fcf6fe..32727c5a54 100644 --- a/include/tool/tool_base.h +++ b/include/tool/tool_base.h @@ -36,7 +36,6 @@ class EDA_ITEM; class TOOL_MANAGER; -class wxWindow; namespace KIGFX { @@ -187,6 +186,9 @@ protected: template <typename T> T* getEditFrame() const { +#if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework + wxASSERT( dynamic_cast<T*>( getEditFrameInt() ) ); +#endif return static_cast<T*>( getEditFrameInt() ); } @@ -199,8 +201,9 @@ protected: T* getModel() const { EDA_ITEM* m = getModelInt(); +#if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework wxASSERT( dynamic_cast<T*>( m ) ); - +#endif return static_cast<T*>( m ); } @@ -220,7 +223,7 @@ private: // hide the implementation to avoid spreading half of // kicad and wxWidgets headers to the tools that may not need them at all! EDA_ITEM* getModelInt() const; - wxWindow* getEditFrameInt() const; + EDA_BASE_FRAME* getEditFrameInt() const; }; #endif diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index f88b670ecb..0449c3782e 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -158,9 +158,11 @@ public: RunAction( aAction, aNow, (void*) NULL ); } + const std::map<std::string, TOOL_ACTION*>& GetActions(); + ///> @copydoc ACTION_MANAGER::GetHotKey() int GetHotKey( const TOOL_ACTION& aAction ); - + ///> @copydoc ACTION_MANAGER::UpdateHotKeys() void UpdateHotKeys(); diff --git a/include/widgets/widget_hotkey_list.h b/include/widgets/widget_hotkey_list.h index 6c1065aa9f..4dfb92a9ee 100644 --- a/include/widgets/widget_hotkey_list.h +++ b/include/widgets/widget_hotkey_list.h @@ -55,13 +55,6 @@ class WIDGET_HOTKEY_LIST : public TWO_COLUMN_TREE_LIST */ WIDGET_HOTKEY_CLIENT_DATA* GetHKClientData( wxTreeListItem aItem ); - /** - * Method GetSelHKClientData - * Return the WIDGET_HOTKEY_CLIENT_DATA for the item being edited, or NULL if - * none is selected. - */ - WIDGET_HOTKEY_CLIENT_DATA* GetSelHKClientData(); - /** * Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't * found. This is for use when the data not being present indicates an @@ -93,7 +86,7 @@ class WIDGET_HOTKEY_LIST : public TWO_COLUMN_TREE_LIST * @param aHotkey the change-able hotkey to try to change * @param aKey the key code to change it to */ - void changeHotkey( CHANGED_HOTKEY& aHotkey, long aKey ); + void changeHotkey( HOTKEY& aHotkey, long aKey ); protected: @@ -150,11 +143,11 @@ protected: * section and g_CommonSectionTag section. * * @param aKey - key to check - * @param aSectionTag - section tag into which the key is proposed to be installed + * @param aActionName - name of the action into which the key is proposed to be installed * * @return true iff the user accepted the overwrite or no conflict existed */ - bool ResolveKeyConflicts( long aKey, const wxString& aSectionTag ); + bool ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey ); public: /** diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 3948e241f5..b8d4d56825 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -142,8 +142,5 @@ void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, const w btn->SetToolTip( aToolTip ); - m_buttonSizer->Add( btn, - 0, - wxALL | wxEXPAND, - BUTTON_SEPARATION ); + m_buttonSizer->Add( btn, 0, wxALL | wxEXPAND, BUTTON_SEPARATION ); } diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 63dae24711..a201b961a0 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -124,11 +124,6 @@ bool PGM_KICAD::OnPgmInit() m_bm.m_search.Insert( it->second.GetValue(), 0 ); } - // Must be called before creating the main frame in order to - // display the real hotkeys in menus or tool tips - extern struct EDA_HOTKEY_CONFIG kicad_Manager_Hotkeys_Descr[]; - ReadHotkeyConfig( KICAD_MANAGER_FRAME_NAME, kicad_Manager_Hotkeys_Descr ); - KICAD_MANAGER_FRAME* frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ), wxDefaultPosition, wxSize( 775, -1 ) ); App().SetTopWindow( frame ); diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index e40cbc12e1..4e99f8ccab 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -23,8 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <eda_draw_frame.h> -#include <panel_hotkeys_editor.h> #include <gestfich.h> #include <kiway.h> #include <kiway_player.h> @@ -32,12 +30,13 @@ #include <bitmaps.h> #include <executable_names.h> #include <build_version.h> -#include <dialog_configure_paths.h> -#include <dialog_edit_library_tables.h> #include "pgm_kicad.h" #include "tree_project_frame.h" #include "kicad_id.h" #include <tool/tool_manager.h> +#include <tool/action_toolbar.h> +#include <tool/common_control.h> +#include <tools/kicad_manager_actions.h> #include <tools/kicad_manager_control.h> #ifdef __WXMAC__ @@ -58,7 +57,6 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl m_active_project = false; m_mainToolBar = nullptr; m_leftWinWidth = 60; - m_manager_Hotkeys_Descr = NULL; m_AboutTitle = "KiCad"; // Create the status line (bottom of the frame) @@ -90,8 +88,10 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl // Create the manager m_toolManager = new TOOL_MANAGER; m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, this ); + m_actions = new KICAD_MANAGER_ACTIONS(); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new KICAD_MANAGER_CONTROL ); m_toolManager->InitTools(); @@ -162,7 +162,6 @@ const wxString KICAD_MANAGER_FRAME::SchFileName() wxFileName fn( GetProjectFileName() ); fn.SetExt( SchematicFileExtension ); - return fn.GetFullPath(); } @@ -172,7 +171,6 @@ const wxString KICAD_MANAGER_FRAME::PcbFileName() wxFileName fn( GetProjectFileName() ); fn.SetExt( PcbFileExtension ); - return fn.GetFullPath(); } @@ -182,7 +180,6 @@ const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName() wxFileName fn( GetProjectFileName() ); fn.SetExt( LegacyPcbFileExtension ); - return fn.GetFullPath(); } @@ -257,8 +254,9 @@ void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate( int pid, int status ) { - wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ), - GetChars( m_appName ), pid ); + wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ), + m_appName, + pid ); wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME ); @@ -276,8 +274,7 @@ void KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate( int pid, int status ) } -void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, - wxString params ) +void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, wxString params ) { if( params.size() ) AddDelimiterString( params ); @@ -289,8 +286,9 @@ void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, if( pid > 0 ) { wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ), - GetChars( execFile ), GetChars( params ), pid ); - + execFile, + params, + pid ); PrintMsg( msg ); #ifdef __WXMAC__ @@ -585,34 +583,3 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo() } -void KICAD_MANAGER_FRAME::OnShowHotkeys( wxCommandEvent& event ) -{ - DisplayHotkeyList( this, m_manager_Hotkeys_Descr ); -} - - -void KICAD_MANAGER_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) -{ - KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB ); - kiface->CreateWindow( this, DIALOG_CONFIGUREPATHS, &Kiway() ); -} - - -void KICAD_MANAGER_FRAME::OnEditSymLibTable( wxCommandEvent& aEvent ) -{ - KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_SCH ); - kiface->CreateWindow( this, DIALOG_SCH_LIBRARY_TABLE, &Kiway() ); -} - - -void KICAD_MANAGER_FRAME::OnEditFpLibTable( wxCommandEvent& aEvent ) -{ - KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB ); - kiface->CreateWindow( this, DIALOG_PCB_LIBRARY_TABLE, &Kiway() ); -} - - -void KICAD_MANAGER_FRAME::OnPreferences( wxCommandEvent& aEvent ) -{ - ShowPreferences( m_manager_Hotkeys_Descr, m_manager_Hotkeys_Descr, wxT( "kicad" ) ); -} diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index 8da9bfe059..91d8b56240 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file kicad/kicad.h - * @brief KICAD_MANAGER_FRAME is the KiCad main frame. - */ - #ifndef KICAD_H #define KICAD_H @@ -40,6 +35,7 @@ class LAUNCHER_PANEL; class TREEPROJECTFILES; class TREE_PROJECT_FRAME; +class ACTION_TOOLBAR; // Identify the type of files handled by Kicad manager // @@ -99,14 +95,9 @@ public: void OnRunPcbCalculator( wxCommandEvent& event ); void OnRunPageLayoutEditor( wxCommandEvent& event ); - void OnConfigurePaths( wxCommandEvent& aEvent ); - void OnEditSymLibTable( wxCommandEvent& aEvent ); - void OnEditFpLibTable( wxCommandEvent& aEvent ); - void OnPreferences( wxCommandEvent& aEvent ); void OnOpenTextEditor( wxCommandEvent& event ); void OnOpenFileInTextEditor( wxCommandEvent& event ); void OnBrowseInFileExplorer( wxCommandEvent& event ); - void OnShowHotkeys( wxCommandEvent& event ); void OnFileHistory( wxCommandEvent& event ); void OnExit( wxCommandEvent& event ); @@ -224,7 +215,6 @@ private: ACTION_TOOLBAR* m_mainToolBar; int m_leftWinWidth; - EDA_HOTKEY_CONFIG* m_manager_Hotkeys_Descr; void language_change( wxCommandEvent& event ); diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 1d01724e1b..6c1d284a08 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -27,6 +27,7 @@ #include <hotkeys_basic.h> #include <menus_helpers.h> #include <tool/tool_manager.h> +#include <tool/action_toolbar.h> #include <tools/kicad_manager_control.h> #include <tools/kicad_manager_actions.h> #include "kicad_manager_frame.h" @@ -45,10 +46,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) EVT_MENU( ID_TO_TEXT_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor ) EVT_MENU( ID_BROWSE_AN_SELECT_FILE, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ) EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer ) - EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, KICAD_MANAGER_FRAME::OnConfigurePaths ) - EVT_MENU( ID_EDIT_SYMBOL_LIBRARY_TABLE, KICAD_MANAGER_FRAME::OnEditSymLibTable ) - EVT_MENU( ID_EDIT_FOOTPRINT_LIBRARY_TABLE, KICAD_MANAGER_FRAME::OnEditFpLibTable ) - EVT_MENU( wxID_PREFERENCES, KICAD_MANAGER_FRAME::OnPreferences ) EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles ) EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles ) EVT_MENU( ID_IMPORT_EAGLE_PROJECT, KICAD_MANAGER_FRAME::OnImportEagleFiles ) @@ -59,10 +56,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, KICAD_MANAGER_FRAME::OnFileHistory ) - // Show hotkeys - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, KICAD_MANAGER_FRAME::OnShowHotkeys ) - - // Special functions EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths ) @@ -95,9 +88,7 @@ END_EVENT_TABLE() enum hotkey_id_command { - HK_RUN_EESCHEMA = HK_COMMON_END, - HK_NEW_PRJ_TEMPLATE, - HK_REFRESH, + HK_RUN_EESCHEMA = 0, HK_RUN_LIBEDIT, HK_RUN_PCBNEW, HK_RUN_FPEDITOR, @@ -115,9 +106,6 @@ enum hotkey_id_command // See hotkeys_basic.h for more info // hotkeys command: -static EDA_HOTKEY HkNewProjectFromTemplate( _HKI( "New Project From Template" ), - HK_NEW_PRJ_TEMPLATE, 'T' + GR_KB_CTRL ); -static EDA_HOTKEY HkRefresh( _HKI( "Refresh Project Tree" ), HK_REFRESH, GR_KB_CTRL + 'R' ); static EDA_HOTKEY HkRunEeschema( _HKI( "Run Eeschema" ), HK_RUN_EESCHEMA, 'E' + GR_KB_CTRL, 0 ); static EDA_HOTKEY HkRunLibedit( _HKI( "Run LibEdit" ), HK_RUN_LIBEDIT, 'L' + GR_KB_CTRL, 0 ); static EDA_HOTKEY HkRunPcbnew( _HKI( "Run Pcbnew" ), HK_RUN_PCBNEW, 'P' + GR_KB_CTRL, 0 ); @@ -129,24 +117,9 @@ static EDA_HOTKEY HkRunPcbCalc( _HKI( "Run PcbCalculator" ), HK_RUN_PCBCALCULATOR, 'A' + GR_KB_CTRL, 0 ); static EDA_HOTKEY HkRunPleditor( _HKI( "Run PlEditor" ), HK_RUN_PLEDITOR, 'Y' + GR_KB_CTRL, 0 ); -// Common: hotkeys_basic.h -static EDA_HOTKEY HkNewProject( _HKI( "New Project" ), HK_NEW, GR_KB_CTRL + 'N' ); -static EDA_HOTKEY HkOpenProject( _HKI( "Open Project" ), HK_OPEN, GR_KB_CTRL + 'O' ); -static EDA_HOTKEY HkSaveProject( _HKI( "Save Project" ), HK_SAVE, GR_KB_CTRL + 'S' ); -static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); -static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), - HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES ); - // List of hotkey descriptors EDA_HOTKEY* common_Hotkey_List[] = { - &HkNewProject, &HkNewProjectFromTemplate, &HkOpenProject, - // Currently there is nothing to save - // (Kicad manager does not save any info in .pro file) -#if 0 - &HkSaveProject, -#endif - &HkRefresh, &HkHelp, &HkPreferences, &HkRunEeschema, &HkRunLibedit, &HkRunPcbnew, &HkRunModedit, &HkRunGerbview, &HkRunBm2Cmp, &HkRunPcbCalc, &HkRunPleditor, @@ -160,7 +133,7 @@ static wxString sectionTitle( _HKI( "Kicad Manager Hotkeys" ) ); struct EDA_HOTKEY_CONFIG kicad_Manager_Hotkeys_Descr[] = { { &g_CommonSectionTag, common_Hotkey_List, §ionTitle }, - { NULL, NULL, NULL } + { nullptr, nullptr, nullptr } }; ///////////// End hotkeys management /////////////////////////////////////// @@ -176,8 +149,6 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* menuBar = new wxMenuBar(); - m_manager_Hotkeys_Descr = kicad_Manager_Hotkeys_Descr; - //-- File menu ----------------------------------------------------------- // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, controlTool ); @@ -295,7 +266,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() prefsMenu->AddItem( ACTIONS::showSymbolLibTable, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), kicad_Manager_Hotkeys_Descr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, SELECTION_CONDITIONS::ShowAlways ); @@ -312,15 +283,6 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() SetMenuBar( menuBar ); delete oldMenuBar; - - // Add the hotkey to the "show hotkey list" menu, because we do not have - // a management of the keyboard keys in Kicad. - // So all hotheys should be added to the menubar - // Note Use wxMenuBar::SetLabel only after the menubar - // has been associated with a frame. (see wxWidgets doc) - msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ), - kicad_Manager_Hotkeys_Descr, HK_HELP ); - menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg ); } diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index b679bc3b3d..75e4948622 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -30,17 +30,20 @@ #include <pgm_base.h> TOOL_ACTION KICAD_MANAGER_ACTIONS::newProject( "kicad.Control.newProject", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_NEW ), + AS_GLOBAL, + MD_CTRL + 'N', LEGACY_HK_NAME( "New Project" ), _( "New Project..." ), _( "Create new blank project" ), new_project_xpm ); TOOL_ACTION KICAD_MANAGER_ACTIONS::newFromTemplate( "kicad.Control.newFromTemplate", - AS_GLOBAL, 0, // TOOL_ACTION::LegacyHotKey( HK_NEW_PRJ_TEMPLATE ), + AS_GLOBAL, + MD_CTRL + 'T', LEGACY_HK_NAME( "New Project From Template" ), _( "New Project from Template..." ), _( "Create new project from template" ), new_project_with_template_xpm ); TOOL_ACTION KICAD_MANAGER_ACTIONS::openProject( "kicad.Control.openProject", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_OPEN ), + AS_GLOBAL, + MD_CTRL + 'O', LEGACY_HK_NAME( "Open Project" ), _( "Open Project..." ), _( "Open an existing project" ), open_project_xpm ); @@ -192,8 +195,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) // Get project destination folder and project file name. wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep(); wxString title = _( "New Project Folder" ); - wxFileDialog dlg( m_frame, title, default_dir, wxEmptyString, - ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFileDialog dlg( m_frame, title, default_dir, wxEmptyString, ProjectFileWildcard(), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); // Add a "Create a new directory" checkbox dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create ); @@ -299,7 +302,6 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent ) m_frame->CreateNewProject( fn.GetFullPath() ); m_frame->LoadProject( fn ); - return 0; } @@ -323,12 +325,10 @@ int KICAD_MANAGER_CONTROL::OpenProject( const TOOL_EVENT& aEvent ) return -1; m_frame->LoadProject( pro ); - return 0; } - int KICAD_MANAGER_CONTROL::Refresh( const TOOL_EVENT& aEvent ) { m_frame->RefreshProjectTree(); @@ -338,9 +338,9 @@ int KICAD_MANAGER_CONTROL::Refresh( const TOOL_EVENT& aEvent ) void KICAD_MANAGER_CONTROL::setTransitions() { - Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() ); - Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newFromTemplate.MakeEvent() ); - Go( &KICAD_MANAGER_CONTROL::OpenProject, KICAD_MANAGER_ACTIONS::openProject.MakeEvent() ); + Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() ); + Go( &KICAD_MANAGER_CONTROL::NewFromTemplate, KICAD_MANAGER_ACTIONS::newFromTemplate.MakeEvent() ); + Go( &KICAD_MANAGER_CONTROL::OpenProject, KICAD_MANAGER_ACTIONS::openProject.MakeEvent() ); - Go( &KICAD_MANAGER_CONTROL::Refresh, ACTIONS::zoomRedraw.MakeEvent() ); + Go( &KICAD_MANAGER_CONTROL::Refresh, ACTIONS::zoomRedraw.MakeEvent() ); } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index 42a23973eb..a1955b06f7 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -24,7 +24,6 @@ set( PL_EDITOR_SRCS pl_draw_panel_gal.cpp pl_editor_undo_redo.cpp properties_frame.cpp - hotkeys.cpp menubar.cpp toolbars_pl_editor.cpp diff --git a/pagelayout_editor/hotkeys.cpp b/pagelayout_editor/hotkeys.cpp deleted file mode 100644 index 991cf87075..0000000000 --- a/pagelayout_editor/hotkeys.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors. - * @author Jean-Pierre Charras, jp.charras at wanadoo.fr - * - * 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <fctsys.h> -#include <common.h> -#include <id.h> -#include <pl_editor_frame.h> -#include <hotkeys.h> -#include <pl_editor_id.h> - - -// Remark: the hotkey message info is used as keyword in hotkey config files and -// as comments in help windows, therefore translated only when displayed -// they are marked _HKI to be extracted by translation tools -// See hotkeys_basic.h for more info - - -/* How to add a new hotkey: - * add a new id in the enum hotkey_id_command like MY_NEW_ID_FUNCTION. - * add a new EDA_HOTKEY entry like: - * static EDA_HOTKEY HkMyNewEntry(_HKI("Command Label"), MY_NEW_ID_FUNCTION, default key value); - * 'Command Label' is the name used in hotkey list display, and the identifier in the - * hotkey list file - * 'MY_NEW_ID_FUNCTION' is the id event function used in the switch in OnHotKey() function. - * 'Default key value' is the default hotkey for this command. - * Can be overrided by the user hotkey list - * Add the 'HkMyNewEntry' pointer in the s_PlEditor_Hotkey_List list - * Add the new code in the switch in OnHotKey() function. - * - * Note: If an hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX) - * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp) - * and see this list for some ascii keys (space ...) - */ - -// Hotkey list: - -// mouse click command: -static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, 0 ); -static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ), HK_LEFT_DCLICK, - WXK_END, 0 ); - -static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); -static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION, - GR_KB_CTRL + WXK_F5 ); -static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); -static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE, 'M' ); -static EDA_HOTKEY HkDeleteItem( _HKI( "Delete Item" ), HK_DELETE, WXK_DELETE ); - -// Common: hotkeys_basic.h -static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO ); -static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO ); - -static EDA_HOTKEY HkCut( _HKI( "Cut" ), HK_CUT, GR_KB_CTRL + 'X' ); -static EDA_HOTKEY HkCopy( _HKI( "Copy" ), HK_COPY, GR_KB_CTRL + 'C' ); -static EDA_HOTKEY HkPaste( _HKI( "Paste" ), HK_PASTE, GR_KB_CTRL + 'V' ); - -static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW ); -static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O', (int) wxID_OPEN ); -static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S', (int) wxID_SAVE ); -static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_CTRL + GR_KB_SHIFT + 'S', - (int) wxID_SAVEAS ); -static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P', (int) wxID_PRINT ); -static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES ); - -// List of common hotkey descriptors -EDA_HOTKEY* s_Common_Hotkey_List[] = -{ - &HkNew, &HkOpen, &HkSave, &HkSaveAs, &HkPrint, - &HkUndo, &HkRedo, - &HkCut, &HkCopy, &HkPaste, &HkDeleteItem, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkZoomAuto, &HkZoomSelection, &HkResetLocalCoord, - &HkHelp, &HkPreferences, - &HkMouseLeftClick, &HkMouseLeftDClick, - NULL -}; - -EDA_HOTKEY* s_PlEditor_Hotkey_List[] = -{ - &HkMoveItem, - &HkDeleteItem, - NULL -}; - -// Titles for hotkey editor and hotkey display -static wxString commonSectionTitle( _HKI( "Common" ) ); - -// list of sections and corresponding hotkey list for Pl_Editor -// (used to create an hotkey config file) -static wxString s_PlEditorSectionTag( wxT( "[pl_editor]" ) ); -static wxString s_PlEditorSectionTitle( _HKI( "Page Layout Editor" ) ); - -struct EDA_HOTKEY_CONFIG PlEditorHotkeysDescr[] = -{ - { &g_CommonSectionTag, s_Common_Hotkey_List, &commonSectionTitle }, - { &s_PlEditorSectionTag, s_PlEditor_Hotkey_List, &s_PlEditorSectionTitle }, - { NULL, NULL, NULL } -}; - - -EDA_HOTKEY* PL_EDITOR_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, s_Common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, s_PlEditor_Hotkey_List ); - - return HK_Descr; -} - - diff --git a/pagelayout_editor/hotkeys.h b/pagelayout_editor/hotkeys.h deleted file mode 100644 index 2d2293bdd2..0000000000 --- a/pagelayout_editor/hotkeys.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file pagelayout_editor/hotkeys.h - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * Copyright (C) 2016-2019 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PL_EDITOR_KOTKEYS_H_ -#define PL_EDITOR_KOTKEYS_H_ - -#include <hotkeys_basic.h> - -// List of hot keys id. -// see also enum common_hotkey_id_command in hotkeys_basic.h -// for shared hotkeys id -enum hotkey_id_command { - HK_PL_EDITOR_START = HK_COMMON_END, - HK_MOVE, - HK_PL_EDITOR_END -}; - -// List of hotkey descriptors for PlEditor. -extern struct EDA_HOTKEY_CONFIG PlEditorHotkeysDescr[]; - -#endif // PL_EDITOR_KOTKEYS_H_ diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index b34a49d826..be64cf6f92 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -31,7 +31,6 @@ #include <tool/selection.h> #include <tools/pl_actions.h> #include <tools/pl_selection_tool.h> -#include "hotkeys.h" #include "pl_editor_frame.h" #include "pl_editor_id.h" @@ -157,7 +156,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() CONDITIONAL_MENU* preferencesMenu = new CONDITIONAL_MENU( false, selTool ); preferencesMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), PlEditorHotkeysDescr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, SELECTION_CONDITIONS::ShowAlways ); diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index fce0b776fe..fb4f668483 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -33,10 +33,7 @@ #include <gestfich.h> #include <ws_draw_item.h> #include <pl_editor_frame.h> -#include <hotkeys.h> - #include <build_version.h> - #include <wx/file.h> #include <wx/snglinst.h> @@ -119,11 +116,6 @@ PGM_BASE& Pgm() bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) { start_common( aCtlBits ); - - // Must be called before creating the main frame in order to - // display the real hotkeys in menus or tool tips - ReadHotkeyConfig( PL_EDITOR_FRAME_NAME, PlEditorHotkeysDescr ); - return true; } diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 17a4abd9bf..13230ef6f5 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -33,15 +33,16 @@ #include <pl_editor_frame.h> #include <pl_editor_id.h> #include <pl_draw_panel_gal.h> -#include <hotkeys.h> #include <pl_editor_screen.h> #include <ws_data_model.h> #include <properties_frame.h> #include <view/view.h> #include <confirm.h> #include <tool/selection.h> +#include <tool/action_toolbar.h> #include <tool/tool_dispatcher.h> #include <tool/tool_manager.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/pl_actions.h> @@ -59,14 +60,10 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory ) - // menu Preferences - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions ) - EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions ) - EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) - EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner) - EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions) + EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner ) + EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::OnSelectPage ) EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode ) EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayEditMode ) @@ -87,7 +84,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_showAxis = false; // true to show X and Y axis on screen m_showGridAxis = true; m_showBorderAndTitleBlock = true; // true for reference drawings. - m_hotkeysDescrList = PlEditorHotkeysDescr; m_originSelectChoice = 0; SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK) WS_DATA_MODEL::GetTheInstance().m_EditMode = true; @@ -206,6 +202,7 @@ void PL_EDITOR_FRAME::setupTools() GetGalCanvas()->SetEventDispatcher( m_toolDispatcher ); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new PL_SELECTION_TOOL ); @@ -266,34 +263,12 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event ) /* Handles the selection of tools, menu, and popup menu commands. */ -void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) +void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event ) { - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetEventObject( this ); - - switch( event.GetId() ) - { - case wxID_PREFERENCES: - ShowPreferences( PlEditorHotkeysDescr, PlEditorHotkeysDescr, wxT( "pl_editor" ) ); - break; - - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - DisplayHotkeyList( this, PlEditorHotkeysDescr ); - break; - - case ID_SELECT_PAGE_NUMBER: - { - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 ); - view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 ); - GetGalCanvas()->Refresh(); - } - break; - - default: - wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) ); - break; - } + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 ); + view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 ); + GetGalCanvas()->Refresh(); } @@ -627,7 +602,7 @@ void PL_EDITOR_FRAME::HardRedraw() drawPanel->DisplayWorksheet(); PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>(); - SELECTION& selection = selTool->GetSelection(); + PL_SELECTION& selection = selTool->GetSelection(); WS_DATA_ITEM* item = nullptr; if( selection.GetSize() == 1 ) diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 54247f2c0a..ce85d6ccf0 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -199,7 +199,7 @@ public: void SaveSettings( wxConfigBase* aCfg ) override; - void Process_Special_Functions( wxCommandEvent& event ); + void OnSelectPage( wxCommandEvent& event ); /** * called when the user select one of the 4 page corner as corner reference (or the @@ -219,9 +219,6 @@ public: void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ); void OnUpdateTitleBlockDisplayEditMode( wxUpdateUIEvent& event ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - /** * Function ToPrinter * Open a dialog frame to print layers diff --git a/pagelayout_editor/properties_frame.cpp b/pagelayout_editor/properties_frame.cpp index d0a7d4852e..014a85261d 100644 --- a/pagelayout_editor/properties_frame.cpp +++ b/pagelayout_editor/properties_frame.cpp @@ -287,7 +287,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WS_DATA_ITEM* aItem ) void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event ) { PL_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PL_SELECTION_TOOL>(); - SELECTION& selection = selTool->GetSelection(); + PL_SELECTION& selection = selTool->GetSelection(); m_parent->SaveCopyInUndoList(); diff --git a/pagelayout_editor/toolbars_pl_editor.cpp b/pagelayout_editor/toolbars_pl_editor.cpp index 7c18be8298..89793270a9 100644 --- a/pagelayout_editor/toolbars_pl_editor.cpp +++ b/pagelayout_editor/toolbars_pl_editor.cpp @@ -20,14 +20,13 @@ */ #include <fctsys.h> - #include <common.h> #include <macros.h> #include <bitmaps.h> +#include <tool/action_toolbar.h> #include <tools/pl_actions.h> #include <pl_editor_id.h> #include <pl_editor_frame.h> -#include <hotkeys.h> void PL_EDITOR_FRAME::ReCreateHToolbar() { diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index 9346b469b4..533314d86d 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -40,42 +40,42 @@ // Drawing tool actions TOOL_ACTION PL_ACTIONS::drawLine( "plEditor.InteractiveDrawing.drawLine", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Line" ), _( "Add a line" ), add_graphical_segments_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::drawRectangle( "plEditor.InteractiveDrawing.drawRectangle", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Rectangle" ), _( "Add a rectangle" ), add_rectangle_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::placeText( "plEditor.InteractiveDrawing.placeText", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Text" ), _( "Add a text item" ), text_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::placeImage( "plEditor.InteractiveDrawing.placeImage", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Bitmap" ), _( "Add a bitmap image" ), image_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::addLine( "plEditor.InteractiveDrawing.addLine", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Line" ), _( "Add a line" ), add_dashed_line_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::addRectangle( "plEditor.InteractiveDrawing.addRectangle", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Rectangle" ), _( "Add a rectangle" ), add_rectangle_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::addText( "plEditor.InteractiveDrawing.addText", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Text" ), _( "Add a text item" ), text_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::addImage( "plEditor.InteractiveDrawing.addImage", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Bitmap" ), _( "Add a bitmap image" ), image_xpm, AF_ACTIVATE ); diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 0770d0947f..e031b0995d 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -29,7 +29,6 @@ #include <tools/pl_picker_tool.h> #include <ws_data_model.h> #include <ws_draw_item.h> -#include <hotkeys.h> #include <bitmaps.h> #include <confirm.h> #include <base_struct.h> @@ -40,18 +39,19 @@ TOOL_ACTION PL_ACTIONS::move( "plEditor.InteractiveEdit.move", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE ), + AS_GLOBAL, + 'M', LEGACY_HK_NAME( "Move Item" ), _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::appendImportedWorksheet( "plEditor.InteractiveEdit.appendWorksheet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Append Existing Page Layout File..." ), _( "Append an existing page layout design file to current file" ), import_xpm, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::deleteItemCursor( "plEditor.InteractiveEdit.deleteTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Delete Items" ), _( "Delete clicked items" ), delete_xpm, AF_ACTIVATE ); diff --git a/pagelayout_editor/tools/pl_editor_control.cpp b/pagelayout_editor/tools/pl_editor_control.cpp index 9cf0ffd17b..4ed45e1f8b 100644 --- a/pagelayout_editor/tools/pl_editor_control.cpp +++ b/pagelayout_editor/tools/pl_editor_control.cpp @@ -37,10 +37,10 @@ #include <dialog_page_settings.h> TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview", - AS_GLOBAL, 0, "", "" ); + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::toggleBackground( "plEditor.EditorControl.ToggleBackground", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Background White" ), _( "Switch between white and black background" ), palette_xpm ); diff --git a/pagelayout_editor/tools/pl_picker_tool.cpp b/pagelayout_editor/tools/pl_picker_tool.cpp index aa6238a5b9..b9ce7ccffe 100644 --- a/pagelayout_editor/tools/pl_picker_tool.cpp +++ b/pagelayout_editor/tools/pl_picker_tool.cpp @@ -28,11 +28,12 @@ #include <view/view_controls.h> #include <pl_editor_frame.h> -TOOL_ACTION PL_ACTIONS::pickerTool( "plEditor.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); +TOOL_ACTION PL_ACTIONS::pickerTool( "plEditor.InteractivePicker.activate", + AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE ); PL_PICKER_TOOL::PL_PICKER_TOOL() : - TOOL_INTERACTIVE( "plEditor.Picker" ), + TOOL_INTERACTIVE( "plEditor.InteractivePicker" ), m_frame( nullptr ), m_cursorCapture( false ), m_autoPanning( false ) diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index 1e6f7b7d96..736572b14c 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -46,26 +46,26 @@ // Selection tool actions TOOL_ACTION PL_ACTIONS::selectionActivate( "plEditor.InteractiveSelection", - AS_GLOBAL, 0, "", "", // No description, not shown anywhere + AS_GLOBAL, 0, "", "", "", // No description, not shown anywhere nullptr, AF_ACTIVATE ); TOOL_ACTION PL_ACTIONS::selectionMenu( "plEditor.InteractiveSelection.SelectionMenu", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::addItemToSel( "plEditor.InteractiveSelection.AddItemToSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::addItemsToSel( "plEditor.InteractiveSelection.AddItemsToSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::removeItemFromSel( "plEditor.InteractiveSelection.RemoveItemFromSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::removeItemsFromSel( "plEditor.InteractiveSelection.RemoveItemsFromSel", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PL_ACTIONS::clearSelection( "plEditor.InteractiveSelection.ClearSelection", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); SELECTION_CONDITION PL_CONDITIONS::Idle = [] (const SELECTION& aSelection ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 2ed5c5f23d..9813b13d58 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -14,7 +14,7 @@ add_subdirectory(connectivity) add_subdirectory(router) -# psnrouter depends on make_lexer outputs in common (bug # 1285878 ) +# psnrouter depends on make_lexer outputs in common (bug #1285878 ) add_dependencies( pnsrouter pcbcommon ) if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) @@ -252,7 +252,6 @@ set( PCBNEW_CLASS_SRCS generate_footprint_info.cpp grid_layer_box_helpers.cpp grid_layer_box_helpers.h - hotkeys.cpp initpcb.cpp layer_widget.cpp load_select_footprint.cpp @@ -328,6 +327,7 @@ set( PCBNEW_SRCS set( PCBNEW_COMMON_SRCS ../common/dialogs/dialog_page_settings.cpp ../common/base_units.cpp + ../common/hotkeys_basic.cpp ) set( PCBNEW_SCRIPTING_DIALOGS diff --git a/pcbnew/array_creator.h b/pcbnew/array_creator.h index 399a57a1ff..21bc29b32a 100644 --- a/pcbnew/array_creator.h +++ b/pcbnew/array_creator.h @@ -30,7 +30,7 @@ #include <class_board.h> #include <class_module.h> #include <class_board_item.h> -#include <tool/selection.h> +#include <tools/pcbnew_selection.h> /*! * Class that performs array creation by producing a dialog to gather @@ -39,7 +39,7 @@ class ARRAY_CREATOR { public: - ARRAY_CREATOR( PCB_BASE_FRAME& aParent, bool editModules, const SELECTION& aSelection ) : + ARRAY_CREATOR( PCB_BASE_FRAME& aParent, bool editModules, const PCBNEW_SELECTION& aSelection ) : m_parent( aParent ), m_editModules( editModules ), m_selection( aSelection ) @@ -53,9 +53,9 @@ public: void Invoke(); private: - PCB_BASE_FRAME& m_parent; - bool m_editModules; - const SELECTION& m_selection; + PCB_BASE_FRAME& m_parent; + bool m_editModules; + const PCBNEW_SELECTION& m_selection; }; #endif /* ARRAY_CREATOR_H_ */ diff --git a/pcbnew/autorouter/autoplacer_tool.cpp b/pcbnew/autorouter/autoplacer_tool.cpp index 87b0694e5c..7e061a364c 100644 --- a/pcbnew/autorouter/autoplacer_tool.cpp +++ b/pcbnew/autorouter/autoplacer_tool.cpp @@ -51,13 +51,13 @@ TOOL_ACTION PCB_ACTIONS::autoplaceSelectedComponents( "pcbnew.Autoplacer.autoplaceSelected", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Place Selected Footprints" ), _( "Performs automatic placement of selected components" ), module_check_xpm ); TOOL_ACTION PCB_ACTIONS::autoplaceOffboardComponents( "pcbnew.Autoplacer.autoplaceOffboard", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Place Off-Board Footprints" ), _( "Performs automatic placement of components outside board area" ), module_xpm ); diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index 4f8340ff4e..c8a2f14b30 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -220,8 +220,8 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid() bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow() { - SELECTION& selection = m_parent->GetToolManager()->GetTool<SELECTION_TOOL>()->GetSelection(); - auto item = dynamic_cast<BOARD_CONNECTED_ITEM*>( selection.Front() ); + PCBNEW_SELECTION& selection = m_parent->GetToolManager()->GetTool<SELECTION_TOOL>()->GetSelection(); + auto item = dynamic_cast<BOARD_CONNECTED_ITEM*>( selection.Front() ); m_tracks->SetValue( g_modifyTracks ); m_vias->SetValue( g_modifyVias ); diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index a38d8ce932..e8718a8f1d 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -25,7 +25,6 @@ #include <base_units.h> #include <common.h> #include <widgets/unit_binder.h> -#include <hotkeys.h> #include <pcb_base_edit_frame.h> #include <class_draw_panel_gal.h> #include <gal/graphics_abstraction_layer.h> @@ -136,8 +135,8 @@ bool DIALOG_SET_GRID::TransferDataToWindow() m_comboBoxGrid1->SetSelection( m_parent->m_FastGrid1 ); m_comboBoxGrid2->SetSelection( m_parent->m_FastGrid2 ); - int hk1 = m_parent->GetHotKeyDescription( HK_SWITCH_GRID_TO_FASTGRID1 )->m_KeyCode; - int hk2 = m_parent->GetHotKeyDescription( HK_SWITCH_GRID_TO_FASTGRID2 )->m_KeyCode; + int hk1 = ACTIONS::gridFast1.GetHotKey(); + int hk2 = ACTIONS::gridFast1.GetHotKey(); m_grid1HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk1 ) ) ); m_grid2HotKey->SetLabel( wxString::Format( wxT( "(%s)" ), KeyNameFromKeyCode( hk2 ) ) ); diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index b7fec69038..66bc976b72 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -35,7 +35,7 @@ #include <board_commit.h> DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, - const SELECTION& aItems, + const PCBNEW_SELECTION& aItems, COMMIT& aCommit ) : DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ), m_frame( aParent ), diff --git a/pcbnew/dialogs/dialog_track_via_properties.h b/pcbnew/dialogs/dialog_track_via_properties.h index e7008470d6..5d0ca907b7 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.h +++ b/pcbnew/dialogs/dialog_track_via_properties.h @@ -27,7 +27,7 @@ #include <core/optional.h> #include <layers_id_colors_and_visibility.h> -class SELECTION; +class PCBNEW_SELECTION; class COMMIT; class NET_SELECTOR_COMBO_POPUP; class PCB_BASE_FRAME; @@ -36,7 +36,7 @@ class D_PAD; class DIALOG_TRACK_VIA_PROPERTIES : public DIALOG_TRACK_VIA_PROPERTIES_BASE { public: - DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems, + DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const PCBNEW_SELECTION& aItems, COMMIT& aCommit ); bool TransferDataFromWindow() override; @@ -51,17 +51,17 @@ private: bool confirmPadChange( const std::vector<D_PAD*>& connectedPads ); - PCB_BASE_FRAME* m_frame; - const SELECTION& m_items; // List of items to be modified. - COMMIT& m_commit; // An undo record to add any changes to. + PCB_BASE_FRAME* m_frame; + const PCBNEW_SELECTION& m_items; // List of items to be modified. + COMMIT& m_commit; // An undo record to add any changes to. - UNIT_BINDER m_trackStartX, m_trackStartY; - UNIT_BINDER m_trackEndX, m_trackEndY; - UNIT_BINDER m_trackWidth; + UNIT_BINDER m_trackStartX, m_trackStartY; + UNIT_BINDER m_trackEndX, m_trackEndY; + UNIT_BINDER m_trackWidth; - UNIT_BINDER m_viaX, m_viaY; - UNIT_BINDER m_viaDiameter, m_viaDrill; + UNIT_BINDER m_viaX, m_viaY; + UNIT_BINDER m_viaDiameter, m_viaDrill; - bool m_tracks; // True if dialog displays any track properties. - bool m_vias; // True if dialog displays any via properties. + bool m_tracks; // True if dialog displays any track properties. + bool m_vias; // True if dialog displays any via properties. }; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 41ddeb7922..070b1460a7 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -39,15 +39,16 @@ #include <class_module.h> #include <pcbnew.h> #include <pcbnew_id.h> -#include <hotkeys.h> #include <footprint_edit_frame.h> #include <footprint_viewer_frame.h> #include <wildcards_and_files_ext.h> #include <pcb_layer_widget.h> #include <invoke_pcb_dialog.h> #include <tool/tool_manager.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> #include <tool/zoom_tool.h> #include <footprint_tree_pane.h> #include <widgets/lib_tree.h> @@ -57,6 +58,7 @@ #include <dialogs/panel_modedit_settings.h> #include <dialogs/panel_modedit_defaults.h> #include <dialogs/panel_modedit_display_options.h> +#include <panel_hotkeys_editor.h> #include <tools/position_relative_tool.h> #include <widgets/progress_reporter.h> #include "tools/selection_tool.h" @@ -86,10 +88,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard ) EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - // Preferences and option menus - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) - EVT_MENU( wxID_PREFERENCES, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) - // popup commands EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) @@ -114,7 +112,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_showBorderAndTitleBlock = false; // true to show the frame references m_showAxis = true; // true to show X and Y axis on screen m_showGridAxis = true; // show the grid origin axis - m_hotkeysDescrList = g_Module_Editor_Hotkeys_Descr; m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_canvasType = aBackend; m_AboutTitle = "ModEdit"; @@ -755,36 +752,16 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & ) } -void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) -{ - int id = event.GetId(); - - switch( id ) - { - // Hotkey IDs - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - // Display current hotkey list for the footprint editor. - DisplayHotkeyList( this, g_Module_Editor_Hotkeys_Descr ); - break; - - case wxID_PREFERENCES: - ShowPreferences( g_Pcbnew_Editor_Hotkeys_Descr, g_Module_Editor_Hotkeys_Descr, - wxT( "pcbnew" ) ); - break; - - default: - DisplayError( this, "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" ); - } -} - - -void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) +void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { wxTreebook* book = aParent->GetTreebook(); book->AddPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Footprint Editor" ) ); book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) ); + + aHotkeysPanel->AddHotKeys( GetToolManager() ); } @@ -801,6 +778,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools() drawPanel->SetEventDispatcher( m_toolDispatcher ); + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new SELECTION_TOOL ); m_toolManager->RegisterTool( new ZOOM_TOOL ); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index e3d6d34945..9ca8f2ad98 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -104,8 +104,6 @@ public: void Process_Special_Functions( wxCommandEvent& event ); - void ProcessPreferences( wxCommandEvent& event ); - /** * Refresh the library tree and redraw the window */ @@ -140,11 +138,7 @@ public: */ bool SaveLibraryAs( const wxString& aLibraryPath ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ); - void OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent ); void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent ); void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent ); @@ -318,7 +312,7 @@ public: /** * Allows Modedit to install its preferences panel into the preferences dialog. */ - void InstallPreferences( PAGED_DIALOG* aParent ) override; + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; void ReFillLayerWidget(); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 9f5491470f..dd1a6d705d 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -39,18 +39,15 @@ #include <pcb_painter.h> #include <class_board.h> #include <class_module.h> - #include <pcbnew.h> #include <pcbnew_id.h> #include <footprint_viewer_frame.h> #include <footprint_info.h> - -#include <hotkeys.h> #include <wildcards_and_files_ext.h> #include <config_params.h> - #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> #include <tool/common_tools.h> #include "tools/selection_tool.h" #include "tools/pcbnew_control.h" @@ -143,8 +140,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); SetIcon( icon ); - m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr; - m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL | wxNO_BORDER ); diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 3f1573102f..340b95fa86 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -121,9 +121,6 @@ private: void InstallDisplayOptions( wxCommandEvent& event ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 816f087870..8c521b327a 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -26,35 +26,27 @@ #include <fctsys.h> #include <kiface_i.h> -#include <gal/graphics_abstraction_layer.h> #include <pcb_draw_panel_gal.h> #include <pcb_edit_frame.h> -#include <pcbnew.h> #include <3d_viewer/eda_3d_viewer.h> #include <msgpanel.h> #include <macros.h> #include <bitmaps.h> #include <grid_tricks.h> #include <eda_dockart.h> - #include <class_board.h> #include <class_module.h> #include <footprint_edit_frame.h> - #include <pcbnew_id.h> #include "footprint_wizard_frame.h" #include <footprint_info.h> -#include <wx/grid.h> #include <wx/tokenzr.h> #include <wx/numformatter.h> -#include <wx/statline.h> - -#include <hotkeys.h> #include <wildcards_and_files_ext.h> #include <base_units.h> - #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> #include <tool/common_tools.h> #include "tools/selection_tool.h" #include "tools/pcbnew_control.h" @@ -107,7 +99,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) ); SetIcon( icon ); - m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr; m_wizardName.Empty(); SetBoard( new BOARD() ); diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 381915bc97..d81a4cb9c5 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -181,9 +181,6 @@ private: void ClickOnPageList( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp deleted file mode 100644 index 4aac52b340..0000000000 --- a/pcbnew/hotkeys.cpp +++ /dev/null @@ -1,607 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <fctsys.h> -#include <pcbnew.h> -#include <pcb_edit_frame.h> -#include <footprint_edit_frame.h> -#include <footprint_viewer_frame.h> -#include <footprint_wizard_frame.h> -#include <pcbnew_id.h> -#include <hotkeys.h> - -// Remark: the hotkey message info is used as keyword in hotkey config files and -// as comments in help windows, therefore translated only when displayed -// they are marked _HKI to be extracted by translation tools -// See hotkeys_basic.h for more info - - -/* How to add a new hotkey: - * add a new id in the enum hotkey_id_command like MY_NEW_ID_FUNCTION. - * add a new EDA_HOTKEY entry like: - * static EDA_HOTKEY HkMyNewEntry(_HKI("Command Label"), MY_NEW_ID_FUNCTION, default key value); - * "Command Label" is the name used in hotkey list display, and the identifier in the - * hotkey list file MY_NEW_ID_FUNCTION is an equivalent id function used in the switch - * in OnHotKey() function. - * default key value is the default hotkey for this command. Can be overridden by the user - * hotkey list file - * add the HkMyNewEntry pointer in the s_board_edit_Hotkey_List list ( or/and the - * s_module_edit_Hotkey_List list) - * Add the new code in the switch in OnHotKey() function. - * Note: when the variable itemCurrentlyEdited is true, an item is currently edited. - * This can be useful if the new function cannot be executed while an item is currently - * being edited ( For example, one cannot start a new wire when a component is moving.) - * - * Note: If a hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX) - * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp) - * and see this list for some ascii keys (space ...) - */ - -// Hotkey list: - -// mouse click command: -static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ), - HK_LEFT_CLICK, WXK_RETURN, 0 ); -static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ), - HK_LEFT_DCLICK, WXK_END, 0 ); - -static EDA_HOTKEY HkSwitch2CopperLayer( _HKI( "Switch to Copper (B.Cu) layer" ), - HK_SWITCH_LAYER_TO_COPPER, WXK_PAGEDOWN ); - -static EDA_HOTKEY HkSwitch2ComponentLayer( _HKI( "Switch to Component (F.Cu) layer" ), - HK_SWITCH_LAYER_TO_COMPONENT, WXK_PAGEUP ); - -static EDA_HOTKEY HkSwitch2InnerLayer1( _HKI( "Switch to Inner layer 1" ), - HK_SWITCH_LAYER_TO_INNER1, WXK_F5 ); -static EDA_HOTKEY HkSwitch2InnerLayer2( _HKI( "Switch to Inner layer 2" ), - HK_SWITCH_LAYER_TO_INNER2, WXK_F6 ); -static EDA_HOTKEY HkSwitch2InnerLayer3( _HKI( "Switch to Inner layer 3" ), - HK_SWITCH_LAYER_TO_INNER3, WXK_F7 ); -static EDA_HOTKEY HkSwitch2InnerLayer4( _HKI( "Switch to Inner layer 4" ), - HK_SWITCH_LAYER_TO_INNER4, WXK_F8 ); -static EDA_HOTKEY HkSwitch2InnerLayer5( _HKI( "Switch to Inner layer 5" ), - HK_SWITCH_LAYER_TO_INNER5, GR_KB_SHIFT+WXK_F5 ); -static EDA_HOTKEY HkSwitch2InnerLayer6( _HKI( "Switch to Inner layer 6" ), - HK_SWITCH_LAYER_TO_INNER6, GR_KB_SHIFT+WXK_F6 ); - -static EDA_HOTKEY HkSwitch2NextCopperLayer( _HKI( "Switch to Next Layer" ), - HK_SWITCH_LAYER_TO_NEXT, '+' ); -static EDA_HOTKEY HkSwitch2PreviousCopperLayer( _HKI( "Switch to Previous Layer" ), - HK_SWITCH_LAYER_TO_PREVIOUS, '-' ); - -static EDA_HOTKEY HkFind( _HKI( "Find" ), HK_FIND, 'F' + GR_KB_CTRL ); -static EDA_HOTKEY HkReplace( _HKI( "Find and Replace" ), HK_REPLACE, 'F' + GR_KB_CTRL + GR_KB_ALT ); -static EDA_HOTKEY HkBackspace( _HKI( "Delete Track Segment" ), HK_BACK_SPACE, WXK_BACK ); -static EDA_HOTKEY HkAddNewTrack( _HKI( "Add New Track" ), HK_ADD_NEW_TRACK, 'X' ); - -static EDA_HOTKEY HkRouteDiffPair( _HKI( "Route Differential Pair (Modern Toolset only)" ), - HK_ROUTE_DIFF_PAIR, '6' ); -static EDA_HOTKEY HkRouteTuneSingle( _HKI( "Tune Single Track (Modern Toolset only)" ), - HK_ROUTE_TUNE_SINGLE, '7' ); -static EDA_HOTKEY HkRouteTuneDiffPair( _HKI( "Tune Differential Pair Length (Modern Toolset only)" ), - HK_ROUTE_TUNE_DIFF_PAIR, '8' ); -static EDA_HOTKEY HkRouteTuneSkew( _HKI( "Tune Differential Pair Skew (Modern Toolset only)" ), - HK_ROUTE_TUNE_SKEW, '9' ); -static EDA_HOTKEY HkRouteTuneSettings( _HKI( "Length Tuning Settings (Modern Toolset only)" ), - HK_ROUTE_TUNE_SETTINGS, 'L' + GR_KB_CTRL ); - -static EDA_HOTKEY HkRouteTuneIncreaseSpacing( _HKI( "Increase meander spacing by one step." ), - HK_ROUTE_TUNE_INCREASE_SPACING, '1' ); -static EDA_HOTKEY HkRouteTuneDecreaseSpacing( _HKI( "Decrease meander spacing by one step." ), - HK_ROUTE_TUNE_DECREASE_SPACING, '2' ); -static EDA_HOTKEY HkRouteTuneIncreaseAmp( _HKI( "Increase meander amplitude by one step." ), - HK_ROUTE_TUNE_INCREASE_AMP, '3' ); -static EDA_HOTKEY HkRouteTuneDecreaseAmp( _HKI( "Decrease meander amplitude by one step." ), - HK_ROUTE_TUNE_DECREASE_AMP, '4' ); - -static EDA_HOTKEY HkAddThroughVia( _HKI( "Add Through Via" ), HK_ADD_THROUGH_VIA, 'V' ); -static EDA_HOTKEY HkSelLayerAndAddThroughVia( _HKI( "Select Layer and Add Through Via" ), - HK_SEL_LAYER_AND_ADD_THROUGH_VIA, '<' ); -static EDA_HOTKEY HkAddMicroVia( _HKI( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL ); -static EDA_HOTKEY HkAddBlindBuriedVia( _HKI( "Add Blind/Buried Via" ), HK_ADD_BLIND_BURIED_VIA, - 'V' + GR_KB_ALT + GR_KB_SHIFT ); -static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( _HKI( "Select Layer and Add Blind/Buried Via" ), - HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA, - '<' + GR_KB_ALT ); -static EDA_HOTKEY HkSwitchTrackPosture( _HKI( "Switch Track Posture" ), - HK_SWITCH_TRACK_POSTURE, '/' ); -static EDA_HOTKEY HkDragTrackKeepSlope( _HKI( "Drag Track Keep Slope" ), - HK_DRAG_TRACK_KEEP_SLOPE, 'D' ); -static EDA_HOTKEY HkPlaceItem( _HKI( "Place Item" ), HK_PLACE_ITEM, 'P' ); -static EDA_HOTKEY HkEditBoardItem( _HKI( "Edit Item" ), HK_EDIT_ITEM, 'E' ); -static EDA_HOTKEY HkEditWithModedit( _HKI( "Edit with Footprint Editor" ), - HK_EDIT_MODULE_WITH_MODEDIT, 'E' + GR_KB_CTRL ); -static EDA_HOTKEY HkFlipItem( _HKI( "Flip Item" ), HK_FLIP_ITEM, 'F' ); -static EDA_HOTKEY HkRotateItem( _HKI( "Rotate Item" ), HK_ROTATE_ITEM, 'R' ); -static EDA_HOTKEY HkRotateItemClockwise( _HKI( "Rotate Item Clockwise (Modern Toolset only)" ), - HK_ROTATE_ITEM_CLOCKWISE, GR_KB_SHIFT + 'R' ); -static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE_ITEM, 'M' ); -static EDA_HOTKEY HkMoveItemExact( _HKI( "Move Item Exactly" ), HK_MOVE_ITEM_EXACT, - 'M' + GR_KB_CTRL ); -static EDA_HOTKEY HkPositionItemRelative( _HKI( "Position Item Relative" ), HK_POSITION_RELATIVE, - 'P' + GR_KB_SHIFT ); -static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Item" ), HK_DUPLICATE, 'D' + GR_KB_CTRL ); -static EDA_HOTKEY HkDuplicateItemAndIncrement( _HKI( "Duplicate Item and Increment" ), - HK_DUPLICATE_ITEM_AND_INCREMENT, - 'D' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkCreateArray( _HKI( "Create Array" ), HK_CREATE_ARRAY, 'T' + GR_KB_CTRL ); -static EDA_HOTKEY HkDragFootprint( _HKI( "Drag Item" ), HK_DRAG_ITEM, 'G' ); -static EDA_HOTKEY HkGetAndMoveFootprint( _HKI( "Get and Move Footprint" ), - HK_GET_AND_MOVE_FOOTPRINT, 'T' ); -static EDA_HOTKEY HkLock_Unlock_Footprint( _HKI( "Lock/Unlock Footprint" ), - HK_LOCK_UNLOCK_FOOTPRINT, 'L' ); -static EDA_HOTKEY HkDelete( _HKI( "Delete Full Track" ), HK_DELETE, WXK_DELETE ); -static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkSwitchHighContrastMode( _HKI( "Toggle High Contrast Mode" ), - HK_SWITCH_HIGHCONTRAST_MODE, 'H'+GR_KB_CTRL ); - -static EDA_HOTKEY HkAddLine( _HKI( "Draw Line" ), HK_ADD_LINE, 'L' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddPolygon( _HKI( "Draw Graphic Polygon" ), HK_ADD_POLYGON, - 'P' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddCircle( _HKI( "Draw Circle" ), HK_ADD_CIRCLE, 'C' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddArc( _HKI( "Draw Arc" ), HK_ADD_ARC, 'A' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddText( _HKI( "Add Text" ), HK_ADD_TEXT, 'T' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddDimension( _HKI( "Add Dimension" ), HK_ADD_DIMENSION, - 'H' + GR_KB_SHIFTCTRL ); -#ifdef __WXMAC__ -static EDA_HOTKEY HkAddFilledZone( _HKI( "Add Filled Zone" ), HK_ADD_ZONE, 'Z' + GR_KB_ALT ); -#else -static EDA_HOTKEY HkAddFilledZone( _HKI( "Add Filled Zone" ), HK_ADD_ZONE, 'Z' + GR_KB_SHIFTCTRL ); -#endif -static EDA_HOTKEY HkAddFreeVia( _HKI( "Add Vias" ), HK_ADD_FREE_VIA, 'V' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddKeepout( _HKI( "Add Keepout Area" ), HK_ADD_KEEPOUT, 'K' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddZoneCutout( _HKI( "Add a Zone Cutout" ), HK_ADD_CUTOUT, 'C' + GR_KB_SHIFT ); -static EDA_HOTKEY HkAddSimilarZone( _HKI( "Add a Similar Zone" ), HK_ADD_SIMILAR_ZONE, - '.' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddDXF( _HKI( "Place DXF" ), HK_ADD_DXF, 'F' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkAddAnchor( _HKI( "Place the Footprint Anchor" ), HK_ADD_ANCHOR, - 'N' + GR_KB_SHIFTCTRL ); - -static EDA_HOTKEY HkIncreaseLineWidth( _HKI( "Increase Line Width" ), HK_INC_LINE_WIDTH, - '+' + GR_KB_CTRL ); -static EDA_HOTKEY HkDecreaseLineWidth( _HKI( "Decrease Line Width" ), HK_DEC_LINE_WIDTH, - '-' + GR_KB_CTRL ); - - -static EDA_HOTKEY HkSetGridOrigin( _HKI( "Set Grid Origin" ), HK_SET_GRID_ORIGIN, 'S' ); -static EDA_HOTKEY HkResetGridOrigin( _HKI( "Reset Grid Origin" ), HK_RESET_GRID_ORIGIN, 'Z' ); - -static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), - HK_CANVAS_OPENGL, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F11 ); -static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ), - HK_CANVAS_CAIRO, -#ifdef __WXMAC__ - GR_KB_ALT + -#endif - WXK_F12 ); - -static EDA_HOTKEY HkZoneFillOrRefill( _HKI( "Fill or Refill All Zones" ), - HK_ZONE_FILL_OR_REFILL, 'B' ); -static EDA_HOTKEY HkZoneRemoveFilled( _HKI( "Remove Filled Areas in All Zones" ), - HK_ZONE_REMOVE_FILLED, 'B' + GR_KB_CTRL ); - -static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), - HK_UPDATE_PCB_FROM_SCH, WXK_F8 ); - -/* Fit on Screen */ -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); -#else -static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0' ); -#endif - -static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); - -/* Refresh Screen */ -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); -#else -static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL + 'R' ); -#endif - -/* Zoom In */ -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -#else -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+' ); -#endif - -/* Zoom Out */ -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); -#else -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' ); -#endif - -static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION, - GR_KB_CTRL + WXK_F5, ID_ZOOM_SELECTION ); - -static EDA_HOTKEY Hk3DViewer( _HKI( "3D Viewer" ), HK_3D_VIEWER, GR_KB_ALT + '3' ); - -static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 ); - -static EDA_HOTKEY HkSwitchTrackWidthToNext( _HKI( "Switch Track Width To Next" ), - HK_SWITCH_TRACK_WIDTH_TO_NEXT, 'W' ); - -static EDA_HOTKEY HkSwitchTrackWidthToPrevious( _HKI( "Switch Track Width To Previous" ), - HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS, - 'W' + GR_KB_SHIFT ); - -static EDA_HOTKEY HkSwitchGridToFastGrid1( _HKI( "Switch Grid To Fast Grid1" ), - HK_SWITCH_GRID_TO_FASTGRID1, GR_KB_ALT + '1' ); - -static EDA_HOTKEY HkSwitchGridToFastGrid2( _HKI( "Switch Grid To Fast Grid2" ), - HK_SWITCH_GRID_TO_FASTGRID2, GR_KB_ALT + '2' ); - -static EDA_HOTKEY HkSwitchGridToNext( _HKI( "Switch Grid To Next" ), - HK_SWITCH_GRID_TO_NEXT, 'N' ); - -static EDA_HOTKEY HkSwitchGridToPrevious( _HKI( "Switch Grid To Previous" ), - HK_SWITCH_GRID_TO_PREVIOUS, 'N' + GR_KB_SHIFT ); - -static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL ); - -static EDA_HOTKEY HkTrackDisplayMode( _HKI( "Track Display Mode" ), - HK_SWITCH_TRACK_DISPLAY_MODE, 'K' ); - -static EDA_HOTKEY HkAddModule( _HKI( "Add Footprint" ), HK_ADD_MODULE, 'O' ); - -// These hotkeys work only in GAL canvas, because the legacy canvas using wxDC does not know -// the transparency (alpha channel) -static EDA_HOTKEY HkIncLayerAlpha( _HKI( "Increment Layer Transparency (Modern Toolset only)" ), - HK_INC_LAYER_ALPHA, '}' ); - -static EDA_HOTKEY HkDecLayerAlpha( _HKI( "Decrement Layer Transparency (Modern Toolset only)" ), - HK_DEC_LAYER_ALPHA, '{' ); - -// These two are currently unused, and are intentionally not added to a list below. -static EDA_HOTKEY HkIncHighContrast( _HKI( "Increment High Contrast" ), HK_HIGHCONTRAST_INC, '>' ); -static EDA_HOTKEY HkDecHighContrast( _HKI( "Decrement High Contrast" ), HK_HIGHCONTRAST_DEC, '<' ); - -static EDA_HOTKEY HkSelectConnection( _HKI( "Select Single Track" ), HK_SEL_TRIVIAL_CONNECTION, - 'U' ); - -static EDA_HOTKEY HkSelectCopper( _HKI( "Select Connected Tracks" ), HK_SEL_COPPER_CONNECTION, - 'I' ); - -static EDA_HOTKEY HkRoutingOptions( _HKI( "Routing Options" ), HK_ROUTING_OPTIONS, - ',' + GR_KB_CTRL + GR_KB_SHIFT ); - -static EDA_HOTKEY HkCustomTrackWidth( _HKI( "Custom Track/Via Size" ), HK_CUSTOM_TRACK_WIDTH, 'Q' ); - -static EDA_HOTKEY HkDpDimension( _HKI( "Differential Pair Dimensions" ), HK_DP_DIMENSIONS, - 'R' + GR_KB_SHIFTCTRL ); - -static EDA_HOTKEY HkViaSizeInc( _HKI( "Increase Via Size" ), HK_VIA_SIZE_INC, '\'' ); - -static EDA_HOTKEY HkViaSizeDec( _HKI( "Decrease Via Size" ), HK_VIA_SIZE_DEC, '\\' ); - -static EDA_HOTKEY HkHighlightNetSelection( _HKI( "Toggle Highlight of Selected Net (Modern Toolset only)" ), - HK_HIGHLIGHT_NET_SELECTION, '`' ); - -// Common: hotkeys_basic.h -static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW ); -static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O', (int) wxID_OPEN ); -static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S', (int) wxID_SAVE ); -static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_SHIFT + GR_KB_CTRL + 'S', - (int) wxID_SAVEAS ); -static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P', (int) wxID_PRINT ); - -static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z' ); - -#if !defined( __WXMAC__ ) -static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y' ); -#else -static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_SHIFT + GR_KB_CTRL + 'Z' ); -#endif - -static EDA_HOTKEY HkCut( _HKI( "Cut" ), HK_CUT, GR_KB_CTRL + 'X' ); -static EDA_HOTKEY HkCopy( _HKI( "Copy" ), HK_COPY, GR_KB_CTRL + 'C' ); -static EDA_HOTKEY HkPaste( _HKI( "Paste" ), HK_PASTE, GR_KB_CTRL + 'V' ); - -static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), - HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES ); - -static EDA_HOTKEY HkToggleCursor( _HKI( "Toggle Cursor Display (Modern Toolset only)" ), - HK_TOGGLE_CURSOR, 'X' + GR_KB_SHIFTCTRL ); -static EDA_HOTKEY HkMeasureTool( _HKI( "Measure Distance (Modern Toolset only)" ), - HK_MEASURE_TOOL, 'M' + GR_KB_SHIFTCTRL ); - -static EDA_HOTKEY HkInsertCorner( _HKI( "Insert Corner (Modern Toolset only)" ), - HK_INSERT_CORNER, WXK_INSERT ); - -// List of common hotkey descriptors -EDA_HOTKEY* common_Hotkey_List[] = -{ - &HkNew, &HkOpen, &HkSave, &HkSaveAs, &HkPrint, - &HkUndo, &HkRedo, - &HkCut, &HkCopy, &HkPaste, - &HkFind, &HkReplace, - &HkHelp, &HkPreferences, - &HkZoomIn, &HkZoomOut, - &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, &HkZoomSelection, - &Hk3DViewer, - &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkResetGridOrigin, - &HkMouseLeftClick, - &HkMouseLeftDClick, - &HkIncLayerAlpha, &HkDecLayerAlpha, - &HkToggleCursor, - &HkMeasureTool, - NULL -}; - -// common hotkey descriptors only useful in footprint viewer -EDA_HOTKEY* common_basic_Hotkey_List[] = -{ - &HkHelp, &HkZoomIn, &HkZoomOut, - &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, &Hk3DViewer, - &HkSwitchUnits, &HkResetLocalCoord, - &HkCut, &HkCopy, &HkPaste, - &HkFind, &HkReplace, - &HkMouseLeftClick, - &HkMouseLeftDClick, - NULL -}; - -// List of hotkey descriptors for Pcbnew -EDA_HOTKEY* board_edit_Hotkey_List[] = -{ - // Adding Items - &HkPlaceItem, - &HkAddModule, - &HkAddFreeVia, - &HkAddFilledZone, - &HkAddKeepout, - &HkAddZoneCutout, - &HkAddSimilarZone, - &HkAddLine, - &HkAddCircle, - &HkAddArc, - &HkAddPolygon, - &HkAddText, - &HkAddDimension, - &HkAddDXF, - - // Routing and options during routing - &HkAddNewTrack, - &HkSwitchTrackPosture, - &HkDragTrackKeepSlope, - &HkAddThroughVia, - &HkAddBlindBuriedVia, - &HkAddMicroVia, - - // Routing - &HkRouteDiffPair, - &HkRouteTuneSingle, - &HkRouteTuneDiffPair, - &HkRouteTuneSkew, - - // Routing Options - &HkRoutingOptions, - &HkRouteTuneSettings, - &HkRouteTuneIncreaseSpacing, - &HkRouteTuneDecreaseSpacing, - &HkRouteTuneIncreaseAmp, - &HkRouteTuneDecreaseAmp, - &HkDpDimension, - - // Zones - &HkZoneFillOrRefill, - &HkZoneRemoveFilled, - - // Point editor (zones and segments) - &HkInsertCorner, - - // Highlight and display - &HkSelectConnection, - &HkSelectCopper, - &HkHighlightNetSelection, - &HkTrackDisplayMode, - - // Adjust track/via sizes - &HkCustomTrackWidth, - &HkSwitchTrackWidthToNext, - &HkSwitchTrackWidthToPrevious, - &HkViaSizeInc, - &HkViaSizeDec, - - // Remove items - &HkDelete, - &HkBackspace, - - // Edit placement - &HkDragFootprint, - &HkMoveItem, - &HkGetAndMoveFootprint, - &HkMoveItemExact, - &HkPositionItemRelative, - &HkFlipItem, - &HkRotateItem, - &HkRotateItemClockwise, - - &HkSelLayerAndAddThroughVia, - &HkSelLayerAndAddBlindBuriedVia, - - &HkDuplicateItem, - &HkDuplicateItemAndIncrement, - &HkCreateArray, - &HkLock_Unlock_Footprint, - - &HkEditBoardItem, - &HkEditWithModedit, - &HkUpdatePcbFromSch, - - // Active Layer - &HkSwitch2ComponentLayer, - &HkSwitch2CopperLayer, - &HkSwitch2InnerLayer1, - &HkSwitch2InnerLayer2, - &HkSwitch2InnerLayer3, - &HkSwitch2InnerLayer4, - &HkSwitch2InnerLayer5, - &HkSwitch2InnerLayer6, - &HkSwitch2NextCopperLayer, - &HkSwitch2PreviousCopperLayer, - - // Grids - &HkSwitchGridToFastGrid1, - &HkSwitchGridToFastGrid2, - &HkSwitchGridToNext, - &HkSwitchGridToPrevious, - - // Display - &HkSwitchHighContrastMode, - &HkCanvasCairo, - &HkCanvasOpenGL, - NULL -}; - -// List of hotkey descriptors for the module editor -EDA_HOTKEY* module_edit_Hotkey_List[] = { - // Add Items - &HkAddLine, - &HkAddCircle, - &HkAddArc, - &HkAddPolygon, - &HkAddText, - &HkAddAnchor, - - // Delete/Move - &HkDelete, - &HkMoveItem, - &HkMoveItemExact, - &HkRotateItem, - &HkSwitchTrackPosture, - - // Edit/Duplicate - &HkEditBoardItem, - &HkDuplicateItem, - &HkDuplicateItemAndIncrement, - &HkCreateArray, - - // Grids - &HkSwitchGridToFastGrid1, - &HkSwitchGridToFastGrid2, - &HkSwitchGridToNext, - &HkSwitchGridToPrevious, - - // Display - &HkSwitchHighContrastMode, - &HkCanvasCairo, - &HkCanvasOpenGL, - NULL - }; - -// List of hotkey descriptors for the module viewer -// Currently empty -EDA_HOTKEY* module_viewer_Hotkey_List[] = { - NULL - }; - -// Keyword Identifiers (tags) in key code configuration file (section names) -// (.m_SectionTag member of a EDA_HOTKEY_CONFIG) -static wxString boardEditorSectionTag( wxT( "[pcbnew]" ) ); -static wxString moduleEditSectionTag( wxT( "[footprinteditor]" ) ); - -// Titles for hotkey editor and hotkey display -static wxString commonSectionTitle( _HKI( "Common" ) ); -static wxString boardEditorSectionTitle( _HKI( "Board Editor" ) ); -static wxString moduleEditSectionTitle( _HKI( "Footprint Editor" ) ); - -// list of sections and corresponding hotkey list for Pcbnew -// (used to create an hotkey config file, and edit hotkeys ) -struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hotkeys_Descr[] = { - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &boardEditorSectionTag, board_edit_Hotkey_List, &boardEditorSectionTitle }, - { &moduleEditSectionTag, module_edit_Hotkey_List, &moduleEditSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the board editor -// (used to list current hotkeys in the board editor) -struct EDA_HOTKEY_CONFIG g_Board_Editor_Hotkeys_Descr[] = { - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &boardEditorSectionTag, board_edit_Hotkey_List, &boardEditorSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the footprint editor -// (used to list current hotkeys in the module editor) -struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[] = { - { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle }, - { &moduleEditSectionTag, module_edit_Hotkey_List, &moduleEditSectionTitle }, - { NULL, NULL, NULL } -}; - -// list of sections and corresponding hotkey list for the footprint viewer -// (used to list current hotkeys in the module viewer) -struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[] = { - { &g_CommonSectionTag, common_basic_Hotkey_List, &commonSectionTitle }, - { NULL, NULL, NULL } -}; - - -EDA_HOTKEY* FOOTPRINT_VIEWER_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, module_viewer_Hotkey_List ); - - return HK_Descr; -} - - -EDA_HOTKEY* FOOTPRINT_WIZARD_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - return HK_Descr; -} - - -EDA_HOTKEY* PCB_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, board_edit_Hotkey_List ); - - return HK_Descr; -} - - -EDA_HOTKEY* FOOTPRINT_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const -{ - EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromCommand( aCommand, module_edit_Hotkey_List ); - - return HK_Descr; -} diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h deleted file mode 100644 index 611db296a1..0000000000 --- a/pcbnew/hotkeys.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @file pcbnew/hotkeys.h - * Pcbnew hotkeys - */ -#ifndef _PCBNEW_HOTKEYS_H -#define _PCBNEW_HOTKEYS_H - -#include <hotkeys_basic.h> - -// List of hot keys id. -// see also enum common_hotkey_id_command in hotkeys_basic.h -// for shared hotkeys id -enum hotkey_id_command { - HK_BACK_SPACE = HK_COMMON_END, - HK_ROTATE_ITEM, - HK_ROTATE_ITEM_CLOCKWISE, - HK_FLIP_ITEM, - HK_MOVE_ITEM, - HK_MOVE_ITEM_EXACT, - HK_POSITION_RELATIVE, - HK_DRAG_ITEM, - HK_GET_AND_MOVE_FOOTPRINT, - HK_LOCK_UNLOCK_FOOTPRINT, - HK_ADD_NEW_TRACK, - HK_ROUTE_DIFF_PAIR, - HK_ROUTE_TUNE_SINGLE, - HK_ROUTE_TUNE_DIFF_PAIR, - HK_ROUTE_TUNE_SKEW, - HK_ROUTE_TUNE_SETTINGS, - HK_ROUTE_TUNE_INCREASE_SPACING, - HK_ROUTE_TUNE_DECREASE_SPACING, - HK_ROUTE_TUNE_INCREASE_AMP, - HK_ROUTE_TUNE_DECREASE_AMP, - HK_ADD_THROUGH_VIA, - HK_SEL_LAYER_AND_ADD_THROUGH_VIA, - HK_ADD_BLIND_BURIED_VIA, - HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA, - HK_ADD_MICROVIA, - HK_SWITCH_TRACK_POSTURE, - HK_DRAG_TRACK_KEEP_SLOPE, - HK_SWITCH_TRACK_DISPLAY_MODE, - HK_3D_VIEWER, - HK_EDIT_ITEM, - HK_EDIT_MODULE_WITH_MODEDIT, - HK_DUPLICATE_ITEM_AND_INCREMENT, - HK_CREATE_ARRAY, - HK_PLACE_ITEM, - HK_SWITCH_TRACK_WIDTH_TO_NEXT, - HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS, - HK_SWITCH_LAYER_TO_COPPER, - HK_SWITCH_LAYER_TO_COMPONENT, - HK_SWITCH_LAYER_TO_NEXT, - HK_SWITCH_LAYER_TO_PREVIOUS, - HK_SWITCH_LAYER_TO_INNER1, - HK_SWITCH_LAYER_TO_INNER2, - HK_SWITCH_LAYER_TO_INNER3, - HK_SWITCH_LAYER_TO_INNER4, - HK_SWITCH_LAYER_TO_INNER5, - HK_SWITCH_LAYER_TO_INNER6, - HK_SWITCH_LAYER_TO_INNER7, - HK_SWITCH_LAYER_TO_INNER8, - HK_SWITCH_LAYER_TO_INNER9, - HK_SWITCH_LAYER_TO_INNER10, - HK_SWITCH_LAYER_TO_INNER11, - HK_SWITCH_LAYER_TO_INNER12, - HK_SWITCH_LAYER_TO_INNER13, - HK_SWITCH_LAYER_TO_INNER14, - HK_ADD_MODULE, - HK_ADD_LINE, - HK_ADD_POLYGON, - HK_ADD_CIRCLE, - HK_ADD_ARC, - HK_ADD_TEXT, - HK_ADD_DIMENSION, - HK_ADD_ZONE, - HK_ADD_FREE_VIA, - HK_ADD_KEEPOUT, - HK_ADD_CUTOUT, - HK_ADD_SIMILAR_ZONE, - HK_ADD_DXF, - HK_ADD_ANCHOR, - HK_INC_LINE_WIDTH, - HK_DEC_LINE_WIDTH, - HK_SWITCH_HIGHCONTRAST_MODE, - HK_HIGHCONTRAST_INC, - HK_HIGHCONTRAST_DEC, - HK_CANVAS_OPENGL, - HK_CANVAS_CAIRO, - HK_ZONE_FILL_OR_REFILL, - HK_ZONE_REMOVE_FILLED, - HK_INC_LAYER_ALPHA, - HK_DEC_LAYER_ALPHA, - HK_SEL_TRIVIAL_CONNECTION, - HK_SEL_COPPER_CONNECTION, - HK_ROUTING_OPTIONS, - HK_CUSTOM_TRACK_WIDTH, - HK_DP_DIMENSIONS, - HK_VIA_SIZE_INC, - HK_VIA_SIZE_DEC, - HK_HIGHLIGHT_NET_SELECTION, - HK_INSERT_CORNER -}; - -// Full list of hotkey descriptors for board editor and footprint editor -extern struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hotkeys_Descr[]; - -// List of hotkey descriptors for the board editor only -extern struct EDA_HOTKEY_CONFIG g_Board_Editor_Hotkeys_Descr[]; - -// List of hotkey descriptors for the footprint editor only -extern struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[]; - -// List of hotkey descriptors for the footprint editor only -extern struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[]; - -// List of common hotkey descriptors -extern EDA_HOTKEY* common_Hotkey_List[]; - -// List of hotkey descriptors for pcbnew -extern EDA_HOTKEY* board_edit_Hotkey_List[]; - -// List of hotkey descriptors for the module editor -extern EDA_HOTKEY* module_edit_Hotkey_List[]; - - -#endif /* _PCBNEW_HOTKEYS_H_ */ diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 3fa4064c61..7fcf81efdd 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -59,7 +59,7 @@ void CLIPBOARD_IO::SetBoard( BOARD* aBoard ) } -void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected ) +void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected ) { VECTOR2I refPoint( 0, 0 ); diff --git a/pcbnew/kicad_clipboard.h b/pcbnew/kicad_clipboard.h index 4c57efbffb..4d2a3797ee 100644 --- a/pcbnew/kicad_clipboard.h +++ b/pcbnew/kicad_clipboard.h @@ -35,8 +35,7 @@ #include <class_module.h> #include <pcb_parser.h> #include <memory.h> - -#include <tool/selection.h> +#include <tools/pcbnew_selection.h> class CLIPBOARD_PARSER : public PCB_PARSER { @@ -63,7 +62,7 @@ public: /* Writes all the settings of the BOARD* set by setBoard() and then adds all * the BOARD_ITEM* found in selection formatted by PCB_IO to clipboard as a text */ - void SaveSelection( const SELECTION& selected ); + void SaveSelection( const PCBNEW_SELECTION& selected ); BOARD_ITEM* Parse(); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 22029d6b4b..eefbc61b91 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -35,7 +35,6 @@ #include <tools/selection_tool.h> #include <tools/pcb_actions.h> #include "help_common_strings.h" -#include "hotkeys.h" #include "pcbnew.h" #include "pcbnew_id.h" @@ -277,7 +276,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, SELECTION_CONDITIONS::ShowAlways ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index a386c8b4c2..23aa94c99c 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -37,7 +37,6 @@ #include <tools/selection_tool.h> #include <tools/pcb_actions.h> #include "help_common_strings.h" -#include "hotkeys.h" #include "pcbnew.h" #include "pcbnew_id.h" @@ -486,7 +485,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() import3d_xpm, SELECTION_CONDITIONS::ShowAlways ); #endif prefsMenu->AddItem( wxID_PREFERENCES, - AddHotkeyName( _( "Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ), + _( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ), preference_xpm, SELECTION_CONDITIONS::ShowAlways ); diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 1133965a2e..7e44f98b1d 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -124,8 +124,8 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, // Now fix a reference point to move the footprints. // We use the first footprint in list as reference point // The graphic cursor will be on this fp when moving the footprints. - SELECTION_TOOL* selTool = GetToolManager()->GetTool<SELECTION_TOOL>(); - SELECTION& selection = selTool->GetSelection(); + SELECTION_TOOL* selTool = GetToolManager()->GetTool<SELECTION_TOOL>(); + PCBNEW_SELECTION& selection = selTool->GetSelection(); selection.SetReferencePoint( newFootprints[0]->GetPosition() ); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index f73769130c..ec0fce4d72 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -36,7 +36,6 @@ #include <tools/drc.h> #include <layer_widget.h> #include <pcb_layer_widget.h> -#include <hotkeys.h> #include <config_params.h> #include <footprint_edit_frame.h> #include <dialog_helpers.h> @@ -62,6 +61,8 @@ #include <functional> #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/action_toolbar.h> +#include <tool/common_control.h> #include <tool/common_tools.h> #include <tool/zoom_tool.h> #include <tools/selection_tool.h> @@ -138,9 +139,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit ) // menu Config - EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::Process_Config ) - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PCB_EDIT_FRAME::Process_Config ) - EVT_MENU( wxID_PREFERENCES, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::On3DShapeLibWizard ) EVT_MENU( ID_GRID_SETTINGS, PCB_EDIT_FRAME::OnGridSettings ) // menu Postprocess @@ -148,7 +147,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) // Horizontal toolbar EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::ExportSVG ) - EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) @@ -167,7 +165,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) // User interface update event handlers. - EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair ) EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize ) @@ -195,7 +192,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_SelLayerBox = NULL; m_show_microwave_tools = false; m_show_layer_manager_tools = true; - m_hotkeysDescrList = g_Board_Editor_Hotkeys_Descr; m_hasAutoSave = true; m_microWaveToolBar = NULL; m_Layers = nullptr; @@ -418,6 +414,7 @@ void PCB_EDIT_FRAME::setupTools() m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); // Register tools + m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new SELECTION_TOOL ); m_toolManager->RegisterTool( new ZOOM_TOOL ); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 350ef2cfb5..aa81297bde 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -297,7 +297,6 @@ public: void ExportSVG( wxCommandEvent& event ); // User interface update command event handlers. - void OnUpdateLayerPair( wxUpdateUIEvent& aEvent ); void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); bool LayerManagerShown(); bool MicrowaveToolbarShown(); @@ -440,9 +439,6 @@ public: */ void SetLastNetListRead( const wxString& aNetListFile ); - ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() - EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - void OnCloseWindow( wxCloseEvent& Event ) override; void Process_Special_Functions( wxCommandEvent& event ); void Tracks_and_Vias_Size_Event( wxCommandEvent& event ); @@ -1012,10 +1008,12 @@ public: */ void UpdateTitle(); + void On3DShapeLibWizard( wxCommandEvent& event ); + /** * Allows Pcbnew to install its preferences panel into the preferences dialog. */ - void InstallPreferences( PAGED_DIALOG* aParent ) override; + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; /** * Called after the preferences dialog is run. diff --git a/pcbnew/pcb_layer_box_selector.cpp b/pcbnew/pcb_layer_box_selector.cpp index 937310c061..1103594045 100644 --- a/pcbnew/pcb_layer_box_selector.cpp +++ b/pcbnew/pcb_layer_box_selector.cpp @@ -35,36 +35,27 @@ #include <layers_id_colors_and_visibility.h> #include <class_board.h> -#include <hotkeys.h> - #include <pcb_layer_box_selector.h> +#include <tools/pcb_actions.h> // translate aLayer to its hotkey -static int layer2hotkey_id( PCB_LAYER_ID aLayer ) +static TOOL_ACTION* layer2action( PCB_LAYER_ID aLayer ) { switch( aLayer ) { - case F_Cu: return HK_SWITCH_LAYER_TO_COMPONENT; + case F_Cu: return &PCB_ACTIONS::layerTop; - case B_Cu: return HK_SWITCH_LAYER_TO_COPPER; + case B_Cu: return &PCB_ACTIONS::layerBottom; - case In1_Cu: return HK_SWITCH_LAYER_TO_INNER1; - case In2_Cu: return HK_SWITCH_LAYER_TO_INNER2; - case In3_Cu: return HK_SWITCH_LAYER_TO_INNER3; - case In4_Cu: return HK_SWITCH_LAYER_TO_INNER4; - case In5_Cu: return HK_SWITCH_LAYER_TO_INNER5; - case In6_Cu: return HK_SWITCH_LAYER_TO_INNER6; - case In7_Cu: return HK_SWITCH_LAYER_TO_INNER7; - case In8_Cu: return HK_SWITCH_LAYER_TO_INNER8; - case In9_Cu: return HK_SWITCH_LAYER_TO_INNER9; - case In10_Cu: return HK_SWITCH_LAYER_TO_INNER10; - case In11_Cu: return HK_SWITCH_LAYER_TO_INNER11; - case In12_Cu: return HK_SWITCH_LAYER_TO_INNER12; - case In13_Cu: return HK_SWITCH_LAYER_TO_INNER13; - case In14_Cu: return HK_SWITCH_LAYER_TO_INNER14; + case In1_Cu: return &PCB_ACTIONS::layerInner1; + case In2_Cu: return &PCB_ACTIONS::layerInner2; + case In3_Cu: return &PCB_ACTIONS::layerInner3; + case In4_Cu: return &PCB_ACTIONS::layerInner4; + case In5_Cu: return &PCB_ACTIONS::layerInner5; + case In6_Cu: return &PCB_ACTIONS::layerInner6; default: - return -1; + return nullptr; } } @@ -103,12 +94,12 @@ void PCB_LAYER_BOX_SELECTOR::Resync() wxString layername = GetLayerName( layerid ) + layerstatus; - if( m_layerhotkeys && m_hotkeys ) + if( m_layerhotkeys ) { - int id = layer2hotkey_id( layerid ); + TOOL_ACTION* action = layer2action( layerid ); - if( id != -1 ) - layername = AddHotkeyName( layername, m_hotkeys, id, IS_COMMENT ); + if( action ) + layername = AddHotkeyName( layername, action->GetHotKey(), IS_COMMENT ); } Append( layername, bmp, (void*)(intptr_t) layerid ); diff --git a/pcbnew/pcb_layer_box_selector.h b/pcbnew/pcb_layer_box_selector.h index fb275714ea..861ec3bc67 100644 --- a/pcbnew/pcb_layer_box_selector.h +++ b/pcbnew/pcb_layer_box_selector.h @@ -41,10 +41,6 @@ class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR bool m_showNotEnabledBrdlayers; // true to list all allowed layers // (with not activated layers flagged) -public: - // Hotkey Info - EDA_HOTKEY_CONFIG* m_hotkeys; - public: // If you are thinking the constructor is a bit curious, // just remember it is used by automatically generated by wxFormBuilder files, @@ -59,7 +55,6 @@ public: LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices ) { m_boardFrame = NULL; - m_hotkeys = NULL; m_showNotEnabledBrdlayers = false; } diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index d649024b8e..c4e7d509dc 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -47,7 +47,6 @@ #include <wx/dir.h> #include <gestfich.h> #include <pcbnew.h> -#include <hotkeys.h> #include <wildcards_and_files_ext.h> #include <class_board.h> #include <class_draw_panel_gal.h> @@ -322,10 +321,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) start_common( aCtlBits ); - // Must be called before creating the main frame in order to - // display the real hotkeys in menus or tool tips - ReadHotkeyConfig( PCB_EDIT_FRAME_NAME, g_Board_Editor_Hotkeys_Descr ); - wxFileName fn = FP_LIB_TABLE::GetGlobalTableFileName(); if( !fn.FileExists() ) diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 3e59486dfc..15a2ee554a 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -45,6 +45,7 @@ #include <panel_pcbnew_settings.h> #include <panel_pcbnew_display_options.h> #include <panel_pcbnew_action_plugins.h> +#include <panel_hotkeys_editor.h> #include <fp_lib_table.h> #include <ws_draw_item.h> #include <ws_data_model.h> @@ -52,7 +53,6 @@ #include <class_module.h> #include <pcbplot.h> #include <pcbnew_id.h> -#include <hotkeys.h> #include <footprint_viewer_frame.h> #include <invoke_pcb_dialog.h> #include <wildcards_and_files_ext.h> @@ -60,35 +60,16 @@ #include <widgets/paged_dialog.h> -void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) +void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event ) { - int id = event.GetId(); - - switch( id ) - { - case ID_PCB_3DSHAPELIB_WIZARD: #ifdef BUILD_GITHUB_PLUGIN - Invoke3DShapeLibsDownloaderWizard( this ); + Invoke3DShapeLibsDownloaderWizard( this ); #endif - break; - - case wxID_PREFERENCES: - ShowPreferences( g_Pcbnew_Editor_Hotkeys_Descr, g_Board_Editor_Hotkeys_Descr, wxT( "pcbnew" ) ); - break; - - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - DisplayHotkeyList( this, g_Board_Editor_Hotkeys_Descr ); - break; - - default: - DisplayErrorMessage( this, "Unknown ID in Process Config", - wxString::Format( "PCB_EDIT_FRAME::Process_Config received ID %d", id ) ); - break; - } } -void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) +void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { wxTreebook* book = aParent->GetTreebook(); @@ -97,6 +78,8 @@ void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent ) #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) ); #endif + + aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 1a7330ddfa..0fbbbb3bfc 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -30,12 +30,9 @@ #include <pcb_painter.h> #include <dialogs/dialog_pns_settings.h> #include <dialogs/dialog_pns_length_tuning_settings.h> - #include <tool/action_menu.h> #include <tool/tool_manager.h> #include <tools/pcb_actions.h> -#include <hotkeys.h> - #include "pns_segment.h" #include "pns_router.h" #include "pns_meander_placer.h" // fixme: move settings to separate header @@ -47,37 +44,45 @@ using namespace KIGFX; -static TOOL_ACTION ACT_StartTuning( "pcbnew.LengthTuner.StartTuning", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_TRACK ), - _( "New Track" ), _( "Starts laying a new track." ) ); +static TOOL_ACTION ACT_StartTuning( "pcbnew.LengthTuner.StartTuning", + AS_CONTEXT, + 'X', LEGACY_HK_NAME( "Add New Track" ), + _( "New Track" ), _( "Starts laying a new track." ) ); -static TOOL_ACTION ACT_EndTuning( "pcbnew.LengthTuner.EndTuning", AS_CONTEXT, WXK_END, - _( "End Track" ), _( "Stops laying the current meander." ) ); +static TOOL_ACTION ACT_EndTuning( "pcbnew.LengthTuner.EndTuning", + AS_CONTEXT, + WXK_END, + _( "End Track" ), _( "Stops laying the current meander." ) ); -static TOOL_ACTION ACT_Settings( "pcbnew.LengthTuner.Settings", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_SETTINGS ), - _( "Length Tuning Settings..." ), _( "Sets the length tuning parameters for currently routed item." ), - router_len_tuner_setup_xpm ); +static TOOL_ACTION ACT_Settings( "pcbnew.LengthTuner.Settings", + AS_CONTEXT, + MD_CTRL + 'L', LEGACY_HK_NAME( "Length Tuning Settings (Modern Toolset only)" ), + _( "Length Tuning Settings..." ), _( "Sets the length tuning parameters for currently routed item." ), + router_len_tuner_setup_xpm ); -static TOOL_ACTION ACT_SpacingIncrease( "pcbnew.LengthTuner.SpacingIncrease", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_INCREASE_SPACING ), - _( "Increase Spacing" ), _( "Increase meander spacing by one step." ), - router_len_tuner_dist_incr_xpm ); +static TOOL_ACTION ACT_SpacingIncrease( "pcbnew.LengthTuner.SpacingIncrease", + AS_CONTEXT, + '1', LEGACY_HK_NAME( "Increase meander spacing by one step." ), + _( "Increase Spacing" ), _( "Increase meander spacing by one step." ), + router_len_tuner_dist_incr_xpm ); -static TOOL_ACTION ACT_SpacingDecrease( "pcbnew.LengthTuner.SpacingDecrease", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_DECREASE_SPACING ), - _( "Decrease Spacing" ), _( "Decrease meander spacing by one step." ), - router_len_tuner_dist_decr_xpm ); +static TOOL_ACTION ACT_SpacingDecrease( "pcbnew.LengthTuner.SpacingDecrease", + AS_CONTEXT, + '2', LEGACY_HK_NAME( "Decrease meander spacing by one step." ), + _( "Decrease Spacing" ), _( "Decrease meander spacing by one step." ), + router_len_tuner_dist_decr_xpm ); -static TOOL_ACTION ACT_AmplIncrease( "pcbnew.LengthTuner.AmplIncrease", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_INCREASE_AMP ), - _( "Increase Amplitude" ), _( "Increase meander amplitude by one step." ), - router_len_tuner_amplitude_incr_xpm ); +static TOOL_ACTION ACT_AmplIncrease( "pcbnew.LengthTuner.AmplIncrease", + AS_CONTEXT, + '3', LEGACY_HK_NAME( "Increase meander amplitude by one step." ), + _( "Increase Amplitude" ), _( "Increase meander amplitude by one step." ), + router_len_tuner_amplitude_incr_xpm ); -static TOOL_ACTION ACT_AmplDecrease( "pcbnew.LengthTuner.AmplDecrease", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_DECREASE_AMP ), - _( "Decrease Amplitude" ), _( "Decrease meander amplitude by one step." ), - router_len_tuner_amplitude_decr_xpm ); +static TOOL_ACTION ACT_AmplDecrease( "pcbnew.LengthTuner.AmplDecrease", + AS_CONTEXT, + '4', LEGACY_HK_NAME( "Decrease meander amplitude by one step." ), + _( "Decrease Amplitude" ), _( "Decrease meander amplitude by one step." ), + router_len_tuner_amplitude_decr_xpm ); LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() : diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index fe78b9bcdc..9c7a2b703f 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -39,7 +39,6 @@ using namespace std::placeholders; #include <dialogs/dialog_track_via_size.h> #include <base_units.h> #include <bitmaps.h> -#include <hotkeys.h> #include <tool/action_menu.h> #include <tools/pcb_actions.h> diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index bb0f44881b..eae6eb9633 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -40,16 +40,13 @@ using namespace std::placeholders; #include <dialogs/dialog_pns_diff_pair_dimensions.h> #include <dialogs/dialog_track_via_size.h> #include <base_units.h> -#include <hotkeys.h> #include <confirm.h> #include <bitmaps.h> #include <collectors.h> - #include <tool/action_menu.h> #include <tool/tool_manager.h> #include <tool/tool_settings.h> #include <tool/grid_menu.h> - #include <tool/zoom_menu.h> #include <tools/pcb_actions.h> #include <tools/selection_tool.h> @@ -80,137 +77,148 @@ enum VIA_ACTION_FLAGS TOOL_ACTION PCB_ACTIONS::routerActivateSingle( "pcbnew.InteractiveRouter.SingleTrack", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_TRACK ), - _( "Interactive Router (Single Tracks)" ), - _( "Run push & shove router (single tracks)" ), + AS_GLOBAL, + 'X', LEGACY_HK_NAME( "Add New Track" ), + _( "Interactive Router (Single Tracks)" ), _( "Run push & shove router (single tracks)" ), add_tracks_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffPair", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_DIFF_PAIR ), - _( "Interactive Router (Differential Pairs)" ), - _( "Run push & shove router (differential pairs)" ), + AS_GLOBAL, + '6', LEGACY_HK_NAME( "Route Differential Pair (Modern Toolset only)" ), + _( "Interactive Router (Differential Pairs)" ), _( "Run push & shove router (differential pairs)" ), ps_diff_pair_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTING_OPTIONS ), - _( "Interactive Router Settings..." ), - _( "Open Interactive Router settings" ), + AS_GLOBAL, + MD_CTRL + MD_SHIFT + ',', LEGACY_HK_NAME( "Routing Options" ), + _( "Interactive Router Settings..." ), _( "Open Interactive Router settings" ), tools_xpm ); TOOL_ACTION PCB_ACTIONS::routerDiffPairDialog( "pcbnew.InteractiveRouter.DiffPairDialog", - AS_GLOBAL, 0, - _( "Differential Pair Dimension Settings..." ), - _( "Open Differential Pair Dimension settings" ), + AS_GLOBAL, 0, "", + _( "Differential Pair Dimensions..." ), _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm ); TOOL_ACTION PCB_ACTIONS::selectLayerPair( "pcbnew.InteractiveRouter.SelectLayerPair", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Set Layer Pair..." ), _( "Change active layer pair for routing" ), select_layer_pair_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_SINGLE ), + AS_GLOBAL, + '7', LEGACY_HK_NAME( "Tune Single Track (Modern Toolset only)" ), _( "Tune length of a single track" ), "", ps_tune_length_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_DIFF_PAIR ), + AS_GLOBAL, + '8', LEGACY_HK_NAME( "Tune Differential Pair Length (Modern Toolset only)" ), _( "Tune length of a differential pair" ), "", - NULL, AF_ACTIVATE ); + nullptr, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_SKEW ), + AS_GLOBAL, + '9', LEGACY_HK_NAME( "Tune Differential Pair Skew (Modern Toolset only)" ), _( "Tune skew of a differential pair" ), "", - NULL, AF_ACTIVATE ); + nullptr, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag", - AS_CONTEXT, 0, + AS_CONTEXT, 0, "", _( "Drag Track/Via" ), _( "Drags tracks and vias without breaking connections" ), drag_xpm ); TOOL_ACTION PCB_ACTIONS::inlineBreakTrack( "pcbnew.InteractiveRouter.InlineBreakTrack", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Break Track" ), _( "Splits the track segment into two segments connected at the cursor position." ), break_line_xpm ); TOOL_ACTION PCB_ACTIONS::breakTrack( "pcbnew.InteractiveRouter.BreakTrack", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Break Track" ), _( "Splits the track segment into two segments connected at the cursor position." ), break_line_xpm ); TOOL_ACTION PCB_ACTIONS::drag45Degree( "pcbnew.InteractiveRouter.Drag45Degree", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG_TRACK_KEEP_SLOPE ), + AS_GLOBAL, + 'D', LEGACY_HK_NAME( "Drag Track Keep Slope" ), _( "Drag (45 degree mode)" ), _( "Drags the track segment while keeping connected tracks at 45 degrees." ), drag_segment_withslope_xpm ); TOOL_ACTION PCB_ACTIONS::dragFreeAngle( "pcbnew.InteractiveRouter.DragFreeAngle", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG_ITEM ), + AS_GLOBAL, + 'G', LEGACY_HK_NAME( "Drag Item" ), _( "Drag (free angle)" ), _( "Drags the nearest joint in the track without restricting the track angle." ), move_xpm ); -static const TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_TRACK ), - _( "New Track" ), _( "Starts laying a new track." ), - add_tracks_xpm ); +static const TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack", + AS_CONTEXT, + 'X', LEGACY_HK_NAME( "Add New Track" ), + _( "New Track" ), _( "Starts laying a new track." ), + add_tracks_xpm ); -static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, - _( "End Track" ), _( "Stops laying the current track." ), - checked_ok_xpm ); +static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack", + AS_CONTEXT, + WXK_END, "", + _( "End Track" ), _( "Stops laying the current track." ), + checked_ok_xpm ); -static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F', - _( "Auto-end Track" ), _( "Automagically finishes currently routed track." ) ); +static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute", + AS_CONTEXT, + 'F', "", + _( "Auto-end Track" ), _( "Automagically finishes currently routed track." ) ); static const TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_ADD_THROUGH_VIA ), - _( "Place Through Via" ), - _( "Adds a through-hole via at the end of currently routed track." ), - via_xpm, AF_NONE, - (void*) VIA_ACTION_FLAGS::VIA ); + AS_CONTEXT, + 'V', LEGACY_HK_NAME( "Add Through Via" ), + _( "Place Through Via" ), + _( "Adds a through-hole via at the end of currently routed track." ), + via_xpm, AF_NONE, (void*) VIA_ACTION_FLAGS::VIA ); static const TOOL_ACTION ACT_PlaceBlindVia( "pcbnew.InteractiveRouter.PlaceBlindVia", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_ADD_BLIND_BURIED_VIA ), - _( "Place Blind/Buried Via" ), - _( "Adds a blind or buried via at the end of currently routed track."), - via_buried_xpm, AF_NONE, - (void*) VIA_ACTION_FLAGS::BLIND_VIA ); + AS_CONTEXT, + MD_ALT + MD_SHIFT + 'V', LEGACY_HK_NAME( "Add Blind/Buried Via" ), + _( "Place Blind/Buried Via" ), + _( "Adds a blind or buried via at the end of currently routed track."), + via_buried_xpm, AF_NONE, (void*) VIA_ACTION_FLAGS::BLIND_VIA ); static const TOOL_ACTION ACT_PlaceMicroVia( "pcbnew.InteractiveRouter.PlaceMicroVia", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_ADD_MICROVIA ), - _( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ), - via_microvia_xpm, AF_NONE, - (void*) VIA_ACTION_FLAGS::MICROVIA ); + AS_CONTEXT, + MD_CTRL + 'V', LEGACY_HK_NAME( "Add MicroVia" ), + _( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ), + via_microvia_xpm, AF_NONE, (void*) VIA_ACTION_FLAGS::MICROVIA ); -static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia( - "pcbnew.InteractiveRouter.SelLayerAndPlaceVia", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_SEL_LAYER_AND_ADD_THROUGH_VIA ), - _( "Select Layer and Place Through Via..." ), - _( "Select a layer, then add a through-hole via at the end of currently routed track." ), - select_w_layer_xpm, AF_NONE, - (void*) ( VIA_ACTION_FLAGS::VIA | VIA_ACTION_FLAGS::SELECT_LAYER ) ); +static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia( "pcbnew.InteractiveRouter.SelLayerAndPlaceVia", + AS_CONTEXT, + '<', LEGACY_HK_NAME( "Select Layer and Add Through Via" ), + _( "Select Layer and Place Through Via..." ), + _( "Select a layer, then add a through-hole via at the end of currently routed track." ), + select_w_layer_xpm, AF_NONE, + (void*) ( VIA_ACTION_FLAGS::VIA | VIA_ACTION_FLAGS::SELECT_LAYER ) ); -static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia( - "pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA ), - _( "Select Layer and Place Blind/Buried Via..." ), - _( "Select a layer, then add a blind or buried via at the end of currently routed track."), - select_w_layer_xpm, AF_NONE, - (void*) ( VIA_ACTION_FLAGS::BLIND_VIA | VIA_ACTION_FLAGS::SELECT_LAYER ) ); +static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia( "pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", + AS_CONTEXT, + MD_ALT + '<', LEGACY_HK_NAME( "Select Layer and Add Blind/Buried Via" ), + _( "Select Layer and Place Blind/Buried Via..." ), + _( "Select a layer, then add a blind or buried via at the end of currently routed track."), + select_w_layer_xpm, AF_NONE, + (void*) ( VIA_ACTION_FLAGS::BLIND_VIA | VIA_ACTION_FLAGS::SELECT_LAYER ) ); static const TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackViaSize", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_CUSTOM_TRACK_WIDTH ), - _( "Custom Track/Via Size..." ), - _( "Shows a dialog for changing the track width and via size." ), - width_track_xpm ); + AS_CONTEXT, + 'Q', LEGACY_HK_NAME( "Custom Track/Via Size" ), + _( "Custom Track/Via Size..." ), + _( "Shows a dialog for changing the track width and via size." ), + width_track_xpm ); -static const TOOL_ACTION ACT_SwitchPosture( "pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, - TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_POSTURE ), - _( "Switch Track Posture" ), - _( "Switches posture of the currently routed track." ), - change_entry_orient_xpm ); +static const TOOL_ACTION ACT_SwitchPosture( "pcbnew.InteractiveRouter.SwitchPosture", + AS_CONTEXT, + '/', LEGACY_HK_NAME( "Switch Track Posture" ), + _( "Switch Track Posture" ), + _( "Switches posture of the currently routed track." ), + change_entry_orient_xpm ); ROUTER_TOOL::ROUTER_TOOL() : TOOL_BASE( "pcbnew.InteractiveRouter" ) @@ -783,7 +791,7 @@ bool ROUTER_TOOL::prepareInteractive() return false; } - m_endItem = NULL; + m_endItem = nullptr; m_endSnapPoint = m_startSnapPoint; frame()->UndoRedoBlock( true ); @@ -840,7 +848,7 @@ void ROUTER_TOOL::performRouting() frame()->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) ); updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); - m_startItem = NULL; + m_startItem = nullptr; } else if( evt->IsAction( &ACT_SwitchPosture ) ) { diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp index 2a2aa7fc6d..d00a5c4594 100644 --- a/pcbnew/swig/pcbnew_action_plugins.cpp +++ b/pcbnew/swig/pcbnew_action_plugins.cpp @@ -39,6 +39,7 @@ #include <class_zone.h> #include <board_commit.h> #include <tool/action_menu.h> +#include <tool/action_toolbar.h> PYTHON_ACTION_PLUGIN::PYTHON_ACTION_PLUGIN( PyObject* aAction ) { diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 0a5b38a696..2fd5d14c8c 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -27,8 +27,8 @@ #include <footprint_edit_frame.h> #include <dialog_helpers.h> #include <pcbnew_id.h> -#include <hotkeys.h> #include <bitmaps.h> +#include <tool/action_toolbar.h> #include <tools/pcb_actions.h> void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index e676ea47ff..b4d09295a0 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -20,18 +20,15 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <dialog_helpers.h> + #include <macros.h> -#include <menus_helpers.h> -#include <tool/actions.h> +#include <bitmaps.h> +#include <tool/action_toolbar.h> #include <tool/conditional_menu.h> #include <tool/tool_manager.h> #include <tools/selection_tool.h> #include <tools/pcb_actions.h> -#include "help_common_strings.h" -#include "hotkeys.h" #include "footprint_viewer_frame.h" -#include "pcbnew.h" #include "pcbnew_id.h" @@ -124,13 +121,12 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar() //----- File menu ----------------------------------------------------------- // - wxMenu* fileMenu = new wxMenu; + CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); - // Close viewer - AddMenuItem( fileMenu, wxID_EXIT, - _( "Cl&ose" ), - _( "Close footprint viewer" ), - KiBitmap( exit_xpm ) ); + fileMenu->AddItem( wxID_EXIT, _( "Close" ), _( "Close footprint viewer" ), + exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + + fileMenu->Resolve(); //----- View menu ----------------------------------------------------------- // diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 2d0cf77a88..4b8942ee71 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -32,17 +32,16 @@ #include <confirm.h> #include <bitmaps.h> #include <class_board.h> +#include <tool/action_toolbar.h> #include <tool/actions.h> #include <pcbnew.h> -#include <pcbnew_id.h> -#include <hotkeys.h> #include <pcb_layer_box_selector.h> #include <view/view.h> - #include <wx/wupdlock.h> #include <memory> #include <pgm_base.h> #include <tools/pcb_actions.h> +#include <pcbnew_id.h> extern bool IsWxPythonLoaded(); @@ -207,7 +206,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() if( m_mainToolBar ) { - m_mainToolBar->SetToolBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, *LayerPairBitmap ); + m_mainToolBar->SetToolBitmap( PCB_ACTIONS::selectLayerPair.GetId(), *LayerPairBitmap ); m_mainToolBar->Refresh(); } } @@ -285,10 +284,9 @@ void PCB_EDIT_FRAME::ReCreateHToolbar() ReCreateLayerBox( false ); m_mainToolBar->AddControl( m_SelLayerBox ); + m_mainToolBar->Add( PCB_ACTIONS::selectLayerPair ); PrepareLayerIndicator(); // Initialize the bitmap with the active layer colors - m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, *LayerPairBitmap, - SEL_LAYER_HELP ); - + KiScaledSeparator( m_mainToolBar, this ); ADD_TOOL( ID_RUN_EESCHEMA, eeschema_xpm, _( "Open schematic in Eeschema" ) ); @@ -624,7 +622,6 @@ void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar ) return; m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); - m_SelLayerBox->m_hotkeys = g_Board_Editor_Hotkeys_Descr; m_SelLayerBox->Resync(); if( aForceResizeToolbar ) @@ -653,12 +650,6 @@ void PCB_EDIT_FRAME::ToggleMicrowaveToolbar() } -void PCB_EDIT_FRAME::OnUpdateLayerPair( wxUpdateUIEvent& aEvent ) -{ - PrepareLayerIndicator(); -} - - void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ) { if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH ) @@ -723,6 +714,8 @@ void PCB_EDIT_FRAME::SyncMenusAndToolbars() #endif m_mainToolBar->Refresh(); + PrepareLayerIndicator(); + m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES ); m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 94d5352714..40801c8d18 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -44,7 +44,6 @@ #include <board_commit.h> #include <scoped_set_reset.h> #include <bitmaps.h> -#include <hotkeys.h> #include <painter.h> #include <status_popup.h> #include "grid_helper.h" @@ -66,80 +65,101 @@ using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>; // Drawing tool actions TOOL_ACTION PCB_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_LINE ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'L', LEGACY_HK_NAME( "Draw Line" ), _( "Draw Line" ), _( "Draw a line" ), add_graphical_segments_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawPolygon( "pcbnew.InteractiveDrawing.graphicPolygon", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_POLYGON ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'P', LEGACY_HK_NAME( "Draw Graphic Polygon" ), _( "Draw Graphic Polygon" ), _( "Draw a graphic polygon" ), add_graphical_polygon_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_CIRCLE ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'C', LEGACY_HK_NAME( "Draw Circle" ), _( "Draw Circle" ), _( "Draw a circle" ), add_circle_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawArc( "pcbnew.InteractiveDrawing.arc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_ARC ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'A', LEGACY_HK_NAME( "Draw Arc" ), _( "Draw Arc" ), _( "Draw an arc" ), add_arc_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::placeText( "pcbnew.InteractiveDrawing.text", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_TEXT ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'T', LEGACY_HK_NAME( "Add Text" ), _( "Add Text" ), _( "Add a text item" ), text_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawDimension( "pcbnew.InteractiveDrawing.dimension", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_DIMENSION ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'H', LEGACY_HK_NAME( "Add Dimension" ), _( "Add Dimension" ), _( "Add a dimension" ), add_dimension_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_ZONE ), + AS_GLOBAL, +#ifdef __WXOSX_MAC__ + GR_KB_ALT + 'Z', +#else + MD_SHIFT + MD_CTRL + 'Z', +#endif + LEGACY_HK_NAME( "Add Filled Zone" ), _( "Add Filled Zone" ), _( "Add a filled zone" ), add_zone_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawVia( "pcbnew.InteractiveDrawing.via", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_FREE_VIA ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'V', LEGACY_HK_NAME( "Add Vias" ), _( "Add Vias" ), _( "Add free-standing vias" ), add_via_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawZoneKeepout( "pcbnew.InteractiveDrawing.keepout", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_KEEPOUT ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'K', LEGACY_HK_NAME( "Add Keepout Area" ), _( "Add Keepout Area" ), _( "Add a keepout area" ), add_keepout_area_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawZoneCutout( "pcbnew.InteractiveDrawing.zoneCutout", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_CUTOUT ), + AS_GLOBAL, + GR_KB_SHIFT + 'C', LEGACY_HK_NAME( "Add a Zone Cutout" ), _( "Add a Zone Cutout" ), _( "Add a cutout area of an existing zone" ), add_zone_cutout_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_SIMILAR_ZONE ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + '.', LEGACY_HK_NAME( "Add a Similar Zone" ), _( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ), add_zone_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::placeImportedGraphics( "pcbnew.InteractiveDrawing.placeImportedGraphics", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_DXF ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'F', LEGACY_HK_NAME( "Place DXF" ), _( "Place Imported Graphics" ), "", import_vector_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_ANCHOR ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'N', LEGACY_HK_NAME( "Place the Footprint Anchor" ), _( "Place the Footprint Anchor" ), "", anchor_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::incWidth( "pcbnew.InteractiveDrawing.incWidth", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_INC_LINE_WIDTH ), + AS_CONTEXT, + MD_CTRL + '+', LEGACY_HK_NAME( "Increase Line Width" ), _( "Increase Line Width" ), _( "Increase the line width" ) ); TOOL_ACTION PCB_ACTIONS::decWidth( "pcbnew.InteractiveDrawing.decWidth", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_DEC_LINE_WIDTH ), + AS_CONTEXT, + MD_CTRL + '-', LEGACY_HK_NAME( "Decrease Line Width" ), _( "Decrease Line Width" ), _( "Decrease the line width" ) ); TOOL_ACTION PCB_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_POSTURE ), + AS_CONTEXT, + '/', LEGACY_HK_NAME( "Switch Track Posture" ), _( "Switch Arc Posture" ), _( "Switch the arc posture" ) ); /* @@ -147,12 +167,13 @@ TOOL_ACTION PCB_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture", */ static TOOL_ACTION deleteLastPoint( "pcbnew.InteractiveDrawing.deleteLastPoint", - AS_CONTEXT, WXK_BACK, + AS_CONTEXT, + WXK_BACK, "", _( "Delete Last Point" ), _( "Delete the last point added to the current item" ), undo_xpm ); static TOOL_ACTION closeZoneOutline( "pcbnew.InteractiveDrawing.closeZoneOutline", - AS_CONTEXT, 0, + AS_CONTEXT, 0, "", _( "Close Zone Outline" ), _( "Close the outline of a zone in progress" ), checked_ok_xpm ); diff --git a/pcbnew/tools/drc.cpp b/pcbnew/tools/drc.cpp index 9f6351c8b1..1117fb8d3f 100644 --- a/pcbnew/tools/drc.cpp +++ b/pcbnew/tools/drc.cpp @@ -60,7 +60,7 @@ TOOL_ACTION PCB_ACTIONS::runDRC( "pcbnew.DRCTool.runDRC", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Design Rules Checker" ), _( "Show the design rules checker window" ), erc_xpm ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 86434e6b5d..bba3524d4f 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -45,12 +45,9 @@ #include <connectivity/connectivity_data.h> #include <confirm.h> #include <bitmaps.h> -#include <hotkeys.h> - #include <cassert> #include <functional> using namespace std::placeholders; - #include "pcb_actions.h" #include "selection_tool.h" #include "edit_tool.h" @@ -69,79 +66,90 @@ using namespace std::placeholders; // Edit tool actions TOOL_ACTION PCB_ACTIONS::editFootprintInFpEditor( "pcbnew.InteractiveEdit.EditFpInFpEditor", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_MODULE_WITH_MODEDIT ), + AS_GLOBAL, + MD_CTRL + 'E', LEGACY_HK_NAME( "Edit with Footprint Editor" ), _( "Open in Footprint Editor" ), _( "Opens the selected footprint in the Footprint Editor" ), module_editor_xpm ); TOOL_ACTION PCB_ACTIONS::editActivate( "pcbnew.InteractiveEdit", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Activate" ), "", move_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::move( "pcbnew.InteractiveEdit.move", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_ITEM ), + AS_GLOBAL, + 'M', LEGACY_HK_NAME( "Move Item" ), _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::duplicate( "pcbnew.InteractiveEdit.duplicate", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ), + AS_GLOBAL, + MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate Item" ), _( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm ); TOOL_ACTION PCB_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM_AND_INCREMENT ), + AS_GLOBAL, + MD_SHIFT + MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate Item and Increment" ), _( "Duplicate" ), _( "Duplicates the selected item(s), incrementing pad numbers" ), duplicate_xpm ); TOOL_ACTION PCB_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_ITEM_EXACT ), + AS_GLOBAL, + MD_CTRL + 'M', LEGACY_HK_NAME( "Move Item Exactly" ), _( "Move Exactly..." ), _( "Moves the selected item(s) by an exact amount" ), move_exactly_xpm ); TOOL_ACTION PCB_ACTIONS::createArray( "pcbnew.InteractiveEdit.createArray", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CREATE_ARRAY ), + AS_GLOBAL, + MD_CTRL + 'T', LEGACY_HK_NAME( "Create Array" ), _( "Create Array..." ), _( "Create array" ), array_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM_CLOCKWISE ), + AS_GLOBAL, + MD_SHIFT + 'R', LEGACY_HK_NAME( "Rotate Item Clockwise (Modern Toolset only)" ), _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ), rotate_cw_xpm, AF_NONE, (void*) -1 ); TOOL_ACTION PCB_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM ), + AS_GLOBAL, + 'R', LEGACY_HK_NAME( "Rotate Item" ), _( "Rotate Counterclockwise" ), _( "Rotates selected item(s) counterclockwise" ), rotate_ccw_xpm, AF_NONE, (void*) 1 ); TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ), + AS_GLOBAL, + 'F', LEGACY_HK_NAME( "Flip Item" ), _( "Flip" ), _( "Flips selected item(s)" ), swap_layer_xpm ); TOOL_ACTION PCB_ACTIONS::mirror( "pcbnew.InteractiveEdit.mirror", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Mirror" ), _( "Mirrors selected item" ), mirror_h_xpm ); TOOL_ACTION PCB_ACTIONS::remove( "pcbnew.InteractiveEdit.remove", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BACK_SPACE ), + AS_GLOBAL, + WXK_BACK, "", _( "Delete" ), _( "Deletes selected item(s)" ), delete_xpm, AF_NONE, (void*) REMOVE_FLAGS::NORMAL ); -TOOL_ACTION PCB_ACTIONS::removeAlt( "pcbnew.InteractiveEdit.removeAlt", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ), +TOOL_ACTION PCB_ACTIONS::deleteFull( "pcbnew.InteractiveEdit.deleteFull", + AS_GLOBAL, + WXK_DELETE, LEGACY_HK_NAME( "Delete Full Track" ), _( "Delete Full Track" ), _( "Deletes selected item(s) and copper connections" ), delete_xpm, AF_NONE, (void*) REMOVE_FLAGS::ALT ); TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ), + AS_GLOBAL, + 'E', LEGACY_HK_NAME( "Edit Item" ), _( "Properties..." ), _( "Displays item properties dialog" ), config_xpm ); TOOL_ACTION PCB_ACTIONS::updateUnits( "pcbnew.InteractiveEdit.updateUnits", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags ) @@ -1439,7 +1447,7 @@ void EDIT_TOOL::setTransitions() Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() ); Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() ); Go( &EDIT_TOOL::Remove, PCB_ACTIONS::remove.MakeEvent() ); - Go( &EDIT_TOOL::Remove, PCB_ACTIONS::removeAlt.MakeEvent() ); + Go( &EDIT_TOOL::Remove, PCB_ACTIONS::deleteFull.MakeEvent() ); Go( &EDIT_TOOL::Properties, PCB_ACTIONS::properties.MakeEvent() ); Go( &EDIT_TOOL::MoveExact, PCB_ACTIONS::moveExact.MakeEvent() ); Go( &EDIT_TOOL::Duplicate, PCB_ACTIONS::duplicate.MakeEvent() ); diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index c8dd6d5935..38520b4ceb 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -41,7 +41,6 @@ #include <collectors.h> #include <confirm.h> #include <dialogs/dialog_enum_pads.h> -#include <hotkeys.h> #include <bitmaps.h> #include <pcb_edit_frame.h> #include <class_board.h> @@ -57,95 +56,96 @@ using namespace std::placeholders; TOOL_ACTION PCB_ACTIONS::toggleFootprintTree( "pcbnew.ModuleEditor.toggleFootprintTree", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Footprint Tree" ), _( "Toggles the footprint tree visibility" ), search_tree_xpm ); TOOL_ACTION PCB_ACTIONS::newFootprint( "pcbnew.ModuleEditor.newFootprint", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_NEW ), + AS_GLOBAL, + MD_CTRL + 'N', LEGACY_HK_NAME( "New" ), _( "New Footprint..." ), _( "Create a new, empty footprint" ), new_footprint_xpm ); TOOL_ACTION PCB_ACTIONS::createFootprint( "pcbnew.ModuleEditor.createFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Create Footprint..." ), _( "Create a new footprint using the Footprint Wizard" ), module_wizard_xpm ); TOOL_ACTION PCB_ACTIONS::saveToBoard( "pcbnew.ModuleEditor.saveToBoard", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Save to Board" ), _( "Update footprint on board" ), save_fp_to_board_xpm ); TOOL_ACTION PCB_ACTIONS::saveToLibrary( "pcbnew.ModuleEditor.saveToLibrary", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Save to Library" ), _( "Save changes to library" ), save_xpm ); TOOL_ACTION PCB_ACTIONS::editFootprint( "pcbnew.ModuleEditor.editFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Footprint" ), _( "Show selected footprint on editor canvas" ), edit_xpm ); TOOL_ACTION PCB_ACTIONS::deleteFootprint( "pcbnew.ModuleEditor.deleteFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Delete Footprint from Library" ), "", delete_xpm ); TOOL_ACTION PCB_ACTIONS::cutFootprint( "pcbnew.ModuleEditor.cutFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Cut Footprint" ), "", cut_xpm ); TOOL_ACTION PCB_ACTIONS::copyFootprint( "pcbnew.ModuleEditor.copyFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Copy Footprint" ), "", copy_xpm ); TOOL_ACTION PCB_ACTIONS::pasteFootprint( "pcbnew.ModuleEditor.pasteFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Paste Footprint" ), "", paste_xpm ); TOOL_ACTION PCB_ACTIONS::importFootprint( "pcbnew.ModuleEditor.importFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Import Footprint..." ), "", import_module_xpm ); TOOL_ACTION PCB_ACTIONS::exportFootprint( "pcbnew.ModuleEditor.exportFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Export Footprint..." ), "", export_module_xpm ); // Module editor tools TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Footprint Properties..." ), "", module_options_xpm ); TOOL_ACTION PCB_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Pad" ), _( "Add a pad" ), pad_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::createPadFromShapes( "pcbnew.ModuleEditor.createPadFromShapes", - AS_CONTEXT, 0, + AS_CONTEXT, 0, "", _( "Create Pad from Selected Shapes" ), _( "Creates a custom-shaped pads from a set of selected shapes" ), primitives_to_custom_pad_xpm ); TOOL_ACTION PCB_ACTIONS::explodePadToShapes( "pcbnew.ModuleEditor.explodePadToShapes", - AS_CONTEXT, 0, + AS_CONTEXT, 0, "", _( "Explode Pad to Graphic Shapes" ), _( "Converts a custom-shaped pads to a set of graphical shapes" ), custom_pad_to_primitives_xpm ); TOOL_ACTION PCB_ACTIONS::enumeratePads( "pcbnew.ModuleEditor.enumeratePads", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Renumber Pads..." ), _( "Renumber pads by clicking on them in the desired order" ), pad_enumerate_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::defaultPadProperties( "pcbnew.ModuleEditor.defaultPadProperties", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Default Pad Properties..." ), _( "Edit the pad properties used when creating new pads" ), options_pad_xpm ); diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 71509f5106..d3ba4cc4d1 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -35,50 +35,50 @@ TOOL_ACTION PCB_ACTIONS::updateFootprint( "pcbnew.GlobalEdit.updateFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Update Footprint..." ), _( "Update footprint to include any changes from the library" ), reload_xpm ); TOOL_ACTION PCB_ACTIONS::updateFootprints( "pcbnew.GlobalEdit.updateFootprints", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Update Footprints from Library..." ), _( "Update footprints to include any changes from the library" ), reload_xpm ); TOOL_ACTION PCB_ACTIONS::changeFootprint( "pcbnew.GlobalEdit.changeFootprint", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change Footprint..." ), _( "Assign a different footprint from the library" ), exchange_xpm ); TOOL_ACTION PCB_ACTIONS::changeFootprints( "pcbnew.GlobalEdit.changeFootprints", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Change Footprints..." ), _( "Assign different footprints from the library" ), exchange_xpm ); TOOL_ACTION PCB_ACTIONS::swapLayers( "pcbnew.GlobalEdit.swapLayers", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Swap Layers..." ), _( "Move tracks or drawings from one layer to another" ), swap_layer_xpm ); TOOL_ACTION PCB_ACTIONS::editTracksAndVias( "pcbnew.GlobalEdit.editTracksAndVias", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Track && Via Properties..." ), "", width_track_via_xpm ); TOOL_ACTION PCB_ACTIONS::editTextAndGraphics( "pcbnew.GlobalEdit.editTextAndGraphics", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Edit Text && Graphic Properties..." ), "", reset_text_xpm ); TOOL_ACTION PCB_ACTIONS::globalDeletions( "pcbnew.GlobalEdit.globalDeletions", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Global Deletions..." ), _( "Delete tracks, footprints and graphic items from board" ), general_deletions_xpm ); TOOL_ACTION PCB_ACTIONS::cleanupTracksAndVias( "pcbnew.GlobalEdit.cleanupTracksAndVias", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Cleanup Tracks && Vias..." ), _( "Clean stubs, vias, delete break points or unconnected tracks" ), delete_xpm ); diff --git a/pcbnew/tools/microwave_tool.cpp b/pcbnew/tools/microwave_tool.cpp index c1185db78b..c0ffd3c8db 100644 --- a/pcbnew/tools/microwave_tool.cpp +++ b/pcbnew/tools/microwave_tool.cpp @@ -61,31 +61,31 @@ enum MWAVE_TOOL_SIMPLE_ID TOOL_ACTION PCB_ACTIONS::microwaveCreateGap( "pcbnew.MicrowaveTool.createGap", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Gap" ), _( "Create gap of specified length for microwave applications" ), mw_add_gap_xpm, AF_ACTIVATE, (void*) MWAVE_TOOL_SIMPLE_ID::GAP ); TOOL_ACTION PCB_ACTIONS::microwaveCreateStub( "pcbnew.MicrowaveTool.createStub", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Stub" ), _( "Create stub of specified length for microwave applications" ), mw_add_stub_xpm, AF_ACTIVATE, (void*) MWAVE_TOOL_SIMPLE_ID::STUB ); TOOL_ACTION PCB_ACTIONS::microwaveCreateStubArc( "pcbnew.MicrowaveTool.createStubArc", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Arc Stub" ), _( "Create stub (arc) of specified length for microwave applications" ), mw_add_stub_arc_xpm, AF_ACTIVATE, (void*) MWAVE_TOOL_SIMPLE_ID::STUB_ARC ); TOOL_ACTION PCB_ACTIONS::microwaveCreateFunctionShape( "pcbnew.MicrowaveTool.createFunctionShape", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Polynomial Shape" ), _( "Create polynomial shape for microwave applications" ), mw_add_gap_xpm, AF_ACTIVATE, (void*) MWAVE_TOOL_SIMPLE_ID::FUNCTION_SHAPE ); TOOL_ACTION PCB_ACTIONS::microwaveCreateLine( "pcbnew.MicrowaveTool.createLine", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Microwave Line" ), _( "Create line of specified length for microwave applications" ), mw_add_line_xpm, AF_ACTIVATE ); diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 2c232a52c2..903411c165 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -42,21 +42,18 @@ #include "pcbnew_id.h" // Pad tools -TOOL_ACTION PCB_ACTIONS::copyPadSettings( - "pcbnew.PadTool.CopyPadSettings", - AS_GLOBAL, 0, +TOOL_ACTION PCB_ACTIONS::copyPadSettings( "pcbnew.PadTool.CopyPadSettings", + AS_GLOBAL, 0, "", _( "Copy Pad Properties" ), _( "Copy current pad's properties" ), copy_pad_settings_xpm ); -TOOL_ACTION PCB_ACTIONS::applyPadSettings( - "pcbnew.PadTool.ApplyPadSettings", - AS_GLOBAL, 0, +TOOL_ACTION PCB_ACTIONS::applyPadSettings( "pcbnew.PadTool.ApplyPadSettings", + AS_GLOBAL, 0, "", _( "Paste Pad Properties" ), _( "Replace the current pad's properties with those copied earlier" ), apply_pad_settings_xpm ); -TOOL_ACTION PCB_ACTIONS::pushPadSettings( - "pcbnew.PadTool.PushPadSettings", - AS_GLOBAL, 0, +TOOL_ACTION PCB_ACTIONS::pushPadSettings( "pcbnew.PadTool.PushPadSettings", + AS_GLOBAL, 0, "", _( "Push Pad Properties..." ), _( "Copy the current pad's properties to other pads" ), push_pad_settings_xpm ); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index bb69b22b8c..fa2bd90734 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -115,7 +115,7 @@ public: /// Deleting a BOARD_ITEM static TOOL_ACTION remove; - static TOOL_ACTION removeAlt; + static TOOL_ACTION deleteFull; static TOOL_ACTION selectLayerPair; @@ -283,7 +283,6 @@ public: static TOOL_ACTION showLayersManager; static TOOL_ACTION showMicrowaveToolbar; static TOOL_ACTION showPythonConsole; - static TOOL_ACTION showHelp; // Module editor tools @@ -367,7 +366,6 @@ public: static TOOL_ACTION drillOrigin; static TOOL_ACTION crossProbeSchToPcb; static TOOL_ACTION appendBoard; - static TOOL_ACTION toBeDone; // Ratsnest static TOOL_ACTION localRatsnestTool; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 7add1d634f..bff00c19f0 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -51,8 +51,6 @@ #include <board_commit.h> #include <confirm.h> #include <bitmaps.h> -#include <hotkeys.h> - #include <view/view_group.h> #include <view/view_controls.h> #include <origin_viewitem.h> @@ -69,179 +67,183 @@ using namespace std::placeholders; TOOL_ACTION PCB_ACTIONS::boardSetup( "pcbnew.EditorControl.boardSetup", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Board Setup..." ), _( "Edit board setup including layers, design rules and various defaults" ), options_board_xpm ); TOOL_ACTION PCB_ACTIONS::importNetlist( "pcbnew.EditorControl.importNetlist", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Netlist..." ), _( "Read netlist and update board connectivity" ), netlist_xpm ); TOOL_ACTION PCB_ACTIONS::importSpecctraSession( "pcbnew.EditorControl.importSpecctraSession", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Specctra Session..." ), _( "Import routed Specctra session (*.ses) file" ), import_xpm ); TOOL_ACTION PCB_ACTIONS::exportSpecctraDSN( "pcbnew.EditorControl.exportSpecctraDSN", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Specctra DSN..." ), _( "Export Specctra DSN routing info" ), export_dsn_xpm ); TOOL_ACTION PCB_ACTIONS::generateGerbers( "pcbnew.EditorControl.generateGerbers", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "&Gerbers (.gbr)..." ), _( "Generate Gerbers for fabrication" ), post_compo_xpm ); TOOL_ACTION PCB_ACTIONS::generateDrillFiles( "pcbnew.EditorControl.generateDrillFiles", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "&Drill Files (.drl)..." ), _( "Generate Excellon drill file(s)" ), post_drill_xpm ); TOOL_ACTION PCB_ACTIONS::generatePosFile( "pcbnew.EditorControl.generatePosFile", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Footprint &Positions (.pos)..." ), _( "Generate footprint position file for pick and place" ), post_compo_xpm ); TOOL_ACTION PCB_ACTIONS::generateReportFile( "pcbnew.EditorControl.generateReportFile", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "&Footprint Report (.rpt)..." ), _( "Create report of all footprints from current board" ), tools_xpm ); TOOL_ACTION PCB_ACTIONS::generateD356File( "pcbnew.EditorControl.generateD356File", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "IPC-D-356 Netlist File..." ), _( "Generate IPC-D-356 netlist file" ), netlist_xpm ); TOOL_ACTION PCB_ACTIONS::generateBOM( "pcbnew.EditorControl.generateBOM", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "&BOM..." ), _( "Create bill of materials from current schematic" ), bom_xpm ); // Track & via size control TOOL_ACTION PCB_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_WIDTH_TO_NEXT ), + AS_GLOBAL, + 'W', LEGACY_HK_NAME( "Switch Track Width To Next" ), "", "" ); TOOL_ACTION PCB_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS ), + AS_GLOBAL, + MD_SHIFT + 'W', LEGACY_HK_NAME( "Switch Track Width To Previous" ), "", "" ); TOOL_ACTION PCB_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_VIA_SIZE_INC ), + AS_GLOBAL, + '\'', LEGACY_HK_NAME( "Increase Via Size" ), "", "" ); TOOL_ACTION PCB_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_VIA_SIZE_DEC ), + AS_GLOBAL, + '\\', LEGACY_HK_NAME( "Decrease Via Size" ), "", "" ); TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", "", "", nullptr, AF_NOTIFY ); TOOL_ACTION PCB_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Merge Zones" ), _( "Merge zones" ) ); TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Duplicate Zone onto Layer..." ), _( "Duplicate zone outline onto a different layer" ), zone_duplicate_xpm ); TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), add_pcb_target_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_MODULE ), + AS_GLOBAL, + 'O', LEGACY_HK_NAME( "Add Footprint" ), _( "Add Footprint" ), _( "Add a footprint" ), module_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Drill and Place Offset" ), _( "Place origin point for drill and place files" ), pcb_offset_xpm ); TOOL_ACTION PCB_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LOCK_UNLOCK_FOOTPRINT ), + AS_GLOBAL, + 'L', LEGACY_HK_NAME( "Lock/Unlock Footprint" ), "Toggle Lock", "", lock_unlock_xpm ); TOOL_ACTION PCB_ACTIONS::lock( "pcbnew.EditorControl.lock", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Lock" ), "", locked_xpm ); TOOL_ACTION PCB_ACTIONS::unlock( "pcbnew.EditorControl.unlock", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Unlock" ), "", unlocked_xpm ); TOOL_ACTION PCB_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard", - AS_GLOBAL, 0, - "Append Board...", "", add_board_xpm ); + AS_GLOBAL, 0, "", + "Append Board...", "", + add_board_xpm ); TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::clearHighlight( "pcbnew.EditorControl.clearHighlight", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::highlightNetTool( "pcbnew.EditorControl.highlightNetTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Nets" ), _( "Highlight all copper items of a net" ), net_highlight_xpm ); TOOL_ACTION PCB_ACTIONS::highlightNetSelection( "pcbnew.EditorControl.highlightNetSelection", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHLIGHT_NET_SELECTION ), + AS_GLOBAL, + '`', LEGACY_HK_NAME( "Toggle Highlight of Selected Net (Modern Toolset only)" ), _( "Highlight Net" ), _( "Highlight all copper items of a net" ), net_highlight_xpm ); TOOL_ACTION PCB_ACTIONS::localRatsnestTool( "pcbnew.Control.localRatsnestTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Highlight Ratsnest" ), "", tool_ratsnest_xpm ); -TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( - "pcbnew.Control.hideDynamicRatsnest", AS_GLOBAL, 0, "", "" ); +TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( "pcbnew.Control.hideDynamicRatsnest", + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::updateLocalRatsnest( "pcbnew.Control.updateLocalRatsnest", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::listNets( "pcbnew.Control.listNets", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "List Nets" ), _( "Show a list of nets with names and IDs" ), list_nets_xpm ); TOOL_ACTION PCB_ACTIONS::showPythonConsole( "pcbnew.Control.showPythonConsole", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Scripting Console" ), _( "Show the Python scripting console" ), py_script_xpm ); TOOL_ACTION PCB_ACTIONS::showLayersManager( "pcbnew.Control.showLayersManager", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Layers Manager" ), _( "Show/hide the layers manager" ), layers_manager_xpm ); TOOL_ACTION PCB_ACTIONS::showMicrowaveToolbar( "pcbnew.Control.showMicrowaveToolbar", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Microwave Toolbar" ), _( "Show/hide microwave toolbar\n(Experimental feature)" ), mw_toolbar_xpm ); TOOL_ACTION PCB_ACTIONS::flipBoard( "pcbnew.Control.flipBoard", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Flip Board View" ), _( "Flip (mirror) the board view" ), flip_board_xpm ); diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index fef67360c2..d81e07d882 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -37,9 +37,7 @@ #include <class_track.h> #include <class_zone.h> #include <pcb_screen.h> - #include <confirm.h> -#include <hotkeys.h> #include <properties.h> #include <io_mgr.h> #include <kicad_plugin.h> @@ -71,137 +69,150 @@ extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl ); // Display modes TOOL_ACTION PCB_ACTIONS::showRatsnest( "pcbnew.Control.showRatsnest", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Show Ratsnest" ), _( "Show board ratsnest" ), general_ratsnest_xpm ); TOOL_ACTION PCB_ACTIONS::ratsnestLineMode( "pcbnew.Control.ratsnestLineMode", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Curved Ratsnest Lines" ), _( "Show ratsnest with curved lines" ), curved_ratsnest_xpm ); TOOL_ACTION PCB_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_DISPLAY_MODE ), + AS_GLOBAL, + 'K', LEGACY_HK_NAME( "Track Display Mode" ), _( "Sketch Tracks" ), _( "Show tracks in outline mode" ), showtrack_xpm ); TOOL_ACTION PCB_ACTIONS::padDisplayMode( "pcbnew.Control.padDisplayMode", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Sketch Pads" ), _( "Show pads in outline mode" ), pad_sketch_xpm ); TOOL_ACTION PCB_ACTIONS::viaDisplayMode( "pcbnew.Control.viaDisplayMode", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Sketch Vias" ), _( "Show vias in outline mode" ), via_sketch_xpm ); TOOL_ACTION PCB_ACTIONS::graphicDisplayMode( "pcbnew.Control.graphicDisplayMode", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::moduleEdgeOutlines( "pcbnew.Control.graphicOutlines", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Sketch Graphics" ), _( "Show footprint graphic items in outline mode" ), show_mod_edge_xpm ); TOOL_ACTION PCB_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Fill Zones" ), _( "Show filled areas of zones" ), show_zone_xpm); TOOL_ACTION PCB_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Wireframe Zones" ), _( "Show only zone boundaries" ), show_zone_disable_xpm ); TOOL_ACTION PCB_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Sketch Zones" ), _( "Show solid areas of zones in outline mode" ), show_zone_outline_only_xpm); // Layer control TOOL_ACTION PCB_ACTIONS::layerTop( "pcbnew.Control.layerTop", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_COMPONENT ), - "", "", NULL, AF_NONE, (void*) F_Cu ); + AS_GLOBAL, + WXK_PAGEUP, LEGACY_HK_NAME( "Switch to Component (F.Cu) layer" ), + "Switch to Component (F.Cu) layer", "", + nullptr, AF_NONE, (void*) F_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner1( "pcbnew.Control.layerInner1", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER1 ), - "", "", NULL, AF_NONE, (void*) In1_Cu ); + AS_GLOBAL, + WXK_F5, LEGACY_HK_NAME( "Switch to Inner layer 1" ), + "Switch to Inner layer 1", "", + nullptr, AF_NONE, (void*) In1_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner2( "pcbnew.Control.layerInner2", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER2 ), - "", "", NULL, AF_NONE, (void*) In2_Cu ); + AS_GLOBAL, + WXK_F6, LEGACY_HK_NAME( "Switch to Inner layer 2" ), + "Switch to Inner layer 2", "", + nullptr, AF_NONE, (void*) In2_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner3( "pcbnew.Control.layerInner3", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER3 ), - "", "", NULL, AF_NONE, (void*) In3_Cu ); + AS_GLOBAL, + WXK_F7, LEGACY_HK_NAME( "Switch to Inner layer 3" ), + "Switch to Inner layer 3", "", + nullptr, AF_NONE, (void*) In3_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner4( "pcbnew.Control.layerInner4", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER4 ), - "", "", NULL, AF_NONE, (void*) In4_Cu ); + AS_GLOBAL, + WXK_F8, LEGACY_HK_NAME( "Switch to Inner layer 4" ), + "Switch to Inner layer 4", "", + nullptr, AF_NONE, (void*) In4_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner5( "pcbnew.Control.layerInner5", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER5 ), - "", "", NULL, AF_NONE, (void*) In5_Cu ); + AS_GLOBAL, + MD_SHIFT + WXK_F5, LEGACY_HK_NAME( "Switch to Inner layer 5" ), + "Switch to Inner layer 5", "", + nullptr, AF_NONE, (void*) In5_Cu ); TOOL_ACTION PCB_ACTIONS::layerInner6( "pcbnew.Control.layerInner6", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER6 ), - "", "", NULL, AF_NONE, (void*) In6_Cu ); + AS_GLOBAL, + MD_SHIFT + WXK_F6, LEGACY_HK_NAME( "Switch to Inner layer 6" ), + "Switch to Inner layer 6", "", + nullptr, AF_NONE, (void*) In6_Cu ); TOOL_ACTION PCB_ACTIONS::layerBottom( "pcbnew.Control.layerBottom", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_COPPER ), - "", "", NULL, AF_NONE, (void*) B_Cu ); + AS_GLOBAL, + WXK_PAGEDOWN, LEGACY_HK_NAME( "Switch to Copper (B.Cu) layer" ), + "Switch to Copper (B.Cu) layer", "", + nullptr, AF_NONE, (void*) B_Cu ); TOOL_ACTION PCB_ACTIONS::layerNext( "pcbnew.Control.layerNext", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_NEXT ), - "", "" ); + AS_GLOBAL, + '+', LEGACY_HK_NAME( "Switch to Next Layer" ), + "Switch to Next Layer", "" ); TOOL_ACTION PCB_ACTIONS::layerPrev( "pcbnew.Control.layerPrev", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_PREVIOUS ), - "", "" ); + AS_GLOBAL, + '-', LEGACY_HK_NAME( "Switch to Previous Layer" ), + "Switch to Previous Layer", "" ); TOOL_ACTION PCB_ACTIONS::layerToggle( "pcbnew.Control.layerToggle", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_THROUGH_VIA ), - "", "" ); + AS_GLOBAL, + 'V', LEGACY_HK_NAME( "Add Through Via" ), + "Add Through Via", "" ); TOOL_ACTION PCB_ACTIONS::layerAlphaInc( "pcbnew.Control.layerAlphaInc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_INC_LAYER_ALPHA ), + AS_GLOBAL, + '}', LEGACY_HK_NAME( "Increment Layer Transparency (Modern Toolset only)" ), _( "Increase Layer Opacity" ), _( "Make the current layer more transparent" ), contrast_mode_xpm ); TOOL_ACTION PCB_ACTIONS::layerAlphaDec( "pcbnew.Control.layerAlphaDec", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DEC_LAYER_ALPHA ), + AS_GLOBAL, + '{', LEGACY_HK_NAME( "Decrement Layer Transparency (Modern Toolset only)" ), _( "Decrease Layer Opacity" ), _( "Make the current layer more transparent" ), contrast_mode_xpm ); TOOL_ACTION PCB_ACTIONS::layerChanged( "pcbnew.Control.layerChanged", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", "", "", - NULL, AF_NOTIFY ); + nullptr, AF_NOTIFY ); // Miscellaneous TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Select item(s)" ), "", cursor_xpm, AF_ACTIVATE ); TOOL_ACTION PCB_ACTIONS::deleteTool( "pcbnew.Control.deleteTool", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Delete Items Tool" ), _( "Click on items to delete them" ), delete_xpm ); -TOOL_ACTION PCB_ACTIONS::showHelp( "pcbnew.Control.showHelp", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ), - "", "" ); - -TOOL_ACTION PCB_ACTIONS::toBeDone( "pcbnew.Control.toBeDone", - AS_GLOBAL, 0, // dialog saying it is not implemented yet - "", "" ); // so users are aware of that - - PCBNEW_CONTROL::PCBNEW_CONTROL() : - PCB_TOOL_BASE( "pcbnew.Control" ), m_frame( NULL ) + PCB_TOOL_BASE( "pcbnew.Control" ), + m_frame( nullptr ) { m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() ); } @@ -408,18 +419,6 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent ) } -int PCBNEW_CONTROL::HighContrastInc( const TOOL_EVENT& aEvent ) -{ - return 0; -} - - -int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent ) -{ - return 0; -} - - // Layer control int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent ) { @@ -973,14 +972,6 @@ int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent ) } -int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) -{ - DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() ); - - return 0; -} - - int PCBNEW_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent ) { EDA_3D_VIEWER* draw3DFrame = m_frame->CreateAndShow3D_Frame(); @@ -1001,13 +992,6 @@ int PCBNEW_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent ) } -int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent ) -{ - DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) ); - return 0; -} - - void PCBNEW_CONTROL::updateGrid() { BASE_SCREEN* screen = m_frame->GetScreen(); @@ -1066,8 +1050,6 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() ); Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() ); Go( &PCBNEW_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() ); - Go( &PCBNEW_CONTROL::HighContrastInc, ACTIONS::highContrastInc.MakeEvent() ); - Go( &PCBNEW_CONTROL::HighContrastDec, ACTIONS::highContrastDec.MakeEvent() ); // Layer control Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerTop.MakeEvent() ); @@ -1095,9 +1077,7 @@ void PCBNEW_CONTROL::setTransitions() // Miscellaneous Go( &PCBNEW_CONTROL::DeleteItemCursor, PCB_ACTIONS::deleteTool.MakeEvent() ); - Go( &PCBNEW_CONTROL::ShowHelp, PCB_ACTIONS::showHelp.MakeEvent() ); Go( &PCBNEW_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() ); - Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() ); // Append control Go( &PCBNEW_CONTROL::AppendBoardFromFile, PCB_ACTIONS::appendBoard.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index a1b7c306f1..ff53ebdf1a 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -63,8 +63,6 @@ public: int GraphicDisplayMode( const TOOL_EVENT& aEvent ); int ModuleEdgeOutlines( const TOOL_EVENT& aEvent ); int HighContrastMode( const TOOL_EVENT& aEvent ); - int HighContrastInc( const TOOL_EVENT& aEvent ); - int HighContrastDec( const TOOL_EVENT& aEvent ); // Layer control int LayerSwitch( const TOOL_EVENT& aEvent ); @@ -96,9 +94,7 @@ public: int Paste( const TOOL_EVENT& aEvent ); int AppendBoardFromFile( const TOOL_EVENT& aEvent ); int AppendBoard( PLUGIN& pi, wxString& fileName ); - int ShowHelp( const TOOL_EVENT& aEvent ); int Show3DViewer( const TOOL_EVENT& aEvent ); - int ToBeDone( const TOOL_EVENT& aEvent ); int UpdateMessagePanel( const TOOL_EVENT& aEvent ); ///> Sets up handlers for various events. diff --git a/pcbnew/tools/pcbnew_picker_tool.cpp b/pcbnew/tools/pcbnew_picker_tool.cpp index 1515f32bfb..a6e95cf67c 100644 --- a/pcbnew/tools/pcbnew_picker_tool.cpp +++ b/pcbnew/tools/pcbnew_picker_tool.cpp @@ -30,11 +30,12 @@ #include "tool_event_utils.h" #include "selection_tool.h" -TOOL_ACTION PCB_ACTIONS::pickerTool( "pcbnew.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); +TOOL_ACTION PCB_ACTIONS::pickerTool( "pcbnew.InteractivePicker.activate", + AS_GLOBAL, 0, "", "", "", nullptr, AF_ACTIVATE ); PCBNEW_PICKER_TOOL::PCBNEW_PICKER_TOOL() - : PCB_TOOL_BASE( "pcbnew.Picker" ) + : PCB_TOOL_BASE( "pcbnew.InteractivePicker" ) { reset(); } diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 57f52ca3e6..88d3ec8bc0 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -39,42 +39,42 @@ // Placement tool TOOL_ACTION PCB_ACTIONS::alignTop( "pcbnew.AlignAndDistribute.alignTop", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Top" ), _( "Aligns selected items to the top edge" ), align_items_top_xpm ); TOOL_ACTION PCB_ACTIONS::alignBottom( "pcbnew.AlignAndDistribute.alignBottom", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Bottom" ), _( "Aligns selected items to the bottom edge" ), align_items_bottom_xpm ); TOOL_ACTION PCB_ACTIONS::alignLeft( "pcbnew.AlignAndDistribute.alignLeft", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Left" ), _( "Aligns selected items to the left edge" ), align_items_left_xpm ); TOOL_ACTION PCB_ACTIONS::alignRight( "pcbnew.AlignAndDistribute.alignRight", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Right" ), _( "Aligns selected items to the right edge" ), align_items_right_xpm ); TOOL_ACTION PCB_ACTIONS::alignCenterX( "pcbnew.AlignAndDistribute.alignCenterX", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Middle" ), _( "Aligns selected items to the vertical center" ), align_items_middle_xpm ); TOOL_ACTION PCB_ACTIONS::alignCenterY( "pcbnew.AlignAndDistribute.alignCenterY", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Align to Center" ), _( "Aligns selected items to the horizontal center" ), align_items_center_xpm ); TOOL_ACTION PCB_ACTIONS::distributeHorizontally( "pcbnew.AlignAndDistribute.distributeHorizontally", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Distribute Horizontally" ), _( "Distributes selected items along the horizontal axis" ), distribute_horizontal_xpm ); TOOL_ACTION PCB_ACTIONS::distributeVertically( "pcbnew.AlignAndDistribute.distributeVertically", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Distribute Vertically" ), _( "Distributes selected items along the vertical axis" ), distribute_vertical_xpm ); diff --git a/pcbnew/tools/placement_tool.h b/pcbnew/tools/placement_tool.h index deef4fb9a1..947111025e 100644 --- a/pcbnew/tools/placement_tool.h +++ b/pcbnew/tools/placement_tool.h @@ -26,6 +26,7 @@ #define ALIGN_DISTRIBUTE_TOOL_H_ #include <tool/tool_interactive.h> +#include <tools/pcbnew_selection.h> #include <class_board_item.h> #include <pcb_base_frame.h> @@ -142,7 +143,7 @@ private: * We also check the lock of a pad's parent as we will not move pads independently of * the parent module */ - int checkLockedStatus( const SELECTION &selection ) const; + int checkLockedStatus( const PCBNEW_SELECTION &selection ) const; /** * Distributes selected items using an even spacing between the centers of their bounding boxes diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 81ba5c85d0..64d081f486 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -52,11 +52,12 @@ using namespace std::placeholders; // Point editor TOOL_ACTION PCB_ACTIONS::pointEditorAddCorner( "pcbnew.PointEditor.addCorner", - AS_GLOBAL, WXK_INSERT, + AS_GLOBAL, + WXK_INSERT, "", _( "Create Corner" ), _( "Create a corner" ), add_corner_xpm ); TOOL_ACTION PCB_ACTIONS::pointEditorRemoveCorner( "pcbnew.PointEditor.removeCorner", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Remove Corner" ), _( "Remove corner" ), delete_xpm ); diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index ea7a38e03a..dc63ef93ff 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -29,11 +29,9 @@ using namespace std::placeholders; #include "selection_tool.h" #include "edit_tool.h" #include "pcbnew_picker_tool.h" - #include <dialogs/dialog_position_relative.h> #include <status_popup.h> #include <board_commit.h> -#include <hotkeys.h> #include <bitmaps.h> #include <confirm.h> @@ -41,15 +39,15 @@ using namespace std::placeholders; // Position relative tool actions TOOL_ACTION PCB_ACTIONS::positionRelative( "pcbnew.PositionRelative.positionRelative", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_POSITION_RELATIVE ), + AS_GLOBAL, + MD_SHIFT + 'P', LEGACY_HK_NAME( "Position Item Relative" ), _( "Position Relative To..." ), _( "Positions the selected item(s) by an exact amount relative to another" ), move_relative_xpm ); -TOOL_ACTION PCB_ACTIONS::selectpositionRelativeItem( - "pcbnew.PositionRelative.selectpositionRelativeItem", - AS_GLOBAL, 0, "", "", nullptr ); +TOOL_ACTION PCB_ACTIONS::selectpositionRelativeItem( "pcbnew.PositionRelative.selectpositionRelativeItem", + AS_GLOBAL ); POSITION_RELATIVE_TOOL::POSITION_RELATIVE_TOOL() : diff --git a/pcbnew/tools/position_relative_tool.h b/pcbnew/tools/position_relative_tool.h index f854926264..725febd092 100644 --- a/pcbnew/tools/position_relative_tool.h +++ b/pcbnew/tools/position_relative_tool.h @@ -82,8 +82,8 @@ private: DIALOG_POSITION_RELATIVE* m_dialog; ///> Selection tool used for obtaining selected items - SELECTION_TOOL* m_selectionTool; - SELECTION m_selection; + SELECTION_TOOL* m_selectionTool; + PCBNEW_SELECTION m_selection; std::unique_ptr<BOARD_COMMIT> m_commit; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index b5fb4f1fce..1a2fda6db6 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -47,8 +47,6 @@ using namespace std::placeholders; #include <preview_items/selection_area.h> #include <painter.h> #include <bitmaps.h> -#include <hotkeys.h> - #include <tool/tool_event.h> #include <tool/tool_manager.h> #include <router/router_tool.h> @@ -63,72 +61,75 @@ using namespace std::placeholders; // Selection tool actions TOOL_ACTION PCB_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection", - AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); // No description, not shown anywhere + AS_GLOBAL, 0, "", "", "", nullptr, AF_ACTIVATE ); // No description, not shown anywhere TOOL_ACTION PCB_ACTIONS::selectionCursor( "pcbnew.InteractiveSelection.Cursor", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::selectItem( "pcbnew.InteractiveSelection.SelectItem", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::selectItems( "pcbnew.InteractiveSelection.SelectItems", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::unselectItem( "pcbnew.InteractiveSelection.UnselectItem", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::unselectItems( "pcbnew.InteractiveSelection.UnselectItems", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::selectionMenu( "pcbnew.InteractiveSelection.SelectionMenu", - AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::selectConnection( "pcbnew.InteractiveSelection.SelectConnection", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SEL_TRIVIAL_CONNECTION ), + AS_GLOBAL, + 'U', LEGACY_HK_NAME( "Select Single Track" ), _( "Single Track" ), _( "Selects all track segments & vias between two junctions." ), add_tracks_xpm ); TOOL_ACTION PCB_ACTIONS::selectCopper( "pcbnew.InteractiveSelection.SelectCopper", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SEL_COPPER_CONNECTION ), + AS_GLOBAL, + 'I', LEGACY_HK_NAME( "Select Connected Tracks" ), _( "Connected Tracks" ), _( "Selects all connected tracks & vias." ), net_highlight_xpm ); TOOL_ACTION PCB_ACTIONS::expandSelectedConnection( "pcbnew.InteractiveSelection.ExpandConnection", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Expand Selected Connection" ), _( "Expands the current selection to select a connection between two junctions." ) ); TOOL_ACTION PCB_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "All Tracks in Net" ), _( "Selects all tracks & vias belonging to the same net." ), mode_track_xpm ); TOOL_ACTION PCB_ACTIONS::selectOnSheetFromEeschema( "pcbnew.InteractiveSelection.SelectOnSheet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Sheet" ), _( "Selects all modules and tracks in the schematic sheet" ), select_same_sheet_xpm ); TOOL_ACTION PCB_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Items in Same Hierarchical Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ), select_same_sheet_xpm ); TOOL_ACTION PCB_ACTIONS::findMove( "pcbnew.InteractiveSelection.FindMove", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GET_AND_MOVE_FOOTPRINT ), + AS_GLOBAL, + 'T', LEGACY_HK_NAME( "Get and Move Footprint" ), _( "Get and Move Footprint" ), _( "Selects a footprint by reference and places it under the cursor for moving"), move_xpm ); TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSelection", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Filter Selection..." ), _( "Filter the types of items in the selection" ), options_generic_xpm ); diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index 9d9d39fb9c..acc3955cf9 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -34,8 +34,6 @@ #include <widgets/progress_reporter.h> #include <tool/tool_manager.h> #include <bitmaps.h> -#include <hotkeys.h> - #include "pcb_actions.h" #include "selection_tool.h" #include "zone_filler_tool.h" @@ -43,25 +41,28 @@ // Zone actions TOOL_ACTION PCB_ACTIONS::zoneFill( "pcbnew.ZoneFiller.zoneFill", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Fill" ), _( "Fill zone(s)" ), fill_zone_xpm ); TOOL_ACTION PCB_ACTIONS::zoneFillAll( "pcbnew.ZoneFiller.zoneFillAll", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_FILL_OR_REFILL ), + AS_GLOBAL, + 'B', LEGACY_HK_NAME( "Fill or Refill All Zones" ), _( "Fill All" ), _( "Fill all zones" ), fill_zone_xpm ); TOOL_ACTION PCB_ACTIONS::zoneUnfill( "pcbnew.ZoneFiller.zoneUnfill", - AS_GLOBAL, 0, + AS_GLOBAL, 0, "", _( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm ); TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.ZoneFiller.zoneUnfillAll", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_REMOVE_FILLED ), + AS_GLOBAL, + MD_CTRL + 'B', LEGACY_HK_NAME( "Remove Filled Areas in All Zones" ), _( "Unfill All" ), _( "Unfill all zones" ), zone_unfill_xpm ); + ZONE_FILLER_TOOL::ZONE_FILLER_TOOL() : PCB_TOOL_BASE( "pcbnew.ZoneFiller" ) { diff --git a/qa/common/CMakeLists.txt b/qa/common/CMakeLists.txt index 68bda9fe12..71dd152a12 100644 --- a/qa/common/CMakeLists.txt +++ b/qa/common/CMakeLists.txt @@ -44,7 +44,6 @@ set( common_srcs test_color4d.cpp test_coroutine.cpp test_format_units.cpp - test_hotkey_store.cpp test_lib_table.cpp test_kicad_string.cpp test_refdes_utils.cpp diff --git a/qa/common/test_hotkey_store.cpp b/qa/common/test_hotkey_store.cpp deleted file mode 100644 index 34c9878b7f..0000000000 --- a/qa/common/test_hotkey_store.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2018 KiCad Developers, see CHANGELOG.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 2 - * 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 here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <boost/test/unit_test.hpp> -#include <boost/test/test_case_template.hpp> - -#include <hotkey_store.h> - -// ---------------------------------------------------------------------------- -// Dummy Hotkey definitions - -static EDA_HOTKEY actionA1( _HKI("A1"), 1001, WXK_F1 ); -static EDA_HOTKEY actionA2( _HKI("A2"), 1002, WXK_F2 ); - -static wxString sectionATag( "[a]" ); -static wxString sectionATitle( "Section A" ); - -static EDA_HOTKEY actionB1( _HKI("B1"), 2001, WXK_F10 ); -static EDA_HOTKEY actionB2( _HKI("B2"), 2002, WXK_F11 ); - -static wxString sectionBTag( "[b]" ); -static wxString sectionBTitle( "Section B" ); - -// A keycode that is unused by any hotkey -static const int unused_keycode = WXK_F5; - -// List of hotkey descriptors for library editor -static EDA_HOTKEY* sectionAHotkeyList[] = -{ - &actionA1, - &actionA2, - NULL -}; - -static EDA_HOTKEY* sectionBHotkeyList[] = -{ - &actionB1, - &actionB2, - NULL -}; - -static EDA_HOTKEY_CONFIG test_hotkeys_descr[] = -{ - { §ionATag, sectionAHotkeyList, §ionATitle }, - { §ionBTag, sectionBHotkeyList, §ionBTitle }, - { NULL, NULL, NULL } -}; - -// Number of sections in the above table -static const unsigned num_cfg_sections = - sizeof( test_hotkeys_descr ) / sizeof( EDA_HOTKEY_CONFIG ) - 1; - -// ---------------------------------------------------------------------------- - -struct HotkeyStoreFixture -{ - HotkeyStoreFixture(): - m_hotkey_store( test_hotkeys_descr ) - {} - - HOTKEY_STORE m_hotkey_store; -}; - - -/** - * Declares a struct as the Boost test fixture. - */ -BOOST_FIXTURE_TEST_SUITE( HotkeyStore, HotkeyStoreFixture ) - - -/** - * Check conflict detections - */ -BOOST_AUTO_TEST_CASE( StoreConstruction ) -{ - // Should have ingested two sections (A and B) - BOOST_CHECK_EQUAL( m_hotkey_store.GetSections().size(), num_cfg_sections ); -} - - -/** - * Check conflict detections - */ -BOOST_AUTO_TEST_CASE( HotkeyConflict ) -{ - EDA_HOTKEY* conf_key = nullptr; - EDA_HOTKEY_CONFIG* conf_sect = nullptr; - bool conflict; - - conflict = m_hotkey_store.CheckKeyConflicts( unused_keycode, sectionATag, - &conf_key, &conf_sect ); - - // No conflicts - BOOST_CHECK_EQUAL( conflict, true ); - - conflict = m_hotkey_store.CheckKeyConflicts( actionA1.m_KeyCode, sectionATag, - &conf_key, &conf_sect ); - - // See if we conflicted with the correct key in the correct section - BOOST_CHECK_EQUAL( conflict, false ); - BOOST_CHECK_EQUAL( conf_key->m_Idcommand, actionA1.m_Idcommand ); - BOOST_CHECK_EQUAL( conf_sect, &test_hotkeys_descr[0] ); -} - - -/** - * Check the undo works - */ -BOOST_AUTO_TEST_CASE( HotkeySetUndo ) -{ - CHANGED_HOTKEY* hk = m_hotkey_store.FindHotkey( sectionATag, actionA1.m_Idcommand ); - - // Found something - BOOST_CHECK( hk ); - BOOST_CHECK_EQUAL( hk->GetCurrentValue().m_Idcommand, actionA1.m_Idcommand ); - - // Change the Key code - hk->GetCurrentValue().m_KeyCode = unused_keycode; - - // Change everything back - m_hotkey_store.ResetAllHotkeysToDefault(); - - // Check it went back - BOOST_CHECK_EQUAL( hk->GetCurrentValue().m_Idcommand, actionA1.m_Idcommand ); -} - - -BOOST_AUTO_TEST_SUITE_END() diff --git a/qa/gal/gal_pixel_alignment/CMakeLists.txt b/qa/gal/gal_pixel_alignment/CMakeLists.txt index f680e93939..db80d10fdb 100644 --- a/qa/gal/gal_pixel_alignment/CMakeLists.txt +++ b/qa/gal/gal_pixel_alignment/CMakeLists.txt @@ -25,7 +25,7 @@ find_package(Boost COMPONENTS unit_test_framework REQUIRED) find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED ) -add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DUSE_TOOL_MANAGER) +add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DUSE_TOOL_MANAGER -DQA_TEST) if( BUILD_GITHUB_PLUGIN ) set( GITHUB_PLUGIN_LIBRARIES github_plugin ) diff --git a/qa/pcb_test_window/CMakeLists.txt b/qa/pcb_test_window/CMakeLists.txt index 15e8abeb73..fecdb6f960 100644 --- a/qa/pcb_test_window/CMakeLists.txt +++ b/qa/pcb_test_window/CMakeLists.txt @@ -39,7 +39,7 @@ add_executable(test_window WIN32 ../qa_utils/mocks.cpp ../../common/base_units.cpp ../../pcbnew/tools/pcb_tool_base.cpp - ../../pcbnew/tools/selection.cpp + ../../pcbnew/tools/pcbnew_selection.cpp ../../pcbnew/tools/selection_tool.cpp ../../pcbnew/tools/tool_event_utils.cpp #../../pcbnew/tools/outline_editor.cpp diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 17667fa605..b34f45a36d 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -39,7 +39,6 @@ #include <wx/dir.h> #include <gestfich.h> #include <pcbnew.h> -#include <hotkeys.h> #include <wildcards_and_files_ext.h> #include <class_board.h> #include <fp_lib_table.h> @@ -229,25 +228,23 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() return nullptr; } -TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( - "pcbnew.Control.hideLocalRatsnest", AS_GLOBAL, 0, "", "" ); +TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( "pcbnew.Control.hideLocalRatsnest", + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ), + AS_GLOBAL, 'F', "", _( "Flip" ), _( "Flips selected item(s)" ), nullptr ); TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ), + AS_GLOBAL, 'E', "", _( "Properties..." ), _( "Displays item properties dialog" ), nullptr ); TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); TOOL_ACTION PCB_ACTIONS::clearHighlight( "pcbnew.EditorControl.clearHighlight", - AS_GLOBAL, 0, - "", "" ); + AS_GLOBAL ); DIALOG_BLOCK_OPTIONS_BASE::DIALOG_BLOCK_OPTIONS_BASE( wxWindow* parent, @@ -281,12 +278,12 @@ DIALOG_BLOCK_OPTIONS_BASE::~DIALOG_BLOCK_OPTIONS_BASE() TOOL_ACTION PCB_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw", - AS_GLOBAL, MD_SHIFT + 'R', + AS_GLOBAL, MD_SHIFT + 'R', "", _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ), nullptr, AF_NONE, (void*) -1 ); TOOL_ACTION PCB_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM ), + AS_GLOBAL, 'R', "", _( "Rotate Counterclockwise" ), _( "Rotates selected item(s) counterclockwise" ), nullptr, AF_NONE, (void*) 1 );