Wx_view_controls: Allow two input devices to simultaneously pan & zoom

Instead of the mouse move and zoom algorithms calculating the new
position or scale values relative to a starting value, the new values
are calculated relative to the current values. This allows the user to
use a second input device to move or zoom the view at the same time
without its change being undone by the mouse.
This commit is contained in:
markus-bonk 2021-04-28 12:10:06 +02:00 committed by Wayne Stambaugh
parent 8282130bbe
commit 47603fbc76
2 changed files with 5 additions and 11 deletions

View File

@ -75,7 +75,6 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPane
m_state( IDLE ),
m_parentPanel( aParentPanel ),
m_scrollScale( 1.0, 1.0 ),
m_initialZoomScale( 0.0 ),
#ifdef __WXGTK3__
m_lastTimestamp( 0 ),
#endif
@ -238,8 +237,9 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
if( !justWarped )
{
VECTOR2D d = m_dragStartPoint - mousePos;
m_dragStartPoint = mousePos;
VECTOR2D delta = m_view->ToWorld( d, false );
m_view->SetCenter( m_lookStartPoint + delta );
m_view->SetCenter( m_view->GetCenter() + delta );
aEvent.StopPropagation();
}
@ -275,11 +275,13 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
if( !justWarped )
{
VECTOR2D d = m_dragStartPoint - mousePos;
m_dragStartPoint = mousePos;
double scale = exp( d.y * m_settings.m_zoomSpeed * 0.001 );
wxLogTrace( traceZoomScroll, wxString::Format( "dy: %f scale: %f", d.y, scale ) );
m_view->SetScale( m_initialZoomScale * scale, m_view->ToWorld( m_zoomStartPoint ) );
m_view->SetScale( m_view->GetScale() * scale, m_view->ToWorld( m_zoomStartPoint ) );
aEvent.StopPropagation();
}
@ -402,7 +404,6 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::PAN ) )
{
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
m_lookStartPoint = m_view->GetCenter();
m_state = DRAG_PANNING;
#if defined USE_MOUSE_CAPTURE
@ -415,7 +416,6 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
{
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
m_zoomStartPoint = m_dragStartPoint;
m_initialZoomScale = m_view->GetScale();
m_state = DRAG_ZOOMING;
#if defined USE_MOUSE_CAPTURE

View File

@ -168,9 +168,6 @@ private:
///< Store information about point where dragging has started.
VECTOR2D m_dragStartPoint;
///< Stores information about the center of viewport when dragging has started.
VECTOR2D m_lookStartPoint;
///< Current direction of panning (only autopanning mode).
VECTOR2D m_panDirection;
@ -183,9 +180,6 @@ private:
///< Current scrollbar position.
VECTOR2I m_scrollPos;
///< The zoom scale when a drag zoom started.
double m_initialZoomScale;
///< The mouse position when a drag zoom started.
VECTOR2D m_zoomStartPoint;