← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] - Implement auto panning while moving in EDA_DRAW_PANEL::OnMouseEvent()

 

Le 09/06/2013 20:25, Chris Morgan a écrit :
I think you have good points. I'll take a look at the more comprehensive
fix for the issue.

On the point of animating the pan, what are your thoughts? The pan today is
very discontinuous looking.

Chris



On Sunday, June 9, 2013, Dick Hollenbeck wrote:

On 06/09/2013 01:01 PM, Dick Hollenbeck wrote:

The if() test should probably be:


if( size.x <= event.GetX() || size.y <= event.GetY()
      || event.GetX() < 0  || event.GetY() < 0 )


Fine, that works.

It does not work very well for me, for *very slow* mouse movements (the event.GetXY() < 0 or size.xy <= event.GetXY() does not always happens). Because we are inside a EVT_LEAVE_WINDOW event, I think the "if( ..) is not needed (perhaps it comes from legacy code).

Also, although I do not noticed strange pannings, I noticed the cross hair position, used to center the screen (ProcessEvent with ID_POPUP_ZOOM_CENTER event id) is not updated, and therefore the cross hair position used by the ID_POPUP_ZOOM_CENTER event come from a previous command.

Can you test the attached patch:
It removes the if( ..) useless test (and perhaps broken) which explains sometimes the panning does not happen. It set the cross hair position before sending the event which uses this position, and ensure the zoom center does not uses a strange previous position.


--
Jean-Pierre CHARRAS
=== modifié fichier common/drawpanel.cpp
--- common/drawpanel.cpp	2013-06-09 18:14:01 +0000
+++ common/drawpanel.cpp	2013-06-10 08:26:44 +0000
@@ -830,16 +830,26 @@
     if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents )
         return;

-    // Auto pan if mouse has left the client window
+    // Auto pan when mouse has left the client window
+    // Ensure the cross_hair position is updated,
+    // because it will be used to center the screen.
+    // We use a position inside the client window
     wxSize size = GetClientSize();
-
-    if( size.x <= event.GetX() || event.GetX() < 0 ||
-        size.y <= event.GetY() || event.GetY() < 0 )
-    {
-        wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
-        cmd.SetEventObject( this );
-        GetEventHandler()->ProcessEvent( cmd );
-    }
+    wxPoint cross_hair_pos = event.GetPosition();
+    cross_hair_pos.x = std::min( cross_hair_pos.x, size.x );
+    cross_hair_pos.y = std::min( cross_hair_pos.y, size.x );
+    cross_hair_pos.x = std::max( cross_hair_pos.x, 0 );
+    cross_hair_pos.y = std::max( cross_hair_pos.y, 0 );
+
+    INSTALL_UNBUFFERED_DC( dc, this );
+    cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x );
+    cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y );
+
+    GetScreen()->SetCrossHairPosition( cross_hair_pos );
+
+    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
+    cmd.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( cmd );

     event.Skip();
 }


Follow ups

References