Add mouse gestures to List Hotkeys.
Fixes: lp:1778437 * https://bugs.launchpad.net/kicad/+bug/1778437
This commit is contained in:
parent
4043a15482
commit
158e05adea
|
@ -24,9 +24,28 @@
|
||||||
#include <hotkey_store.h>
|
#include <hotkey_store.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/action_manager.h>
|
#include <tool/action_manager.h>
|
||||||
|
#include <tool/tool_event.h>
|
||||||
#include <tool/tool_action.h>
|
#include <tool/tool_action.h>
|
||||||
|
|
||||||
|
|
||||||
|
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 HOTKEY_STORE::GetAppName( TOOL_ACTION* aAction )
|
||||||
{
|
{
|
||||||
wxString name( aAction->GetName() );
|
wxString name( aAction->GetName() );
|
||||||
|
@ -50,7 +69,7 @@ wxString HOTKEY_STORE::GetSectionName( TOOL_ACTION* aAction )
|
||||||
if( s_AppNames.count( appName ) )
|
if( s_AppNames.count( appName ) )
|
||||||
return s_AppNames[ appName ];
|
return s_AppNames[ appName ];
|
||||||
else
|
else
|
||||||
return wxT( "XXX" + appName );
|
return appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +100,6 @@ void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList )
|
||||||
|
|
||||||
wxString currentApp;
|
wxString currentApp;
|
||||||
HOTKEY_SECTION* currentSection = nullptr;
|
HOTKEY_SECTION* currentSection = nullptr;
|
||||||
HOTKEY* currentHotKey = nullptr;
|
|
||||||
|
|
||||||
for( const auto& entry : masterMap )
|
for( const auto& entry : masterMap )
|
||||||
{
|
{
|
||||||
|
@ -95,11 +113,15 @@ void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList )
|
||||||
currentSection->m_SectionName = GetSectionName( entry.second );
|
currentSection->m_SectionName = GetSectionName( entry.second );
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSection->m_HotKeys.emplace_back( HOTKEY() );
|
currentSection->m_HotKeys.emplace_back( HOTKEY( entry.second ) );
|
||||||
currentHotKey = ¤tSection->m_HotKeys.back();
|
|
||||||
currentHotKey->m_Parent = entry.second;
|
|
||||||
currentHotKey->m_EditKeycode = entry.second->GetHotKey();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,11 @@ static struct hotkey_name_descr hotkeyNameList[] =
|
||||||
|
|
||||||
{ wxT( "<unassigned>" ), 0 },
|
{ wxT( "<unassigned>" ), 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
|
// Do not change this line: end of list
|
||||||
{ wxT( "" ), KEY_NON_FOUND }
|
{ wxT( "" ), KEY_NON_FOUND }
|
||||||
};
|
};
|
||||||
|
|
|
@ -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()
|
TOOL_ACTION::~TOOL_ACTION()
|
||||||
{
|
{
|
||||||
ACTION_MANAGER::GetActionList().remove( this );
|
ACTION_MANAGER::GetActionList().remove( this );
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define HOTKEY_STORE__H
|
#define HOTKEY_STORE__H
|
||||||
|
|
||||||
#include <hotkeys_basic.h>
|
#include <hotkeys_basic.h>
|
||||||
|
#include <tool/tool_action.h>
|
||||||
|
|
||||||
class TOOL_MANAGER;
|
class TOOL_MANAGER;
|
||||||
|
|
||||||
|
@ -33,6 +34,11 @@ struct HOTKEY
|
||||||
{
|
{
|
||||||
TOOL_ACTION* m_Parent;
|
TOOL_ACTION* m_Parent;
|
||||||
int m_EditKeycode;
|
int m_EditKeycode;
|
||||||
|
|
||||||
|
HOTKEY( TOOL_ACTION* aParent ) :
|
||||||
|
m_Parent( aParent ),
|
||||||
|
m_EditKeycode( aParent->GetHotKey() )
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,14 @@ class TOOL_MANAGER;
|
||||||
class EDA_BASE_FRAME;
|
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
|
* Function KeyCodeFromKeyName
|
||||||
* return the key code from its user-friendly key name (ie: "Ctrl+M")
|
* return the key code from its user-friendly key name (ie: "Ctrl+M")
|
||||||
|
|
|
@ -150,7 +150,9 @@ public:
|
||||||
return m_icon;
|
return m_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
TOOL_ACTION();
|
||||||
|
|
||||||
friend class ACTION_MANAGER;
|
friend class ACTION_MANAGER;
|
||||||
|
|
||||||
/// Name of the action (convention is "app.tool.actionName")
|
/// Name of the action (convention is "app.tool.actionName")
|
||||||
|
@ -161,7 +163,7 @@ private:
|
||||||
int m_hotKey; // The curret hotkey (post-user-settings-application)
|
int m_hotKey; // The curret hotkey (post-user-settings-application)
|
||||||
const std::string m_legacyName; // Name for reading legacy hotkey settings
|
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_menuItem; // Label + hotkey text for menus
|
||||||
wxString m_tooltip;
|
wxString m_tooltip;
|
||||||
const BITMAP_OPAQUE* m_icon; // Icon for the menu entry
|
const BITMAP_OPAQUE* m_icon; // Icon for the menu entry
|
||||||
|
|
Loading…
Reference in New Issue