Commit f9cc9149 authored by Maciej Suminski's avatar Maciej Suminski

Mouse movement events are sent during autopanning, as the cursor position...

Mouse movement events are sent during autopanning, as the cursor position changes in the world coordinates (even if it stays still in the screen coordinates). It allows tools to update their state, as if the mouse was moved.
parent d9ff4b85
...@@ -87,10 +87,12 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -87,10 +87,12 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
// Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) ); Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
// Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this ); Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( TOOL_DISPATCHER::EVT_REFRESH_MOUSE, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
NULL, this );
m_refreshTimer.SetOwner( this ); m_refreshTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this ); Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
...@@ -243,8 +245,9 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent ) ...@@ -243,8 +245,9 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
} }
void EDA_DRAW_PANEL_GAL::onEnter ( wxEvent& aEvent ) void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
{ {
// Getting focus is necessary in order to receive key events properly
SetFocus(); SetFocus();
} }
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
using boost::optional; using boost::optional;
const wxEventType TOOL_DISPATCHER::EVT_REFRESH_MOUSE = wxNewEventType();
struct TOOL_DISPATCHER::ButtonState struct TOOL_DISPATCHER::ButtonState
{ {
ButtonState( TOOL_MouseButtons aButton, const wxEventType& aDownEvent, ButtonState( TOOL_MouseButtons aButton, const wxEventType& aDownEvent,
...@@ -215,10 +217,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -215,10 +217,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL || if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP ||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ) type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
type == EVT_REFRESH_MOUSE )
{ {
pos = getView()->ToWorld ( getCurrentMousePos() ); pos = getView()->ToWorld ( getCurrentMousePos() );
if( pos != m_lastMousePos ) if( pos != m_lastMousePos || type == EVT_REFRESH_MOUSE )
{ {
motion = true; motion = true;
m_lastMousePos = pos; m_lastMousePos = pos;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <view/view.h> #include <view/view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h>
using namespace KiGfx; using namespace KiGfx;
...@@ -197,7 +198,9 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) ...@@ -197,7 +198,9 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false ); dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed );
m_parentPanel->Refresh(); // Notify tools that the cursor position has changed in the world coordinates
wxCommandEvent moveEvent( TOOL_DISPATCHER::EVT_REFRESH_MOUSE );
wxPostEvent( m_parentPanel, moveEvent );
} }
break; break;
......
...@@ -65,6 +65,9 @@ public: ...@@ -65,6 +65,9 @@ public:
virtual void DispatchWxEvent( wxEvent& aEvent ); virtual void DispatchWxEvent( wxEvent& aEvent );
virtual void DispatchWxCommand( wxCommandEvent& aEvent ); virtual void DispatchWxCommand( wxCommandEvent& aEvent );
/// Event that forces mouse move event in the dispatcher
static const wxEventType EVT_REFRESH_MOUSE;
private: private:
static const int MouseButtonCount = 3; static const int MouseButtonCount = 3;
static const int DragTimeThreshold = 300; static const int DragTimeThreshold = 300;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment