|
|
@ -55,6 +55,8 @@ struct TOOL_DISPATCHER::ButtonState |
|
|
|
bool pressed; |
|
|
|
|
|
|
|
VECTOR2D dragOrigin; |
|
|
|
VECTOR2D downPosition; |
|
|
|
|
|
|
|
double dragMaxDelta; |
|
|
|
|
|
|
|
TOOL_MouseButtons button; |
|
|
@ -117,13 +119,21 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const |
|
|
|
return mods; |
|
|
|
} |
|
|
|
|
|
|
|
wxPoint TOOL_DISPATCHER::getCurrentMousePos() |
|
|
|
{ |
|
|
|
wxPoint msp = wxGetMousePosition() ; |
|
|
|
wxPoint winp = m_editFrame->GetGalCanvas()->GetScreenPosition(); |
|
|
|
|
|
|
|
return wxPoint(msp.x - winp.x, msp.y - winp.y); |
|
|
|
} |
|
|
|
|
|
|
|
bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion ) |
|
|
|
{ |
|
|
|
ButtonState* st = m_buttons[aIndex]; |
|
|
|
wxEventType type = aEvent.GetEventType(); |
|
|
|
optional<TOOL_EVENT> evt; |
|
|
|
|
|
|
|
bool isClick = false; |
|
|
|
|
|
|
|
bool up = type == st->upEvent; |
|
|
|
bool down = type == st->downEvent; |
|
|
|
|
|
|
@ -134,20 +144,20 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti |
|
|
|
{ |
|
|
|
st->downTimestamp = wxGetLocalTimeMillis(); |
|
|
|
st->dragOrigin = m_lastMousePos; |
|
|
|
st->downPosition = m_lastMousePos; |
|
|
|
st->dragMaxDelta = 0; |
|
|
|
st->pressed = true; |
|
|
|
evt = TOOL_EVENT( TC_Mouse, TA_MouseDown, args ); |
|
|
|
} |
|
|
|
else if( up ) |
|
|
|
{ |
|
|
|
bool isClick = false; |
|
|
|
st->pressed = false; |
|
|
|
|
|
|
|
if( st->dragging ) |
|
|
|
{ |
|
|
|
wxLongLong t = wxGetLocalTimeMillis(); |
|
|
|
|
|
|
|
if( t - st->downTimestamp < DragTimeThreshold && |
|
|
|
if( t - st->downTimestamp < DragTimeThreshold || |
|
|
|
st->dragMaxDelta < DragDistanceThreshold ) |
|
|
|
isClick = true; |
|
|
|
else |
|
|
@ -158,13 +168,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti |
|
|
|
|
|
|
|
|
|
|
|
if( isClick ) |
|
|
|
{ |
|
|
|
if( st->triggerContextMenu && !mods ) |
|
|
|
{} |
|
|
|
// evt = TOOL_EVENT( TC_Command, TA_ContextMenu );
|
|
|
|
else |
|
|
|
evt = TOOL_EVENT( TC_Mouse, TA_MouseClick, args ); |
|
|
|
} |
|
|
|
evt = TOOL_EVENT( TC_Mouse, TA_MouseClick, args ); |
|
|
|
|
|
|
|
st->dragging = false; |
|
|
|
} |
|
|
@ -177,7 +181,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti |
|
|
|
|
|
|
|
wxLongLong t = wxGetLocalTimeMillis(); |
|
|
|
|
|
|
|
if( t - st->downTimestamp > DragTimeThreshold || st->dragMaxDelta > DragDistanceThreshold ) |
|
|
|
if( t - st->downTimestamp > DragTimeThreshold && st->dragMaxDelta > DragDistanceThreshold ) |
|
|
|
{ |
|
|
|
evt = TOOL_EVENT( TC_Mouse, TA_MouseDrag, args ); |
|
|
|
evt->SetMouseDragOrigin( st->dragOrigin ); |
|
|
@ -187,7 +191,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti |
|
|
|
|
|
|
|
if( evt ) |
|
|
|
{ |
|
|
|
evt->SetMousePosition( m_lastMousePos ); |
|
|
|
evt->SetMousePosition( isClick ? st->downPosition : m_lastMousePos ); |
|
|
|
m_toolMgr->ProcessEvent( *evt ); |
|
|
|
|
|
|
|
return true; |
|
|
@ -212,7 +216,9 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) |
|
|
|
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ) |
|
|
|
{ |
|
|
|
wxMouseEvent* me = static_cast<wxMouseEvent*>( &aEvent ); |
|
|
|
pos = getView()->ToWorld( VECTOR2D( me->GetX(), me->GetY() ) ); |
|
|
|
|
|
|
|
|
|
|
|
pos = getView()->ToWorld ( getCurrentMousePos() ); |
|
|
|
if( pos != m_lastMousePos ) |
|
|
|
{ |
|
|
|
motion = true; |
|
|
|