UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

90 lines (89 loc) 2.79 kB
/// <reference path="../../pxtlib.d.ts" /> import * as Blockly from "blockly"; import svg = pxt.svgUtil; import { FieldCustom, FieldCustomOptions } from "./field_utils"; export declare const HEADER_HEIGHT = 50; export declare const TOTAL_WIDTH = 300; export declare class FieldCustomMelody<U extends FieldCustomOptions> extends Blockly.Field implements FieldCustom { isFieldCustom_: boolean; SERIALIZABLE: boolean; protected params: U; private melody; private soundingKeys; private numRow; private numCol; private tempo; private stringRep; private isPlaying; private timeouts; private invalidString; private prevString; private topDiv; private editorDiv; private gridDiv; private bottomDiv; private doneButton; private playButton; private playIcon; private tempoInput; private static CELL_WIDTH; private static CELL_HORIZONTAL_MARGIN; private static CELL_VERTICAL_MARGIN; private static CELL_CORNER_RADIUS; private elt; private cells; private static VIEWBOX_WIDTH; private static VIEWBOX_HEIGHT; private static COLOR_BLOCK_WIDTH; private static COLOR_BLOCK_HEIGHT; private static COLOR_BLOCK_X; private static COLOR_BLOCK_Y; private static COLOR_BLOCK_SPACING; private static MUSIC_ICON_WIDTH; private toggle; private root; private gallery; constructor(value: string, params: U, validator?: Blockly.FieldValidator); init(): void; showEditor_(): void; getValue(): string; doValueUpdate_(newValue: string): void; getText_(): string; protected onInit(): void; render_(): void; protected renderEditor(div: HTMLDivElement): void; protected onEditorClose(): void; private onDone; private clearDomReferences; protected getTypeScriptValue(): string; protected parseTypeScriptValue(value: string): void; private isValidNote; protected getPreviewWidth(): number; protected getPreviewHeight(): number; protected getDropdownBackgroundColour(): string; protected getDropdownBorderColour(): string; private updateFieldLabel; private setTempo; private syncTempoField; private getDuration; private createMelodyIfDoesntExist; private onNoteSelect; private updateGrid; private playNote; protected queueToneForColumn(column: number, delay: number, duration: number): void; protected playToneCore(row: number): void; private highlightColumn; private createGridDisplay; private createCell; private togglePlay; private updatePlayButton; private playMelody; private stopMelody; private showGallery; private hideGallery; } export interface ButtonGroup { root: svg.Group; cx: number; cy: number; }