Clicking with keyboard handles keyboard modifiers (GAL).
This commit is contained in:
parent
e7099036d7
commit
15e9e69ae0
|
@ -438,7 +438,6 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
|
|||
VECTOR2D cursor = getViewControls()->GetCursorPosition();
|
||||
VECTOR2I gridSize = gridHelper.GetGrid();
|
||||
VECTOR2D newCursor = gridHelper.Align( cursor );
|
||||
bool warp = true;
|
||||
|
||||
if( fastMove )
|
||||
gridSize = gridSize * 10;
|
||||
|
@ -461,75 +460,75 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
|
|||
newCursor += VECTOR2D( gridSize.x, 0 );
|
||||
break;
|
||||
|
||||
case COMMON_ACTIONS::CURSOR_CLICK:
|
||||
{
|
||||
TOOL_EVENT evtClick( TC_MOUSE, TA_MOUSE_CLICK, BUT_LEFT );
|
||||
evtClick.SetMousePosition( getViewControls()->GetCursorPosition() );
|
||||
m_toolMgr->ProcessEvent( evtClick );
|
||||
warp = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case COMMON_ACTIONS::CURSOR_CLICK: // fall through
|
||||
case COMMON_ACTIONS::CURSOR_DBL_CLICK:
|
||||
{
|
||||
TOOL_EVENT evtDblClick( TC_MOUSE, TA_MOUSE_DBLCLICK, BUT_LEFT );
|
||||
evtDblClick.SetMousePosition( getViewControls()->GetCursorPosition() );
|
||||
m_toolMgr->ProcessEvent( evtDblClick );
|
||||
warp = false;
|
||||
}
|
||||
break;
|
||||
{
|
||||
TOOL_ACTIONS action;
|
||||
int modifiers = 0;
|
||||
|
||||
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
|
||||
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
|
||||
modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
|
||||
|
||||
if( type == COMMON_ACTIONS::CURSOR_CLICK )
|
||||
action = TA_MOUSE_CLICK;
|
||||
else if( type == COMMON_ACTIONS::CURSOR_DBL_CLICK )
|
||||
action = TA_MOUSE_DBLCLICK;
|
||||
else
|
||||
assert( false );
|
||||
|
||||
TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
|
||||
evt.SetMousePosition( getViewControls()->GetCursorPosition() );
|
||||
m_toolMgr->ProcessEvent( evt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( warp )
|
||||
// Handler cursor movement
|
||||
KIGFX::VIEW* view = getView();
|
||||
newCursor = view->ToScreen( newCursor );
|
||||
|
||||
// Pan the screen if required
|
||||
const VECTOR2I& screenSize = view->GetGAL()->GetScreenPixelSize();
|
||||
BOX2I screenBox( VECTOR2I( 0, 0 ), screenSize );
|
||||
|
||||
if( !screenBox.Contains( newCursor ) )
|
||||
{
|
||||
KIGFX::VIEW* view = getView();
|
||||
VECTOR2D worldCursor = newCursor;
|
||||
newCursor = view->ToScreen( newCursor );
|
||||
VECTOR2D delta( 0, 0 );
|
||||
|
||||
// Pan the screen if required
|
||||
const VECTOR2I& screenSize = view->GetGAL()->GetScreenPixelSize();
|
||||
BOX2I screenBox( VECTOR2I( 0, 0 ), screenSize );
|
||||
|
||||
if( !screenBox.Contains( newCursor ) )
|
||||
if( newCursor.x < screenBox.GetLeft() )
|
||||
{
|
||||
VECTOR2D delta( 0, 0 );
|
||||
|
||||
if( newCursor.x < screenBox.GetLeft() )
|
||||
{
|
||||
delta.x = newCursor.x - screenBox.GetLeft();
|
||||
newCursor.x = screenBox.GetLeft();
|
||||
}
|
||||
else if( newCursor.x > screenBox.GetRight() )
|
||||
{
|
||||
delta.x = newCursor.x - screenBox.GetRight();
|
||||
// -1 is to keep the cursor within the drawing area,
|
||||
// so the cursor coordinates are updated
|
||||
newCursor.x = screenBox.GetRight() - 1;
|
||||
}
|
||||
|
||||
if( newCursor.y < screenBox.GetTop() )
|
||||
{
|
||||
delta.y = newCursor.y - screenBox.GetTop();
|
||||
newCursor.y = screenBox.GetTop();
|
||||
}
|
||||
else if( newCursor.y > screenBox.GetBottom() )
|
||||
{
|
||||
delta.y = newCursor.y - screenBox.GetBottom();
|
||||
// -1 is to keep the cursor within the drawing area,
|
||||
// so the cursor coordinates are updated
|
||||
newCursor.y = screenBox.GetBottom() - 1;
|
||||
}
|
||||
|
||||
view->SetCenter( view->GetCenter() + view->ToWorld( delta, false ) );
|
||||
delta.x = newCursor.x - screenBox.GetLeft();
|
||||
newCursor.x = screenBox.GetLeft();
|
||||
}
|
||||
else if( newCursor.x > screenBox.GetRight() )
|
||||
{
|
||||
delta.x = newCursor.x - screenBox.GetRight();
|
||||
// -1 is to keep the cursor within the drawing area,
|
||||
// so the cursor coordinates are still updated
|
||||
newCursor.x = screenBox.GetRight() - 1;
|
||||
}
|
||||
|
||||
TOOL_EVENT evt( TC_MOUSE, TA_MOUSE_MOTION );
|
||||
evt.SetMousePosition( worldCursor );
|
||||
m_toolMgr->ProcessEvent( evt );
|
||||
if( newCursor.y < screenBox.GetTop() )
|
||||
{
|
||||
delta.y = newCursor.y - screenBox.GetTop();
|
||||
newCursor.y = screenBox.GetTop();
|
||||
}
|
||||
else if( newCursor.y > screenBox.GetBottom() )
|
||||
{
|
||||
delta.y = newCursor.y - screenBox.GetBottom();
|
||||
// -1 is to keep the cursor within the drawing area,
|
||||
// so the cursor coordinates are still updated
|
||||
newCursor.y = screenBox.GetBottom() - 1;
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->WarpPointer( newCursor.x, newCursor.y );
|
||||
view->SetCenter( view->GetCenter() + view->ToWorld( delta, false ) );
|
||||
}
|
||||
|
||||
m_frame->GetGalCanvas()->WarpPointer( newCursor.x, newCursor.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue