Unroll ACTIONS::CURSOR_EVENT_TYPE into a flat enum.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15666
This commit is contained in:
parent
d02ca968d1
commit
93a5d01230
|
@ -518,7 +518,7 @@ TOOL_ACTION ACTIONS::cursorUpFast( TOOL_ACTION_ARGS()
|
|||
.DefaultHotkey( MD_CTRL + WXK_UP )
|
||||
.MenuText( _( "Cursor Up Fast" ) )
|
||||
.Flags( AF_NONE )
|
||||
.Parameter( CURSOR_UP | CURSOR_FAST_MOVE ) );
|
||||
.Parameter( CURSOR_UP_FAST ) );
|
||||
|
||||
TOOL_ACTION ACTIONS::cursorDownFast( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.cursorDownFast" )
|
||||
|
@ -526,7 +526,7 @@ TOOL_ACTION ACTIONS::cursorDownFast( TOOL_ACTION_ARGS()
|
|||
.DefaultHotkey( MD_CTRL + WXK_DOWN )
|
||||
.MenuText( _( "Cursor Down Fast" ) )
|
||||
.Flags( AF_NONE )
|
||||
.Parameter( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
|
||||
.Parameter( CURSOR_DOWN_FAST ) );
|
||||
|
||||
TOOL_ACTION ACTIONS::cursorLeftFast( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.cursorLeftFast" )
|
||||
|
@ -534,7 +534,7 @@ TOOL_ACTION ACTIONS::cursorLeftFast( TOOL_ACTION_ARGS()
|
|||
.DefaultHotkey( MD_CTRL + WXK_LEFT )
|
||||
.MenuText( _( "Cursor Left Fast" ) )
|
||||
.Flags( AF_NONE )
|
||||
.Parameter( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
|
||||
.Parameter( CURSOR_LEFT_FAST ) );
|
||||
|
||||
TOOL_ACTION ACTIONS::cursorRightFast( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.cursorRightFast" )
|
||||
|
@ -542,7 +542,7 @@ TOOL_ACTION ACTIONS::cursorRightFast( TOOL_ACTION_ARGS()
|
|||
.DefaultHotkey( MD_CTRL + WXK_RIGHT )
|
||||
.MenuText( _( "Cursor Right Fast" ) )
|
||||
.Flags( AF_NONE )
|
||||
.Parameter( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
|
||||
.Parameter( CURSOR_RIGHT_FAST ) );
|
||||
|
||||
TOOL_ACTION ACTIONS::cursorClick( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.cursorClick" )
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
COMMON_TOOLS::COMMON_TOOLS() :
|
||||
|
@ -100,32 +101,38 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent )
|
|||
// Cursor control
|
||||
int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
long type = static_cast<long>( aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>() );
|
||||
|
||||
bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
|
||||
type &= ~ACTIONS::CURSOR_FAST_MOVE;
|
||||
bool mirroredX = getView()->IsMirroredX();
|
||||
ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>();
|
||||
|
||||
bool mirroredX = getView()->IsMirroredX();
|
||||
VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
|
||||
VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
|
||||
|
||||
if( fastMove )
|
||||
gridSize = gridSize * 10;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case ACTIONS::CURSOR_UP_FAST:
|
||||
gridSize *= 10;
|
||||
KI_FALLTHROUGH;
|
||||
case ACTIONS::CURSOR_UP:
|
||||
cursor -= VECTOR2D( 0, gridSize.y );
|
||||
break;
|
||||
|
||||
case ACTIONS::CURSOR_DOWN_FAST:
|
||||
gridSize *= 10;
|
||||
KI_FALLTHROUGH;
|
||||
case ACTIONS::CURSOR_DOWN:
|
||||
cursor += VECTOR2D( 0, gridSize.y );
|
||||
break;
|
||||
|
||||
case ACTIONS::CURSOR_LEFT_FAST:
|
||||
gridSize *= 10;
|
||||
KI_FALLTHROUGH;
|
||||
case ACTIONS::CURSOR_LEFT:
|
||||
cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
|
||||
break;
|
||||
|
||||
case ACTIONS::CURSOR_RIGHT_FAST:
|
||||
gridSize *= 10;
|
||||
KI_FALLTHROUGH;
|
||||
case ACTIONS::CURSOR_RIGHT:
|
||||
cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
|
||||
break;
|
||||
|
@ -134,9 +141,9 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
|||
case ACTIONS::CURSOR_DBL_CLICK:
|
||||
case ACTIONS::CURSOR_RIGHT_CLICK:
|
||||
{
|
||||
TOOL_ACTIONS action = TA_MOUSE_CLICK;
|
||||
TOOL_ACTIONS action = TA_MOUSE_CLICK;
|
||||
TOOL_MOUSE_BUTTONS button = BUT_LEFT;
|
||||
int modifiers = 0;
|
||||
int modifiers = 0;
|
||||
|
||||
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
|
||||
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
|
||||
|
@ -144,11 +151,10 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( type == ACTIONS::CURSOR_DBL_CLICK )
|
||||
action = TA_MOUSE_DBLCLICK;
|
||||
|
||||
if( type == ACTIONS::CURSOR_RIGHT_CLICK )
|
||||
else if( type == ACTIONS::CURSOR_RIGHT_CLICK )
|
||||
button = BUT_RIGHT;
|
||||
|
||||
TOOL_EVENT evt( TC_MOUSE, action, button | modifiers );
|
||||
TOOL_EVENT evt( TC_MOUSE, action, static_cast<int>( button | modifiers ) );
|
||||
evt.SetParameter( type );
|
||||
evt.SetMousePosition( getViewControls()->GetMousePosition() );
|
||||
m_toolMgr->ProcessEvent( evt );
|
||||
|
|
|
@ -193,12 +193,29 @@ public:
|
|||
static TOOL_ACTION reportBug;
|
||||
|
||||
///< Cursor control event types
|
||||
enum CURSOR_EVENT_TYPE { CURSOR_NONE, CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT,
|
||||
CURSOR_CLICK, CURSOR_DBL_CLICK, CURSOR_RIGHT_CLICK,
|
||||
CURSOR_FAST_MOVE = 0x8000 };
|
||||
enum CURSOR_EVENT_TYPE
|
||||
{
|
||||
CURSOR_NONE = 0,
|
||||
CURSOR_UP,
|
||||
CURSOR_UP_FAST,
|
||||
CURSOR_DOWN,
|
||||
CURSOR_DOWN_FAST,
|
||||
CURSOR_LEFT,
|
||||
CURSOR_LEFT_FAST,
|
||||
CURSOR_RIGHT,
|
||||
CURSOR_RIGHT_FAST,
|
||||
CURSOR_CLICK,
|
||||
CURSOR_DBL_CLICK,
|
||||
CURSOR_RIGHT_CLICK
|
||||
};
|
||||
|
||||
///< Remove event modifier flags
|
||||
enum class REMOVE_FLAGS { NORMAL = 0x00, ALT = 0x01, CUT = 0x02 };
|
||||
enum class REMOVE_FLAGS
|
||||
{
|
||||
NORMAL = 0x00,
|
||||
ALT = 0x01,
|
||||
CUT = 0x02
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue