Use idle events to update TrackPanel cursor...
... As when recording starts or stops, or the Tools button has changed, or scrolling has changed the results of hit-test. This reduces TrackPanel's intrusions into other code, including ProjectHistory. Also for AdornedRulerPanel, which shares the base class CellularPanel
This commit is contained in:
parent
702199f9d9
commit
b7386c2db1
|
@ -984,8 +984,6 @@ void AdornedRulerPanel::UpdatePrefs()
|
|||
// Affected by the last
|
||||
UpdateRects();
|
||||
SetPanelSize();
|
||||
|
||||
RegenerateTooltips();
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::ReCreateButtons()
|
||||
|
@ -1121,11 +1119,6 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::RegenerateTooltips()
|
||||
{
|
||||
CallAfter( [this]{ HandleCursorForPresentMouseState(); } );
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
||||
{
|
||||
evt.Skip();
|
||||
|
@ -1142,8 +1135,6 @@ void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
|||
mIsRecording = false;
|
||||
UpdateButtonStates();
|
||||
}
|
||||
|
||||
RegenerateTooltips();
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
||||
|
@ -1796,7 +1787,6 @@ void AdornedRulerPanel::OnToggleQuickPlay(wxCommandEvent&)
|
|||
mQuickPlayEnabled = (mQuickPlayEnabled)? false : true;
|
||||
gPrefs->Write(wxT("/QuickPlay/QuickPlayEnabled"), mQuickPlayEnabled);
|
||||
gPrefs->Flush();
|
||||
RegenerateTooltips();
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnSyncSelToQuickPlay(wxCommandEvent&)
|
||||
|
@ -1834,7 +1824,6 @@ void AdornedRulerPanel::OnTimelineToolTips(wxCommandEvent&)
|
|||
mTimelineToolTip = (mTimelineToolTip)? false : true;
|
||||
gPrefs->Write(wxT("/QuickPlay/ToolTips"), mTimelineToolTip);
|
||||
gPrefs->Flush();
|
||||
RegenerateTooltips();
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnAutoScroll(wxCommandEvent&)
|
||||
|
|
|
@ -62,8 +62,6 @@ public:
|
|||
void UpdatePrefs() override;
|
||||
void ReCreateButtons();
|
||||
|
||||
void RegenerateTooltips();
|
||||
|
||||
void UpdateQuickPlayPos(wxCoord &mousePosX, bool shiftDown);
|
||||
|
||||
bool ShowingScrubRuler() const { return mShowScrubbing; }
|
||||
|
|
|
@ -103,6 +103,7 @@ BEGIN_EVENT_TABLE(CellularPanel, OverlayPanel)
|
|||
EVT_SET_FOCUS(CellularPanel::OnSetFocus)
|
||||
EVT_KILL_FOCUS(CellularPanel::OnKillFocus)
|
||||
EVT_CONTEXT_MENU(CellularPanel::OnContextMenu)
|
||||
EVT_IDLE(CellularPanel::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CellularPanel::CellularPanel(
|
||||
|
@ -472,6 +473,12 @@ void CellularPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event))
|
|||
DoContextMenu();
|
||||
}
|
||||
|
||||
void CellularPanel::OnIdle(wxIdleEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
HandleCursorForPresentMouseState();
|
||||
}
|
||||
|
||||
/// Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)
|
||||
void CellularPanel::HandleWheelRotation( TrackPanelMouseEvent &tpmEvent )
|
||||
{
|
||||
|
|
|
@ -134,6 +134,8 @@ private:
|
|||
|
||||
void OnContextMenu(wxContextMenuEvent & event);
|
||||
|
||||
void OnIdle(wxIdleEvent & event);
|
||||
|
||||
void HandleInterruptedDrag();
|
||||
void Uncapture( bool escaping, wxMouseState *pState = nullptr );
|
||||
bool HandleEscapeKey(bool down);
|
||||
|
|
|
@ -115,8 +115,6 @@ void ProjectHistory::PushState(const wxString &desc,
|
|||
ViewActions::DoZoomFitV( project );
|
||||
if((flags & UndoPush::AUTOSAVE) != UndoPush::MINIMAL)
|
||||
projectFileIO.AutoSave();
|
||||
|
||||
TrackPanel::Get( project ).HandleCursorForPresentMouseState();
|
||||
}
|
||||
|
||||
void ProjectHistory::RollbackState()
|
||||
|
@ -138,7 +136,6 @@ void ProjectHistory::ModifyState(bool bWantsAutoSave)
|
|||
&tracks, viewInfo.selectedRegion, tags.shared_from_this());
|
||||
if (bWantsAutoSave)
|
||||
projectFileIO.AutoSave();
|
||||
TrackPanel::Get( project ).HandleCursorForPresentMouseState();
|
||||
}
|
||||
|
||||
// LL: Is there a memory leak here as "l" and "t" are not deleted???
|
||||
|
|
|
@ -880,13 +880,6 @@ void ProjectWindow::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
|||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void ProjectWindow::RefreshCursor()
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
trackPanel.HandleCursorForPresentMouseState();
|
||||
}
|
||||
|
||||
void ProjectWindow::OnThemeChange(wxCommandEvent& evt)
|
||||
{
|
||||
evt.Skip();
|
||||
|
@ -1289,12 +1282,6 @@ void ProjectWindow::FixScrollbars()
|
|||
if (oldhstate != newhstate || oldvstate != newvstate) {
|
||||
UpdateLayout();
|
||||
}
|
||||
|
||||
wxWeakRef< TrackPanel > pPanel = &TrackPanel::Get( project );
|
||||
CallAfter( [pPanel]{
|
||||
if ( pPanel )
|
||||
pPanel->HandleCursorForPresentMouseState();
|
||||
} );
|
||||
}
|
||||
|
||||
void ProjectWindow::UpdateLayout()
|
||||
|
@ -1491,12 +1478,6 @@ void ProjectWindow::DoScroll()
|
|||
if (!mAutoScrolling) {
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
wxWeakRef< TrackPanel > pPanel = &TrackPanel::Get( project );
|
||||
CallAfter( [pPanel]{
|
||||
if ( pPanel )
|
||||
pPanel->HandleCursorForPresentMouseState();
|
||||
} );
|
||||
}
|
||||
|
||||
void ProjectWindow::OnMenu(wxCommandEvent & event)
|
||||
|
|
|
@ -85,7 +85,6 @@ public:
|
|||
wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
|
||||
|
||||
void RedrawProject(const bool bForceWaveTracks = false);
|
||||
void RefreshCursor();
|
||||
|
||||
void Zoom(double level);
|
||||
void ZoomInByFactor( double ZoomFactor );
|
||||
|
|
|
@ -313,9 +313,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||
mTracks->Bind(EVT_TRACKLIST_DELETION,
|
||||
&TrackPanel::OnTrackListDeletion,
|
||||
this);
|
||||
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
|
||||
&TrackPanel::OnPlayback,
|
||||
this);
|
||||
|
||||
auto theProject = GetProject();
|
||||
theProject->Bind(EVT_ODTASK_UPDATE, &TrackPanel::OnODTask, this);
|
||||
|
@ -429,6 +426,7 @@ AudacityProject * TrackPanel::GetProject() const
|
|||
|
||||
void TrackPanel::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
// The window must be ready when the timer fires (#1401)
|
||||
if (IsShownOnScreen())
|
||||
{
|
||||
|
@ -792,15 +790,6 @@ void TrackPanel::UpdateViewIfNoTracks()
|
|||
}
|
||||
}
|
||||
|
||||
void TrackPanel::OnPlayback(wxEvent &e)
|
||||
{
|
||||
e.Skip();
|
||||
// Starting or stopping of play or record affects some cursors.
|
||||
// Start or stop is in progress now, not completed; so delay the cursor
|
||||
// change until next idle time.
|
||||
CallAfter( [this] { HandleCursorForPresentMouseState(); } );
|
||||
}
|
||||
|
||||
// The tracks positions within the list have changed, so update the vertical
|
||||
// ruler size for the track that triggered the event.
|
||||
void TrackPanel::OnTrackListResizing(TrackListEvent & e)
|
||||
|
|
|
@ -276,7 +276,6 @@ class AUDACITY_DLL_API TrackPanel final
|
|||
void OnMouseEvent(wxMouseEvent & event);
|
||||
void OnKeyDown(wxKeyEvent & event);
|
||||
|
||||
void OnPlayback(wxEvent &);
|
||||
void OnTrackListResizing(TrackListEvent & event);
|
||||
void OnTrackListDeletion(wxEvent & event);
|
||||
void UpdateViewIfNoTracks(); // Call this to update mViewInfo, etc, after track(s) removal, before Refresh().
|
||||
|
|
|
@ -138,6 +138,7 @@ ScreenshotCommand * ScreenshotCommand::mpShooter=NULL;
|
|||
// fully created. Usually the dialog will have been created by invoking
|
||||
// an effects gui.
|
||||
void IdleHandler(wxIdleEvent& event){
|
||||
event.Skip();
|
||||
wxWindow * pWin = dynamic_cast<wxWindow*>(event.GetEventObject());
|
||||
wxASSERT( pWin );
|
||||
pWin->Unbind(wxEVT_IDLE, IdleHandler);
|
||||
|
|
|
@ -233,10 +233,6 @@ void ToolsToolBar::SetCurrentTool(int tool)
|
|||
//for ( auto pProject : AllProjects{} )
|
||||
// ProjectWindow::Get( *pProject ).RedrawProject();
|
||||
|
||||
//msmeyer: But we instruct the projects to handle the cursor shape again
|
||||
for ( auto pProject : AllProjects{} )
|
||||
ProjectWindow::Get( *pProject ).RefreshCursor();
|
||||
|
||||
gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
|
||||
IsDown(multiTool));
|
||||
gPrefs->Flush();
|
||||
|
|
Loading…
Reference in New Issue