Skip to content

Commit

Permalink
Add UI follows track cursor selection
Browse files Browse the repository at this point in the history
  • Loading branch information
dozius committed Jan 2, 2022
1 parent b42843a commit 3324b86
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/io/github/dozius/TwisterSisterExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ private void addTrackKnobs()
sendBank.itemCount().markInterested();
send.sendChannelColor().markInterested();

setupUIFollowsCursor(cursorTrack);

final TwisterKnob selectionKnob = knobs[0];
selectionKnob.setBinding(cursorTrack);
selectionKnob.ringLight().observeValue(new CursorNormalizedValue(cursorTrack, trackBank));
Expand Down Expand Up @@ -374,6 +376,25 @@ private void addDeviceKnobs()
}
}

/**
* Makes the UI follow the track cursor selection.
*
* Only follows when the cursor is not pinned.
*
* @param cursorTrack The cursor to follow.
*/
private void setupUIFollowsCursor(CursorTrack cursorTrack)
{
cursorTrack.isPinned().markInterested();

cursorTrack.position().addValueObserver((position) -> {
if (!cursorTrack.isPinned().get()) {
cursorTrack.makeVisibleInArranger();
cursorTrack.makeVisibleInMixer();
}
});
}

/**
* Helper to bind a pinnable cursors pinned state to a light indicator.
*
Expand Down

0 comments on commit 3324b86

Please sign in to comment.