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

View File

@ -5784,9 +5784,10 @@ void AudacityProject::RemoveTrack(Track * toRemove)
bool toRemoveWasFocused = mTrackPanel->GetFocusedTrack() == toRemove;
Track* newFocus{};
if (toRemoveWasFocused) {
newFocus = mTracks->GetNext(toRemove, true);
auto iterNext = mTracks->FindLeader(toRemove), iterPrev = iterNext;
newFocus = *++iterNext;
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. */
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;
bool CanMoveUp(Track * t) const;
@ -1623,6 +1616,9 @@ private:
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;
template < typename TrackType >

View File

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

View File

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

View File

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