Reenabled snapping for tools.
This commit is contained in:
parent
8e0674b724
commit
ab21124b71
|
@ -31,6 +31,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
|
||||
#include <class_drawpanel_gal.h>
|
||||
|
||||
|
@ -122,15 +123,6 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const
|
|||
}
|
||||
|
||||
|
||||
wxPoint TOOL_DISPATCHER::getCurrentMousePos() const
|
||||
{
|
||||
wxPoint msp = wxGetMousePosition();
|
||||
wxPoint winp = m_editFrame->GetGalCanvas()->GetScreenPosition();
|
||||
|
||||
return wxPoint( msp.x - winp.x, msp.y - winp.y );
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion )
|
||||
{
|
||||
ButtonState* st = m_buttons[aIndex];
|
||||
|
@ -208,7 +200,6 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
|||
void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||
{
|
||||
bool motion = false, buttonEvents = false;
|
||||
VECTOR2D pos;
|
||||
optional<TOOL_EVENT> evt;
|
||||
|
||||
int type = aEvent.GetEventType();
|
||||
|
@ -220,7 +211,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
|
||||
type == EVT_REFRESH_MOUSE )
|
||||
{
|
||||
pos = getView()->ToWorld ( getCurrentMousePos() );
|
||||
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetCursorPosition();
|
||||
VECTOR2D pos = getView()->ToWorld( screenPos );
|
||||
if( pos != m_lastMousePos || type == EVT_REFRESH_MOUSE )
|
||||
{
|
||||
motion = true;
|
||||
|
|
|
@ -65,11 +65,6 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
|||
m_mousePosition.x = aEvent.GetX();
|
||||
m_mousePosition.y = aEvent.GetY();
|
||||
|
||||
if( m_snappingEnabled )
|
||||
m_cursorPosition = m_view->GetGAL()->GetGridPoint( m_mousePosition );
|
||||
else
|
||||
m_cursorPosition = m_mousePosition;
|
||||
|
||||
bool isAutoPanning = false;
|
||||
|
||||
if( m_autoPanEnabled )
|
||||
|
@ -222,6 +217,24 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
|||
}
|
||||
|
||||
|
||||
const VECTOR2D WX_VIEW_CONTROLS::GetMousePosition() const
|
||||
{
|
||||
wxPoint msp = wxGetMousePosition();
|
||||
wxPoint winp = m_parentPanel->GetScreenPosition();
|
||||
|
||||
return VECTOR2D( msp.x - winp.x, msp.y - winp.y );
|
||||
}
|
||||
|
||||
|
||||
const VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
|
||||
{
|
||||
if( m_snappingEnabled )
|
||||
return m_view->GetGAL()->GetGridPoint( GetMousePosition() );
|
||||
else
|
||||
return GetMousePosition();
|
||||
}
|
||||
|
||||
|
||||
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
||||
{
|
||||
VECTOR2D p( aEvent.GetX(), aEvent.GetY() );
|
||||
|
|
|
@ -76,8 +76,6 @@ private:
|
|||
bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion );
|
||||
bool handlePopupMenu( wxEvent& aEvent );
|
||||
|
||||
wxPoint getCurrentMousePos() const;
|
||||
|
||||
int decodeModifiers( const wxKeyboardState* aState ) const;
|
||||
|
||||
struct ButtonState;
|
||||
|
|
|
@ -110,10 +110,7 @@ public:
|
|||
*
|
||||
* @return The current mouse pointer position.
|
||||
*/
|
||||
virtual const VECTOR2D& GetMousePosition() const
|
||||
{
|
||||
return m_mousePosition;
|
||||
}
|
||||
virtual const VECTOR2D GetMousePosition() const = 0;
|
||||
|
||||
/**
|
||||
* Function GetCursorPosition()
|
||||
|
@ -122,21 +119,7 @@ public:
|
|||
*
|
||||
* @return The current cursor position in screen coordinates.
|
||||
*/
|
||||
virtual const VECTOR2D& GetCursorPosition() const
|
||||
{
|
||||
return m_cursorPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetCursorPosition()
|
||||
* Allows to move the cursor to a different location.
|
||||
*
|
||||
* @param aPosition is the new location expressed in screen coordinates.
|
||||
*/
|
||||
virtual void SetCursorPosition( const VECTOR2D& aPosition )
|
||||
{
|
||||
m_cursorPosition = aPosition;
|
||||
}
|
||||
virtual const VECTOR2D GetCursorPosition() const = 0;
|
||||
|
||||
protected:
|
||||
/// Pointer to controlled VIEW.
|
||||
|
@ -145,9 +128,6 @@ protected:
|
|||
/// Current mouse position
|
||||
VECTOR2D m_mousePosition;
|
||||
|
||||
/// Current cursor position
|
||||
VECTOR2D m_cursorPosition;
|
||||
|
||||
/// Should the cursor snap to grid or move freely
|
||||
bool m_snappingEnabled;
|
||||
|
||||
|
|
|
@ -78,6 +78,12 @@ public:
|
|||
m_state = IDLE;
|
||||
}
|
||||
|
||||
/// @copydoc VIEW_CONTROLS::GetMousePosition()
|
||||
virtual const VECTOR2D GetMousePosition() const;
|
||||
|
||||
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
|
||||
virtual const VECTOR2D GetCursorPosition() const;
|
||||
|
||||
private:
|
||||
/// Possible states for WX_VIEW_CONTROLS
|
||||
enum State {
|
||||
|
|
Loading…
Reference in New Issue