Browse Source

Add support for panning with left and right mouse buttons

pull/7/merge
Jon Evans 8 years ago
committed by Maciej Suminski
parent
commit
d9396616ef
  1. 2
      common/view/view_controls.cpp
  2. 10
      common/view/wx_view_controls.cpp
  3. 12
      include/view/view_controls.h

2
common/view/view_controls.cpp

@ -66,6 +66,8 @@ void VC_SETTINGS::Reset()
m_autoPanSpeed = 0.15;
m_warpCursor = false;
m_enableMousewheelPan = false;
m_panWithRightButton = false;
m_panWithLeftButton = false;
}

10
common/view/wx_view_controls.cpp

@ -55,6 +55,10 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_RIGHT_UP,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_RIGHT_DOWN,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
#if defined _WIN32 || defined _WIN64
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
@ -223,7 +227,9 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
{
case IDLE:
case AUTO_PANNING:
if( aEvent.MiddleDown() )
if( aEvent.MiddleDown() ||
( aEvent.LeftDown() && m_settings.m_panWithLeftButton ) ||
( aEvent.RightDown() && m_settings.m_panWithRightButton ) )
{
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
m_lookStartPoint = m_view->GetCenter();
@ -236,7 +242,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
break;
case DRAG_PANNING:
if( aEvent.MiddleUp() )
if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
m_state = IDLE;
break;

12
include/view/view_controls.h

@ -83,6 +83,12 @@ struct VC_SETTINGS
///> Mousewheel (2-finger touchpad) panning
bool m_enableMousewheelPan;
///> Allow panning with the right button in addition to middle
bool m_panWithRightButton;
///> Allow panning with the left button in addition to middle
bool m_panWithLeftButton;
};
@ -309,6 +315,12 @@ public:
*/
virtual void CenterOnCursor() const = 0;
void SetAdditionalPanButtons( bool aLeft = false, bool aRight = false )
{
m_settings.m_panWithLeftButton = aLeft;
m_settings.m_panWithRightButton = aRight;
}
/**
* Function Reset()
* Restores the default VIEW_CONTROLS settings.

Loading…
Cancel
Save