feat: pattern gallery as a preset editor; chase steps; sim split with the preset editor
- Pattern gallery shows the controller's presets, one at a time, with a dropdown, Save, Add preset, and the controller's field labels, delay limits and colour counts. Edits show in the preview; Save writes to the controller only. - Presets are always timed in ms (beat_time is no longer sent to drivers); beats stay in sequences. - Chase steps of 0 hold still; the marquee style is removed from the controller, the gallery and the driver (submodule commit 12a8e22). - The rig's split pane opens the preset editor too (Rig / Presets switch and a Preset editor menu entry). - Sequence editor, room layout and simulator controls from earlier work are included. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8c783ab926
commit
cb51a726bc
79 files changed
+5183
-934
No files matched your search
@@ -1179,6 +1179,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
updateManualModeAvailability();
|
||||
};
|
||||
presetModeInput?.addEventListener('change', () => {
|
||||
const patternName = presetPatternInput ? presetPatternInput.value.trim() : '';
|
||||
updatePresetNLabels(patternName, { mode: presetModeInput.value, n6: presetModeInput.value });
|
||||
});
|
||||
|
||||
const renderPresets = (presets) => {
|
||||
presetsList.innerHTML = '';
|
||||
|
||||
+47
-24
@@ -101,6 +101,11 @@ function tlWindowOf(doc) {
|
||||
}
|
||||
|
||||
/** The window in both units, as saved: the player and older clients read whichever they use. */
|
||||
/** The length of a clip dropped or clicked in: fixed, so only the end marker changes the sequence's duration. */
|
||||
function tlNewLen() {
|
||||
return tlTimed() ? 4 : TL_BAR;
|
||||
}
|
||||
|
||||
function tlWindowFields() {
|
||||
const w = tlLoopLen();
|
||||
const beatS = 60 / tlBpm();
|
||||
@@ -472,14 +477,17 @@ function tlRender() {
|
||||
}
|
||||
ruler.appendChild(tick);
|
||||
}
|
||||
if (loop) {
|
||||
{
|
||||
// The end marker sets the loop's length, or, with Loop off, how long the one-shot plays
|
||||
const brace = document.createElement('div');
|
||||
brace.className = 'tl-loop';
|
||||
brace.style.width = `${loopLen * ppb}px`;
|
||||
brace.title = 'Loop: every track restarts here. Drag the end to change it.';
|
||||
brace.title = loop
|
||||
? 'Loop: every track restarts here. Drag the end to change it.'
|
||||
: 'Duration: the one-shot plays this long. Drag the end to change it.';
|
||||
const end = document.createElement('div');
|
||||
end.className = 'tl-loop-end';
|
||||
end.title = 'Drag to set where the loop restarts';
|
||||
end.title = loop ? 'Drag to set where the loop restarts' : 'Drag to set how long the one-shot plays';
|
||||
end.addEventListener('pointerdown', (e) => tlStartDrag(e, { kind: 'loop' }));
|
||||
brace.appendChild(end);
|
||||
ruler.appendChild(brace);
|
||||
@@ -609,12 +617,7 @@ function tlRenderAddTrack() {
|
||||
.sort(byName(seqEd.groupsMap))
|
||||
.forEach((g) => gg.appendChild(new Option((seqEd.groupsMap[g] && seqEd.groupsMap[g].name) || g, `g:${g}`)));
|
||||
if (gg.children.length) sel.appendChild(gg);
|
||||
const dg = document.createElement('optgroup');
|
||||
dg.label = 'Single drivers';
|
||||
Object.keys(seqEd.devicesMap)
|
||||
.sort(byName(seqEd.devicesMap))
|
||||
.forEach((m) => dg.appendChild(new Option((seqEd.devicesMap[m] && seqEd.devicesMap[m].name) || m, `d:${m}`)));
|
||||
if (dg.children.length) sel.appendChild(dg);
|
||||
// Sequences play to groups only: no single drivers as tracks
|
||||
sel.appendChild(new Option('Empty track (pick later)', 'empty'));
|
||||
sel.value = '';
|
||||
}
|
||||
@@ -629,9 +632,6 @@ function tlAddTrack(v) {
|
||||
if (v.startsWith('g:')) {
|
||||
const g = v.slice(2);
|
||||
t = { name: (seqEd.groupsMap[g] && seqEd.groupsMap[g].name) || g, group_ids: [g] };
|
||||
} else if (v.startsWith('d:')) {
|
||||
const m = v.slice(2);
|
||||
t = { name: (seqEd.devicesMap[m] && seqEd.devicesMap[m].name) || m, devices: [m] };
|
||||
}
|
||||
if (addSeqTarget(t)) {
|
||||
seqTl.sel = v === 'empty' ? { track: seqEd.targets[seqEd.targets.length - 1].uid } : seqTl.sel;
|
||||
@@ -768,7 +768,6 @@ function tlInspectClip(host, c) {
|
||||
}
|
||||
c.start = s;
|
||||
c.len = l;
|
||||
seqTl.lastLen = l;
|
||||
tlRender();
|
||||
};
|
||||
start.addEventListener('change', apply);
|
||||
@@ -847,10 +846,6 @@ function tlInspectTrack(host, t) {
|
||||
Object.keys(seqEd.groupsMap)
|
||||
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))
|
||||
.forEach((g) => box((seqEd.groupsMap[g] && seqEd.groupsMap[g].name) || g, t.group_ids, g));
|
||||
lab('and single drivers');
|
||||
Object.keys(seqEd.devicesMap)
|
||||
.sort((a, b) => String((seqEd.devicesMap[a] || {}).name || a).localeCompare(String((seqEd.devicesMap[b] || {}).name || b)))
|
||||
.forEach((m) => box((seqEd.devicesMap[m] && seqEd.devicesMap[m].name) || m, t.devices, m));
|
||||
host.appendChild(pick);
|
||||
const btns = document.createElement('div');
|
||||
btns.className = 'tl-insp-btns';
|
||||
@@ -871,8 +866,7 @@ function tlInspectTrack(host, t) {
|
||||
'Remove track',
|
||||
'Remove the track and its clips',
|
||||
() => {
|
||||
const n = tlClipsOn(t.uid).length;
|
||||
if (n && !confirm(`Remove this track and its ${n} clip(s)?`)) return;
|
||||
// No confirm(): some webviews block it and the track never went. Undo (Ctrl+Z) brings it back
|
||||
seqTl.clips = seqTl.clips.filter((c) => c.uid !== t.uid);
|
||||
seqEd.targets.splice(seqEd.targets.indexOf(t), 1);
|
||||
seqTl.sel = null;
|
||||
@@ -956,7 +950,7 @@ function tlAddAt(uid, start, play) {
|
||||
alert('Pick a preset in the browser first (click it), or drag one onto the track.');
|
||||
return;
|
||||
}
|
||||
const want = play.startsWith('a:') ? tlSeqLen(seqEd.seqMap[play.slice(2)]) : seqTl.lastLen;
|
||||
const want = play.startsWith('a:') ? tlSeqLen(seqEd.seqMap[play.slice(2)]) : tlNewLen();
|
||||
const gap = tlGap(uid, start);
|
||||
if (!gap) return;
|
||||
const len = tlR(Math.min(want, gap.to - start));
|
||||
@@ -1125,6 +1119,19 @@ function tlStartDrag(e, d) {
|
||||
if (d.kind === 'move' || d.kind === 'left' || d.kind === 'right') {
|
||||
if (!seqTl.sel || seqTl.sel.clip !== d.id) tlSelect({ clip: d.id });
|
||||
}
|
||||
if (d.kind === 'move' || d.kind === 'new') {
|
||||
// Held near the timeline's edge, the timeline scrolls, and the ghost follows the pointer
|
||||
seqTl.drag.scroll = setInterval(() => {
|
||||
const dd = seqTl.drag;
|
||||
if (!dd || !dd.last) return;
|
||||
const sp = tlEdgeSpeed(dd.last.clientX);
|
||||
const sc = tlEl('tl-scroll');
|
||||
if (sp && sc) {
|
||||
sc.scrollLeft += sp;
|
||||
tlDragMove(dd.last);
|
||||
}
|
||||
}, 16);
|
||||
}
|
||||
}
|
||||
|
||||
function tlGhost(lane) {
|
||||
@@ -1154,9 +1161,22 @@ function tlFloat(d, x, y) {
|
||||
f.style.top = `${y + 8}px`;
|
||||
}
|
||||
|
||||
/** Scroll per frame while the pointer is within TL_EDGE px of the timeline's left or right edge (0 elsewhere). */
|
||||
const TL_EDGE = 40;
|
||||
function tlEdgeSpeed(clientX) {
|
||||
const sc = tlEl('tl-scroll');
|
||||
if (!sc) return 0;
|
||||
const r = sc.getBoundingClientRect();
|
||||
if (clientX > r.right - TL_EDGE) return Math.min(24, 4 + (clientX - (r.right - TL_EDGE)) / 2);
|
||||
const left = r.left + tlHeadWidth();
|
||||
if (clientX < left + TL_EDGE) return -Math.min(24, 4 + (left + TL_EDGE - clientX) / 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
function tlDragMove(e) {
|
||||
const d = seqTl.drag;
|
||||
if (!d || e.pointerId !== d.pid) return;
|
||||
d.last = e;
|
||||
const dxp = e.clientX - d.x0;
|
||||
const dyp = e.clientY - d.y0;
|
||||
if (!d.moved && Math.hypot(dxp, dyp) < 5) return;
|
||||
@@ -1176,9 +1196,11 @@ function tlDragMove(e) {
|
||||
const c = tlClip(d.id);
|
||||
if (!c) return;
|
||||
const end0 = d.start0 + d.len0;
|
||||
// The right edge the user grabbed is where the clip is drawn: the window's end when the clip falls off it
|
||||
const visEnd0 = d.start0 + Math.min(d.len0, tlLoopLen() - d.start0);
|
||||
if (d.kind === 'right') {
|
||||
const gap = tlGap(c.uid, d.start0, c.id);
|
||||
const len = Math.max(tlMin(), tlQ(end0 + dx) - d.start0);
|
||||
const len = Math.max(tlMin(), tlQ(visEnd0 + dx) - d.start0);
|
||||
c.len = tlR(Math.min(len, (gap ? gap.to : Infinity) - d.start0));
|
||||
} else {
|
||||
const gap = tlGap(c.uid, end0 - TL_EPS * 10, c.id);
|
||||
@@ -1187,7 +1209,7 @@ function tlDragMove(e) {
|
||||
c.len = tlR(end0 - s);
|
||||
}
|
||||
d.el.style.left = `${c.start * ppb}px`;
|
||||
d.el.style.width = `${c.len * ppb}px`;
|
||||
d.el.style.width = `${Math.min(c.len, tlLoopLen() - c.start) * ppb}px`; // drawn up to the window's end, as tlRender does
|
||||
return;
|
||||
}
|
||||
// move / new: a ghost on the track under the pointer
|
||||
@@ -1203,7 +1225,7 @@ function tlDragMove(e) {
|
||||
let ok;
|
||||
if (d.kind === 'new') {
|
||||
start = tlQ(tlLaneX(lane, e.clientX) / ppb, true);
|
||||
const want = d.play.startsWith('a:') ? tlSeqLen(seqEd.seqMap[d.play.slice(2)]) : seqTl.lastLen;
|
||||
const want = d.play.startsWith('a:') ? tlSeqLen(seqEd.seqMap[d.play.slice(2)]) : tlNewLen();
|
||||
const gap = tlGap(uid, start);
|
||||
len = gap ? tlR(Math.min(want, gap.to - start)) : want;
|
||||
ok = !!gap && len >= tlMin() - TL_EPS;
|
||||
@@ -1221,6 +1243,7 @@ function tlDragMove(e) {
|
||||
function tlDragEnd(e, cancelled) {
|
||||
const d = seqTl.drag;
|
||||
seqTl.drag = null;
|
||||
if (d && d.scroll) clearInterval(d.scroll);
|
||||
tlGhost(null);
|
||||
const f = tlEl('tl-float');
|
||||
if (f) f.remove();
|
||||
@@ -1255,7 +1278,7 @@ function tlDragEnd(e, cancelled) {
|
||||
if (c && cancelled) {
|
||||
c.start = d.start0;
|
||||
c.len = d.len0;
|
||||
} else if (c) seqTl.lastLen = c.len;
|
||||
}
|
||||
}
|
||||
tlRender();
|
||||
}
|
||||
|
||||
+93
-14
@@ -13,10 +13,14 @@
|
||||
const LOCK_PX = 10; // movement before a touch counts as a swipe or a scroll
|
||||
const DRAG_CLASS = 'sim-swipe-dragging';
|
||||
|
||||
// What the pane shows: the rig, or the preset editor (the pattern gallery) in the same pane
|
||||
const VIEWS = { rig: '/sim/', presets: '/sim/gallery' };
|
||||
let pane = null;
|
||||
let frame = null;
|
||||
let pager = null;
|
||||
let width = 0;
|
||||
let page = 0; // swipe mode: 0 the controller, 1 the rig
|
||||
let view = 'rig';
|
||||
|
||||
function load() {
|
||||
try {
|
||||
@@ -56,6 +60,20 @@
|
||||
document.documentElement.style.setProperty('--sim-drag', `${Math.round(px)}px`);
|
||||
}
|
||||
|
||||
// Show the rig or the preset editor in the pane. Switching unloads the other page (its bars power off)
|
||||
function setView(v) {
|
||||
view = v === 'presets' ? 'presets' : 'rig';
|
||||
if (frame && frame.dataset.view !== view) {
|
||||
frame.dataset.view = view;
|
||||
frame.src = VIEWS[view];
|
||||
}
|
||||
if (pane) {
|
||||
pane.querySelectorAll('.sim-pane-tabs button').forEach((b) =>
|
||||
b.setAttribute('aria-pressed', String(b.dataset.view === view)));
|
||||
}
|
||||
save({ view });
|
||||
}
|
||||
|
||||
function setPage(p) {
|
||||
page = p ? 1 : 0;
|
||||
document.documentElement.style.setProperty('--sim-page', String(page));
|
||||
@@ -89,7 +107,7 @@
|
||||
}
|
||||
|
||||
function popOut() {
|
||||
const win = window.open('/sim/', 'led-simulator', 'popup,width=1200,height=800');
|
||||
const win = window.open(VIEWS[view], 'led-simulator', 'popup,width=1200,height=800');
|
||||
if (!win) {
|
||||
// Pop-ups blocked: keep the simulator here
|
||||
alert('The browser blocked the simulator window. Allow pop-ups for this site, or open /sim/ in a new tab.');
|
||||
@@ -201,20 +219,21 @@
|
||||
'<div class="sim-pane-divider" role="separator" aria-orientation="vertical" ' +
|
||||
'aria-label="Resize the simulator" title="Drag to resize"></div>' +
|
||||
'<div class="sim-pane-body">' +
|
||||
'<div class="sim-pane-bar">' +
|
||||
'<span class="sim-pane-title">Simulator</span>' +
|
||||
'<button type="button" class="btn btn-secondary btn-small" data-sim="popout" ' +
|
||||
'title="Open the simulator in its own window">Pop out ↗</button>' +
|
||||
'<button type="button" class="btn btn-secondary btn-small" data-sim="close" ' +
|
||||
'title="Close the simulator (its bars power off)" aria-label="Close the simulator">×</button>' +
|
||||
'<div class="sim-pane-tabs" role="group" aria-label="Show the rig or the preset editor">' +
|
||||
'<button type="button" data-view="rig">Rig</button>' +
|
||||
'<button type="button" data-view="presets">Presets</button>' +
|
||||
'</div>' +
|
||||
'<iframe class="sim-pane-frame" src="/sim/" title="Simulated rig"></iframe>' +
|
||||
'<iframe class="sim-pane-frame" title="Simulator"></iframe>' +
|
||||
'</div>';
|
||||
pane.querySelector('[data-sim="popout"]').addEventListener('click', popOut);
|
||||
pane.querySelector('[data-sim="close"]').addEventListener('click', close);
|
||||
pane.querySelectorAll('.sim-pane-tabs button').forEach((b) => {
|
||||
b.setAttribute('aria-pressed', String(b.dataset.view === view));
|
||||
b.addEventListener('click', () => setView(b.dataset.view));
|
||||
});
|
||||
|
||||
// Swipes that start in the rig (same origin, so its document can be listened to)
|
||||
const frame = pane.querySelector('iframe');
|
||||
frame = pane.querySelector('iframe');
|
||||
frame.dataset.view = view;
|
||||
frame.src = VIEWS[view];
|
||||
frame.addEventListener('load', () => {
|
||||
try {
|
||||
attachSwipe(frame.contentDocument);
|
||||
@@ -262,14 +281,21 @@
|
||||
document.body.appendChild(pager);
|
||||
}
|
||||
|
||||
function open() {
|
||||
function open(which) {
|
||||
if (which) {
|
||||
view = which === 'presets' ? 'presets' : 'rig';
|
||||
}
|
||||
if (!pane) {
|
||||
build();
|
||||
width = load().width || 0;
|
||||
page = swipeMode() ? 1 : 0; // on a phone, opening it shows it
|
||||
// On a phone, opening the rig shows it. Opening the preset editor leaves the controller on screen
|
||||
page = swipeMode() && view === 'rig' ? 1 : 0;
|
||||
} else {
|
||||
setView(view);
|
||||
}
|
||||
save({ open: true });
|
||||
layout();
|
||||
syncMenu();
|
||||
window.dispatchEvent(new Event('resize')); // the UI lays out for its new width
|
||||
}
|
||||
|
||||
@@ -277,6 +303,7 @@
|
||||
if (pane) {
|
||||
pane.remove(); // the iframe goes with it: its bars power off
|
||||
pane = null;
|
||||
frame = null;
|
||||
}
|
||||
if (pager) {
|
||||
pager.remove();
|
||||
@@ -290,6 +317,7 @@
|
||||
document.documentElement.style.setProperty('--sim-page', '0');
|
||||
setDrag(0);
|
||||
save({ open: false });
|
||||
syncMenu();
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}
|
||||
|
||||
@@ -304,6 +332,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The Menu's Preset editor entry: open the pane on the presets, or switch the open pane to them
|
||||
function openPresets() {
|
||||
if (!isOpen()) {
|
||||
open('presets');
|
||||
return;
|
||||
}
|
||||
setView('presets'); // the controller stays on screen; on a phone the pager switches to it
|
||||
}
|
||||
const paneItems = []; // the Menu's Pop out and Close entries
|
||||
|
||||
function addMenuEntries() {
|
||||
// A header button for the Menu item to forward to, as the other entries do (help.js)
|
||||
const headerActions = document.querySelector('.header-actions');
|
||||
@@ -325,6 +363,45 @@
|
||||
item.textContent = 'Simulator';
|
||||
const settingsItem = menu.querySelector('[data-target="settings-btn"]');
|
||||
menu.insertBefore(item, settingsItem);
|
||||
const presetsReal = document.createElement('button');
|
||||
presetsReal.id = 'sim-presets-btn';
|
||||
presetsReal.hidden = true;
|
||||
presetsReal.addEventListener('click', openPresets);
|
||||
document.body.appendChild(presetsReal);
|
||||
const presetsItem = document.createElement('button');
|
||||
presetsItem.type = 'button';
|
||||
presetsItem.className = 'edit-mode-only';
|
||||
presetsItem.dataset.target = 'sim-presets-btn';
|
||||
presetsItem.textContent = 'Preset editor';
|
||||
menu.insertBefore(presetsItem, settingsItem);
|
||||
|
||||
// Pop out and Close: in the Menu only while the pane is open (syncMenu). The menu forwards its clicks to
|
||||
// the real buttons with these ids (help.js)
|
||||
for (const [label, id, action] of [
|
||||
['Pop out ↗', 'sim-popout-btn', popOut],
|
||||
['Close simulator', 'sim-close-btn', close],
|
||||
]) {
|
||||
const real = document.createElement('button');
|
||||
real.id = id;
|
||||
real.hidden = true;
|
||||
real.addEventListener('click', action);
|
||||
document.body.appendChild(real);
|
||||
const entry = document.createElement('button');
|
||||
entry.type = 'button';
|
||||
entry.className = 'sim-pane-item';
|
||||
entry.dataset.target = id;
|
||||
entry.textContent = label;
|
||||
entry.style.display = 'none';
|
||||
menu.insertBefore(entry, settingsItem);
|
||||
paneItems.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The pane's Menu entries show while it is open. An inline display wins over the menu's own rules
|
||||
function syncMenu() {
|
||||
for (const entry of paneItems) {
|
||||
entry.style.display = isOpen() ? '' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,16 +419,18 @@
|
||||
addMenuEntries();
|
||||
attachSwipe(document); // swipes that start on the controller's page
|
||||
const saved = load();
|
||||
view = saved.view === 'presets' ? 'presets' : 'rig';
|
||||
if (saved.open) {
|
||||
build();
|
||||
width = saved.width || 0;
|
||||
page = saved.page ? 1 : 0;
|
||||
layout();
|
||||
}
|
||||
syncMenu();
|
||||
window.addEventListener('resize', layout);
|
||||
}
|
||||
|
||||
window.simSplit = { open, close, popOut, setPage };
|
||||
window.simSplit = { open, close, popOut, setPage, setView };
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
|
||||
+21
-9
@@ -3551,18 +3551,30 @@ body.sim-split-dragging .sim-pane-divider {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sim-pane-bar {
|
||||
|
||||
.sim-pane-tabs {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.35rem 0.5rem;
|
||||
background-color: #1a1a1a;
|
||||
border-bottom: 2px solid #4a4a4a;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
background-color: #16181d;
|
||||
border-bottom: 1px solid #2a2d35;
|
||||
}
|
||||
|
||||
.sim-pane-title {
|
||||
flex: 1;
|
||||
font-weight: 600;
|
||||
.sim-pane-tabs button {
|
||||
padding: 2px 10px;
|
||||
font-size: 12px;
|
||||
color: #c9ced8;
|
||||
background-color: #23262e;
|
||||
border: 1px solid #3a3e48;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sim-pane-tabs button[aria-pressed="true"] {
|
||||
color: #0e0f12;
|
||||
background-color: #5aa9ff;
|
||||
border-color: #5aa9ff;
|
||||
}
|
||||
|
||||
.sim-pane-frame {
|
||||
|
||||
@@ -399,8 +399,7 @@
|
||||
<option value="time">Seconds</option>
|
||||
</select></label>
|
||||
<label class="tl-tfield">Snap <select id="tl-snap"></select></label>
|
||||
<label class="tl-tfield tl-loop-toggle" title="On: loops, every track restarting at the end of the loop bar. Off: a one-shot that plays once in seconds, then the zone goes back to its last looping preset or sequence."><input type="checkbox" id="sequence-editor-loop" checked> Loop</label>
|
||||
<label class="tl-tfield" title="Add a track for a group or a single driver"><select id="tl-add-track"></select></label>
|
||||
<label class="tl-tfield tl-loop-toggle" title="On: loops, every track restarting at the end of the loop bar. Off: a one-shot that plays once in seconds, then the zone goes back to its last looping preset or sequence."><input type="checkbox" id="sequence-editor-loop" checked> Loop</label> <label class="tl-tfield" title="Add a track for a group or a single driver"><select id="tl-add-track"></select></label>
|
||||
<div class="tl-tgroup">
|
||||
<button type="button" class="tl-tbtn" id="tl-zoom-out" title="Zoom out">−</button>
|
||||
<button type="button" class="tl-tbtn" id="tl-zoom-in" title="Zoom in">+</button>
|
||||
|
||||
Reference in new issue
Block a user