AdornedRulerPanel updates its play region in idle time...

... Eliminating TP_DisplaySelection and making ProjectWindow independent of
AdornedRulerPanel
This commit is contained in:
Paul Licameli 2019-07-03 23:35:20 -04:00
parent 1c1aca521d
commit eb4eba6325
17 changed files with 28 additions and 85 deletions

View File

@ -380,6 +380,7 @@ enum {
};
BEGIN_EVENT_TABLE(AdornedRulerPanel, CellularPanel)
EVT_IDLE( AdornedRulerPanel::OnIdle )
EVT_PAINT(AdornedRulerPanel::OnPaint)
EVT_SIZE(AdornedRulerPanel::OnSize)
@ -1129,6 +1130,23 @@ namespace {
}
}
void AdornedRulerPanel::OnIdle( wxIdleEvent &evt )
{
evt.Skip();
auto &project = *mProject;
auto &viewInfo = ViewInfo::Get( project );
const auto &selectedRegion = viewInfo.selectedRegion;
auto &playRegion = ViewInfo::Get( project ).playRegion;
auto gAudioIO = AudioIOBase::Get();
if (!gAudioIO->IsBusy() && !playRegion.Locked())
SetPlayRegion( selectedRegion.t0(), selectedRegion.t1() );
else
// Cause ruler redraw anyway, because we may be zooming or scrolling
Refresh();
}
void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
{
evt.Skip();

View File

@ -76,6 +76,7 @@ public:
private:
void OnIdle( wxIdleEvent &evt );
void OnRecordStartStop(wxCommandEvent & evt);
void OnPaint(wxPaintEvent &evt);
void OnSize(wxSizeEvent &evt);

View File

@ -76,7 +76,6 @@ bool ProjectSelectionManager::SnapSelection()
if (t0 != oldt0 || t1 != oldt1) {
selectedRegion.setTimes(t0, t1);
window.TP_DisplaySelection();
return true;
}
}

View File

@ -12,7 +12,6 @@ Paul Licameli split from AudacityProject.cpp
#include "Experimental.h"
#include "AdornedRulerPanel.h"
#include "AllThemeResources.h"
#include "Menus.h"
#include "Project.h"
@ -1587,23 +1586,6 @@ void ProjectWindow::SkipEnd(bool shift)
ScrollIntoView(len);
}
void ProjectWindow::TP_DisplaySelection()
{
auto &project = mProject;
auto &ruler = AdornedRulerPanel::Get(project);
auto &viewInfo = ViewInfo::Get( project );
const auto &selectedRegion = viewInfo.selectedRegion;
auto &playRegion = ViewInfo::Get( project ).playRegion;
auto gAudioIO = AudioIOBase::Get();
if (!gAudioIO->IsBusy() && !playRegion.Locked())
ruler.SetPlayRegion( selectedRegion.t0(), selectedRegion.t1() );
else
// Cause ruler redraw anyway, because we may be zooming or scrolling
ruler.Refresh();
}
// TrackPanel callback method
void ProjectWindow::TP_ScrollLeft()
{

View File

@ -133,9 +133,6 @@ public:
wxSize GetTPTracksUsableArea() /* not override */;
void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
// TrackPanel callback methods, overrides of TrackPanelListener
void TP_DisplaySelection() override;
void TP_RedrawScrollbars() override;
void TP_ScrollLeft() override;
void TP_ScrollRight() override;

View File

@ -26,7 +26,7 @@ namespace RefreshCode
RefreshAll = 0x8,
FixScrollbars = 0x10,
Resize = 0x20,
UpdateSelection = 0x40,
/* 0x40 not used */
UpdateVRuler = 0x80, // of the clicked track
EnsureVisible = 0x100, // for the clicked track
DrawOverlays = 0x200,

View File

@ -429,9 +429,6 @@ void TrackPanel::OnTimer(wxTimerEvent& )
window.RedrawProject();
mRedrawAfterStop = false;
//ANSWER-ME: Was DisplaySelection added to solve a repaint problem?
DisplaySelection();
}
if (mLastDrawnSelectedRegion != mViewInfo->selectedRegion) {
UpdateSelectionDisplay();
@ -627,23 +624,6 @@ void TrackPanel::ProcessUIHandleResult
if (refreshResult & Resize)
panel->GetListener()->TP_HandleResize();
// This flag is superfluous if you do full refresh,
// because TrackPanel::Refresh() does this too
if (refreshResult & UpdateSelection) {
panel->DisplaySelection();
{
// Formerly in TrackPanel::UpdateSelectionDisplay():
// Make sure the ruler follows suit.
// mRuler->DrawSelection();
// ... but that too is superfluous it does nothing but refresh
// the ruler, while DisplaySelection calls TP_DisplaySelection which
// also always refreshes the ruler.
}
}
if ((refreshResult & RefreshCode::EnsureVisible) && pClickedTrack)
pClickedTrack->EnsureVisible();
}
@ -681,9 +661,6 @@ void TrackPanel::UpdateSelectionDisplay()
// Make sure the ruler follows suit.
mRuler->DrawSelection();
// As well as the SelectionBar.
DisplaySelection();
}
// Counts selected tracks, counting stereo tracks as one track.
@ -845,7 +822,6 @@ void TrackPanel::Refresh(bool eraseBackground /* = TRUE */,
mRefreshBacking = true;
}
wxWindow::Refresh(eraseBackground, rect);
DisplaySelection();
}
#include "TrackPanelDrawingContext.h"
@ -1337,17 +1313,6 @@ wxRect TrackPanel::FindTrackRect( const Track * target )
} );
}
/// Displays the bounds of the selection in the status bar.
void TrackPanel::DisplaySelection()
{
if (!mListener)
return;
// DM: Note that the Selection Bar can actually MODIFY the selection
// if snap-to mode is on!!!
mListener->TP_DisplaySelection();
}
TrackPanelCell *TrackPanel::GetFocusedCell()
{
auto pTrack = TrackFocus::Get( *GetProject() ).Get();

View File

@ -111,8 +111,6 @@ class AUDACITY_DLL_API TrackPanel final
void RefreshTrack(Track *trk, bool refreshbacking = true);
void DisplaySelection();
void HandlePageUpKey();
void HandlePageDownKey();
AudacityProject * GetProject() const override;

View File

@ -26,8 +26,6 @@ class AUDACITY_DLL_API TrackPanelListener /* not final */ {
TrackPanelListener(){};
virtual ~TrackPanelListener(){};
virtual void TP_DisplaySelection() = 0;
virtual void TP_RedrawScrollbars() = 0;
virtual void TP_ScrollLeft() = 0;
virtual void TP_ScrollRight() = 0;

View File

@ -259,11 +259,8 @@ void MoveWhenAudioInactive
// Move the visual cursor, avoiding an unnecessary complete redraw
trackPanel.DrawOverlays(false);
ruler.DrawOverlays(false);
// This updates the selection shown on the selection bar, and the play
// region
window.TP_DisplaySelection();
} else
}
else
{
// Transition to cursor mode.
if( seekStep < 0 )

View File

@ -119,8 +119,6 @@ void DoPlayStop(const CommandContext &context)
//play the front project
if (!gAudioIO->IsBusy()) {
//update the playing area
window.TP_DisplaySelection();
//Otherwise, start playing (assuming audio I/O isn't busy)
// Will automatically set mLastPlayMode

View File

@ -560,9 +560,6 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
projectAudioManager.Stop();
if (p)
ProjectWindow::Get( *p ).TP_DisplaySelection();
PlayDefault();
}

View File

@ -195,7 +195,7 @@ UIHandle::Result LabelTextHandle::Click
if (!unsafe)
ProjectHistory::Get( *pProject ).ModifyState(false);
return result | RefreshCode::RefreshCell | RefreshCode::UpdateSelection;
return result | RefreshCode::RefreshCell;
}
void LabelTextHandle::HandleTextDragRelease(

View File

@ -178,7 +178,7 @@ UIHandle::Result StretchHandle::Click
// newly selected tracks. (I'm really not sure if the label area
// needs to be refreshed or how to just refresh non-label areas.-RBD)
return RefreshAll | UpdateSelection;
return RefreshAll;
}
UIHandle::Result StretchHandle::Drag

