mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-04 17:49:45 +02:00
Cursor handling always relies on current mouse state, not remembered
This commit is contained in:
parent
308d89b0e6
commit
4ec6baf059
@ -1386,7 +1386,7 @@ void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
|||||||
|
|
||||||
void AudacityProject::RefreshCursor()
|
void AudacityProject::RefreshCursor()
|
||||||
{
|
{
|
||||||
mTrackPanel->HandleCursorForLastMouseState();
|
mTrackPanel->HandleCursorForPresentMouseState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudacityProject::SetSel0(double newSel0)
|
void AudacityProject::SetSel0(double newSel0)
|
||||||
|
@ -757,7 +757,7 @@ void TrackPanel::Uncapture(wxMouseEvent *pEvent)
|
|||||||
{
|
{
|
||||||
if (HasCapture())
|
if (HasCapture())
|
||||||
ReleaseMouse();
|
ReleaseMouse();
|
||||||
HandleMotion( pEvent );
|
HandleMotion( *pEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::CancelDragging()
|
void TrackPanel::CancelDragging()
|
||||||
@ -812,14 +812,9 @@ void TrackPanel::UpdateMouseState(const wxMouseState &state)
|
|||||||
|
|
||||||
void TrackPanel::HandleModifierKey()
|
void TrackPanel::HandleModifierKey()
|
||||||
{
|
{
|
||||||
// Get the button and key states
|
HandleCursorForPresentMouseState();
|
||||||
auto state = ::wxGetMouseState();
|
|
||||||
// Remap the position
|
|
||||||
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
|
||||||
|
|
||||||
UpdateMouseState(state);
|
|
||||||
HandleCursorForLastMouseState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandlePageUpKey()
|
void TrackPanel::HandlePageUpKey()
|
||||||
{
|
{
|
||||||
mListener->TP_ScrollWindow(2 * mViewInfo->h - GetScreenEndTime());
|
mListener->TP_ScrollWindow(2 * mViewInfo->h - GetScreenEndTime());
|
||||||
@ -830,12 +825,19 @@ void TrackPanel::HandlePageDownKey()
|
|||||||
mListener->TP_ScrollWindow(GetScreenEndTime());
|
mListener->TP_ScrollWindow(GetScreenEndTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandleCursorForLastMouseState()
|
void TrackPanel::HandleCursorForPresentMouseState()
|
||||||
{
|
{
|
||||||
// Come here on modifier key or mouse button transitions,
|
// Come here on modifier key or mouse button transitions,
|
||||||
// or on starting or stopping of play or record,
|
// or on starting or stopping of play or record,
|
||||||
|
// or change of toolbar button,
|
||||||
// and change the cursor appropriately.
|
// and change the cursor appropriately.
|
||||||
HandleMotion( &mLastMouseState );
|
|
||||||
|
// Get the button and key states
|
||||||
|
auto state = ::wxGetMouseState();
|
||||||
|
// Remap the position
|
||||||
|
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
||||||
|
|
||||||
|
HandleMotion( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackPanel::IsAudioActive()
|
bool TrackPanel::IsAudioActive()
|
||||||
@ -852,20 +854,15 @@ bool TrackPanel::IsAudioActive()
|
|||||||
/// may cause the appropriate cursor and message to change.
|
/// may cause the appropriate cursor and message to change.
|
||||||
/// As this procedure checks which region the mouse is over, it is
|
/// As this procedure checks which region the mouse is over, it is
|
||||||
/// appropriate to establish the message in the status bar.
|
/// appropriate to establish the message in the status bar.
|
||||||
void TrackPanel::HandleMotion( wxMouseState *pState )
|
void TrackPanel::HandleMotion( wxMouseState &inState )
|
||||||
{
|
{
|
||||||
wxMouseState dummy;
|
UpdateMouseState( inState );
|
||||||
if (!pState)
|
|
||||||
pState = &dummy;
|
|
||||||
else
|
|
||||||
UpdateMouseState( *pState ), pState = &mLastMouseState;
|
|
||||||
auto &state = *pState;
|
|
||||||
|
|
||||||
const auto foundCell = FindCell( state.m_x, state.m_y );
|
const auto foundCell = FindCell( inState.m_x, inState.m_y );
|
||||||
auto &track = foundCell.pTrack;
|
auto &track = foundCell.pTrack;
|
||||||
auto &rect = foundCell.rect;
|
auto &rect = foundCell.rect;
|
||||||
auto &pCell = foundCell.pCell;
|
auto &pCell = foundCell.pCell;
|
||||||
const TrackPanelMouseState tpmState{ state, rect, pCell };
|
const TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
|
||||||
HandleMotion( tpmState );
|
HandleMotion( tpmState );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1036,7 +1033,7 @@ void TrackPanel::OnPlayback(wxCommandEvent &e)
|
|||||||
// Starting or stopping of play or record affects some cursors.
|
// Starting or stopping of play or record affects some cursors.
|
||||||
// Start or stop is in progress now, not completed; so delay the cursor
|
// Start or stop is in progress now, not completed; so delay the cursor
|
||||||
// change until next idle time.
|
// change until next idle time.
|
||||||
CallAfter( [this] { HandleCursorForLastMouseState(); } );
|
CallAfter( [this] { HandleCursorForPresentMouseState(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
// The tracks positions within the list have changed, so update the vertical
|
// The tracks positions within the list have changed, so update the vertical
|
||||||
@ -1554,7 +1551,7 @@ try
|
|||||||
// consider it not a drag, even if button is down during motion, if
|
// consider it not a drag, even if button is down during motion, if
|
||||||
// mUIHandle is null, as it becomes during interrupted drag
|
// mUIHandle is null, as it becomes during interrupted drag
|
||||||
// (e.g. by hitting space to play while dragging an envelope point)
|
// (e.g. by hitting space to play while dragging an envelope point)
|
||||||
HandleMotion( &event );
|
HandleMotion( event );
|
||||||
else if ( event.ButtonDown() || event.ButtonDClick() )
|
else if ( event.ButtonDown() || event.ButtonDClick() )
|
||||||
HandleClick( tpmEvent );
|
HandleClick( tpmEvent );
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
|
|||||||
Track *GetFocusedTrack();
|
Track *GetFocusedTrack();
|
||||||
void SetFocusedTrack(Track *t);
|
void SetFocusedTrack(Track *t);
|
||||||
|
|
||||||
void HandleCursorForLastMouseState();
|
void HandleCursorForPresentMouseState();
|
||||||
|
|
||||||
void UpdateVRulers();
|
void UpdateVRulers();
|
||||||
void UpdateVRuler(Track *t);
|
void UpdateVRuler(Track *t);
|
||||||
@ -377,7 +377,7 @@ protected:
|
|||||||
};
|
};
|
||||||
FoundCell FindCell(int mouseX, int mouseY);
|
FoundCell FindCell(int mouseX, int mouseY);
|
||||||
|
|
||||||
void HandleMotion( wxMouseState *pState );
|
void HandleMotion( wxMouseState &state );
|
||||||
void HandleMotion( const TrackPanelMouseState &tpmState );
|
void HandleMotion( const TrackPanelMouseState &tpmState );
|
||||||
|
|
||||||
// If label, rectangle includes track control panel only.
|
// If label, rectangle includes track control panel only.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user