@grame/faust-ui 0.0.0-stage → 1.2.1
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.
- package/LICENSE +674 -0
- package/README.md +168 -2
- package/dist/esm/index.css +448 -0
- package/dist/esm/index.css.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3871 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.ts +684 -0
- package/dist/index.html +17 -0
- package/dist/index.js +5720 -0
- package/dist/index.js.map +1 -0
- package/dist/test.html +29 -0
- package/package.json +61 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { FaustUIDescriptor, FaustUIGroupType, FaustUIInputItem, FaustUIInputType, FaustUIItem, FaustUIMeta, FaustUIOutputType, FaustUIType } from '@grame/faustwasm';
|
|
4
|
+
|
|
5
|
+
declare const $AnyEventType: unique symbol;
|
|
6
|
+
export interface IEmitOptions {
|
|
7
|
+
excludeAny?: boolean;
|
|
8
|
+
exclude?: ((...args: any[]) => any)[];
|
|
9
|
+
}
|
|
10
|
+
declare class TypedEventEmitter<M> {
|
|
11
|
+
private _listeners;
|
|
12
|
+
get listeners(): {
|
|
13
|
+
[eventName: string]: ((e?: any, emitter?: any) => any)[];
|
|
14
|
+
[$AnyEventType]: ((eventName: string, eventData?: any, emitter?: any) => any)[];
|
|
15
|
+
};
|
|
16
|
+
private getListeners;
|
|
17
|
+
on<K extends keyof M & string>(eventName: K, listener: (e: M[K], emitter?: this) => any): void;
|
|
18
|
+
once<K extends keyof M & string>(eventName: K, listener: (e: M[K], emitter?: this) => any): void;
|
|
19
|
+
onAny<K extends keyof M & string>(listener: <KK extends K>(eventName: KK, eventData?: M[KK], emitter?: this) => any): void;
|
|
20
|
+
off<K extends keyof M & string>(eventName: K, listener: (e: M[K], emitter?: this) => any): void;
|
|
21
|
+
offAny<K extends keyof M & string>(listener: <KK extends K>(eventName: KK, eventData?: M[KK], emitter?: this) => any): void;
|
|
22
|
+
emit<K extends keyof M & string>(eventName: K, eventData?: M[K], options?: IEmitOptions): Promise<any[]>;
|
|
23
|
+
emitSerial<K extends keyof M & string>(eventName: K, eventData?: M[K], options?: IEmitOptions): Promise<any[]>;
|
|
24
|
+
emitSync<K extends keyof M & string>(eventName: K, eventData?: M[K], options?: IEmitOptions): any[];
|
|
25
|
+
offAll(eventName?: keyof M & string): void;
|
|
26
|
+
listenerCount(eventName: keyof M & string): number;
|
|
27
|
+
}
|
|
28
|
+
declare abstract class AbstractComponent<T extends {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}> extends TypedEventEmitter<T> {
|
|
31
|
+
/**
|
|
32
|
+
* The default state of the component.
|
|
33
|
+
*/
|
|
34
|
+
static defaultProps: Record<string, any>;
|
|
35
|
+
get defaultProps(): T;
|
|
36
|
+
/**
|
|
37
|
+
* Here stores corrent state of component
|
|
38
|
+
* change the state with `setState` method to fire state events
|
|
39
|
+
* then UI parts will get notified and rerender
|
|
40
|
+
*/
|
|
41
|
+
state: T;
|
|
42
|
+
/**
|
|
43
|
+
* Frame count in order to reduce frame rate
|
|
44
|
+
*/
|
|
45
|
+
private $frame;
|
|
46
|
+
/**
|
|
47
|
+
* Frame reducing factor, 1 = render at every browser rendering tick, 2 will skip one every two ticks.
|
|
48
|
+
*/
|
|
49
|
+
frameReduce: number;
|
|
50
|
+
/**
|
|
51
|
+
* Here stores current `requestAnimationFrame` reference
|
|
52
|
+
* if we have a new state to render, we cancel the old one
|
|
53
|
+
*/
|
|
54
|
+
private $raf;
|
|
55
|
+
/**
|
|
56
|
+
* `requestAnimationFrame` callback
|
|
57
|
+
*/
|
|
58
|
+
private raf;
|
|
59
|
+
/**
|
|
60
|
+
* tasks to execute in next redering tick
|
|
61
|
+
*/
|
|
62
|
+
private tasks;
|
|
63
|
+
/**
|
|
64
|
+
* Initiate default state with incoming state.
|
|
65
|
+
*/
|
|
66
|
+
constructor(props?: T);
|
|
67
|
+
/**
|
|
68
|
+
* set internal state and fire events for UI parts subscribed
|
|
69
|
+
*/
|
|
70
|
+
setState(newState: Partial<T>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Use this method to request a new rendering
|
|
73
|
+
* schedule what you need to do in next render tick in `raf` callback
|
|
74
|
+
*/
|
|
75
|
+
schedule(func: () => any): void;
|
|
76
|
+
}
|
|
77
|
+
export interface FaustUIItemProps<T extends FaustUIItemStyle> {
|
|
78
|
+
value?: number;
|
|
79
|
+
active?: boolean;
|
|
80
|
+
focus?: boolean;
|
|
81
|
+
label?: string;
|
|
82
|
+
address: string;
|
|
83
|
+
min?: number;
|
|
84
|
+
max?: number;
|
|
85
|
+
init: number;
|
|
86
|
+
step?: number;
|
|
87
|
+
tooltip?: string;
|
|
88
|
+
enums?: {
|
|
89
|
+
[key: string]: number;
|
|
90
|
+
};
|
|
91
|
+
type?: "enum" | "int" | "float";
|
|
92
|
+
unit?: string;
|
|
93
|
+
scale?: "linear" | "exp" | "log";
|
|
94
|
+
style?: T;
|
|
95
|
+
emitter?: FaustUI;
|
|
96
|
+
}
|
|
97
|
+
export interface FaustUIGroupProps {
|
|
98
|
+
label?: string;
|
|
99
|
+
type?: "tgroup" | "vgroup" | "hgroup";
|
|
100
|
+
style?: FaustUIItemStyle;
|
|
101
|
+
items?: FaustUIItem[];
|
|
102
|
+
isRoot?: boolean;
|
|
103
|
+
emitter?: FaustUI;
|
|
104
|
+
}
|
|
105
|
+
export interface FaustUIItemStyle {
|
|
106
|
+
width?: number;
|
|
107
|
+
height?: number;
|
|
108
|
+
left?: number;
|
|
109
|
+
top?: number;
|
|
110
|
+
grid?: number;
|
|
111
|
+
labelcolor?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface PointerDownEvent {
|
|
114
|
+
pointerId: number;
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
originalEvent: MouseEvent | TouchEvent;
|
|
118
|
+
}
|
|
119
|
+
export interface PointerDragEvent {
|
|
120
|
+
pointerId: number;
|
|
121
|
+
prevValue: number;
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
fromX: number;
|
|
125
|
+
fromY: number;
|
|
126
|
+
movementX: number;
|
|
127
|
+
movementY: number;
|
|
128
|
+
originalEvent: MouseEvent | TouchEvent;
|
|
129
|
+
}
|
|
130
|
+
export interface PointerUpEvent {
|
|
131
|
+
pointerId: number;
|
|
132
|
+
x: number;
|
|
133
|
+
y: number;
|
|
134
|
+
originalEvent: MouseEvent | TouchEvent;
|
|
135
|
+
}
|
|
136
|
+
declare abstract class AbstractItem<T extends FaustUIItemStyle> extends AbstractComponent<FaustUIItemProps<T>> {
|
|
137
|
+
/**
|
|
138
|
+
* The default state of the component.
|
|
139
|
+
*/
|
|
140
|
+
static defaultProps: FaustUIItemProps<FaustUIItemStyle>;
|
|
141
|
+
/**
|
|
142
|
+
* DOM Div container of the component
|
|
143
|
+
*/
|
|
144
|
+
container: HTMLDivElement;
|
|
145
|
+
/**
|
|
146
|
+
* DOM Div container of label canvas
|
|
147
|
+
*/
|
|
148
|
+
label: HTMLDivElement;
|
|
149
|
+
/**
|
|
150
|
+
* Use canvas as label to fit full text in.
|
|
151
|
+
*/
|
|
152
|
+
labelCanvas: HTMLCanvasElement;
|
|
153
|
+
labelCtx: CanvasRenderingContext2D;
|
|
154
|
+
/**
|
|
155
|
+
* Override this to get css work
|
|
156
|
+
*/
|
|
157
|
+
className: string;
|
|
158
|
+
frameReduce: number;
|
|
159
|
+
/**
|
|
160
|
+
* Default DOM event listeners, unify mousedown and touchstart events
|
|
161
|
+
* For mouse or touch events, please use `handlePointerDown` `handlePointerUp` `handlePointerDrag` callbacks
|
|
162
|
+
*/
|
|
163
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
164
|
+
handleKeyUp: (e: KeyboardEvent) => void;
|
|
165
|
+
handleTouchStart: (e: TouchEvent) => void;
|
|
166
|
+
handleWheel: (e: WheelEvent) => void;
|
|
167
|
+
handleClick: (e: MouseEvent) => void;
|
|
168
|
+
/**
|
|
169
|
+
* Handle double-click events to reset the value to its initial state.
|
|
170
|
+
*/
|
|
171
|
+
handleDoubleClick: (e: MouseEvent) => void;
|
|
172
|
+
handleMouseDown: (e: MouseEvent) => void;
|
|
173
|
+
handleMouseOver: (e: MouseEvent) => void;
|
|
174
|
+
handleMouseOut: (e: MouseEvent) => void;
|
|
175
|
+
handleContextMenu: (e: MouseEvent) => void;
|
|
176
|
+
handlePointerDown: (e: PointerEvent) => void;
|
|
177
|
+
handleMouseOrTouchDown: (e: PointerDownEvent) => void;
|
|
178
|
+
handleMouseOrTouchMove: (e: PointerDragEvent) => void;
|
|
179
|
+
handleMouseOrTouchUp: (e: PointerUpEvent) => void;
|
|
180
|
+
handleFocusIn: (e: FocusEvent) => boolean;
|
|
181
|
+
handleFocusOut: (e: FocusEvent) => boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Initiate default state with incoming state.
|
|
184
|
+
*/
|
|
185
|
+
constructor(props?: FaustUIItemProps<T>);
|
|
186
|
+
/**
|
|
187
|
+
* Get a nearest valid number. An entry of a menu or a radio is valid as
|
|
188
|
+
* written, even off the step grid: the C++ GUIs send it unchanged.
|
|
189
|
+
*/
|
|
190
|
+
toValidNumber(value: number): number;
|
|
191
|
+
/**
|
|
192
|
+
* The value as displayed, with 3 decimals or more when the step is finer (0.0001)
|
|
193
|
+
* or the range smaller than 1 (a bargraph from 0 to 0.001), without trailing zeros
|
|
194
|
+
*/
|
|
195
|
+
get displayValue(): string;
|
|
196
|
+
/**
|
|
197
|
+
* Use this method if you want the emitter to send value to DSP
|
|
198
|
+
*/
|
|
199
|
+
setValue(valueIn: number): boolean;
|
|
200
|
+
setToInitialValue(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Send value to DSP
|
|
203
|
+
*/
|
|
204
|
+
change(valueIn?: number): void;
|
|
205
|
+
/**
|
|
206
|
+
* set internal state and fire events for UI parts subscribed
|
|
207
|
+
* This will not send anything to DSP
|
|
208
|
+
* @returns is state updated
|
|
209
|
+
*/
|
|
210
|
+
setState(newState: {
|
|
211
|
+
[key in keyof FaustUIItemProps<T>]?: FaustUIItemProps<T>[key];
|
|
212
|
+
}): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Create container with class name
|
|
215
|
+
* override it with `super.componentWillMount();`
|
|
216
|
+
*/
|
|
217
|
+
componentWillMount(): this;
|
|
218
|
+
/**
|
|
219
|
+
* Here append all child DOM to container
|
|
220
|
+
*/
|
|
221
|
+
mount(): this;
|
|
222
|
+
paintLabel(align?: CanvasTextAlign): this;
|
|
223
|
+
/**
|
|
224
|
+
* will call this method when mounted
|
|
225
|
+
*/
|
|
226
|
+
componentDidMount(): this;
|
|
227
|
+
/**
|
|
228
|
+
* Count steps in range min-max with step
|
|
229
|
+
*/
|
|
230
|
+
get stepsCount(): number;
|
|
231
|
+
/**
|
|
232
|
+
* Normalized value between 0 - 1.
|
|
233
|
+
*/
|
|
234
|
+
get distance(): number;
|
|
235
|
+
/**
|
|
236
|
+
* Number of steps between the entries of an enum, one less than its entries: `enums` is an object, it has no length
|
|
237
|
+
*/
|
|
238
|
+
static enumSteps(enums: {
|
|
239
|
+
[key: string]: number;
|
|
240
|
+
}): number;
|
|
241
|
+
static getDistance(state: {
|
|
242
|
+
value: number;
|
|
243
|
+
min: number;
|
|
244
|
+
max: number;
|
|
245
|
+
enums?: {
|
|
246
|
+
[key: string]: number;
|
|
247
|
+
};
|
|
248
|
+
type: "enum" | "int" | "float";
|
|
249
|
+
scale: "linear" | "exp" | "log";
|
|
250
|
+
}): number;
|
|
251
|
+
/**
|
|
252
|
+
* Mousemove pixels for each step
|
|
253
|
+
*/
|
|
254
|
+
get stepRange(): number;
|
|
255
|
+
}
|
|
256
|
+
export interface FaustUINentryStyle extends FaustUIItemStyle {
|
|
257
|
+
fontname?: string;
|
|
258
|
+
fontsize?: number;
|
|
259
|
+
fontface?: "regular" | "bold" | "italic" | "bold italic";
|
|
260
|
+
bgcolor?: string;
|
|
261
|
+
bordercolor?: string;
|
|
262
|
+
labelcolor?: string;
|
|
263
|
+
textcolor?: string;
|
|
264
|
+
}
|
|
265
|
+
declare class Nentry extends AbstractItem<FaustUINentryStyle> {
|
|
266
|
+
static get defaultProps(): FaustUIItemProps<FaustUINentryStyle>;
|
|
267
|
+
className: string;
|
|
268
|
+
input: HTMLInputElement;
|
|
269
|
+
componentWillMount(): this;
|
|
270
|
+
handleChange: (e: Event) => void;
|
|
271
|
+
setStyle: () => void;
|
|
272
|
+
componentDidMount(): this;
|
|
273
|
+
mount(): this;
|
|
274
|
+
}
|
|
275
|
+
export interface FaustUISliderStyle extends FaustUINentryStyle {
|
|
276
|
+
sliderwidth?: number;
|
|
277
|
+
sliderbgcolor?: string;
|
|
278
|
+
sliderbgoncolor?: string;
|
|
279
|
+
slidercolor?: string;
|
|
280
|
+
}
|
|
281
|
+
declare class VSlider extends AbstractItem<FaustUISliderStyle> {
|
|
282
|
+
static get defaultProps(): FaustUIItemProps<FaustUISliderStyle>;
|
|
283
|
+
className: string;
|
|
284
|
+
canvas: HTMLCanvasElement;
|
|
285
|
+
inputNumber: HTMLInputElement;
|
|
286
|
+
input: HTMLInputElement;
|
|
287
|
+
flexDiv: HTMLDivElement;
|
|
288
|
+
canvasDiv: HTMLDivElement;
|
|
289
|
+
ctx: CanvasRenderingContext2D;
|
|
290
|
+
interactionRect: number[];
|
|
291
|
+
componentWillMount(): this;
|
|
292
|
+
handleChange: (e: Event) => void;
|
|
293
|
+
setStyle: () => void;
|
|
294
|
+
componentDidMount(): this;
|
|
295
|
+
mount(): this;
|
|
296
|
+
paint: () => void;
|
|
297
|
+
get stepsCount(): number;
|
|
298
|
+
get stepRange(): number;
|
|
299
|
+
getValueFromPos(e: {
|
|
300
|
+
x: number;
|
|
301
|
+
y: number;
|
|
302
|
+
}): number;
|
|
303
|
+
handleMouseOrTouchDown: (e: PointerDownEvent) => void;
|
|
304
|
+
handleMouseOrTouchMove: (e: PointerDragEvent) => void;
|
|
305
|
+
}
|
|
306
|
+
export interface FaustUISoundfileStyle extends FaustUIItemStyle {
|
|
307
|
+
fontname?: string;
|
|
308
|
+
fontsize?: number;
|
|
309
|
+
fontface?: "normal" | "bold" | "italic" | "bold italic";
|
|
310
|
+
bgcolor?: string;
|
|
311
|
+
bgoncolor?: string;
|
|
312
|
+
bordercolor?: string;
|
|
313
|
+
borderoncolor?: string;
|
|
314
|
+
textcolor?: string;
|
|
315
|
+
textoncolor?: string;
|
|
316
|
+
}
|
|
317
|
+
declare class Soundfile extends AbstractItem<FaustUISoundfileStyle> {
|
|
318
|
+
static get defaultProps(): FaustUIItemProps<FaustUISoundfileStyle>;
|
|
319
|
+
className: string;
|
|
320
|
+
btn: HTMLDivElement;
|
|
321
|
+
span: HTMLSpanElement;
|
|
322
|
+
componentWillMount(): this;
|
|
323
|
+
setStyle: () => void;
|
|
324
|
+
mount(): this;
|
|
325
|
+
componentDidMount(): this;
|
|
326
|
+
handleMouseOrTouchDown: () => void;
|
|
327
|
+
handleMouseOrTouchUp: () => void;
|
|
328
|
+
}
|
|
329
|
+
export interface FaustUIButtonStyle extends FaustUIItemStyle {
|
|
330
|
+
fontname?: string;
|
|
331
|
+
fontsize?: number;
|
|
332
|
+
fontface?: "normal" | "bold" | "italic" | "bold italic";
|
|
333
|
+
bgcolor?: string;
|
|
334
|
+
bgoncolor?: string;
|
|
335
|
+
bordercolor?: string;
|
|
336
|
+
borderoncolor?: string;
|
|
337
|
+
textcolor?: string;
|
|
338
|
+
textoncolor?: string;
|
|
339
|
+
}
|
|
340
|
+
declare class Button extends AbstractItem<FaustUIButtonStyle> {
|
|
341
|
+
static get defaultProps(): FaustUIItemProps<FaustUIButtonStyle>;
|
|
342
|
+
className: string;
|
|
343
|
+
btn: HTMLDivElement;
|
|
344
|
+
span: HTMLSpanElement;
|
|
345
|
+
componentWillMount(): this;
|
|
346
|
+
setStyle: () => void;
|
|
347
|
+
mount(): this;
|
|
348
|
+
componentDidMount(): this;
|
|
349
|
+
handleContextMenu: (e: MouseEvent) => void;
|
|
350
|
+
handleMouseOrTouchDown: () => void;
|
|
351
|
+
handleMouseOrTouchUp: () => void;
|
|
352
|
+
}
|
|
353
|
+
export interface FaustUIKnobStyle extends FaustUINentryStyle {
|
|
354
|
+
knobwidth?: number;
|
|
355
|
+
knobcolor?: string;
|
|
356
|
+
knoboncolor?: string;
|
|
357
|
+
needlecolor?: string;
|
|
358
|
+
}
|
|
359
|
+
declare class Knob extends AbstractItem<FaustUIKnobStyle> {
|
|
360
|
+
static get defaultProps(): FaustUIItemProps<FaustUIKnobStyle>;
|
|
361
|
+
className: string;
|
|
362
|
+
canvas: HTMLCanvasElement;
|
|
363
|
+
inputNumber: HTMLInputElement;
|
|
364
|
+
input: HTMLInputElement;
|
|
365
|
+
ctx: CanvasRenderingContext2D;
|
|
366
|
+
componentWillMount(): this;
|
|
367
|
+
handleChange: (e: Event) => void;
|
|
368
|
+
setStyle: () => void;
|
|
369
|
+
componentDidMount(): this;
|
|
370
|
+
mount(): this;
|
|
371
|
+
paint: () => void;
|
|
372
|
+
getValueFromDelta(e: PointerDragEvent): number;
|
|
373
|
+
handleMouseOrTouchMove: (e: PointerDragEvent) => void;
|
|
374
|
+
}
|
|
375
|
+
export interface FaustUIMenuStyle extends FaustUIItemStyle {
|
|
376
|
+
fontname?: string;
|
|
377
|
+
fontsize?: number;
|
|
378
|
+
fontface?: "regular" | "bold" | "italic" | "bold italic";
|
|
379
|
+
bgcolor?: string;
|
|
380
|
+
bordercolor?: string;
|
|
381
|
+
labelcolor?: string;
|
|
382
|
+
textcolor?: string;
|
|
383
|
+
}
|
|
384
|
+
declare class Menu extends AbstractItem<FaustUIMenuStyle> {
|
|
385
|
+
static get defaultProps(): FaustUIItemProps<FaustUIMenuStyle>;
|
|
386
|
+
className: string;
|
|
387
|
+
select: HTMLSelectElement;
|
|
388
|
+
componentWillMount(): this;
|
|
389
|
+
getOptions(): void;
|
|
390
|
+
handleChange: (e: Event) => void;
|
|
391
|
+
setStyle: () => void;
|
|
392
|
+
componentDidMount(): this;
|
|
393
|
+
mount(): this;
|
|
394
|
+
}
|
|
395
|
+
export interface FaustUIRadioStyle extends FaustUIItemStyle {
|
|
396
|
+
fontname?: string;
|
|
397
|
+
fontsize?: number;
|
|
398
|
+
fontface?: "regular" | "bold" | "italic" | "bold italic";
|
|
399
|
+
bgcolor?: string;
|
|
400
|
+
bordercolor?: string;
|
|
401
|
+
labelcolor?: string;
|
|
402
|
+
textcolor?: string;
|
|
403
|
+
/** "horizontal" for a radio made from an hslider, "vertical" otherwise. */
|
|
404
|
+
direction?: "horizontal" | "vertical";
|
|
405
|
+
}
|
|
406
|
+
declare class Radio extends AbstractItem<FaustUIRadioStyle> {
|
|
407
|
+
static get defaultProps(): FaustUIItemProps<FaustUIRadioStyle>;
|
|
408
|
+
className: string;
|
|
409
|
+
group: HTMLDivElement;
|
|
410
|
+
componentWillMount(): this;
|
|
411
|
+
getOptions: () => void;
|
|
412
|
+
setStyle: () => void;
|
|
413
|
+
componentDidMount(): this;
|
|
414
|
+
mount(): this;
|
|
415
|
+
}
|
|
416
|
+
export interface FaustUILedStyle extends FaustUINentryStyle {
|
|
417
|
+
shape?: "circle" | "square";
|
|
418
|
+
ledbgcolor?: string;
|
|
419
|
+
coldcolor?: string;
|
|
420
|
+
warmcolor?: string;
|
|
421
|
+
hotcolor?: string;
|
|
422
|
+
overloadcolor?: string;
|
|
423
|
+
}
|
|
424
|
+
declare class Led extends AbstractItem<FaustUILedStyle> {
|
|
425
|
+
static get defaultProps(): FaustUIItemProps<FaustUILedStyle>;
|
|
426
|
+
className: string;
|
|
427
|
+
canvasDiv: HTMLDivElement;
|
|
428
|
+
canvas: HTMLCanvasElement;
|
|
429
|
+
tempCanvas: HTMLCanvasElement;
|
|
430
|
+
ctx: CanvasRenderingContext2D;
|
|
431
|
+
tempCtx: CanvasRenderingContext2D;
|
|
432
|
+
componentWillMount(): this;
|
|
433
|
+
setStyle: () => void;
|
|
434
|
+
componentDidMount(): this;
|
|
435
|
+
mount(): this;
|
|
436
|
+
paint: () => void;
|
|
437
|
+
}
|
|
438
|
+
declare class Numerical extends AbstractItem<FaustUINentryStyle> {
|
|
439
|
+
static get defaultProps(): FaustUIItemProps<FaustUINentryStyle>;
|
|
440
|
+
className: string;
|
|
441
|
+
input: HTMLInputElement;
|
|
442
|
+
componentWillMount(): this;
|
|
443
|
+
setStyle: () => void;
|
|
444
|
+
componentDidMount(): this;
|
|
445
|
+
mount(): this;
|
|
446
|
+
}
|
|
447
|
+
export interface FaustUIBargraphStyle extends FaustUINentryStyle {
|
|
448
|
+
barwidth?: number;
|
|
449
|
+
barbgcolor?: string;
|
|
450
|
+
coldcolor?: string;
|
|
451
|
+
warmcolor?: string;
|
|
452
|
+
hotcolor?: string;
|
|
453
|
+
overloadcolor?: string;
|
|
454
|
+
}
|
|
455
|
+
declare class VBargraph extends AbstractItem<FaustUIBargraphStyle> {
|
|
456
|
+
static get defaultProps(): FaustUIItemProps<FaustUIBargraphStyle>;
|
|
457
|
+
className: string;
|
|
458
|
+
canvas: HTMLCanvasElement;
|
|
459
|
+
input: HTMLInputElement;
|
|
460
|
+
flexDiv: HTMLDivElement;
|
|
461
|
+
canvasDiv: HTMLDivElement;
|
|
462
|
+
ctx: CanvasRenderingContext2D;
|
|
463
|
+
componentWillMount(): this;
|
|
464
|
+
setStyle: () => void;
|
|
465
|
+
componentDidMount(): this;
|
|
466
|
+
mount(): this;
|
|
467
|
+
paintValue: number;
|
|
468
|
+
maxValue: number;
|
|
469
|
+
maxTimer: number;
|
|
470
|
+
paint: () => void;
|
|
471
|
+
}
|
|
472
|
+
export interface LayoutProps {
|
|
473
|
+
type: TLayoutType;
|
|
474
|
+
left?: number;
|
|
475
|
+
top?: number;
|
|
476
|
+
offsetLeft?: number; // relative to parent group
|
|
477
|
+
offsetTop?: number;
|
|
478
|
+
width: number;
|
|
479
|
+
height: number;
|
|
480
|
+
sizing: "horizontal" | "vertical" | "both" | "none";
|
|
481
|
+
}
|
|
482
|
+
export type TLayoutType = "vgroup" | "hgroup" | "tgroup" | "hbargraph" | "vbargraph" | "vslider" | "hslider" | "button" | "checkbox" | "nentry" | "soundfile" | "knob" | "menu" | "radio" | "led" | "numerical";
|
|
483
|
+
export interface IItem {
|
|
484
|
+
/**
|
|
485
|
+
* Initial type of item given by Faust compiler
|
|
486
|
+
*/
|
|
487
|
+
type: FaustUIType;
|
|
488
|
+
/**
|
|
489
|
+
* Initial item label given by Faust compiler
|
|
490
|
+
*/
|
|
491
|
+
label: string;
|
|
492
|
+
/**
|
|
493
|
+
* Calculated layout
|
|
494
|
+
*/
|
|
495
|
+
layout: LayoutProps;
|
|
496
|
+
/**
|
|
497
|
+
* Adjust group width and height by its items' dimensions
|
|
498
|
+
*/
|
|
499
|
+
adjust(): this;
|
|
500
|
+
/**
|
|
501
|
+
* Expand flexible items within a group
|
|
502
|
+
*
|
|
503
|
+
* @param dX - Extra horizontal spaces that this group could take
|
|
504
|
+
* @param dY - Extra vertical spaces that this group could take
|
|
505
|
+
*/
|
|
506
|
+
expand(dX: number, dY: number): this;
|
|
507
|
+
/**
|
|
508
|
+
* calculate all the items' absolute coordination (in grids)
|
|
509
|
+
*/
|
|
510
|
+
offset(): this;
|
|
511
|
+
}
|
|
512
|
+
declare abstract class AbstractItem$1 implements IItem {
|
|
513
|
+
type: FaustUIInputType | FaustUIOutputType;
|
|
514
|
+
label: string;
|
|
515
|
+
address: string;
|
|
516
|
+
shortname: string;
|
|
517
|
+
url: string;
|
|
518
|
+
index: number;
|
|
519
|
+
init: number;
|
|
520
|
+
min: number;
|
|
521
|
+
max: number;
|
|
522
|
+
meta?: FaustUIMeta[];
|
|
523
|
+
layout: LayoutProps;
|
|
524
|
+
constructor(item: FaustUIItem);
|
|
525
|
+
adjust(): this;
|
|
526
|
+
expand(dX: number, dY: number): this;
|
|
527
|
+
offset(): this;
|
|
528
|
+
}
|
|
529
|
+
declare abstract class AbstractGroup implements IItem {
|
|
530
|
+
static padding: number;
|
|
531
|
+
static labelHeight: number;
|
|
532
|
+
static spaceBetween: number;
|
|
533
|
+
isRoot: boolean;
|
|
534
|
+
type: FaustUIGroupType;
|
|
535
|
+
label: string;
|
|
536
|
+
items: (AbstractGroup | AbstractItem$1)[];
|
|
537
|
+
layout: LayoutProps;
|
|
538
|
+
constructor(group: {
|
|
539
|
+
type: FaustUIGroupType;
|
|
540
|
+
label: string;
|
|
541
|
+
items: (AbstractGroup | AbstractItem$1)[];
|
|
542
|
+
}, isRoot?: boolean);
|
|
543
|
+
/**
|
|
544
|
+
* find recursively if the group has horizontal-sizable item
|
|
545
|
+
*/
|
|
546
|
+
get hasHSizingDesc(): boolean;
|
|
547
|
+
/**
|
|
548
|
+
* find recursively if the group has vertical-sizable item
|
|
549
|
+
*/
|
|
550
|
+
get hasVSizingDesc(): boolean;
|
|
551
|
+
adjust(): this;
|
|
552
|
+
expand(dX: number, dY: number): this;
|
|
553
|
+
offset(): this;
|
|
554
|
+
}
|
|
555
|
+
declare abstract class AbstractInputItem extends AbstractItem$1 {
|
|
556
|
+
init: number;
|
|
557
|
+
step: number;
|
|
558
|
+
constructor(item: FaustUIInputItem);
|
|
559
|
+
}
|
|
560
|
+
declare abstract class AbstractOutputItem extends AbstractItem$1 {
|
|
561
|
+
}
|
|
562
|
+
declare class Group extends AbstractComponent<FaustUIGroupProps> {
|
|
563
|
+
static parseMeta(metaIn: FaustUIMeta[]): {
|
|
564
|
+
metaObject: FaustUIMeta;
|
|
565
|
+
enums?: {
|
|
566
|
+
[key: string]: number;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
static getComponent(item: AbstractGroup | AbstractInputItem | AbstractOutputItem, emitter: FaustUI, grid: number): Nentry | VSlider | Soundfile | Button | Knob | Menu | Radio | Led | Numerical | VBargraph | Group;
|
|
570
|
+
/**
|
|
571
|
+
* DOM Div container of the group
|
|
572
|
+
*/
|
|
573
|
+
container: HTMLDivElement;
|
|
574
|
+
/**
|
|
575
|
+
* DOM Div container of label canvas
|
|
576
|
+
*/
|
|
577
|
+
label: HTMLDivElement;
|
|
578
|
+
/**
|
|
579
|
+
* Use canvas as label to fit full text in.
|
|
580
|
+
*/
|
|
581
|
+
labelCanvas: HTMLCanvasElement;
|
|
582
|
+
labelCtx: CanvasRenderingContext2D;
|
|
583
|
+
tabs: HTMLDivElement;
|
|
584
|
+
children: (AbstractItem<FaustUIItemStyle> | Group)[];
|
|
585
|
+
layout: LayoutProps;
|
|
586
|
+
/**
|
|
587
|
+
* Handle double-click events to reset all children's value to its initial state.
|
|
588
|
+
*/
|
|
589
|
+
handleDoubleClick: (e: MouseEvent) => void;
|
|
590
|
+
setToInitialValue(): void;
|
|
591
|
+
setState(newState: {
|
|
592
|
+
[key in keyof FaustUIGroupProps]?: FaustUIGroupProps[key];
|
|
593
|
+
}): void;
|
|
594
|
+
componentWillMount(): this;
|
|
595
|
+
paintLabel(): this;
|
|
596
|
+
updateUI: () => void;
|
|
597
|
+
mount(): this;
|
|
598
|
+
/**
|
|
599
|
+
* Unregister the widgets of this group and of its subgroups from the emitter, before they are replaced
|
|
600
|
+
*/
|
|
601
|
+
unregisterChildren(): this;
|
|
602
|
+
/**
|
|
603
|
+
* Append the tab bar and the children after the label: the tab click handler counts on this order
|
|
604
|
+
*/
|
|
605
|
+
mountChildren(): this;
|
|
606
|
+
componentDidMount(): this;
|
|
607
|
+
}
|
|
608
|
+
export interface IOptions {
|
|
609
|
+
root: HTMLDivElement;
|
|
610
|
+
ui?: FaustUIDescriptor;
|
|
611
|
+
listenWindowResize?: boolean;
|
|
612
|
+
listenWindowMessage?: boolean;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* The main class of UI constructor,
|
|
616
|
+
* listening to `resize` window event to resize component,
|
|
617
|
+
* listening to `message` window event to change UI or param value.
|
|
618
|
+
* See readme.
|
|
619
|
+
*/
|
|
620
|
+
export declare class FaustUI {
|
|
621
|
+
componentMap: {
|
|
622
|
+
[path: string]: AbstractItem<any>[];
|
|
623
|
+
};
|
|
624
|
+
DOMroot: HTMLDivElement;
|
|
625
|
+
faustUIRoot: Group;
|
|
626
|
+
hostWindow: Window;
|
|
627
|
+
grid: number;
|
|
628
|
+
private _ui;
|
|
629
|
+
private _layout;
|
|
630
|
+
/**
|
|
631
|
+
* Calculate incoming UI's layout, bind window events
|
|
632
|
+
*/
|
|
633
|
+
constructor(options: IOptions);
|
|
634
|
+
private handleWindowResize;
|
|
635
|
+
private handleWindowMessage;
|
|
636
|
+
/**
|
|
637
|
+
* Stop listening to the window and remove the UI from the DOM root.
|
|
638
|
+
* Call it before dropping a FaustUI, or creating another one in the same root:
|
|
639
|
+
* otherwise it keeps receiving the window messages, and mounts the UIs they bring.
|
|
640
|
+
*/
|
|
641
|
+
destroy(): void;
|
|
642
|
+
/**
|
|
643
|
+
* Render the UI to DOM root
|
|
644
|
+
*/
|
|
645
|
+
mount(): void;
|
|
646
|
+
/**
|
|
647
|
+
* This method should be called by components to register itself to map.
|
|
648
|
+
*/
|
|
649
|
+
register(path: string, item: AbstractItem<any>): void;
|
|
650
|
+
/**
|
|
651
|
+
* Called by groups for the components they remove, so that the DSP no longer updates them.
|
|
652
|
+
*/
|
|
653
|
+
unregister(path: string, item: AbstractItem<any>): void;
|
|
654
|
+
/**
|
|
655
|
+
* Notify the component to change its value.
|
|
656
|
+
*/
|
|
657
|
+
paramChangeByDSP(path: string, value: number): void;
|
|
658
|
+
/**
|
|
659
|
+
* Can be overriden, called by components when its value is changed by user.
|
|
660
|
+
*/
|
|
661
|
+
paramChangeByUI: (path: string, value: number) => void;
|
|
662
|
+
/**
|
|
663
|
+
* Calculate UI layout in grid then calculate grid size.
|
|
664
|
+
*/
|
|
665
|
+
calc(): void;
|
|
666
|
+
/**
|
|
667
|
+
* Calculate grid size by DOM root size and layout size in grids.
|
|
668
|
+
*/
|
|
669
|
+
calcGrid(): number;
|
|
670
|
+
/**
|
|
671
|
+
* Force recalculate grid size and resize UI
|
|
672
|
+
*/
|
|
673
|
+
resize(): void;
|
|
674
|
+
/** Filter out items with `hidden` metadata and `soundfile` items */
|
|
675
|
+
filter(ui: FaustUIItem[]): FaustUIItem[];
|
|
676
|
+
get ui(): FaustUIItem[];
|
|
677
|
+
set ui(uiIn: FaustUIItem[]);
|
|
678
|
+
get layout(): LayoutProps;
|
|
679
|
+
get minWidth(): number;
|
|
680
|
+
get minHeight(): number;
|
|
681
|
+
}
|
|
682
|
+
export declare const instantiate: () => void;
|
|
683
|
+
|
|
684
|
+
export {};
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
6
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
7
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
8
|
+
<title>FaustUI</title>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body style="margin: 0; position: absolute; width: 100%; height: 100%; overflow: hidden; background-color: black;">
|
|
12
|
+
<div id="root" style="width: 100%; height: 100%; margin: 0; position: absolute; overflow: auto; display: flex; flex-direction: column;"></div>
|
|
13
|
+
</body>
|
|
14
|
+
|
|
15
|
+
<script type="text/javascript" src="./index.js"></script>
|
|
16
|
+
<script>FaustUI.instantiate()</script>
|
|
17
|
+
</html>
|