diff --git a/src.csharp/AlphaTab.Windows/WinForms/ControlContainer.cs b/src.csharp/AlphaTab.Windows/WinForms/ControlContainer.cs index 533961807..1b71c0179 100644 --- a/src.csharp/AlphaTab.Windows/WinForms/ControlContainer.cs +++ b/src.csharp/AlphaTab.Windows/WinForms/ControlContainer.cs @@ -105,39 +105,12 @@ public void Clear() Control.Controls.Clear(); } - private readonly Bounds _lastBounds = new Bounds(); - - public Bounds GetBounds() - { - return _lastBounds; - } - public void SetBounds(double x, double y, double w, double h) { - if (double.IsNaN(x)) - { - x = _lastBounds.X; - } - if (double.IsNaN(y)) - { - y = _lastBounds.Y; - } - if (double.IsNaN(w)) - { - w = _lastBounds.W; - } - if (double.IsNaN(h)) - { - h = _lastBounds.H; - } Control.Left = (int)x; Control.Top = (int)y; Control.Width = (int)w; Control.Height = (int)h; - _lastBounds.X = x; - _lastBounds.Y = y; - _lastBounds.W = w; - _lastBounds.H = h; } public IEventEmitter Resize { get; set; } diff --git a/src.csharp/AlphaTab.Windows/Wpf/FrameworkElementContainer.cs b/src.csharp/AlphaTab.Windows/Wpf/FrameworkElementContainer.cs index b0703da52..701c7217c 100644 --- a/src.csharp/AlphaTab.Windows/Wpf/FrameworkElementContainer.cs +++ b/src.csharp/AlphaTab.Windows/Wpf/FrameworkElementContainer.cs @@ -130,40 +130,12 @@ public void Clear() } } - private readonly Bounds _lastBounds = new Bounds(); - - public Bounds GetBounds() - { - return _lastBounds; - } - public void SetBounds(double x, double y, double w, double h) { - if (double.IsNaN(x)) - { - x = _lastBounds.X; - } - if (double.IsNaN(y)) - { - y = _lastBounds.Y; - } - if (double.IsNaN(w)) - { - w = _lastBounds.W; - } - if (double.IsNaN(h)) - { - h = _lastBounds.H; - } - Canvas.SetLeft(Control, x); Canvas.SetTop(Control, y); Control.Width = w; Control.Height = h; - _lastBounds.X = x; - _lastBounds.Y = y; - _lastBounds.W = w; - _lastBounds.H = h; } public IEventEmitter Resize { get; set; } diff --git a/src/AlphaTabApiBase.ts b/src/AlphaTabApiBase.ts index 215265ccf..09dc1a91f 100644 --- a/src/AlphaTabApiBase.ts +++ b/src/AlphaTabApiBase.ts @@ -761,13 +761,13 @@ export class AlphaTabApiBase { this._playerState = PlayerState.Paused; // we need to update our position caches if we render a tablature this.renderer.postRenderFinished.on(() => { - this.cursorUpdateTick(this._previousTick, false, true); + this.cursorUpdateTick(this._previousTick, false); }); if (this.player) { this.player.positionChanged.on(e => { this._previousTick = e.currentTick; this.uiFacade.beginInvoke(() => { - this.cursorUpdateTick(e.currentTick, false, e.isSeek); + this.cursorUpdateTick(e.currentTick, false); }); }); this.player.stateChanged.on(e => { @@ -790,14 +790,14 @@ export class AlphaTabApiBase { * @param tick * @param stop */ - private cursorUpdateTick(tick: number, stop: boolean, forceImmediateUpdate: boolean): void { + private cursorUpdateTick(tick: number, stop: boolean): void { let cache: MidiTickLookup | null = this._tickCache; if (cache) { let tracks: Track[] = this.tracks; if (tracks.length > 0) { let beat: MidiTickLookupFindBeatResult | null = cache.findBeat(tracks, tick, this._currentBeat); if (beat) { - this.cursorUpdateBeat(beat, stop, forceImmediateUpdate); + this.cursorUpdateBeat(beat, stop); } } } @@ -808,8 +808,7 @@ export class AlphaTabApiBase { */ private cursorUpdateBeat( lookupResult: MidiTickLookupFindBeatResult, - stop: boolean, - forceImmediateUpdate: boolean + stop: boolean ): void { const beat: Beat = lookupResult.currentBeat; const nextBeat: Beat | null = lookupResult.nextBeat; @@ -845,8 +844,7 @@ export class AlphaTabApiBase { stop, beatsToHighlight, cache!, - beatBoundings!, - forceImmediateUpdate + beatBoundings! ); }); } @@ -858,24 +856,17 @@ export class AlphaTabApiBase { stop: boolean, beatsToHighlight: Beat[] | null, cache: BoundsLookup, - beatBoundings: BeatBounds, - forceImmediateUpdate: boolean + beatBoundings: BeatBounds ) { let barCursor: IContainer = this._barCursor!; let beatCursor: IContainer = this._beatCursor!; let barBoundings: MasterBarBounds = beatBoundings.barBounds.masterBarBounds; let barBounds: Bounds = barBoundings.visualBounds; - let needsNewAnimationFrame = false; barCursor.setBounds(barBounds.x, barBounds.y, barBounds.w, barBounds.h); // move beat to start position immediately - const previousBeatBounds: Bounds = beatCursor.getBounds(); - needsNewAnimationFrame = - forceImmediateUpdate || - previousBeatBounds!.y !== barBounds.y || - beatBoundings.visualBounds.x < previousBeatBounds!.x; if (this.settings.player.enableAnimatedBeatCursor) { beatCursor.stopAnimation(); } @@ -918,16 +909,9 @@ export class AlphaTabApiBase { // we need to put the transition to an own animation frame // otherwise the stop animation above is not applied. - // but only if we changed on the y axis. - // as long we scroll horizontally we can keep the animation - // alive. - if (needsNewAnimationFrame) { - this.uiFacade.beginInvoke(() => { - beatCursor!.transitionToX(duration, nextBeatX); - }); - } else { - beatCursor.transitionToX(duration, nextBeatX); - } + this.uiFacade.beginInvoke(() => { + beatCursor!.transitionToX(duration, nextBeatX); + }); } } if (!this._beatMouseDown && this.settings.player.scrollMode !== ScrollMode.Off) { @@ -1081,7 +1065,7 @@ export class AlphaTabApiBase { // move to selection start this._currentBeat = null; // reset current beat so it is updating the cursor if (this._playerState === PlayerState.Paused) { - this.cursorUpdateTick(this._selectionStart.beat.absolutePlaybackStart, false, true); + this.cursorUpdateTick(this._selectionStart.beat.absolutePlaybackStart, false); } this.tickPosition = realMasterBarStart + this._selectionStart.beat.playbackStart; // set playback range diff --git a/src/platform/IContainer.ts b/src/platform/IContainer.ts index b838fbd1d..a1fd3262d 100644 --- a/src/platform/IContainer.ts +++ b/src/platform/IContainer.ts @@ -1,6 +1,5 @@ import { IEventEmitter, IEventEmitterOfT } from '@src/EventEmitter'; import { IMouseEventArgs } from '@src/platform/IMouseEventArgs'; -import { Bounds } from '@src/rendering/utils/Bounds'; /** * This interface represents a container control in the UI layer. @@ -51,12 +50,6 @@ export interface IContainer { */ setBounds(x: number, y: number, w: number, h: number): void; - /** - * Gets the current position and size of the container. These - * values might be only filled correctly after a call to setBounds. - */ - getBounds(): Bounds; - /** * Tells the control to move to the given X-position in the given time. * @param duration The milliseconds that should be needed to reach the new X-position diff --git a/src/platform/javascript/HtmlElementContainer.ts b/src/platform/javascript/HtmlElementContainer.ts index 92e1f3684..f3760dd04 100644 --- a/src/platform/javascript/HtmlElementContainer.ts +++ b/src/platform/javascript/HtmlElementContainer.ts @@ -143,10 +143,6 @@ export class HtmlElementContainer implements IContainer { private _lastBounds: Bounds = new Bounds(); - public getBounds() { - return this._lastBounds; - } - public setBounds(x: number, y: number, w: number, h: number) { if (isNaN(x)) { x = this._lastBounds.x;