@coderline/alphatab 1.8.0-alpha.1650 → 1.8.0-alpha.1653

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -364,6 +364,7 @@ export declare class AlphaTabApiBase<TSettings> {
364
364
  private _actualPlayerMode;
365
365
  private _player;
366
366
  private _renderer;
367
+ private _defaultScrollHandler?;
367
368
  /**
368
369
  * An indicator by how many midi-ticks the song contents are shifted.
369
370
  * Grace beats at start might require a shift for the first beat to start at 0.
@@ -836,6 +837,42 @@ export declare class AlphaTabApiBase<TSettings> {
836
837
  */
837
838
  render(): void;
838
839
  private _tickCache;
840
+ /**
841
+ * A custom scroll handler which will be used to handle scrolling operations during playback.
842
+ *
843
+ * @category Properties - Player
844
+ * @since 1.8.0
845
+ * @example
846
+ * JavaScript
847
+ * ```js
848
+ * const api = new alphaTab.AlphaTabApi(document.querySelector('#alphaTab'));
849
+ * api.customScrollHandler = {
850
+ * forceScrollTo(currentBeatBounds) {
851
+ * const scroll = api.uiFacade.getScrollElement();
852
+ * api.uiFacade.scrollToY(scroll, currentBeatBounds.barBounds.masterBarBounds.realBounds.y, 0);
853
+ * },
854
+ * onBeatCursorUpdating(startBeat, endBeat, cursorMode, relativePosition, actualBeatCursorStartX, actualBeatCursorEndX, actualBeatCursorTransitionDuration) {
855
+ * const scroll = api.uiFacade.getScrollElement();
856
+ * api.uiFacade.scrollToY(scroll, startBeat.barBounds.masterBarBounds.realBounds.y, 0);
857
+ * }
858
+ * }
859
+ * ```
860
+ *
861
+ * @example
862
+ * C#
863
+ * ```cs
864
+ * var api = new AlphaTabApi<MyControl>(...);
865
+ * api.CustomScrollHandler = new CustomScrollHandler();
866
+ * ```
867
+ *
868
+ * @example
869
+ * Android
870
+ * ```kotlin
871
+ * val api = AlphaTabApi<MyControl>(...)
872
+ * api.customScrollHandler = CustomScrollHandler();
873
+ * ```
874
+ */
875
+ customScrollHandler?: IScrollHandler;
839
876
  /**
840
877
  * The tick cache allowing lookup of midi ticks to beats.
841
878
  * @remarks
@@ -1643,9 +1680,12 @@ export declare class AlphaTabApiBase<TSettings> {
1643
1680
  private _isInitialBeatCursorUpdate;
1644
1681
  private _previousStateForCursor;
1645
1682
  private _previousCursorCache;
1646
- private _lastScroll;
1647
1683
  private _destroyCursors;
1684
+ private _createCursors;
1648
1685
  private _updateCursors;
1686
+ private _scrollHandlerMode;
1687
+ private _scrollHandlerVertical;
1688
+ private _updateScrollHandler;
1649
1689
  /**
1650
1690
  * updates the cursors to highlight the beat at the specified tick position
1651
1691
  * @param tick
@@ -1663,7 +1703,6 @@ export declare class AlphaTabApiBase<TSettings> {
1663
1703
  * @category Methods - Player
1664
1704
  */
1665
1705
  scrollToCursor(): void;
1666
- private _internalScrollToCursor;
1667
1706
  private _internalCursorUpdateBeat;
1668
1707
  /**
1669
1708
  * This event is fired when the played beat changed.
@@ -9776,6 +9815,47 @@ declare interface IScoreRenderer {
9776
9815
  readonly error: IEventEmitterOfT<Error>;
9777
9816
  }
9778
9817
 
9818
+ /**
9819
+ * Classes implementing this interface can handle the scroll logic
9820
+ * as the playback in alphaTab progresses.
9821
+ *
9822
+ *
9823
+ * @public
9824
+ */
9825
+ export declare interface IScrollHandler extends Disposable {
9826
+ /**
9827
+ * Requests a instant scrolling to the specified beat.
9828
+ * @param currentBeatBounds The bounds and information about the current beat.
9829
+ */
9830
+ forceScrollTo(currentBeatBounds: BeatBounds): void;
9831
+ /**
9832
+ * Updates whenever the currently beat cursor is updating its start and end location
9833
+ * from which it starts and animates to.
9834
+ * @remarks
9835
+ * This method is tightly coupled to how alphaTab internally handles the beat cursor display.
9836
+ * alphaTab looks up the current and next beat to which the beat cursor needs to transition
9837
+ * in a specific amount of time.
9838
+ *
9839
+ * In some occations the cursor will transition to the end of the bar instead of the next beat.
9840
+ *
9841
+ * @param startBeat the information about the beat where the cursor is starting its animation.
9842
+ * @param endBeat the information about the beat where the cursor is ending its animation.
9843
+ * @param cursorMode how the cursor is transitioning (e.g. to end of bar or to the location of the next beat)
9844
+ * @param actualBeatCursorStartX the exact start position of the beat cursor animation.
9845
+ * Depending on the exact time of the player, this position might be relatively adjusted.
9846
+ * @param actualBeatCursorEndX the exact end position of the beat cursor animation.
9847
+ * Depending on the exact time of the player and cursor mode,
9848
+ * this might be beyond the expected bounds.
9849
+ * To ensure a smooth cursor experience (no jumping/flicking back and forth), alphaTab
9850
+ * optimizes the used end position and animation durations.
9851
+ * @param actualBeatCursorTransitionDuration The duration of the beat cursor transition in milliseconds.
9852
+ * Similar to the start and end positions, this duration is adjusted accordingly to ensure
9853
+ * that the beat cursor remains smoothly at the expected position for the currently played time.
9854
+ *
9855
+ */
9856
+ onBeatCursorUpdating(startBeat: BeatBounds, endBeat: BeatBounds | undefined, cursorMode: MidiTickLookupFindBeatResultCursorMode, actualBeatCursorStartX: number, actualBeatCursorEndX: number, actualBeatCursorTransitionDuration: number): void;
9857
+ }
9858
+
9779
9859
  /**
9780
9860
  * This is the base interface for output devices which can
9781
9861
  * request and playback audio samples.
@@ -10007,6 +10087,11 @@ declare interface IUiFacade<TSettings> {
10007
10087
  * @param speed How fast the scrolling from the current offset to the given one should happen in milliseconds.
10008
10088
  */
10009
10089
  scrollToX(scrollElement: IContainer, offset: number, speed: number): void;
10090
+ /**
10091
+ * Stops any ongoing scrolling of the given element.
10092
+ * @param scrollElement The element which might be scrolling dynamically.
10093
+ */
10094
+ stopScrolling(scrollElement: IContainer): void;
10010
10095
  /**
10011
10096
  * Attempts a load of the score represented by the given data object.
10012
10097
  * @param data The data object to decode
@@ -10022,6 +10107,17 @@ declare interface IUiFacade<TSettings> {
10022
10107
  * @returns true if the data object is supported and a load was initiated, otherwise false
10023
10108
  */
10024
10109
  loadSoundFont(data: unknown, append: boolean): boolean;
10110
+ /**
10111
+ * Updates the overflows needed to ensure the smooth scrolling
10112
+ * can reach the "end" at the desired position.
10113
+ * @param canvasElement The canvas element.
10114
+ * @param offset The offset we need
10115
+ * @param isVertical Whether we have a vertical or horizontal overflow
10116
+ * @remarks
10117
+ * Without these overflows we might not have enough scroll space
10118
+ * and we cannot reach a "sticky cursor" behavior.
10119
+ */
10120
+ setCanvasOverflow(canvasElement: IContainer, overflow: number, isVertical: boolean): void;
10025
10121
  /**
10026
10122
  * This events is fired when the {@link canRender} property changes.
10027
10123
  */
@@ -10514,7 +10610,7 @@ declare class MasterBar {
10514
10610
  */
10515
10611
  declare class MasterBarBounds {
10516
10612
  /**
10517
- * Gets or sets the index of this bounds relative within the parent lookup.
10613
+ * The MasterBar index within the data model represented by these bounds.
10518
10614
  */
10519
10615
  index: number;
10520
10616
  /**
@@ -14707,7 +14803,13 @@ export declare enum ScrollMode {
14707
14803
  /**
14708
14804
  * Scrolling happens as soon the cursors exceed the displayed range.
14709
14805
  */
14710
- OffScreen = 2
14806
+ OffScreen = 2,
14807
+ /**
14808
+ * Scrolling happens constantly in a smooth fashion.
14809
+ * This will disable the use of any native scroll optimizations but
14810
+ * manually scroll the scroll container in the required speed.
14811
+ */
14812
+ Smooth = 3
14711
14813
  }
14712
14814
 
14713
14815
  /**