Support autopanning in GALified eeschema

Fixes: lp:1807234
* https://bugs.launchpad.net/kicad/+bug/1807234
This commit is contained in:
Maciej Suminski 2018-12-11 17:49:28 +01:00
parent a9efbf4716
commit 63d4afb3ee
4 changed files with 25 additions and 20 deletions

View File

@ -920,7 +920,7 @@ void EDA_DRAW_PANEL::OnMouseEntering( wxMouseEvent& aEvent )
void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event )
{ {
if( m_mouseCaptureCallback == NULL ) // No command in progress. if( m_mouseCaptureCallback == NULL ) // No command in progress.
m_requestAutoPan = false; SetAutoPanRequest( false );
if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents ) if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents )
return; return;
@ -1094,7 +1094,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_canStartBlock = -1; m_canStartBlock = -1;
if( !IsMouseCaptured() ) // No mouse capture in progress. if( !IsMouseCaptured() ) // No mouse capture in progress.
m_requestAutoPan = false; SetAutoPanRequest( false );
if( GetParent()->IsActive() ) if( GetParent()->IsActive() )
SetFocus(); SetFocus();
@ -1268,7 +1268,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{ {
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{ {
m_requestAutoPan = false; SetAutoPanRequest( false );
GetParent()->HandleBlockPlace( &DC ); GetParent()->HandleBlockPlace( &DC );
m_ignoreNextLeftButtonRelease = true; m_ignoreNextLeftButtonRelease = true;
} }
@ -1298,7 +1298,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
} }
else else
{ {
m_requestAutoPan = true; SetAutoPanRequest( true );
SetCursor( wxCURSOR_SIZING ); SetCursor( wxCURSOR_SIZING );
} }
} }
@ -1324,19 +1324,19 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( m_endMouseCaptureCallback ) if( m_endMouseCaptureCallback )
{ {
m_endMouseCaptureCallback( this, &DC ); m_endMouseCaptureCallback( this, &DC );
m_requestAutoPan = false; SetAutoPanRequest( false );
} }
SetCursor( (wxStockCursor) m_currentCursor ); SetCursor( (wxStockCursor) m_currentCursor );
} }
else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END ) else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
{ {
m_requestAutoPan = false; SetAutoPanRequest( false );
GetParent()->HandleBlockEnd( &DC ); GetParent()->HandleBlockEnd( &DC );
SetCursor( (wxStockCursor) m_currentCursor ); SetCursor( (wxStockCursor) m_currentCursor );
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{ {
m_requestAutoPan = true; SetAutoPanRequest( true );
SetCursor( wxCURSOR_HAND ); SetCursor( wxCURSOR_HAND );
} }
} }
@ -1535,7 +1535,7 @@ void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title,
m_mouseCaptureCallback = NULL; m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL;
m_requestAutoPan = false; SetAutoPanRequest( false );
if( id != -1 && cursor != -1 ) if( id != -1 && cursor != -1 )
{ {

View File

@ -119,7 +119,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
m_mouseCaptureCallback = NULL; m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL;
m_requestAutoPan = false;
m_enableBlockCommands = false; m_enableBlockCommands = false;
m_minDragEventCount = 0; m_minDragEventCount = 0;
@ -216,13 +215,20 @@ void SCH_DRAW_PANEL::SetEnableMousewheelPan( bool aEnable )
void SCH_DRAW_PANEL::SetEnableAutoPan( bool aEnable ) void SCH_DRAW_PANEL::SetEnableAutoPan( bool aEnable )
{ {
m_enableAutoPan = aEnable; EDA_DRAW_PANEL::SetEnableAutoPan( aEnable );
if( GetParent()->IsGalCanvasActive() ) if( GetParent()->IsGalCanvasActive() )
GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable ); GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable );
} }
void SCH_DRAW_PANEL::SetAutoPanRequest( bool aEnable )
{
wxCHECK( GetParent()->IsGalCanvasActive(), /*void*/ );
GetParent()->GetGalCanvas()->GetViewControls()->SetAutoPan( aEnable );
}
void SCH_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable ) void SCH_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
{ {
m_enableZoomNoCenter = aEnable; m_enableZoomNoCenter = aEnable;
@ -293,7 +299,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_canStartBlock = -1; m_canStartBlock = -1;
if( !IsMouseCaptured() ) // No mouse capture in progress. if( !IsMouseCaptured() ) // No mouse capture in progress.
m_requestAutoPan = false; SetAutoPanRequest( false );
if( GetParent()->IsActive() ) if( GetParent()->IsActive() )
SetFocus(); SetFocus();
@ -436,7 +442,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{ {
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{ {
m_requestAutoPan = false; SetAutoPanRequest( false );
GetParent()->HandleBlockPlace( nullptr ); GetParent()->HandleBlockPlace( nullptr );
m_ignoreNextLeftButtonRelease = true; m_ignoreNextLeftButtonRelease = true;
} }
@ -468,7 +474,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
} }
else else
{ {
m_requestAutoPan = true; SetAutoPanRequest( true );
SetCursor( wxCURSOR_SIZING ); SetCursor( wxCURSOR_SIZING );
} }
} }
@ -494,19 +500,19 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( m_endMouseCaptureCallback ) if( m_endMouseCaptureCallback )
{ {
m_endMouseCaptureCallback( this, nullptr ); m_endMouseCaptureCallback( this, nullptr );
m_requestAutoPan = false; SetAutoPanRequest( false );
} }
//SetCursor( (wxStockCursor) m_currentCursor ); //SetCursor( (wxStockCursor) m_currentCursor );
} }
else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END ) else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
{ {
m_requestAutoPan = false; SetAutoPanRequest( false );
GetParent()->HandleBlockEnd( nullptr ); GetParent()->HandleBlockEnd( nullptr );
//SetCursor( (wxStockCursor) m_currentCursor ); //SetCursor( (wxStockCursor) m_currentCursor );
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{ {
m_requestAutoPan = true; SetAutoPanRequest( true );
SetCursor( wxCURSOR_HAND ); SetCursor( wxCURSOR_HAND );
} }
} }
@ -575,7 +581,7 @@ void SCH_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title,
m_mouseCaptureCallback = NULL; m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL;
m_requestAutoPan = false; SetAutoPanRequest( false );
if( id != -1 && cursor != -1 ) if( id != -1 && cursor != -1 )
{ {

View File

@ -66,6 +66,7 @@ public:
void SetEnableMousewheelPan( bool aEnable ) override; void SetEnableMousewheelPan( bool aEnable ) override;
void SetEnableZoomNoCenter( bool aEnable ) override; void SetEnableZoomNoCenter( bool aEnable ) override;
void SetEnableAutoPan( bool aEnable ) override; void SetEnableAutoPan( bool aEnable ) override;
void SetAutoPanRequest( bool aEnable ) override;
BASE_SCREEN* GetScreen() override; BASE_SCREEN* GetScreen() override;
virtual EDA_DRAW_FRAME* GetParent() const override; virtual EDA_DRAW_FRAME* GetParent() const override;

View File

@ -46,8 +46,6 @@ protected:
bool m_enableAutoPan; ///< True to enable automatic panning. bool m_enableAutoPan; ///< True to enable automatic panning.
bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true.
bool m_ignoreMouseEvents; ///< Ignore mouse events when true. bool m_ignoreMouseEvents; ///< Ignore mouse events when true.
/* Used to inhibit a response to a mouse left button release, after a double click /* Used to inhibit a response to a mouse left button release, after a double click
@ -122,7 +120,7 @@ public:
virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; }; virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; };
void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; } virtual void SetAutoPanRequest( bool aEnable ) = 0;
void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; } void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; }