Skip to main content

alphaTab.platform.IUiFacade

This interface represents the UI abstraction between alphaTab and the corresponding UI framework being used.

 interface IUiFacade<TSettings>

Properties​

areWorkersSupported​

Gets a value indicating whether the UI framework supports worker based rendering.

readonly areWorkersSupported: boolean;

canRender​

Gets or sets whether the UI is ready to render the music notation. On some platforms where pre-loading of assets is done asynchronously, rendering might need to be deferred.

readonly canRender: boolean;

canRenderChanged​

This events is fired when the canRender property changes.

readonly canRenderChanged: IEventEmitter;

resizeThrottle​

Gets the resize throttling in milliseconds. Then the music sheet is resized, the re-rendering is deferred until this timeout is reached.

readonly resizeThrottle: number;

rootContainer​

Gets the root UI element that holds the whole alphaTab control.

readonly rootContainer: IContainer;

rootContainerBecameVisible​

This event is fired when rootContainer became visible when it was invisible at the time rendering was initiated.

readonly rootContainerBecameVisible: IEventEmitter;

Methods​

beginAppendRenderResults​

Tells the UI layer to append the given render results to the UI. At this point the partial result is not actually rendered yet, only the layouting process completed.

beginAppendRenderResults(renderResults: RenderFinishedEventArgs | null): void
ParameterSummary
renderResultsAll

The rendered partial that should be added to the UI. null indicates the rendering finished.

beginInvoke​

Tells the UI layer to invoke the given action.

beginInvoke(action: () => void): void
ParameterSummary
actionAll

(no description)

beginUpdateRenderResults​

Tells the UI layer to update the given render results within the UI.

beginUpdateRenderResults(renderResults: RenderFinishedEventArgs): void
ParameterSummary
renderResultsAll

The rendered partial that should be updated within the UI.

createBackingTrackPlayer​

Tells the UI layer to create a player which can play backing tracks.

createBackingTrackPlayer(): IAlphaSynth | null

createCanvasElement​

Creates the canvas element that wraps all individually rendered partials.

createCanvasElement(): IContainer

Returns​

The canvas element that wraps all individually rendered partials.

createCursors​

Creates the cursor objects that are used to highlight the currently played beats and bars.

createCursors(): Cursors | null

createSelectionElement​

Creates a new UI element that is used to display the selection rectangle.

createSelectionElement(): IContainer | null

createWorkerAudioExporter​

Tells the UI layer to create a new audio exporter.

createWorkerAudioExporter(synth: IAlphaSynth | null): IAudioExporterWorker
ParameterSummary
synthAll

The currently active alphaSynth that might be used for synthesizing. If the provided synthesizer is already an active player worker (created via createWorkerPlayer ), it can reuse the already initialized state.

createWorkerPlayer​

Tells the UI layer to create a player worker for the synthesizer.

createWorkerPlayer(): IAlphaSynth | null

createWorkerRenderer​

Tells the UI layer to create the worker renderer. This method is the UI layer supports worker rendering and worker rendering is not disabled via setting.

createWorkerRenderer(): IScoreRenderer

destroy​

Tells the UI layer to destroy the alphaTab controls and restore the initial state.

destroy(): void

destroyCursors​

Destroys the cursor objects that are used to highlight the currently played beats and bars.

destroyCursors(): void

getOffset​

Calculates the relative offset of a container to the scroll element.

getOffset(scrollElement: IContainer | null, container: IContainer): Bounds
ParameterSummary
scrollElementAll

The parent scroll element to which the relative position is computed.

containerAll

The container element for which the relative position is calculated.

getScrollContainer​

Gets the UI element that is used for scrolling during playback.

getScrollContainer(): IContainer

highlightElements​

Tells the UI layer to highlight the music notation elements with the given ID.

highlightElements(groupId: string, masterBarIndex: number): void
ParameterSummary
groupIdAll

The group id that identifies the elements to be highlighted.

masterBarIndexAll

The index of the related masterbar of the highlighted group.

initialize​

Initializes the UI using the given alphaTab API and settings object.

initialize(api: AlphaTabApiBase<TSettings>, settings: TSettings): void
ParameterSummary
apiAll

The alphaTab API wrapper responsible for UI interaction.

settingsAll

The settings object holding the settings from the UI layer.

initialRender​

Tells the UI layer to do the initial rendering.

initialRender(): void

load​

Attempts a load of the score represented by the given data object.

load(data: unknown, success: (score: Score) => void, error: (error: Error) => void): boolean
ParameterSummary
dataAll

The data object to decode

successAll

The action to call if the score was loaded

errorAll

The action to call if any error during loading ocurred.

Returns​

true if the data object is supported and a load was initiated, otherwise false

loadSoundFont​

Attempts a load of the score represented by the given data object.

loadSoundFont(data: unknown, append: boolean): boolean
ParameterSummary
dataAll

The data object to decode

appendAll

Whether to fully replace or append the data from the given soundfont.

Returns​

true if the data object is supported and a load was initiated, otherwise false

removeHighlights​

Tells the UI layer to remove all highlights from highlighted music notation elements.

removeHighlights(): void

scrollToX​

Initiates a horizontal scroll on the given element.

scrollToX(scrollElement: IContainer, offset: number, speed: number): void
ParameterSummary
scrollElementAll

The element on which the scrolling should happen.

offsetAll

The absolute scroll offset to which scrolling should happen.

speedAll

How fast the scrolling from the current offset to the given one should happen in milliseconds.

scrollToY​

Initiates a vertical scroll on the given element.

scrollToY(scrollElement: IContainer, offset: number, speed: number): void
ParameterSummary
scrollElementAll

The element on which the scrolling should happen.

offsetAll

The absolute scroll offset to which scrolling should happen.

speedAll

How fast the scrolling from the current offset to the given one should happen in milliseconds.

setCanvasOverflow​

Updates the overflows needed to ensure the smooth scrolling can reach the "end" at the desired position. Without these overflows we might not have enough scroll space and we cannot reach a "sticky cursor" behavior.

setCanvasOverflow(canvasElement: IContainer, overflow: number, isVertical: boolean): void
ParameterSummary
canvasElementAll

The canvas element.

overflowAll

(no description)

isVerticalAll

Whether we have a vertical or horizontal overflow

stopScrolling​

Stops any ongoing scrolling of the given element.

stopScrolling(scrollElement: IContainer): void
ParameterSummary
scrollElementAll

The element which might be scrolling dynamically.

triggerEvent​

Tells the UI layer to trigger an event with the given name and details.

triggerEvent(container: IContainer, eventName: string, details: unknown, originalEvent?: IMouseEventArgs): void
ParameterSummary
containerAll

The element on which the event should be triggered.

eventNameAll

The event that should be triggered.

detailsAll

The object holding the details about the event.

originalEventAll

The original event related to this custom event.