MCPcopy Create free account
hub / github.com/audacity/audacity / DoNextTrack

Function DoNextTrack

src/menus/NavigationMenus.cpp:183–284  ·  view source on GitHub ↗

The following method moves to the next track, selecting and unselecting depending if you are on the start of a block or not.

Source from the content-addressed store, hash-verified

181/// selecting and unselecting depending if you are on the start of a
182/// block or not.
183void DoNextTrack(
184 AudacityProject &project, bool shift, bool circularTrackNavigation )
185{
186 auto &projectHistory = ProjectHistory::Get(project);
187 auto &trackFocus = TrackFocus::Get(project);
188 auto &tracks = TrackList::Get(project);
189 auto &selectionState = SelectionState::Get(project);
190 auto &viewport = Viewport::Get(project);
191
192 const auto t = trackFocus.Get();
193 if (!t) {
194 // if there isn't one, focus on first
195 const auto first = *tracks.begin();
196 trackFocus.Set(first);
197 if (first) {
198 viewport.ShowTrack(*first);
199 projectHistory.ModifyState(false);
200 }
201 return;
202 }
203
204 if (shift) {
205 auto n = * ++ tracks.Find(t); // Get next track
206 if (!n) {
207 // On last track so stay there
208 wxBell();
209 if (circularTrackNavigation)
210 n = *tracks.begin();
211 else {
212 viewport.ShowTrack(*t);
213 return;
214 }
215 }
216 // If here, then there is a nonempty list and a next track
217 // (maybe circularly)
218 assert(n);
219 auto tSelected = t->GetSelected();
220 auto nSelected = n->GetSelected();
221 if (tSelected && nSelected) {
222 selectionState.SelectTrack(*t, false, false);
223 trackFocus.Set(n); // move focus to next track down
224 if (n) {
225 viewport.ShowTrack(*n);
226 projectHistory.ModifyState(false);
227 }
228 return;
229 }
230 if (tSelected && !nSelected) {
231 selectionState.SelectTrack(*n, true, false);
232 trackFocus.Set(n); // move focus to next track down
233 if (n) {
234 viewport.ShowTrack(*n);
235 projectHistory.ModifyState(false);
236 }
237 return;
238 }
239 if (!tSelected && nSelected) {
240 selectionState.SelectTrack(*n, false, false);

Callers 2

OnCursorDownMethod · 0.85
OnShiftDownMethod · 0.85

Calls 9

GetFunction · 0.85
ShowTrackMethod · 0.80
SelectTrackMethod · 0.80
GetMethod · 0.45
beginMethod · 0.45
SetMethod · 0.45
ModifyStateMethod · 0.45
FindMethod · 0.45
GetSelectedMethod · 0.45

Tested by

no test coverage detected