Add support for panning with left and right mouse buttons
This commit is contained in:
parent
c0bc2f1bee
commit
d9396616ef
|
@ -66,6 +66,8 @@ void VC_SETTINGS::Reset()
|
||||||
m_autoPanSpeed = 0.15;
|
m_autoPanSpeed = 0.15;
|
||||||
m_warpCursor = false;
|
m_warpCursor = false;
|
||||||
m_enableMousewheelPan = false;
|
m_enableMousewheelPan = false;
|
||||||
|
m_panWithRightButton = false;
|
||||||
|
m_panWithLeftButton = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,10 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
|
||||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||||
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
|
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
|
||||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
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
|
#if defined _WIN32 || defined _WIN64
|
||||||
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
|
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
|
||||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
|
||||||
|
@ -223,7 +227,9 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
case IDLE:
|
case IDLE:
|
||||||
case AUTO_PANNING:
|
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_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
||||||
m_lookStartPoint = m_view->GetCenter();
|
m_lookStartPoint = m_view->GetCenter();
|
||||||
|
@ -236,7 +242,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DRAG_PANNING:
|
case DRAG_PANNING:
|
||||||
if( aEvent.MiddleUp() )
|
if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
|
||||||
m_state = IDLE;
|
m_state = IDLE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,6 +83,12 @@ struct VC_SETTINGS
|
||||||
|
|
||||||
///> Mousewheel (2-finger touchpad) panning
|
///> Mousewheel (2-finger touchpad) panning
|
||||||
bool m_enableMousewheelPan;
|
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;
|
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()
|
* Function Reset()
|
||||||
* Restores the default VIEW_CONTROLS settings.
|
* Restores the default VIEW_CONTROLS settings.
|
||||||
|
|
Loading…
Reference in New Issue