The following method moves to the next track, selecting and unselecting depending if you are on the start of a block or not.
| 181 | /// selecting and unselecting depending if you are on the start of a |
| 182 | /// block or not. |
| 183 | void 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); |
no test coverage detected