Remove SetGrabMouse and revert some behaviours
This commit is contained in:
parent
905fd63c9f
commit
16c7180ff5
|
@ -37,7 +37,7 @@
|
||||||
#include <math/util.h> // for KiROUND
|
#include <math/util.h> // for KiROUND
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
|
|
||||||
#if defined _WIN32 || defined _WIN64
|
#if defined __WXMSW__
|
||||||
#define USE_MOUSE_CAPTURE
|
#define USE_MOUSE_CAPTURE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ 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_RIGHT_DOWN,
|
m_parentPanel->Connect( wxEVT_RIGHT_DOWN,
|
||||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||||
#if defined _WIN32 || defined _WIN64
|
#if defined __WXMSW__
|
||||||
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 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -191,36 +191,8 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
||||||
int y = aEvent.GetY();
|
int y = aEvent.GetY();
|
||||||
VECTOR2D mousePos( x, y );
|
VECTOR2D mousePos( x, y );
|
||||||
|
|
||||||
if( m_state != DRAG_PANNING && m_state != DRAG_ZOOMING && m_settings.m_grabMouse )
|
if( m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
|
||||||
{
|
handleCursorCapture( x, y );
|
||||||
bool warp = false;
|
|
||||||
wxSize parentSize = m_parentPanel->GetClientSize();
|
|
||||||
|
|
||||||
if( x < 0 )
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
warp = true;
|
|
||||||
}
|
|
||||||
else if( x >= parentSize.x )
|
|
||||||
{
|
|
||||||
x = parentSize.x - 1;
|
|
||||||
warp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( y < 0 )
|
|
||||||
{
|
|
||||||
y = 0;
|
|
||||||
warp = true;
|
|
||||||
}
|
|
||||||
else if( y >= parentSize.y )
|
|
||||||
{
|
|
||||||
y = parentSize.y - 1;
|
|
||||||
warp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( warp )
|
|
||||||
m_parentPanel->WarpPointer( x, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_settings.m_autoPanEnabled && m_settings.m_autoPanSettingEnabled )
|
if( m_settings.m_autoPanEnabled && m_settings.m_autoPanSettingEnabled )
|
||||||
isAutoPanning = handleAutoPanning( aEvent );
|
isAutoPanning = handleAutoPanning( aEvent );
|
||||||
|
@ -450,7 +422,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
m_state = IDLE;
|
m_state = IDLE;
|
||||||
#if defined USE_MOUSE_CAPTURE
|
#if defined USE_MOUSE_CAPTURE
|
||||||
if( !m_settings.m_grabMouse && m_parentPanel->HasCapture() )
|
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
|
||||||
m_parentPanel->ReleaseMouse();
|
m_parentPanel->ReleaseMouse();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -613,7 +585,7 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
void WX_VIEW_CONTROLS::CaptureCursor( bool aEnabled )
|
||||||
{
|
{
|
||||||
#if defined USE_MOUSE_CAPTURE
|
#if defined USE_MOUSE_CAPTURE
|
||||||
if( aEnabled && !m_parentPanel->HasCapture() )
|
if( aEnabled && !m_parentPanel->HasCapture() )
|
||||||
|
@ -622,25 +594,10 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
||||||
&& m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
|
&& m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
|
||||||
m_parentPanel->ReleaseMouse();
|
m_parentPanel->ReleaseMouse();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VIEW_CONTROLS::SetGrabMouse( aEnabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::CaptureCursor( bool aEnabled )
|
|
||||||
{
|
|
||||||
SetGrabMouse( aEnabled );
|
|
||||||
VIEW_CONTROLS::CaptureCursor( aEnabled );
|
VIEW_CONTROLS::CaptureCursor( aEnabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::SetAutoPan( bool aEnabled )
|
|
||||||
{
|
|
||||||
SetGrabMouse( aEnabled );
|
|
||||||
VIEW_CONTROLS::SetAutoPan( aEnabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
||||||
{
|
{
|
||||||
wxPoint msp = getMouseScreenPosition();
|
wxPoint msp = getMouseScreenPosition();
|
||||||
|
@ -839,6 +796,41 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WX_VIEW_CONTROLS::handleCursorCapture( int x, int y )
|
||||||
|
{
|
||||||
|
if( m_settings.m_cursorCaptured )
|
||||||
|
{
|
||||||
|
bool warp = false;
|
||||||
|
wxSize parentSize = m_parentPanel->GetClientSize();
|
||||||
|
|
||||||
|
if( x < 0 )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
warp = true;
|
||||||
|
}
|
||||||
|
else if( x >= parentSize.x )
|
||||||
|
{
|
||||||
|
x = parentSize.x - 1;
|
||||||
|
warp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( y < 0 )
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
warp = true;
|
||||||
|
}
|
||||||
|
else if( y >= parentSize.y )
|
||||||
|
{
|
||||||
|
y = parentSize.y - 1;
|
||||||
|
warp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( warp )
|
||||||
|
m_parentPanel->WarpPointer( x, y );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::refreshMouse()
|
void WX_VIEW_CONTROLS::refreshMouse()
|
||||||
{
|
{
|
||||||
// Notify tools that the cursor position has changed in the world coordinates
|
// Notify tools that the cursor position has changed in the world coordinates
|
||||||
|
|
|
@ -66,12 +66,6 @@ public:
|
||||||
void onScroll( wxScrollWinEvent& aEvent );
|
void onScroll( wxScrollWinEvent& aEvent );
|
||||||
void onCaptureLost( wxMouseEvent& WXUNUSED( aEvent ) );
|
void onCaptureLost( wxMouseEvent& WXUNUSED( aEvent ) );
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable mouse cursor grabbing (limits the movement field only to the panel area).
|
|
||||||
*
|
|
||||||
* @param aEnabled says whether the option should be enabled or disabled.
|
|
||||||
*/
|
|
||||||
void SetGrabMouse( bool aEnabled ) override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force the cursor to stay within the drawing panel area.
|
* Force the cursor to stay within the drawing panel area.
|
||||||
|
@ -80,13 +74,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void CaptureCursor( bool aEnabled ) override;
|
void CaptureCursor( bool aEnabled ) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn on/off auto panning (this feature is used when there is a tool active (eg. drawing a
|
|
||||||
* track) and user moves mouse to the VIEW edge - then the view can be translated or not).
|
|
||||||
*
|
|
||||||
* @param aEnabled tells if the autopanning should be active.
|
|
||||||
*/
|
|
||||||
void SetAutoPan( bool aEnabled ) override;
|
|
||||||
|
|
||||||
///< @copydoc VIEW_CONTROLS::GetMousePosition()
|
///< @copydoc VIEW_CONTROLS::GetMousePosition()
|
||||||
VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const override;
|
VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const override;
|
||||||
|
@ -144,6 +131,14 @@ private:
|
||||||
*/
|
*/
|
||||||
bool handleAutoPanning( const wxMouseEvent& aEvent );
|
bool handleAutoPanning( const wxMouseEvent& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limit the cursor position to within the canvas by warping it
|
||||||
|
*
|
||||||
|
* @param x Mouse position
|
||||||
|
* @param y Mouse position
|
||||||
|
*/
|
||||||
|
void handleCursorCapture( int x, int y );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an event to refresh mouse position.
|
* Send an event to refresh mouse position.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue