solid-pianoroll 0.0.18 → 0.0.19
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/dist/cjs/index.js +228 -216
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +228 -216
- package/dist/esm/index.js.map +1 -1
- package/dist/source/PianoRoll.jsx +39 -47
- package/dist/source/PianoRollKeys.jsx +17 -14
- package/dist/source/PianoRollNotes.jsx +1 -1
- package/dist/source/viewport/{ScrollContainer.jsx → ScrollZoomContainer.jsx} +6 -6
- package/dist/source/viewport/ScrollZoomViewPort.jsx +13 -1
- package/dist/source/viewport/ZoomSliderControl.jsx +26 -0
- package/dist/source/viewport/createViewPortDimension.js +17 -10
- package/dist/types/viewport/{ScrollContainer.d.ts → ScrollZoomContainer.d.ts} +2 -2
- package/dist/types/viewport/ScrollZoomViewPort.d.ts +14 -3
- package/dist/types/viewport/{VerticalZoomControl.d.ts → ZoomSliderControl.d.ts} +3 -2
- package/dist/types/viewport/createViewPortDimension.d.ts +6 -2
- package/package.json +1 -1
- package/dist/source/viewport/HorizontalZoomControl.jsx +0 -11
- package/dist/source/viewport/VerticalZoomControl.jsx +0 -14
- package/dist/types/viewport/HorizontalZoomControl.d.ts +0 -5
package/dist/cjs/index.js
CHANGED
|
@@ -42,21 +42,28 @@ const usePianoRollContext = () => {
|
|
|
42
42
|
};
|
|
43
43
|
const splitContextProps = allProps => solidJs.splitProps(allProps, ["ppq", "mode", "position", "zoom", "verticalZoom", "verticalPosition", "verticalTrackZoom", "verticalTrackPosition", "gridDivision", "snapToGrid", "duration", "tracks", "selectedTrackIndex", "pressedKeys", "onPpqChange", "onModeChange", "onPositionChange", "onZoomChange", "onVerticalZoomChange", "onVerticalPositionChange", "onVerticalTrackZoomChange", "onVerticalTrackPositionChange", "onGridDivisionChange", "onSnapToGridChange", "onDurationChange", "onTracksChange", "onNoteChange", "onInsertNote", "onRemoveNote", "onSelectedTrackIndexChange", "onPressedKeysChange", "showAllTracks", "showTrackList"]);
|
|
44
44
|
|
|
45
|
-
var css_248z$4 = ".PianoRollKeys-module_PianoRollKeys__5vnQ0 {\n position: relative;\n height: 100%;\n
|
|
45
|
+
var css_248z$4 = ".PianoRollKeys-module_PianoRollKeys__5vnQ0 {\n position: relative;\n height: 100%;\n border-width: 0;\n border-color: #000;\n border-style: solid;\n border-right-width: 1px;\n border-left-width: 1px;\n background: white;\n cursor: pointer;\n}\n\n.PianoRollKeys-module_Key__jybNC {\n transition-property: background-color, box-shadow;\n transition-duration: 200ms;\n transition-timing-function: ease-out;\n border-width: 0px;\n position: absolute;\n box-sizing: border-box;\n width: 120%;\n left: -20%;\n border-color: #000;\n border-style: solid;\n}\n\n.PianoRollKeys-module_black__7rncB {\n background: black;\n border-top-right-radius: 12%;\n border-bottom-right-radius: 12%;\n margin-left: -20%;\n z-index: 1;\n}\n\n.PianoRollKeys-module_white__fR2Lm {\n background: white;\n border-top-width: 0.5px;\n border-bottom-width: 0.5px;\n}\n\n.PianoRollKeys-module_down__GcNeZ {\n transition: none;\n background: red;\n}\n";
|
|
46
46
|
var styles$4 = {"PianoRollKeys":"PianoRollKeys-module_PianoRollKeys__5vnQ0","Key":"PianoRollKeys-module_Key__jybNC","black":"PianoRollKeys-module_black__7rncB","white":"PianoRollKeys-module_white__fR2Lm","down":"PianoRollKeys-module_down__GcNeZ"};
|
|
47
47
|
styleInject(css_248z$4);
|
|
48
48
|
|
|
49
49
|
function createViewPortDimension(getState) {
|
|
50
|
-
const getStateWithFunctions = () =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
const getStateWithFunctions = () => {
|
|
51
|
+
const state = getState();
|
|
52
|
+
const onZoomChange = zoom => state.onZoomChange?.(clamp(zoom, state.minZoom, state.maxZoom));
|
|
53
|
+
const onPositionChange = position => state.onPositionChange?.(position);
|
|
54
|
+
return {
|
|
55
|
+
...state,
|
|
56
|
+
onZoomChange,
|
|
57
|
+
onPositionChange,
|
|
58
|
+
calculatePixelOffset,
|
|
59
|
+
calculatePixelValue,
|
|
60
|
+
calculatePosition,
|
|
61
|
+
calculatePixelDimensions,
|
|
62
|
+
calculateVisibleRange,
|
|
63
|
+
calculateMaxPosition,
|
|
64
|
+
isVisible
|
|
65
|
+
};
|
|
66
|
+
};
|
|
60
67
|
const [state, setState] = store.createStore(getStateWithFunctions());
|
|
61
68
|
solidJs.createEffect(() => setState(getStateWithFunctions()));
|
|
62
69
|
function calculatePixelValue(position = state.position) {
|
|
@@ -95,9 +102,18 @@ function createViewPortDimension(getState) {
|
|
|
95
102
|
}
|
|
96
103
|
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
97
104
|
|
|
105
|
+
const defaultViewPortProps = {
|
|
106
|
+
pixelOffset: 0,
|
|
107
|
+
position: 0,
|
|
108
|
+
range: 1,
|
|
109
|
+
zoom: 1,
|
|
110
|
+
minZoom: 1,
|
|
111
|
+
maxZoom: Infinity
|
|
112
|
+
};
|
|
98
113
|
const ScrollZoomViewPort = props => {
|
|
99
114
|
const viewPorts = Object.entries(props.dimensions).map(([name, viewPortProps]) => createViewPortDimension(() => ({
|
|
100
115
|
name: name,
|
|
116
|
+
...defaultViewPortProps,
|
|
101
117
|
...viewPortProps()
|
|
102
118
|
})));
|
|
103
119
|
const parentViewPorts = solidJs.useContext(ScrollZoomViewPortContext);
|
|
@@ -118,12 +134,12 @@ const useViewPortDimension = name => {
|
|
|
118
134
|
return viewPort;
|
|
119
135
|
};
|
|
120
136
|
|
|
121
|
-
var css_248z$3 = ".
|
|
122
|
-
var styles$3 = {"
|
|
137
|
+
var css_248z$3 = ".ScrollZoomContainer-module_ScrollZoomContainer__o2bRt {\n height: 100%;\n width: 100%;\n z-index: 4;\n}\n";
|
|
138
|
+
var styles$3 = {"ScrollZoomContainer":"ScrollZoomContainer-module_ScrollZoomContainer__o2bRt"};
|
|
123
139
|
styleInject(css_248z$3);
|
|
124
140
|
|
|
125
|
-
const _tmpl$$
|
|
126
|
-
const
|
|
141
|
+
const _tmpl$$7 = /*#__PURE__*/web.template(`<div><div><div><div></div></div></div></div>`, 8);
|
|
142
|
+
const ScrollZoomContainer = props => {
|
|
127
143
|
let scrollContentRef;
|
|
128
144
|
const [ownProps, divProps] = solidJs.splitProps(props, ["ref", "verticalDimensionName", "horizontalDimensionName", "showScrollbar"]);
|
|
129
145
|
const propsWithDefaults = solidJs.mergeProps({
|
|
@@ -194,7 +210,7 @@ const ScrollContainer = props => {
|
|
|
194
210
|
});
|
|
195
211
|
});
|
|
196
212
|
return (() => {
|
|
197
|
-
const _el$ = _tmpl$$
|
|
213
|
+
const _el$ = _tmpl$$7.cloneNode(true),
|
|
198
214
|
_el$2 = _el$.firstChild,
|
|
199
215
|
_el$3 = _el$2.firstChild,
|
|
200
216
|
_el$4 = _el$3.firstChild;
|
|
@@ -202,7 +218,7 @@ const ScrollContainer = props => {
|
|
|
202
218
|
_el$.addEventListener("scroll", handleScroll);
|
|
203
219
|
const _ref$ = props.ref;
|
|
204
220
|
typeof _ref$ === "function" ? web.use(_ref$, _el$) : props.ref = _el$;
|
|
205
|
-
web.spread(_el$, web.mergeProps({
|
|
221
|
+
web.spread(_el$, web.mergeProps(divProps, {
|
|
206
222
|
get style() {
|
|
207
223
|
return {
|
|
208
224
|
overflow: propsWithDefaults.showScrollbar ? "scroll" : "hidden",
|
|
@@ -211,11 +227,11 @@ const ScrollContainer = props => {
|
|
|
211
227
|
},
|
|
212
228
|
get classList() {
|
|
213
229
|
return {
|
|
214
|
-
[styles$3.
|
|
230
|
+
[styles$3.ScrollZoomContainer]: true,
|
|
215
231
|
...divProps.classList
|
|
216
232
|
};
|
|
217
233
|
}
|
|
218
|
-
}
|
|
234
|
+
}), false, true);
|
|
219
235
|
const _ref$2 = scrollContentRef;
|
|
220
236
|
typeof _ref$2 === "function" ? web.use(_ref$2, _el$2) : scrollContentRef = _el$2;
|
|
221
237
|
_el$3.style.setProperty("top", "0");
|
|
@@ -244,9 +260,10 @@ const ScrollContainer = props => {
|
|
|
244
260
|
})();
|
|
245
261
|
};
|
|
246
262
|
|
|
247
|
-
const _tmpl$$
|
|
263
|
+
const _tmpl$$6 = /*#__PURE__*/web.template(`<div></div>`, 2);
|
|
248
264
|
const PianoRollKeys = () => {
|
|
249
|
-
const
|
|
265
|
+
const verticalViewPort = solidJs.createMemo(() => useViewPortDimension("vertical"));
|
|
266
|
+
const horizontalViewPort = solidJs.createMemo(() => useViewPortDimension("horizontalKeys"));
|
|
250
267
|
const [isMouseDown, setIsMouseDown] = solidJs.createSignal(false);
|
|
251
268
|
const context = usePianoRollContext();
|
|
252
269
|
const handleMouseUp = () => {
|
|
@@ -259,106 +276,116 @@ const PianoRollKeys = () => {
|
|
|
259
276
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
260
277
|
}
|
|
261
278
|
});
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
279
|
+
return (() => {
|
|
280
|
+
const _el$ = _tmpl$$6.cloneNode(true);
|
|
281
|
+
web.insert(_el$, web.createComponent(ScrollZoomContainer, {
|
|
282
|
+
horizontalDimensionName: "horizontalKeys",
|
|
283
|
+
showScrollbar: false,
|
|
284
|
+
get children() {
|
|
285
|
+
return web.createComponent(solidJs.Index, {
|
|
286
|
+
each: keys,
|
|
287
|
+
children: key => {
|
|
288
|
+
const isDown = solidJs.createMemo(() => context.pressedKeys.includes(key().number));
|
|
289
|
+
const handleKeyDown = () => {
|
|
290
|
+
context.onPressedKeysChange?.([...context.pressedKeys, key().number]);
|
|
291
|
+
};
|
|
292
|
+
const handleKeyUp = () => {
|
|
293
|
+
context.onPressedKeysChange?.([...context.pressedKeys].filter(number => number !== key().number));
|
|
294
|
+
};
|
|
295
|
+
const virtualDimensions = solidJs.createMemo(() => verticalViewPort().calculatePixelDimensions(127 - key().number, 1));
|
|
296
|
+
const previousIsBlack = blackKeys.includes((key().number - 1) % 12);
|
|
297
|
+
const nextIsBlack = blackKeys.includes((key().number + 1) % 12);
|
|
298
|
+
return web.createComponent(solidJs.Show, {
|
|
299
|
+
get when() {
|
|
300
|
+
return virtualDimensions().size > 0;
|
|
301
|
+
},
|
|
302
|
+
get children() {
|
|
303
|
+
const _el$2 = _tmpl$$6.cloneNode(true);
|
|
304
|
+
_el$2.addEventListener("mouseleave", () => {
|
|
305
|
+
if (isMouseDown()) {
|
|
306
|
+
handleKeyUp();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
_el$2.addEventListener("mouseenter", () => {
|
|
310
|
+
if (isMouseDown()) {
|
|
311
|
+
handleKeyDown();
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
_el$2.$$mouseup = () => {
|
|
291
315
|
handleKeyUp();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (isMouseDown()) {
|
|
316
|
+
};
|
|
317
|
+
_el$2.$$mousedown = () => {
|
|
318
|
+
setIsMouseDown(true);
|
|
296
319
|
handleKeyDown();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
};
|
|
302
|
-
_el$.$$mousedown = () => {
|
|
303
|
-
setIsMouseDown(true);
|
|
304
|
-
handleKeyDown();
|
|
305
|
-
};
|
|
306
|
-
web.insert(_el$, web.createComponent(solidJs.Show, {
|
|
307
|
-
get when() {
|
|
308
|
-
return key().isBlack && false;
|
|
309
|
-
},
|
|
310
|
-
get children() {
|
|
311
|
-
const _el$2 = _tmpl$$7.cloneNode(true);
|
|
312
|
-
web.effect(_p$ => {
|
|
313
|
-
const _v$ = styles$4["black-separator"],
|
|
314
|
-
_v$2 = `${virtualDimensions().offset}px`,
|
|
315
|
-
_v$3 = `${virtualDimensions().size / 2 - 0.25}px`;
|
|
316
|
-
_v$ !== _p$._v$ && web.className(_el$2, _p$._v$ = _v$);
|
|
317
|
-
_v$2 !== _p$._v$2 && _el$2.style.setProperty("top", _p$._v$2 = _v$2);
|
|
318
|
-
_v$3 !== _p$._v$3 && _el$2.style.setProperty("height", _p$._v$3 = _v$3);
|
|
319
|
-
return _p$;
|
|
320
|
-
}, {
|
|
321
|
-
_v$: undefined,
|
|
322
|
-
_v$2: undefined,
|
|
323
|
-
_v$3: undefined
|
|
324
|
-
});
|
|
325
|
-
return _el$2;
|
|
326
|
-
}
|
|
327
|
-
}));
|
|
328
|
-
web.effect(_p$ => {
|
|
329
|
-
const _v$4 = {
|
|
330
|
-
[styles$4["Key"]]: true,
|
|
331
|
-
[styles$4["black"]]: key().isBlack,
|
|
332
|
-
[styles$4["white"]]: !key().isBlack,
|
|
333
|
-
[styles$4["down"]]: isDown()
|
|
320
|
+
};
|
|
321
|
+
web.insert(_el$2, web.createComponent(solidJs.Show, {
|
|
322
|
+
get when() {
|
|
323
|
+
return key().isBlack && false;
|
|
334
324
|
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
325
|
+
get children() {
|
|
326
|
+
const _el$3 = _tmpl$$6.cloneNode(true);
|
|
327
|
+
web.effect(_p$ => {
|
|
328
|
+
const _v$3 = styles$4["black-separator"],
|
|
329
|
+
_v$4 = `${virtualDimensions().offset}px`,
|
|
330
|
+
_v$5 = `${virtualDimensions().size / 2 - 0.25}px`;
|
|
331
|
+
_v$3 !== _p$._v$3 && web.className(_el$3, _p$._v$3 = _v$3);
|
|
332
|
+
_v$4 !== _p$._v$4 && _el$3.style.setProperty("top", _p$._v$4 = _v$4);
|
|
333
|
+
_v$5 !== _p$._v$5 && _el$3.style.setProperty("height", _p$._v$5 = _v$5);
|
|
334
|
+
return _p$;
|
|
335
|
+
}, {
|
|
336
|
+
_v$3: undefined,
|
|
337
|
+
_v$4: undefined,
|
|
338
|
+
_v$5: undefined
|
|
339
|
+
});
|
|
340
|
+
return _el$3;
|
|
341
|
+
}
|
|
342
|
+
}));
|
|
343
|
+
web.effect(_p$ => {
|
|
344
|
+
const _v$6 = {
|
|
345
|
+
[styles$4["Key"]]: true,
|
|
346
|
+
[styles$4["black"]]: key().isBlack,
|
|
347
|
+
[styles$4["white"]]: !key().isBlack,
|
|
348
|
+
[styles$4["down"]]: isDown()
|
|
349
|
+
},
|
|
350
|
+
_v$7 = key().name,
|
|
351
|
+
_v$8 = key().number % 12,
|
|
352
|
+
_v$9 = `${virtualDimensions().offset - (!key().isBlack && nextIsBlack ? virtualDimensions().size / 2 : 0)}px`,
|
|
353
|
+
_v$10 = `${virtualDimensions().size + (!key().isBlack && nextIsBlack ? virtualDimensions().size / 2 : 0) + (!key().isBlack && previousIsBlack ? virtualDimensions().size / 2 : 0)}px`,
|
|
354
|
+
_v$11 = [`0px 0px ${Math.min(virtualDimensions().size / 20, 1)}px ${Math.min(virtualDimensions().size / 50, 1)}px rgba(0, 0, 0, 0.5) ${key().isBlack ? "" : "inset"}`, isDown() && `0px 0px ${Math.min(virtualDimensions().size / 8, 2)}px ${Math.min(virtualDimensions().size / 20, 2)}px rgba(0, 0, 0, 0.5) inset`].filter(item => !!item).join(", ");
|
|
355
|
+
_p$._v$6 = web.classList(_el$2, _v$6, _p$._v$6);
|
|
356
|
+
_v$7 !== _p$._v$7 && web.setAttribute(_el$2, "title", _p$._v$7 = _v$7);
|
|
357
|
+
_v$8 !== _p$._v$8 && web.setAttribute(_el$2, "data-index", _p$._v$8 = _v$8);
|
|
358
|
+
_v$9 !== _p$._v$9 && _el$2.style.setProperty("top", _p$._v$9 = _v$9);
|
|
359
|
+
_v$10 !== _p$._v$10 && _el$2.style.setProperty("height", _p$._v$10 = _v$10);
|
|
360
|
+
_v$11 !== _p$._v$11 && _el$2.style.setProperty("box-shadow", _p$._v$11 = _v$11);
|
|
361
|
+
return _p$;
|
|
362
|
+
}, {
|
|
363
|
+
_v$6: undefined,
|
|
364
|
+
_v$7: undefined,
|
|
365
|
+
_v$8: undefined,
|
|
366
|
+
_v$9: undefined,
|
|
367
|
+
_v$10: undefined,
|
|
368
|
+
_v$11: undefined
|
|
369
|
+
});
|
|
370
|
+
return _el$2;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}));
|
|
377
|
+
web.effect(_p$ => {
|
|
378
|
+
const _v$ = styles$4.PianoRollKeys,
|
|
379
|
+
_v$2 = `${horizontalViewPort().pixelSize}px`;
|
|
380
|
+
_v$ !== _p$._v$ && web.className(_el$, _p$._v$ = _v$);
|
|
381
|
+
_v$2 !== _p$._v$2 && _el$.style.setProperty("width", _p$._v$2 = _v$2);
|
|
382
|
+
return _p$;
|
|
383
|
+
}, {
|
|
384
|
+
_v$: undefined,
|
|
385
|
+
_v$2: undefined
|
|
386
|
+
});
|
|
387
|
+
return _el$;
|
|
388
|
+
})();
|
|
362
389
|
};
|
|
363
390
|
const blackKeys = [1, 3, 6, 8, 10];
|
|
364
391
|
const keyNames = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
|
@@ -375,7 +402,7 @@ var css_248z$2 = ".PianoRollNotes-module_PianoRollNotes__6pF-y {\n position: ab
|
|
|
375
402
|
var styles$2 = {"PianoRollNotes":"PianoRollNotes-module_PianoRollNotes__6pF-y","Note":"PianoRollNotes-module_Note__-jxLb","trimStart":"PianoRollNotes-module_trimStart__vuBlj","trimEnd":"PianoRollNotes-module_trimEnd__zPdjr"};
|
|
376
403
|
styleInject(css_248z$2);
|
|
377
404
|
|
|
378
|
-
const _tmpl$$
|
|
405
|
+
const _tmpl$$5 = /*#__PURE__*/web.template(`<div></div>`, 2);
|
|
379
406
|
const PianoRollNotes = props => {
|
|
380
407
|
const context = usePianoRollContext();
|
|
381
408
|
const verticalViewPort = solidJs.createMemo(() => useViewPortDimension(context.mode === "keys" ? "vertical" : "verticalTracks"));
|
|
@@ -414,7 +441,7 @@ const PianoRollNotes = props => {
|
|
|
414
441
|
return noteDragMode ? [styles$2.Note, styles$2[noteDragMode]] : [styles$2.Note];
|
|
415
442
|
};
|
|
416
443
|
return (() => {
|
|
417
|
-
const _el$ = _tmpl$$
|
|
444
|
+
const _el$ = _tmpl$$5.cloneNode(true);
|
|
418
445
|
_el$.$$click = event => {
|
|
419
446
|
if (currentNote()) {
|
|
420
447
|
setCurrentNoteIndex(-1);
|
|
@@ -472,7 +499,7 @@ const PianoRollNotes = props => {
|
|
|
472
499
|
return web.memo(() => !!verticalViewPort().isVisible(verticalVirtualDimensions()))() && horizontalViewPort().isVisible(horizontalDimensions());
|
|
473
500
|
},
|
|
474
501
|
get children() {
|
|
475
|
-
const _el$2 = _tmpl$$
|
|
502
|
+
const _el$2 = _tmpl$$5.cloneNode(true);
|
|
476
503
|
_el$2.$$mousedown = event => {
|
|
477
504
|
event.stopPropagation();
|
|
478
505
|
setIsDragging(true);
|
|
@@ -569,7 +596,9 @@ const PianoRollNotes = props => {
|
|
|
569
596
|
});
|
|
570
597
|
}
|
|
571
598
|
}));
|
|
572
|
-
web.effect(
|
|
599
|
+
web.effect(_$p => web.classList(_el$, {
|
|
600
|
+
[styles$2.PianoRollNotes]: true
|
|
601
|
+
}, _$p));
|
|
573
602
|
return _el$;
|
|
574
603
|
})();
|
|
575
604
|
};
|
|
@@ -579,7 +608,7 @@ var css_248z$1 = ".PianoRollGrid-module_PianoRollGrid__tG119 {\n position: rela
|
|
|
579
608
|
var styles$1 = {"PianoRollGrid":"PianoRollGrid-module_PianoRollGrid__tG119","PianoRollGrid-Row":"PianoRollGrid-module_PianoRollGrid-Row__nRMCs","PianoRollGrid-Time":"PianoRollGrid-module_PianoRollGrid-Time__jLz3E"};
|
|
580
609
|
styleInject(css_248z$1);
|
|
581
610
|
|
|
582
|
-
const _tmpl$$
|
|
611
|
+
const _tmpl$$4 = /*#__PURE__*/web.template(`<div></div>`, 2);
|
|
583
612
|
const PianoRollGrid = () => {
|
|
584
613
|
const context = usePianoRollContext();
|
|
585
614
|
const verticalViewPort = solidJs.createMemo(() => useViewPortDimension(context.mode === "keys" ? "vertical" : "verticalTracks"));
|
|
@@ -609,7 +638,7 @@ const PianoRollGrid = () => {
|
|
|
609
638
|
}));
|
|
610
639
|
});
|
|
611
640
|
return (() => {
|
|
612
|
-
const _el$ = _tmpl$$
|
|
641
|
+
const _el$ = _tmpl$$4.cloneNode(true);
|
|
613
642
|
web.insert(_el$, web.createComponent(solidJs.Index, {
|
|
614
643
|
get each() {
|
|
615
644
|
return gridArray();
|
|
@@ -621,7 +650,7 @@ const PianoRollGrid = () => {
|
|
|
621
650
|
return virtualDimensions().size > 0;
|
|
622
651
|
},
|
|
623
652
|
get children() {
|
|
624
|
-
const _el$2 = _tmpl$$
|
|
653
|
+
const _el$2 = _tmpl$$4.cloneNode(true);
|
|
625
654
|
web.effect(_p$ => {
|
|
626
655
|
const _v$ = styles$1["PianoRollGrid-Time"],
|
|
627
656
|
_v$2 = Math.ceil((entry().index + 1 * selectedGridDivisorTicks()) / measureTicks()) % 2 === 0 ? "#ddd" : "#ccc",
|
|
@@ -660,7 +689,7 @@ const PianoRollGrid = () => {
|
|
|
660
689
|
return virtualDimensions().size > 0;
|
|
661
690
|
},
|
|
662
691
|
get children() {
|
|
663
|
-
const _el$3 = _tmpl$$
|
|
692
|
+
const _el$3 = _tmpl$$4.cloneNode(true);
|
|
664
693
|
_el$3.style.setProperty("width", "100%");
|
|
665
694
|
web.effect(_p$ => {
|
|
666
695
|
const _v$6 = styles$1["PianoRollGrid-Row"],
|
|
@@ -704,7 +733,7 @@ const PianoRollGrid = () => {
|
|
|
704
733
|
return virtualDimensions().size > 0;
|
|
705
734
|
},
|
|
706
735
|
get children() {
|
|
707
|
-
const _el$4 = _tmpl$$
|
|
736
|
+
const _el$4 = _tmpl$$4.cloneNode(true);
|
|
708
737
|
_el$4.style.setProperty("width", "100%");
|
|
709
738
|
_el$4.style.setProperty("border-width", "0");
|
|
710
739
|
web.effect(_p$ => {
|
|
@@ -763,50 +792,47 @@ function useBoundingClientRect(containerRef) {
|
|
|
763
792
|
return boundingClientRect;
|
|
764
793
|
}
|
|
765
794
|
|
|
766
|
-
const _tmpl$$
|
|
767
|
-
const
|
|
768
|
-
const
|
|
795
|
+
const _tmpl$$3 = /*#__PURE__*/web.template(`<input step="0.01">`, 1);
|
|
796
|
+
const ZoomSliderControl = props => {
|
|
797
|
+
const propsWithDefaults = solidJs.mergeProps({
|
|
798
|
+
orientation: "horizontal"
|
|
799
|
+
}, props);
|
|
800
|
+
const dimension = solidJs.createMemo(() => useViewPortDimension(props.dimensionName ?? propsWithDefaults.orientation));
|
|
769
801
|
return (() => {
|
|
770
|
-
const _el$ = _tmpl$$
|
|
771
|
-
web.spread(_el$, web.mergeProps(
|
|
802
|
+
const _el$ = _tmpl$$3.cloneNode(true);
|
|
803
|
+
web.spread(_el$, web.mergeProps({
|
|
804
|
+
get min() {
|
|
805
|
+
return dimension().minZoom;
|
|
806
|
+
},
|
|
807
|
+
get max() {
|
|
808
|
+
return dimension().maxZoom;
|
|
809
|
+
}
|
|
810
|
+
}, props, {
|
|
772
811
|
get value() {
|
|
773
812
|
return dimension().zoom;
|
|
774
813
|
},
|
|
775
814
|
"onInput": event => dimension().onZoomChange?.(event.currentTarget.valueAsNumber),
|
|
776
815
|
"type": "range"
|
|
777
|
-
}, {
|
|
778
|
-
orient:
|
|
779
|
-
}, {
|
|
816
|
+
}, () => ({
|
|
817
|
+
orient: propsWithDefaults.orientation
|
|
818
|
+
}), {
|
|
780
819
|
get style() {
|
|
781
|
-
return {
|
|
820
|
+
return propsWithDefaults.orientation === "vertical" ? {
|
|
821
|
+
margin: 0,
|
|
822
|
+
"margin-left": "4px",
|
|
823
|
+
"margin-right": "4px",
|
|
782
824
|
width: "16px",
|
|
783
825
|
transform: "rotate(180deg)",
|
|
784
826
|
...{
|
|
785
827
|
"writing-mode": "bt-lr" /* IE */,
|
|
786
828
|
"-webkit-appearance": "slider-vertical" /* WebKit */
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
}), false, false);
|
|
791
|
-
return _el$;
|
|
792
|
-
})();
|
|
793
|
-
};
|
|
829
|
+
},
|
|
794
830
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
web.spread(_el$, web.mergeProps(props, {
|
|
801
|
-
get value() {
|
|
802
|
-
return dimension().zoom;
|
|
803
|
-
},
|
|
804
|
-
"onInput": event => dimension().onZoomChange?.(event.currentTarget.valueAsNumber),
|
|
805
|
-
"type": "range",
|
|
806
|
-
get style() {
|
|
807
|
-
return {
|
|
808
|
-
"margin-left": "50px",
|
|
809
|
-
"margin-right": "16px",
|
|
831
|
+
...(typeof props.style === "object" && props.style)
|
|
832
|
+
} : {
|
|
833
|
+
margin: 0,
|
|
834
|
+
"margin-top": "4px",
|
|
835
|
+
"margin-bottom": "4px",
|
|
810
836
|
...(typeof props.style === "object" && props.style)
|
|
811
837
|
};
|
|
812
838
|
}
|
|
@@ -882,23 +908,11 @@ const PianoRoll = allProps => {
|
|
|
882
908
|
showAllTracks: false
|
|
883
909
|
}, allProps);
|
|
884
910
|
const [context, divProps] = splitContextProps(propsWithDefaults);
|
|
885
|
-
const [
|
|
886
|
-
const [
|
|
887
|
-
const
|
|
888
|
-
const
|
|
911
|
+
const [notesScrollerRef, setNotesScrollerRef] = solidJs.createSignal();
|
|
912
|
+
const [tracksScrollerRef, setTracksScrollerRef] = solidJs.createSignal();
|
|
913
|
+
const notesScrollerClientRect = useBoundingClientRect(notesScrollerRef);
|
|
914
|
+
const tracksScrollerClientRect = useBoundingClientRect(tracksScrollerRef);
|
|
889
915
|
const zoomFactor = 500;
|
|
890
|
-
const minZoom = solidJs.createMemo(() => 1 / (zoomFactor / clientRect().width));
|
|
891
|
-
const maxZoom = solidJs.createMemo(() => 500 * (zoomFactor / clientRect().width));
|
|
892
|
-
const minVerticalZoom = solidJs.createMemo(() => 1 / (zoomFactor / clientRect().height));
|
|
893
|
-
const maxVerticalZoom = solidJs.createMemo(() => 10 * (zoomFactor / clientRect().height));
|
|
894
|
-
const minVerticalTracksZoom = solidJs.createMemo(() => 0.8 / (zoomFactor / trackClientRef().height));
|
|
895
|
-
const maxVerticalTracksZoom = solidJs.createMemo(() => 3 * (zoomFactor / trackClientRef().height));
|
|
896
|
-
solidJs.createEffect(isInitial => {
|
|
897
|
-
if (isInitial) return false;
|
|
898
|
-
if (context.mode === "tracks") {
|
|
899
|
-
context.onVerticalPositionChange?.(0);
|
|
900
|
-
}
|
|
901
|
-
}, true);
|
|
902
916
|
return web.createComponent(PianoRollContextProvider, {
|
|
903
917
|
value: context,
|
|
904
918
|
get children() {
|
|
@@ -911,62 +925,64 @@ const PianoRoll = allProps => {
|
|
|
911
925
|
web.insert(_el$, web.createComponent(ScrollZoomViewPort, {
|
|
912
926
|
dimensions: {
|
|
913
927
|
horizontal: () => ({
|
|
914
|
-
pixelOffset:
|
|
915
|
-
pixelSize:
|
|
928
|
+
pixelOffset: notesScrollerClientRect().left,
|
|
929
|
+
pixelSize: notesScrollerClientRect().width,
|
|
916
930
|
position: context.position,
|
|
917
931
|
range: context.duration,
|
|
918
|
-
zoom: context.zoom * (zoomFactor /
|
|
932
|
+
zoom: context.zoom * (zoomFactor / notesScrollerClientRect().width),
|
|
919
933
|
onPositionChange: context.onPositionChange,
|
|
920
|
-
onZoomChange: zoom => context.onZoomChange?.(
|
|
934
|
+
onZoomChange: zoom => context.onZoomChange?.(zoom / (zoomFactor / notesScrollerClientRect().width)),
|
|
935
|
+
minZoom: 1,
|
|
936
|
+
maxZoom: 500
|
|
921
937
|
}),
|
|
922
938
|
vertical: () => ({
|
|
923
|
-
pixelOffset:
|
|
924
|
-
pixelSize:
|
|
939
|
+
pixelOffset: notesScrollerClientRect().top,
|
|
940
|
+
pixelSize: notesScrollerClientRect().height,
|
|
925
941
|
position: context.verticalPosition,
|
|
926
942
|
range: 128,
|
|
927
|
-
zoom: context.verticalZoom * (zoomFactor /
|
|
943
|
+
zoom: context.verticalZoom * (zoomFactor / notesScrollerClientRect().height),
|
|
928
944
|
onPositionChange: context.onVerticalPositionChange,
|
|
929
|
-
onZoomChange: verticalZoom => context.onVerticalZoomChange?.(
|
|
945
|
+
onZoomChange: verticalZoom => context.onVerticalZoomChange?.(verticalZoom / (zoomFactor / notesScrollerClientRect().height)),
|
|
946
|
+
minZoom: 1,
|
|
947
|
+
maxZoom: 10
|
|
930
948
|
}),
|
|
931
949
|
horizontalTracks: () => ({
|
|
932
|
-
pixelOffset:
|
|
933
|
-
pixelSize:
|
|
934
|
-
position: 0,
|
|
935
|
-
range: 1,
|
|
936
|
-
zoom: 1
|
|
950
|
+
pixelOffset: 0,
|
|
951
|
+
pixelSize: notesScrollerClientRect().width
|
|
937
952
|
}),
|
|
938
953
|
verticalTracks: () => ({
|
|
939
|
-
pixelOffset:
|
|
940
|
-
pixelSize:
|
|
954
|
+
pixelOffset: tracksScrollerClientRect().top,
|
|
955
|
+
pixelSize: tracksScrollerClientRect().height,
|
|
941
956
|
position: context.verticalTrackPosition,
|
|
942
957
|
range: context.tracks.length,
|
|
943
|
-
zoom: context.verticalTrackZoom * (zoomFactor /
|
|
958
|
+
zoom: context.verticalTrackZoom * (zoomFactor / tracksScrollerClientRect().height),
|
|
944
959
|
onPositionChange: context.onVerticalTrackPositionChange,
|
|
945
|
-
onZoomChange: verticalTrackZoom => context.onVerticalTrackZoomChange?.(
|
|
960
|
+
onZoomChange: verticalTrackZoom => context.onVerticalTrackZoomChange?.(verticalTrackZoom / (zoomFactor / tracksScrollerClientRect().height)),
|
|
961
|
+
minZoom: 0.8,
|
|
962
|
+
maxZoom: 3
|
|
963
|
+
}),
|
|
964
|
+
horizontalKeys: () => ({
|
|
965
|
+
pixelSize: 60
|
|
946
966
|
})
|
|
947
967
|
},
|
|
948
968
|
get children() {
|
|
949
969
|
return [(() => {
|
|
950
970
|
const _el$2 = _tmpl$$1.cloneNode(true),
|
|
951
971
|
_el$3 = _el$2.firstChild;
|
|
952
|
-
web.insert(_el$2, web.createComponent(
|
|
953
|
-
|
|
954
|
-
return minVerticalTracksZoom();
|
|
955
|
-
},
|
|
956
|
-
get max() {
|
|
957
|
-
return maxVerticalTracksZoom();
|
|
958
|
-
},
|
|
972
|
+
web.insert(_el$2, web.createComponent(ZoomSliderControl, {
|
|
973
|
+
orientation: "vertical",
|
|
959
974
|
dimensionName: "verticalTracks"
|
|
960
975
|
}), _el$3);
|
|
961
976
|
_el$3.style.setProperty("display", "flex");
|
|
962
|
-
_el$3.style.setProperty("width", "
|
|
977
|
+
_el$3.style.setProperty("width", "30%");
|
|
978
|
+
_el$3.style.setProperty("max-width", "250px");
|
|
963
979
|
web.insert(_el$3, web.createComponent(solidJs.Show, {
|
|
964
980
|
get when() {
|
|
965
981
|
return context.showTrackList;
|
|
966
982
|
},
|
|
967
983
|
get children() {
|
|
968
|
-
return web.createComponent(
|
|
969
|
-
ref:
|
|
984
|
+
return web.createComponent(ScrollZoomContainer, {
|
|
985
|
+
ref: setTracksScrollerRef,
|
|
970
986
|
horizontalDimensionName: "horizontalTracks",
|
|
971
987
|
verticalDimensionName: "verticalTracks",
|
|
972
988
|
get showScrollbar() {
|
|
@@ -986,8 +1002,8 @@ const PianoRoll = allProps => {
|
|
|
986
1002
|
return web.createComponent(PianoRollKeys, {});
|
|
987
1003
|
}
|
|
988
1004
|
}), null);
|
|
989
|
-
web.insert(_el$2, web.createComponent(
|
|
990
|
-
ref:
|
|
1005
|
+
web.insert(_el$2, web.createComponent(ScrollZoomContainer, {
|
|
1006
|
+
ref: setNotesScrollerRef,
|
|
991
1007
|
get verticalDimensionName() {
|
|
992
1008
|
return context.mode === "keys" ? "vertical" : "verticalTracks";
|
|
993
1009
|
},
|
|
@@ -995,25 +1011,21 @@ const PianoRoll = allProps => {
|
|
|
995
1011
|
return [web.memo(() => allProps.children), web.createComponent(PianoRollGrid, {}), web.createComponent(PianoRollNotes, {})];
|
|
996
1012
|
}
|
|
997
1013
|
}), null);
|
|
998
|
-
web.insert(_el$2, web.createComponent(
|
|
999
|
-
|
|
1000
|
-
return minVerticalZoom();
|
|
1001
|
-
},
|
|
1002
|
-
get max() {
|
|
1003
|
-
return maxVerticalZoom();
|
|
1004
|
-
},
|
|
1014
|
+
web.insert(_el$2, web.createComponent(ZoomSliderControl, {
|
|
1015
|
+
orientation: "vertical",
|
|
1005
1016
|
get disabled() {
|
|
1006
1017
|
return context.mode !== "keys";
|
|
1007
1018
|
}
|
|
1008
1019
|
}), null);
|
|
1009
1020
|
web.effect(() => web.className(_el$2, styles$5.PianoRollContainer));
|
|
1010
1021
|
return _el$2;
|
|
1011
|
-
})(), web.createComponent(
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1022
|
+
})(), web.createComponent(ZoomSliderControl, {
|
|
1023
|
+
orientation: "horizontal",
|
|
1024
|
+
get style() {
|
|
1025
|
+
return {
|
|
1026
|
+
"margin-left": `${tracksScrollerClientRect().width + 24}px`,
|
|
1027
|
+
"margin-right": "24px"
|
|
1028
|
+
};
|
|
1017
1029
|
}
|
|
1018
1030
|
})];
|
|
1019
1031
|
}
|