mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 17:39:17 +00:00
Hot keys settings are synchronized between GAL & legacy
This commit is contained in:
parent
99e5228948
commit
da75c52665
common
cvpcb
eeschema
gerbview
include
pagelayout_editor
pcbnew
@ -350,6 +350,15 @@ bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
return false;
|
||||
}
|
||||
|
||||
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName )
|
||||
{
|
||||
int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
GetToolManager()->UpdateHotKeys();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
|
||||
{
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <macros.h>
|
||||
#include <dialog_hotkeys_editor.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <wx/apptrait.h>
|
||||
#include <wx/stdpaths.h>
|
||||
@ -482,6 +483,20 @@ EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList )
|
||||
}
|
||||
|
||||
|
||||
EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList )
|
||||
{
|
||||
for( ; *aList != NULL; aList++ )
|
||||
{
|
||||
EDA_HOTKEY* hk_decr = *aList;
|
||||
|
||||
if( hk_decr->m_Idcommand == aCommand )
|
||||
return hk_decr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
|
||||
wxString* aFullFileName )
|
||||
{
|
||||
|
@ -24,9 +24,12 @@
|
||||
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_action.h>
|
||||
#include <draw_frame.h>
|
||||
|
||||
#include <hotkeys_basic.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <cassert>
|
||||
|
||||
ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
|
||||
@ -61,18 +64,6 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
||||
|
||||
m_actionNameIndex[aAction->m_name] = aAction;
|
||||
m_actionIdIndex[aAction->m_id] = aAction;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Check if there are two global actions assigned to the same hotkey
|
||||
if( aAction->GetScope() == AS_GLOBAL )
|
||||
{
|
||||
BOOST_FOREACH( const TOOL_ACTION* action, m_actionHotKeys[aAction->m_currentHotKey] )
|
||||
assert( action->GetScope() != AS_GLOBAL );
|
||||
}
|
||||
#endif /* not NDEBUG */
|
||||
|
||||
if( aAction->HasHotKey() )
|
||||
m_actionHotKeys[aAction->m_currentHotKey].push_back( aAction );
|
||||
}
|
||||
|
||||
|
||||
@ -181,3 +172,86 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ACTION_MANAGER::UpdateHotKeys()
|
||||
{
|
||||
m_actionHotKeys.clear();
|
||||
std::list<TOOL_ACTION*>& actions = GetActionList();
|
||||
|
||||
for( std::list<TOOL_ACTION*>::iterator it = actions.begin(); it != actions.end(); ++it )
|
||||
{
|
||||
TOOL_ACTION* aAction = *it;
|
||||
|
||||
int hotkey = processHotKey( aAction, true );
|
||||
|
||||
if( hotkey > 0 )
|
||||
m_actionHotKeys[hotkey].push_back( aAction );
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Check if there are two global actions assigned to the same hotkey
|
||||
BOOST_FOREACH( std::list<TOOL_ACTION*>& action_list, m_actionHotKeys | boost::adaptors::map_values )
|
||||
{
|
||||
int global_actions_cnt = 0;
|
||||
|
||||
BOOST_FOREACH( TOOL_ACTION* action, action_list )
|
||||
{
|
||||
if( action->GetScope() == AS_GLOBAL )
|
||||
++global_actions_cnt;
|
||||
}
|
||||
|
||||
assert( global_actions_cnt <= 1 );
|
||||
}
|
||||
#endif /* not NDEBUG */
|
||||
}
|
||||
|
||||
|
||||
int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction, bool aForceUpdate )
|
||||
{
|
||||
int hotkey = 0;
|
||||
|
||||
if( aForceUpdate )
|
||||
hotkey = aAction->getDefaultHotKey();
|
||||
else
|
||||
hotkey = aAction->GetHotKey();
|
||||
|
||||
if( ( hotkey & TOOL_ACTION::LEGACY_HK ) )
|
||||
{
|
||||
hotkey = hotkey & ~TOOL_ACTION::LEGACY_HK; // it leaves only HK_xxx identifier
|
||||
EDA_DRAW_FRAME* frame = static_cast<EDA_DRAW_FRAME*>( m_toolMgr->GetEditFrame() );
|
||||
EDA_HOTKEY* 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;
|
||||
}
|
||||
|
||||
aAction->setHotKey( hotkey );
|
||||
}
|
||||
|
||||
return hotkey;
|
||||
}
|
||||
|
@ -114,33 +114,15 @@ wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPA
|
||||
wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
|
||||
{
|
||||
/// ID numbers for tool actions need to have a value higher than ACTION_ID
|
||||
int id = ACTION_ID + aAction.GetId();
|
||||
const BITMAP_OPAQUE* icon = aAction.GetIcon();
|
||||
|
||||
wxMenuItem* item = new wxMenuItem( this, id, aAction.GetMenuItem(),
|
||||
wxMenuItem* item = new wxMenuItem( this, getMenuId( aAction ), aAction.GetMenuItem(),
|
||||
aAction.GetDescription(), wxITEM_NORMAL );
|
||||
|
||||
if( icon )
|
||||
item->SetBitmap( KiBitmap( icon ) );
|
||||
|
||||
if( aAction.HasHotKey() )
|
||||
{
|
||||
int key = aAction.GetHotKey() & ~MD_MODIFIER_MASK;
|
||||
int mod = aAction.GetHotKey() & MD_MODIFIER_MASK;
|
||||
int flags = wxACCEL_NORMAL;
|
||||
|
||||
switch( mod )
|
||||
{
|
||||
case MD_ALT: flags = wxACCEL_ALT; break;
|
||||
case MD_CTRL: flags = wxACCEL_CTRL; break;
|
||||
case MD_SHIFT: flags = wxACCEL_SHIFT; break;
|
||||
}
|
||||
|
||||
wxAcceleratorEntry accel( flags, key, id, item );
|
||||
item->SetAccel( &accel );
|
||||
}
|
||||
|
||||
m_toolActions[id] = &aAction;
|
||||
m_toolActions[getMenuId( aAction )] = &aAction;
|
||||
|
||||
return Append( item );
|
||||
}
|
||||
@ -198,11 +180,44 @@ void CONTEXT_MENU::Clear()
|
||||
void CONTEXT_MENU::UpdateAll()
|
||||
{
|
||||
m_update_handler();
|
||||
updateHotKeys();
|
||||
|
||||
runOnSubmenus( boost::bind( &CONTEXT_MENU::UpdateAll, _1 ) );
|
||||
}
|
||||
|
||||
|
||||
void CONTEXT_MENU::updateHotKeys()
|
||||
{
|
||||
for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin();
|
||||
it != m_toolActions.end(); ++it )
|
||||
{
|
||||
int id = it->first;
|
||||
const TOOL_ACTION& action = *it->second;
|
||||
|
||||
if( action.HasHotKey() )
|
||||
{
|
||||
int key = action.GetHotKey() & ~MD_MODIFIER_MASK;
|
||||
int mod = action.GetHotKey() & MD_MODIFIER_MASK;
|
||||
int flags = wxACCEL_NORMAL;
|
||||
wxMenuItem* item = FindChildItem( id );
|
||||
|
||||
if( item )
|
||||
{
|
||||
switch( mod )
|
||||
{
|
||||
case MD_ALT: flags = wxACCEL_ALT; break;
|
||||
case MD_CTRL: flags = wxACCEL_CTRL; break;
|
||||
case MD_SHIFT: flags = wxACCEL_SHIFT; break;
|
||||
}
|
||||
|
||||
wxAcceleratorEntry accel( flags, key, id, item );
|
||||
item->SetAccel( &accel );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||
{
|
||||
OPT_TOOL_EVENT evt;
|
||||
|
@ -332,6 +332,12 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
|
||||
}
|
||||
|
||||
|
||||
void TOOL_MANAGER::UpdateHotKeys()
|
||||
{
|
||||
m_actionMgr->UpdateHotKeys();
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
|
||||
{
|
||||
wxASSERT( aTool != NULL );
|
||||
@ -723,6 +729,7 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
|
||||
m_view = aView;
|
||||
m_viewControls = aViewControls;
|
||||
m_editFrame = aFrame;
|
||||
m_actionMgr->UpdateHotKeys();
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,6 +96,9 @@ public:
|
||||
void InstallOptionsDisplay( wxCommandEvent& event );
|
||||
MODULE* Get_Module( const wxString& CmpName );
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const { return NULL; }
|
||||
|
||||
void Process_Settings( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
|
@ -353,6 +353,18 @@ struct EDA_HOTKEY_CONFIG g_Viewlib_Hokeys_Descr[] =
|
||||
{ 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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hot keys. Some commands are relative to the item under the mouse cursor
|
||||
* Commands are case insensitive
|
||||
@ -581,6 +593,17 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
|
||||
{
|
||||
if( aHotKey == 0 )
|
||||
@ -749,6 +772,18 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
EDA_ITEM* aItem )
|
||||
{
|
||||
|
@ -337,6 +337,9 @@ public:
|
||||
double BestZoom(); // Returns the best zoom
|
||||
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
|
||||
|
||||
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
||||
|
@ -357,6 +357,10 @@ public:
|
||||
void ReCreateVToolbar();
|
||||
void ReCreateOptToolbar();
|
||||
void ReCreateMenuBar();
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
|
||||
|
||||
/**
|
||||
|
@ -96,6 +96,9 @@ public:
|
||||
|
||||
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
/**
|
||||
* Function OnHotKey
|
||||
* handle hot key events.
|
||||
|
@ -515,6 +515,9 @@ public:
|
||||
*/
|
||||
void OnQuit( wxCommandEvent& event );
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
/**
|
||||
* Function OnHotKey.
|
||||
* ** Commands are case insensitive **
|
||||
|
@ -102,6 +102,14 @@ struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[] =
|
||||
};
|
||||
|
||||
|
||||
EDA_HOTKEY* GERBVIEW_FRAME::GetHotKeyDescription( int aCommand ) const
|
||||
{
|
||||
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, gerbviewHotkeyList );
|
||||
|
||||
return HK_Descr;
|
||||
}
|
||||
|
||||
|
||||
bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem )
|
||||
{
|
||||
#define CHANGE( x ) ( x ) = not (x )
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <kiway_player.h>
|
||||
|
||||
class wxSingleInstanceChecker;
|
||||
|
||||
class EDA_HOTKEY;
|
||||
|
||||
/**
|
||||
* Class EDA_DRAW_FRAME
|
||||
@ -324,6 +324,18 @@ public:
|
||||
*/
|
||||
void SkipNextLeftButtonReleaseEvent();
|
||||
|
||||
///> @copydoc EDA_BASE_FRAME::WriteHotkeyConfig
|
||||
int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
|
||||
|
||||
/**
|
||||
* Function GetHotKeyDescription
|
||||
* Searches 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;
|
||||
|
||||
virtual bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
EDA_ITEM* aItem = NULL );
|
||||
|
||||
|
@ -196,12 +196,21 @@ void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aList
|
||||
|
||||
/**
|
||||
* Function GetDescriptorFromHotkey
|
||||
* Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function
|
||||
* 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
|
||||
*/
|
||||
EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList );
|
||||
EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList );
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -91,6 +91,13 @@ public:
|
||||
bool RunHotKey( int aHotKey ) const;
|
||||
|
||||
/**
|
||||
* Function UpdateHotKeys()
|
||||
* Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot Key Editor settings.
|
||||
*/
|
||||
void UpdateHotKeys();
|
||||
|
||||
/**
|
||||
* Function GetActionList()
|
||||
* Returns list of TOOL_ACTIONs. TOOL_ACTIONs add themselves to the list upon their
|
||||
* creation.
|
||||
* @return List of TOOL_ACTIONs.
|
||||
@ -104,6 +111,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
///> Resolves a reference to legacy hot key settings to a particular hot key.
|
||||
///> @param aAction is the action to be resolved.
|
||||
///> @param aForceUpdate determines whether it should be resolved only when the current hot key
|
||||
///> setting contains a reference to legacy settings, or update the hot key basing on the
|
||||
///> originally assigned reference.
|
||||
int processHotKey( TOOL_ACTION* aAction, bool aForceUpdate = false );
|
||||
|
||||
///> Tool manager needed to run actions
|
||||
TOOL_MANAGER* m_toolMgr;
|
||||
|
||||
|
@ -173,6 +173,9 @@ private:
|
||||
*/
|
||||
void setTool( TOOL_INTERACTIVE* aTool );
|
||||
|
||||
///> Updates hot key settings for TOOL_ACTIONs in this menu.
|
||||
void updateHotKeys();
|
||||
|
||||
///> Traverses the submenus tree looking for a submenu capable of handling a particular menu
|
||||
///> event. In case it is handled, it is returned the aToolEvent parameter.
|
||||
void runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent );
|
||||
@ -180,6 +183,12 @@ private:
|
||||
///> Runs a function on the menu and all its submenus.
|
||||
void runOnSubmenus( boost::function<void(CONTEXT_MENU*)> aFunction );
|
||||
|
||||
///> Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object.
|
||||
static inline int getMenuId( const TOOL_ACTION& aAction )
|
||||
{
|
||||
return aAction.GetId() + ACTION_ID;
|
||||
}
|
||||
|
||||
///> Flag indicating that the menu title was set up.
|
||||
bool m_titleSet;
|
||||
|
||||
|
@ -96,30 +96,6 @@ public:
|
||||
return m_currentHotKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ChangeHotKey()
|
||||
* Assigns a new hot key.
|
||||
*
|
||||
* @param aNewHotKey is the new hot key.
|
||||
*/
|
||||
void ChangeHotKey( int aNewHotKey )
|
||||
{
|
||||
assert( false );
|
||||
// hotkey has to be changed in the ACTION_MANAGER, or change the implementation
|
||||
m_currentHotKey = aNewHotKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function RestoreHotKey()
|
||||
* Changes the assigned hot key to the default one.
|
||||
*/
|
||||
void RestoreHotKey()
|
||||
{
|
||||
assert( false );
|
||||
// hotkey has to be changed in the ACTION_MANAGER, or change the implementation
|
||||
m_currentHotKey = m_defaultHotKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function HasHotKey()
|
||||
* Checks if the action has a hot key assigned.
|
||||
@ -128,7 +104,7 @@ public:
|
||||
*/
|
||||
bool HasHotKey() const
|
||||
{
|
||||
return m_currentHotKey > 0;
|
||||
return m_currentHotKey != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,9 +180,35 @@ 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;
|
||||
}
|
||||
|
||||
/// Changes the assigned hot key.
|
||||
void setHotKey( int aHotKey )
|
||||
{
|
||||
// it is not the right moment to use legacy hot key, it should be given in the object definition
|
||||
assert( ( aHotKey & LEGACY_HK ) == 0 );
|
||||
|
||||
m_currentHotKey = aHotKey;
|
||||
}
|
||||
|
||||
/// Name of the action (convention is: app.[tool.]action.name)
|
||||
std::string m_name;
|
||||
|
||||
@ -236,6 +238,10 @@ private:
|
||||
|
||||
/// 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
|
||||
|
@ -146,6 +146,9 @@ public:
|
||||
RunAction( aAction, aNow, (void*) NULL );
|
||||
}
|
||||
|
||||
///> @copydoc ACTION_MANAGER::UpdateHotKeys()
|
||||
void UpdateHotKeys();
|
||||
|
||||
/**
|
||||
* Function FindTool()
|
||||
* Searches for a tool with given ID.
|
||||
|
@ -431,6 +431,9 @@ public:
|
||||
m_useCmpFileForFpNames = aUseCmpfile;
|
||||
}
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
/**
|
||||
* Function OnHotKey.
|
||||
* ** Commands are case insensitive **
|
||||
|
@ -285,7 +285,7 @@ public:
|
||||
* the output format is: shortcut "key" "function"
|
||||
* lines starting with # are comments
|
||||
*/
|
||||
int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL);
|
||||
virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
|
||||
|
||||
/**
|
||||
* Function ReadHotkeyConfigFile
|
||||
|
@ -126,6 +126,17 @@ struct EDA_HOTKEY_CONFIG PlEditorHokeysDescr[] =
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
|
||||
const wxPoint& aPosition, EDA_ITEM* aItem )
|
||||
{
|
||||
|
@ -236,6 +236,9 @@ public:
|
||||
*/
|
||||
void OnQuit( wxCommandEvent& event );
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;
|
||||
|
||||
/**
|
||||
* Function OnHotKey.
|
||||
* ** Commands are case insensitive **
|
||||
|
@ -139,6 +139,8 @@ private:
|
||||
void LoadSettings( wxConfigBase* aCfg ); // override virtual
|
||||
void SaveSettings( wxConfigBase* aCfg ); // override virtual
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||
EDA_HOTKEY* GetHotKeyDescription( int ) const { return NULL; }
|
||||
|
||||
/**
|
||||
* Function OnActivate
|
||||
|
@ -371,6 +371,17 @@ struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hokeys_Descr[] = {
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_VIEWER_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
EDA_ITEM* aItem )
|
||||
{
|
||||
|
@ -107,6 +107,17 @@ void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumbe
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
|
||||
EDA_ITEM* aItem )
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user