diff --git a/common/hotkey_store.cpp b/common/hotkey_store.cpp index eab8032f1d..9c04c4bb3b 100644 --- a/common/hotkey_store.cpp +++ b/common/hotkey_store.cpp @@ -24,9 +24,28 @@ #include #include #include +#include #include +class GESTURE_PSEUDO_ACTION : public TOOL_ACTION +{ +public: + GESTURE_PSEUDO_ACTION( const wxString& aLabel, int aHotKey ) + { + m_label = aLabel; + m_hotKey = aHotKey; + } +}; + +static GESTURE_PSEUDO_ACTION g_gesturePseudoActions[] = { + GESTURE_PSEUDO_ACTION( _( "Highlight Net" ), MD_CTRL + PSEUDO_WXK_LMB ), + GESTURE_PSEUDO_ACTION( _( "Clear Net Highlighting" ), MD_CTRL + PSEUDO_WXK_LMB ), + GESTURE_PSEUDO_ACTION( _( "Pan Left/Right" ), MD_CTRL + PSEUDO_WXK_WHEEL ), + GESTURE_PSEUDO_ACTION( _( "Pan Up/Down" ), MD_SHIFT + PSEUDO_WXK_WHEEL ), +}; + + wxString HOTKEY_STORE::GetAppName( TOOL_ACTION* aAction ) { wxString name( aAction->GetName() ); @@ -50,7 +69,7 @@ wxString HOTKEY_STORE::GetSectionName( TOOL_ACTION* aAction ) if( s_AppNames.count( appName ) ) return s_AppNames[ appName ]; else - return wxT( "XXX" + appName ); + return appName; } @@ -81,12 +100,11 @@ void HOTKEY_STORE::Init( std::vector aToolManagerList ) wxString currentApp; HOTKEY_SECTION* currentSection = nullptr; - HOTKEY* currentHotKey = nullptr; for( const auto& entry : masterMap ) { wxString thisApp = GetAppName( entry.second ); - + if( thisApp != currentApp ) { m_hk_sections.emplace_back( HOTKEY_SECTION() ); @@ -95,11 +113,15 @@ void HOTKEY_STORE::Init( std::vector aToolManagerList ) 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(); + currentSection->m_HotKeys.emplace_back( HOTKEY( entry.second ) ); } + + m_hk_sections.emplace_back( HOTKEY_SECTION() ); + currentSection = &m_hk_sections.back(); + currentSection->m_SectionName = _( "Gestures" ); + + for( TOOL_ACTION& gesture : g_gesturePseudoActions ) + currentSection->m_HotKeys.emplace_back( HOTKEY( &gesture ) ); } diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index c9f3c331b0..b1a57fa4ea 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -43,7 +43,7 @@ #include -/* +/* * class to handle the printable name and the keycode */ struct hotkey_name_descr @@ -98,6 +98,11 @@ static struct hotkey_name_descr hotkeyNameList[] = { wxT( "" ), 0 }, + { wxT( "Left Button" ), PSEUDO_WXK_LMB }, + { wxT( "Middle Button" ), PSEUDO_WXK_MMB }, + { wxT( "Right Button" ), PSEUDO_WXK_RMB }, + { wxT( "Mouse Wheel" ), PSEUDO_WXK_WHEEL }, + // Do not change this line: end of list { wxT( "" ), KEY_NON_FOUND } }; diff --git a/common/tool/tool_action.cpp b/common/tool/tool_action.cpp index e3cddcc082..fadced2751 100644 --- a/common/tool/tool_action.cpp +++ b/common/tool/tool_action.cpp @@ -48,6 +48,18 @@ TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope, } +TOOL_ACTION::TOOL_ACTION() : + m_scope( AS_GLOBAL ), + m_defaultHotKey( 0 ), + m_icon( nullptr ), + m_id( -1 ), + m_flags( AF_NONE ), + m_param( nullptr ) +{ + SetHotKey( 0 ); +} + + TOOL_ACTION::~TOOL_ACTION() { ACTION_MANAGER::GetActionList().remove( this ); diff --git a/include/hotkey_store.h b/include/hotkey_store.h index 76182fbca0..2817d56807 100644 --- a/include/hotkey_store.h +++ b/include/hotkey_store.h @@ -25,6 +25,7 @@ #define HOTKEY_STORE__H #include +#include class TOOL_MANAGER; @@ -33,6 +34,11 @@ struct HOTKEY { TOOL_ACTION* m_Parent; int m_EditKeycode; + + HOTKEY( TOOL_ACTION* aParent ) : + m_Parent( aParent ), + m_EditKeycode( aParent->GetHotKey() ) + { } }; diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index 418b2af1b2..cfbf0d7ee5 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -44,6 +44,14 @@ class TOOL_MANAGER; class EDA_BASE_FRAME; +/* + * Keep these out of the ASCII range, and out of the WXK range + */ +#define PSEUDO_WXK_LMB 400 +#define PSEUDO_WXK_MMB 401 +#define PSEUDO_WXK_RMB 402 +#define PSEUDO_WXK_WHEEL 403 + /** * Function KeyCodeFromKeyName * return the key code from its user-friendly key name (ie: "Ctrl+M") diff --git a/include/tool/tool_action.h b/include/tool/tool_action.h index 4b0d8c0c12..8d56803096 100644 --- a/include/tool/tool_action.h +++ b/include/tool/tool_action.h @@ -150,7 +150,9 @@ public: return m_icon; } -private: +protected: + TOOL_ACTION(); + friend class ACTION_MANAGER; /// Name of the action (convention is "app.tool.actionName") @@ -161,7 +163,7 @@ private: int m_hotKey; // The curret hotkey (post-user-settings-application) const std::string m_legacyName; // Name for reading legacy hotkey settings - const wxString m_label; + wxString m_label; wxString m_menuItem; // Label + hotkey text for menus wxString m_tooltip; const BITMAP_OPAQUE* m_icon; // Icon for the menu entry