orpheus-osmd
Version:
An open source JavaScript engine for displaying MusicXML based on VexFlow.
125 lines (124 loc) • 5.61 kB
TypeScript
import { VexFlowBackend } from "./../MusicalScore/Graphical/VexFlow/VexFlowBackend";
import { GraphicalMusicSheet } from "./../MusicalScore/Graphical/GraphicalMusicSheet";
import { VexFlowMusicSheetDrawer } from "./../MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer";
import { MusicSheet } from "./../MusicalScore/MusicSheet";
import { Cursor } from "./Cursor";
import { Promise } from "es6-promise";
import { DrawingParameters } from "../MusicalScore/Graphical/DrawingParameters";
import { IOSMDOptions, BackendType } from "./OSMDOptions";
import { EngravingRules, PageFormat } from "../MusicalScore/Graphical/EngravingRules";
import { GraphicalMusicPage } from "../MusicalScore";
/**
* The main class and control point of OpenSheetMusicDisplay.<br>
* It can display MusicXML sheet music files in an HTML element container.<br>
* After the constructor, use load() and render() to load and render a MusicXML file.
*/
export declare class OpenSheetMusicDisplay {
private version;
/**
* Creates and attaches an OpenSheetMusicDisplay object to an HTML element container.<br>
* After the constructor, use load() and render() to load and render a MusicXML file.
* @param container The container element OSMD will be rendered into.<br>
* Either a string specifying the ID of an HTML container element,<br>
* or a reference to the HTML element itself (e.g. div)
* @param options An object for rendering options like the backend (svg/canvas) or autoResize.<br>
* For defaults see the OSMDOptionsStandard method in the [[OSMDOptions]] class.
*/
constructor(container: string | HTMLElement, options?: IOSMDOptions);
cursor: Cursor;
zoom: number;
private container;
private backendType;
private needBackendUpdate;
private sheet;
private drawer;
private drawBoundingBox;
private drawSkyLine;
private drawBottomLine;
private graphic;
private drawingParameters;
private autoResizeEnabled;
private resizeHandlerAttached;
private followCursor;
/**
* Load a MusicXML file
* @param content is either the url of a file, or the root node of a MusicXML document, or the string content of a .xml/.mxl file
*/
load(content: string | Document): Promise<{}>;
/**
* (Re-)creates the graphic sheet from the music sheet
*/
updateGraphic(): void;
/**
* Render the music sheet in the container
*/
render(): void;
private createOrRefreshRenderBackend;
/** States whether the render() function can be safely called. */
IsReadyToRender(): boolean;
/** Clears what OSMD has drawn on its canvas. */
clear(): void;
/** Set OSMD rendering options using an IOSMDOptions object.
* Can be called during runtime. Also called by constructor.
* For example, setOptions({autoResize: false}) will disable autoResize even during runtime.
*/
setOptions(options: IOSMDOptions): void;
setColoringMode(options: IOSMDOptions): void;
/**
* Sets the logging level for this OSMD instance. By default, this is set to `warn`.
*
* @param: content can be `trace`, `debug`, `info`, `warn` or `error`.
*/
setLogLevel(level: string): void;
getLogLevel(): number;
/**
* Initialize this object to default values
* FIXME: Probably unnecessary
*/
private reset;
/**
* Attach the appropriate handler to the window.onResize event
*/
private autoResize;
/**
* Helper function for managing window's onResize events
* @param startCallback is the function called when resizing starts
* @param endCallback is the function called when resizing (kind-of) ends
*/
private handleResize;
/** Enable or disable (hide) the cursor.
* @param enable whether to enable (true) or disable (false) the cursor
*/
enableOrDisableCursor(enable: boolean): void;
createBackend(type: BackendType, page: GraphicalMusicPage): VexFlowBackend;
/** Standard page format options like A4 or Letter, in portrait and landscape. E.g. PageFormatStandards["A4_P"] or PageFormatStandards["Letter_L"]. */
static PageFormatStandards: {
[type: string]: PageFormat;
};
static StringToPageFormat(pageFormatString: string): PageFormat;
/** Sets page format by string. Alternative to setOptions({pageFormat: PageFormatStandards.Endless}) for example. */
setPageFormat(formatId: string): void;
setCustomPageFormat(width: number, height: number): void;
/**
* Creates a Pdf of the currently rendered MusicXML
* @param pdfName if no name is given, the composer and title of the piece will be used
*/
createPdf(pdfName?: string): void;
set DrawSkyLine(value: boolean);
get DrawSkyLine(): boolean;
set DrawBottomLine(value: boolean);
get DrawBottomLine(): boolean;
set DrawBoundingBox(value: string);
get DrawBoundingBox(): string;
get AutoResizeEnabled(): boolean;
set AutoResizeEnabled(value: boolean);
set FollowCursor(value: boolean);
get FollowCursor(): boolean;
get Sheet(): MusicSheet;
get Drawer(): VexFlowMusicSheetDrawer;
get GraphicSheet(): GraphicalMusicSheet;
get DrawingParameters(): DrawingParameters;
get EngravingRules(): EngravingRules;
/** Returns the version of OSMD this object is built from (the version you are using). */
get Version(): string;
}