Fix cursor bugs in simulation.

1) cancel simProbe or simTune when simulator window closed
2) handle non-stock cursors through SetCurrentCursor()

Fixes: lp:1833583
* https://bugs.launchpad.net/kicad/+bug/1833583
This commit is contained in:
Jeff Young 2019-08-04 14:46:09 -06:00
parent 95bfb733ee
commit 97d70d7844
4 changed files with 26 additions and 37 deletions

View File

@ -61,11 +61,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_lostFocus = false;
m_stealsFocus = true;
#ifdef __WXMAC__
m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
#else
m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
#endif
m_defaultCursor = m_currentCursor = wxStockCursor( wxCURSOR_ARROW );
SetLayoutDirection( wxLayout_LeftToRight );
@ -502,18 +498,23 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
}
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aStockCursorID )
{
if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX )
m_currentCursor = aCursor;
else
m_currentCursor = wxCURSOR_ARROW;
if ( aStockCursorID <= wxCURSOR_NONE || aStockCursorID >= wxCURSOR_MAX )
aStockCursorID = wxCURSOR_ARROW;
SetCursor( (wxStockCursor) m_currentCursor );
SetCurrentCursor( wxCursor( aStockCursorID ) );
}
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( const wxCursor& aCursor )
{
m_currentCursor = aCursor;
SetCursor( m_currentCursor );
}
void EDA_DRAW_PANEL_GAL::onSetCursor( wxSetCursorEvent& event )
{
event.SetCursor( (wxStockCursor) m_currentCursor );
event.SetCursor( m_currentCursor );
}

View File

@ -67,7 +67,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCursor( m_cursor );
m_frame->GetCanvas()->SetCurrentCursor( m_cursor );
VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) );
if( evt->IsClick( BUT_LEFT ) )

View File

@ -1262,6 +1262,9 @@ void SIM_PLOT_FRAME::onClose( wxCloseEvent& aEvent )
if( IsSimulationRunning() )
m_simulator->Stop();
// Cancel a running simProbe or simTune tool
m_schematicFrame->GetToolManager()->RunAction( ACTIONS::cancelInteractive );
Destroy();
}

View File

@ -181,13 +181,8 @@ public:
* Function SetCurrentCursor
* Set the current cursor shape for this panel
*/
virtual void SetCurrentCursor( int aCursor );
/**
* Function GetDefaultCursor
* @return the default cursor shape
*/
virtual int GetDefaultCursor() const { return m_defaultCursor; }
void SetCurrentCursor( int aStockCursorID );
void SetCurrentCursor( const wxCursor& aCursor );
/**
* Returns the bounding box of the view that should be used if model is not valid
@ -213,22 +208,15 @@ protected:
static const int MinRefreshPeriod = 17; ///< 60 FPS.
/// Current mouse cursor shape id.
int m_currentCursor;
/// The default mouse cursor shape id.
int m_defaultCursor;
wxCursor m_currentCursor; /// Current mouse cursor shape id.
wxCursor m_defaultCursor; /// The default mouse cursor shape id.
/// Pointer to the parent window
wxWindow* m_parent;
wxWindow* m_parent; /// Pointer to the parent window
EDA_DRAW_FRAME* m_edaFrame; /// Parent EDA_DRAW_FRAME (if available)
/// Parent EDA_DRAW_FRAME (if available)
EDA_DRAW_FRAME* m_edaFrame;
/// Last timestamp when the panel was refreshed
wxLongLong m_lastRefresh;
/// Is there a redraw event requested?
bool m_pendingRefresh;
wxLongLong m_lastRefresh; /// Last timestamp when the panel was refreshed
bool m_pendingRefresh; /// Is there a redraw event requested?
wxTimer m_refreshTimer; /// Timer to prevent too-frequent refreshing
/// True if GAL is currently redrawing the view
bool m_drawing;
@ -236,9 +224,6 @@ protected:
/// Flag that determines if VIEW may use GAL for redrawing the screen.
bool m_drawingEnabled;
/// Timer responsible for preventing too frequent refresh
wxTimer m_refreshTimer;
/// Timer used to execute OnShow() when the window finally appears on the screen.
wxTimer m_onShowTimer;