Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/AlphaTabApiBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ export class AlphaTabApiBase<TSettings> {
public set playbackRange(value: PlaybackRange | null) {
if (this.player) {
this.player.playbackRange = value;
if (this.settings.player.enableCursor) {
this.updateSelectionCursor(value);
}
}
}

Expand Down Expand Up @@ -798,7 +801,7 @@ export class AlphaTabApiBase<TSettings> {
if (
nextBeatBoundings &&
nextBeatBoundings.barBounds.masterBarBounds.staveGroupBounds ===
barBoundings.staveGroupBounds
barBoundings.staveGroupBounds
) {
nextBeatX = nextBeatBoundings.visualBounds.x;
}
Expand Down Expand Up @@ -962,6 +965,24 @@ export class AlphaTabApiBase<TSettings> {
this._beatMouseDown = false;
}

private updateSelectionCursor(range: PlaybackRange | null) {
if (!this._tickCache) {
return;
}
if(range) {
const startBeat = this._tickCache.findBeat(this.tracks, range.startTick);
const endBeat = this._tickCache.findBeat(this.tracks, range.endTick);
if (startBeat && endBeat) {
const selectionStart = new SelectionInfo(startBeat.currentBeat);
const selectionEnd = new SelectionInfo(endBeat.currentBeat);
this.cursorSelectRange(selectionStart, selectionEnd);
}
} else {
this.cursorSelectRange(null, null);
}

}

private setupClickHandling(): void {
this.canvasElement.mouseDown.on(e => {
if (!e.isLeftMouseButton) {
Expand Down