View File

@ -162,7 +162,6 @@ UIHandle::Result CutlineHandle::Click
}
viewInfo.selectedRegion.setTimes(cutlineStart, cutlineEnd);
result |= UpdateSelection;
}
else if (mLocation.typ == WaveTrackLocation::locationMergePoint) {
const double pos = mLocation.pos;
@ -230,7 +229,6 @@ UIHandle::Result CutlineHandle::Release
case Expand:
ProjectHistory::Get( *pProject )
.PushState(_("Expanded Cut Line"), _("Expand"));
result |= RefreshCode::UpdateSelection;
break;
case Remove:
ProjectHistory::Get( *pProject )
@ -251,7 +249,6 @@ UIHandle::Result CutlineHandle::Cancel(AudacityProject *pProject)
AudacityProject &project = *pProject;
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
selectedRegion.setTimes( mStartTime, mEndTime );
result |= UpdateSelection;
}
return result;
}

View File

@ -181,9 +181,6 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
playPos,
viewInfo.GetScreenEndTime() + tolerance);
// This displays the audio time, too...
window.TP_DisplaySelection();
auto gAudioIO = AudioIO::Get();
// BG: Scroll screen if option is set

View File

@ -500,7 +500,6 @@ void SelectHandle::SetUseSnap(bool use)
ViewInfo::Get( *::GetActiveProject() ),
mUseSnap ? mSnapEnd.outTime : mSnapEnd.timeSnappedTime,
nullptr);
mChangeHighlight |= RefreshCode::UpdateSelection;
}
}
@ -585,7 +584,7 @@ UIHandle::Result SelectHandle::Click
ProjectHistory::Get( *pProject ).ModifyState(false);
// Do not start a drag
return RefreshAll | UpdateSelection | Cancelled;
return RefreshAll | Cancelled;
}
else if (!event.LeftDown())
return Cancelled;
@ -674,7 +673,7 @@ UIHandle::Result SelectHandle::Click
// Full refresh since the label area may need to indicate
// newly selected tracks.
return RefreshAll | UpdateSelection;
return RefreshAll;
}
// II. Unmodified click starts a NEW selection
@ -707,7 +706,7 @@ UIHandle::Result SelectHandle::Click
// For persistence of the selection change:
ProjectHistory::Get( *pProject ).ModifyState(false);
mSelectionBoundary = SBWidth;
return UpdateSelection;
return RefreshNone;
}
else
#endif
@ -779,7 +778,7 @@ UIHandle::Result SelectHandle::Click
});
Connect(pProject);
return RefreshAll | UpdateSelection;
return RefreshAll;
}
else {
Connect(pProject);