1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-18 17:10:05 +02:00

TrackList::GetPrev and ::GetNext are private

This commit is contained in:
Paul Licameli 2016-12-29 19:31:04 -05:00
parent a0e15cfbbd
commit 5c6fd64a0e
6 changed files with 35 additions and 36 deletions

View File

@ -3443,11 +3443,9 @@ void MenuCommandHandler::OnMoveToLabel(AudacityProject &project, bool next)
} }
else if (nLabelTrack > 1) { // find first label track, if any, starting at the focused track else if (nLabelTrack > 1) { // find first label track, if any, starting at the focused track
track = trackPanel->GetFocusedTrack(); track = trackPanel->GetFocusedTrack();
while (track && track->GetKind() != Track::Label) { track = *tracks->Find(track).Filter<LabelTrack>();
track = tracks->GetNext(track, true); if (!track) {
if (!track) { trackPanel->MessageForScreenReader(_("no label track at or below focused track"));
trackPanel->MessageForScreenReader(_("no label track at or below focused track"));
}
} }
} }
@ -3513,7 +3511,7 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
bool pSelected = false; bool pSelected = false;
if( shift ) if( shift )
{ {
p = tracks->GetPrev( t, true ); // Get previous track p = * -- tracks->FindLeader( t ); // Get previous track
if( p == NULL ) // On first track if( p == NULL ) // On first track
{ {
// JKC: wxBell() is probably for accessibility, so a blind // JKC: wxBell() is probably for accessibility, so a blind
@ -3537,7 +3535,7 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
{ {
selectionState.SelectTrack selectionState.SelectTrack
( *tracks, *t, false, false, mixerBoard ); ( *tracks, *t, false, false, mixerBoard );
trackPanel->SetFocusedTrack( p ); // move focus to next track down trackPanel->SetFocusedTrack( p ); // move focus to next track up
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
@ -3546,7 +3544,7 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
{ {
selectionState.SelectTrack selectionState.SelectTrack
( *tracks, *p, true, false, mixerBoard ); ( *tracks, *p, true, false, mixerBoard );
trackPanel->SetFocusedTrack( p ); // move focus to next track down trackPanel->SetFocusedTrack( p ); // move focus to next track up
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
@ -3555,7 +3553,7 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
{ {
selectionState.SelectTrack selectionState.SelectTrack
( *tracks, *p, false, false, mixerBoard ); ( *tracks, *p, false, false, mixerBoard );
trackPanel->SetFocusedTrack( p ); // move focus to next track down trackPanel->SetFocusedTrack( p ); // move focus to next track up
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
@ -3564,25 +3562,25 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
{ {
selectionState.SelectTrack selectionState.SelectTrack
( *tracks, *t, true, false, mixerBoard ); ( *tracks, *t, true, false, mixerBoard );
trackPanel->SetFocusedTrack( p ); // move focus to next track down trackPanel->SetFocusedTrack( p ); // move focus to next track up
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
} }
} }
else else
{ {
p = tracks->GetPrev( t, true ); // Get next track p = * -- tracks->FindLeader( t ); // Get previous track
if( p == NULL ) // On last track so stay there? if( p == NULL ) // On first track so stay there?
{ {
wxBell(); wxBell();
if( mCircularTrackNavigation ) if( mCircularTrackNavigation )
{ {
auto range = tracks->Leaders(); auto range = tracks->Leaders();
p = * range.rbegin(); // null if range is empty p = * range.rbegin(); // null if range is empty
trackPanel->SetFocusedTrack( p ); // Wrap to the first track trackPanel->SetFocusedTrack( p ); // Wrap to the last track
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
} }
else else
@ -3593,7 +3591,7 @@ void MenuCommandHandler::OnPrevTrack( AudacityProject &project, bool shift )
} }
else else
{ {
trackPanel->SetFocusedTrack( p ); // move focus to next track down trackPanel->SetFocusedTrack( p ); // move focus to next track up
trackPanel->EnsureVisible( p ); trackPanel->EnsureVisible( p );
project.ModifyState(false); project.ModifyState(false);
return; return;
@ -3628,7 +3626,7 @@ void MenuCommandHandler::OnNextTrack( AudacityProject &project, bool shift )
if( shift ) if( shift )
{ {
n = tracks->GetNext( t, true ); // Get next track n = * ++ tracks->FindLeader( t ); // Get next track
if( n == NULL ) // On last track so stay there if( n == NULL ) // On last track so stay there
{ {
wxBell(); wxBell();
@ -3684,7 +3682,7 @@ void MenuCommandHandler::OnNextTrack( AudacityProject &project, bool shift )
} }
else else
{ {
n = tracks->GetNext( t, true ); // Get next track n = * ++ tracks->FindLeader( t ); // Get next track
if( n == NULL ) // On last track so stay there if( n == NULL ) // On last track so stay there
{ {
wxBell(); wxBell();

View File

@ -5784,9 +5784,10 @@ void AudacityProject::RemoveTrack(Track * toRemove)
bool toRemoveWasFocused = mTrackPanel->GetFocusedTrack() == toRemove; bool toRemoveWasFocused = mTrackPanel->GetFocusedTrack() == toRemove;
Track* newFocus{}; Track* newFocus{};
if (toRemoveWasFocused) { if (toRemoveWasFocused) {
newFocus = mTracks->GetNext(toRemove, true); auto iterNext = mTracks->FindLeader(toRemove), iterPrev = iterNext;
newFocus = *++iterNext;
if (!newFocus) { if (!newFocus) {
newFocus = mTracks->GetPrev(toRemove, true); newFocus = *--iterPrev;
} }
} }

View File

@ -1526,13 +1526,6 @@ public:
/** Select a track, and if it is linked to another track, select it, too. */ /** Select a track, and if it is linked to another track, select it, too. */
void Select(Track * t, bool selected = true); void Select(Track * t, bool selected = true);
Track *GetPrev(Track * t, bool linked = false) const;
/** Return a track in the list that comes after Track t
* @param t a track in the list
* @param linked if true, skips over linked tracks, if false returns the next track even if it is a linked track
**/
Track *GetNext(Track * t, bool linked = false) const;
int GetGroupHeight(const Track * t) const; int GetGroupHeight(const Track * t) const;
bool CanMoveUp(Track * t) const; bool CanMoveUp(Track * t) const;
@ -1623,6 +1616,9 @@ private:
return { { b, b, e, pred }, { b, e, e, pred } }; return { { b, b, e, pred }, { b, e, e, pred } };
} }
Track *GetPrev(Track * t, bool linked = false) const;
Track *GetNext(Track * t, bool linked = false) const;
std::pair<Track *, Track *> FindSyncLockGroup(Track *pMember) const; std::pair<Track *, Track *> FindSyncLockGroup(Track *pMember) const;
template < typename TrackType > template < typename TrackType >

View File

@ -64,8 +64,8 @@ TrackPanelResizeHandle::TrackPanelResizeHandle
, mMouseClickY( y ) , mMouseClickY( y )
{ {
auto tracks = pProject->GetTracks(); auto tracks = pProject->GetTracks();
Track *prev = tracks->GetPrev(track.get()); auto prev = * -- tracks->Find(track.get());
Track *next = tracks->GetNext(track.get()); auto next = * ++ tracks->Find(track.get());
//STM: Determine whether we should rescale one or two tracks //STM: Determine whether we should rescale one or two tracks
if (prev && prev->GetLink() == track.get()) { if (prev && prev->GetLink() == track.get()) {
@ -184,13 +184,13 @@ UIHandle::Result TrackPanelResizeHandle::Drag
{ {
case IsResizingBelowLinkedTracks: case IsResizingBelowLinkedTracks:
{ {
Track *prev = tracks->GetPrev(pTrack.get()); auto prev = * -- tracks->Find(pTrack.get());
doResizeBelow(prev, false); doResizeBelow(prev, false);
break; break;
} }
case IsResizingBetweenLinkedTracks: case IsResizingBetweenLinkedTracks:
{ {
Track *next = tracks->GetNext(pTrack.get()); auto next = * ++ tracks->Find(pTrack.get());
doResizeBetween(next, false); doResizeBetween(next, false);
break; break;
} }
@ -244,7 +244,7 @@ UIHandle::Result TrackPanelResizeHandle::Cancel(AudacityProject *pProject)
break; break;
case IsResizingBetweenLinkedTracks: case IsResizingBetweenLinkedTracks:
{ {
Track *const next = tracks->GetNext(pTrack.get()); Track *const next = * ++ tracks->Find(pTrack.get());
pTrack->SetHeight(mInitialUpperActualHeight); pTrack->SetHeight(mInitialUpperActualHeight);
pTrack->SetMinimized(mInitialMinimized); pTrack->SetMinimized(mInitialMinimized);
next->SetHeight(mInitialActualHeight); next->SetHeight(mInitialActualHeight);
@ -253,7 +253,7 @@ UIHandle::Result TrackPanelResizeHandle::Cancel(AudacityProject *pProject)
break; break;
case IsResizingBelowLinkedTracks: case IsResizingBelowLinkedTracks:
{ {
Track *const prev = tracks->GetPrev(pTrack.get()); Track *const prev = * -- tracks->Find(pTrack.get());
pTrack->SetHeight(mInitialActualHeight); pTrack->SetHeight(mInitialActualHeight);
pTrack->SetMinimized(mInitialMinimized); pTrack->SetMinimized(mInitialMinimized);
prev->SetHeight(mInitialUpperActualHeight); prev->SetHeight(mInitialUpperActualHeight);

View File

@ -623,7 +623,7 @@ void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData)
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack); WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
TrackList *const tracks = project->GetTracks(); TrackList *const tracks = project->GetTracks();
Track *const next = tracks->GetNext(pTrack); auto next = * ++ tracks->Find(pTrack);
if (isMono) { if (isMono) {
const bool canMakeStereo = const bool canMakeStereo =

View File

@ -225,13 +225,17 @@ void TrackSelectHandle::CalculateRearrangingThresholds(const wxMouseEvent & even
if (tracks->CanMoveUp(mpTrack.get())) if (tracks->CanMoveUp(mpTrack.get()))
mMoveUpThreshold = mMoveUpThreshold =
event.m_y - tracks->GetGroupHeight(tracks->GetPrev(mpTrack.get(), true)); event.m_y -
tracks->GetGroupHeight(
* -- tracks->FindLeader( mpTrack.get() ) );
else else
mMoveUpThreshold = INT_MIN; mMoveUpThreshold = INT_MIN;
if (tracks->CanMoveDown(mpTrack.get())) if (tracks->CanMoveDown(mpTrack.get()))
mMoveDownThreshold = mMoveDownThreshold =
event.m_y + tracks->GetGroupHeight(tracks->GetNext(mpTrack.get(), true)); event.m_y +
tracks->GetGroupHeight(
* ++ tracks->FindLeader( mpTrack.get() ) );
else else
mMoveDownThreshold = INT_MAX; mMoveDownThreshold = INT_MAX;
} }