TOOL_DISPATCHER: drag activation should always use screen coordinates
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9325
This commit is contained in:
parent
a8ec3b58ed
commit
27765cd584
|
@ -69,6 +69,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE
|
||||||
///< Point where dragging has started (in world coordinates).
|
///< Point where dragging has started (in world coordinates).
|
||||||
VECTOR2D dragOrigin;
|
VECTOR2D dragOrigin;
|
||||||
|
|
||||||
|
///< Point where dragging has started (in screen coordinates).
|
||||||
|
VECTOR2D dragOriginScreen;
|
||||||
|
|
||||||
///< Point where click event has occurred.
|
///< Point where click event has occurred.
|
||||||
VECTOR2D downPosition;
|
VECTOR2D downPosition;
|
||||||
|
|
||||||
|
@ -192,7 +195,10 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
||||||
st->downTimestamp = wxGetLocalTimeMillis();
|
st->downTimestamp = wxGetLocalTimeMillis();
|
||||||
|
|
||||||
if( !st->pressed ) // save the drag origin on the first click only
|
if( !st->pressed ) // save the drag origin on the first click only
|
||||||
|
{
|
||||||
st->dragOrigin = m_lastMousePos;
|
st->dragOrigin = m_lastMousePos;
|
||||||
|
st->dragOriginScreen = m_lastMousePosScreen;
|
||||||
|
}
|
||||||
|
|
||||||
st->downPosition = m_lastMousePos;
|
st->downPosition = m_lastMousePos;
|
||||||
st->pressed = true;
|
st->pressed = true;
|
||||||
|
@ -225,7 +231,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
||||||
if( wxGetLocalTimeMillis() - st->downTimestamp > DragTimeThreshold )
|
if( wxGetLocalTimeMillis() - st->downTimestamp > DragTimeThreshold )
|
||||||
st->dragging = true;
|
st->dragging = true;
|
||||||
#endif
|
#endif
|
||||||
VECTOR2D offset = getView()->ToScreen( m_lastMousePos - st->dragOrigin, false );
|
VECTOR2D offset = m_lastMousePosScreen - st->dragOriginScreen;
|
||||||
|
|
||||||
if( abs( offset.x ) > m_sysDragMinX || abs( offset.y ) > m_sysDragMinY )
|
if( abs( offset.x ) > m_sysDragMinX || abs( offset.y ) > m_sysDragMinY )
|
||||||
st->dragging = true;
|
st->dragging = true;
|
||||||
|
@ -481,6 +487,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||||
if( m_toolMgr->GetViewControls() )
|
if( m_toolMgr->GetViewControls() )
|
||||||
{
|
{
|
||||||
pos = m_toolMgr->GetViewControls()->GetMousePosition();
|
pos = m_toolMgr->GetViewControls()->GetMousePosition();
|
||||||
|
m_lastMousePosScreen = m_toolMgr->GetViewControls()->GetMousePosition( false );
|
||||||
|
|
||||||
if( pos != m_lastMousePos )
|
if( pos != m_lastMousePos )
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,9 @@ private:
|
||||||
///< The last mouse cursor position (in world coordinates).
|
///< The last mouse cursor position (in world coordinates).
|
||||||
VECTOR2D m_lastMousePos;
|
VECTOR2D m_lastMousePos;
|
||||||
|
|
||||||
|
///< The last mouse cursor position (in screen coordinates).
|
||||||
|
VECTOR2D m_lastMousePosScreen;
|
||||||
|
|
||||||
///< State of mouse buttons.
|
///< State of mouse buttons.
|
||||||
std::vector<BUTTON_STATE*> m_buttons;
|
std::vector<BUTTON_STATE*> m_buttons;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue