Skip to content

Commit

Permalink
left/right arrow with and without ctrl/command during playback moves …
Browse files Browse the repository at this point in the history
…from playback cursor location

- left/right arrow: move between beats
- left/right arrow + ctrl/command: move between measures
  • Loading branch information
22justinl committed Aug 12, 2023
1 parent efd683d commit dd35901
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,45 @@ void NotationActionController::move(MoveDirection direction, bool quickly)
return;
}

if (playbackController()->isPlaying()) {
// Use current playback location (instead of selection) to move
auto beat = m_playbackController->currentBeat();
int targetBeatIdx = beat.beatIndex;
int targetMeasureIdx = beat.measureIndex;
int increment = (direction == MoveDirection::Right ? 1 : -1);

if (quickly) {
// Move to next/prev measure
targetBeatIdx = 0;
targetMeasureIdx += increment;
} else {
// Move to next/prev beat
targetBeatIdx += increment;
if (targetBeatIdx > beat.maxBeatIndex) {
// Next measure
targetBeatIdx = 0;
targetMeasureIdx += 1;
} else if (targetBeatIdx < 0) {
// Previous measure
targetBeatIdx = beat.maxBeatIndex;
targetMeasureIdx -= 1;
}
}

//Check invalid measure
if (targetMeasureIdx > beat.maxMeasureIndex) {
targetBeatIdx = beat.maxBeatIndex;
targetMeasureIdx = beat.maxMeasureIndex;
} else if (targetMeasureIdx < 0) {
targetBeatIdx = 0;
targetMeasureIdx = 0;
}

audio::msecs_t targetMs = m_playbackController->beatToMilliseconds(targetMeasureIdx, targetBeatIdx);
m_playbackController->seek(targetMs);
return;
}

if (selectedElement && selectedElement->isTextBase()) {
interaction->nudge(direction, quickly);
} else {
Expand Down

0 comments on commit dd35901

Please sign in to comment.