1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 00:30:07 +02:00

CellularPanel handles leave and capture loss like other transitions

This commit is contained in:
Paul Licameli 2018-07-26 08:47:51 -04:00
parent ff98ca5a32
commit 0fc4747742
2 changed files with 21 additions and 8 deletions

View File

@ -263,7 +263,9 @@ void CellularPanel::HandleMotion
// Now do the // Now do the
// UIHANDLE HIT TEST ! // UIHANDLE HIT TEST !
state.mTargets = newCell->HitTest(tpmState, GetProject()); state.mTargets.clear();
if (newCell)
state.mTargets = newCell->HitTest(tpmState, GetProject());
state.mTarget = 0; state.mTarget = 0;
@ -334,8 +336,18 @@ void CellularPanel::HandleMotion
if (pCursor) if (pCursor)
SetCursor( *pCursor ); SetCursor( *pCursor );
ProcessUIHandleResult( if (newCell)
newCell.get(), newCell.get(), refreshCode); ProcessUIHandleResult(newCell.get(), newCell.get(), refreshCode);
}
void CellularPanel::Leave()
{
// Make transition into an empty CellularPanel state
auto state = ::wxGetMouseState();
const wxRect rect;
std::shared_ptr<TrackPanelCell> pCell;
TrackPanelMouseState tpmState{ state, rect, pCell };
HandleMotion( tpmState );
} }
bool CellularPanel::HasRotation() bool CellularPanel::HasRotation()
@ -589,16 +601,17 @@ void CellularPanel::OnKeyUp(wxKeyEvent & event)
event.Skip(); event.Skip();
} }
/// Should handle the case when the mouse capture is lost. /// Should handle the case when the mouse capture is lost. (MSW only)
void CellularPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(event)) void CellularPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(event))
{ {
ClearTargets(); auto &state = *mState;
state.mUIHandle.reset();
Leave();
// This is bad. We are lying abou the event by saying it is a mouse up. // This is bad. We are lying abou the event by saying it is a mouse up.
wxMouseEvent e(wxEVT_LEFT_UP); wxMouseEvent e(wxEVT_LEFT_UP);
e.SetId( kCaptureLostEventId ); e.SetId( kCaptureLostEventId );
auto &state = *mState;
e.m_x = state.mMouseMostRecentX; e.m_x = state.mMouseMostRecentX;
e.m_y = state.mMouseMostRecentY; e.m_y = state.mMouseMostRecentY;
@ -660,8 +673,7 @@ try
if (event.Leaving()) if (event.Leaving())
{ {
if ( !state.mUIHandle ) Leave();
ClearTargets();
auto buttons = auto buttons =
// Bug 1325: button state in Leaving events is unreliable on Mac. // Bug 1325: button state in Leaving events is unreliable on Mac.

View File

@ -103,6 +103,7 @@ private:
void HandleMotion( wxMouseState &state, bool doHit = true ); void HandleMotion( wxMouseState &state, bool doHit = true );
void HandleMotion void HandleMotion
( const TrackPanelMouseState &tpmState, bool doHit = true ); ( const TrackPanelMouseState &tpmState, bool doHit = true );
void Leave();
protected: protected: