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
+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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user