fablecut 1.22.0 → 1.23.0
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/CLAUDE.md +29 -0
- package/README.md +2 -1
- package/app.js +232 -111
- package/compact.css +702 -0
- package/compact.js +785 -0
- package/doc-guard.js +97 -0
- package/index.html +28 -10
- package/layout.js +72 -0
- package/manifest.json +1 -1
- package/mcp-server.js +1 -1
- package/package.json +2 -1
- package/style.css +7 -0
- package/touch.js +815 -0
package/app.js
CHANGED
|
@@ -33,6 +33,13 @@ const TRACK_SIZE_PRESETS = {
|
|
|
33
33
|
m: { thumbs: true, hVideo: 44, hAudio: 32 },
|
|
34
34
|
l: { thumbs: true, hVideo: 58, hAudio: 42 },
|
|
35
35
|
};
|
|
36
|
+
/* a finger needs taller lanes; empty ones shrink to a line (fitTrackHeights) */
|
|
37
|
+
const TRACK_SIZE_PHONE = {
|
|
38
|
+
s: { hVideo: 36, hAudio: 32 },
|
|
39
|
+
m: { hVideo: 46, hAudio: 40 },
|
|
40
|
+
l: { hVideo: 58, hAudio: 50 },
|
|
41
|
+
};
|
|
42
|
+
const TRACK_H_EMPTY = 12;
|
|
36
43
|
const TRACK_SIZE_KEY = "fablecut-track-size";
|
|
37
44
|
const LAST_TRANS_KEY = { in: "fablecut-last-trans-in", out: "fablecut-last-trans-out" };
|
|
38
45
|
const DEFAULT_LAST_TRANS = { type: "fade", duration: 1 };
|
|
@@ -1200,9 +1207,15 @@ function localTimeForMedia(c, mediaTarget) {
|
|
|
1200
1207
|
return (i - 1 + frac) * step;
|
|
1201
1208
|
}
|
|
1202
1209
|
let toastTimer = null;
|
|
1210
|
+
/* A symbol that phones draw as a colour emoji. Desktop shows the character; the
|
|
1211
|
+
compact layouts show the icon compact.css has under the same name. */
|
|
1212
|
+
const GLYPHS = { play: "▶", pause: "⏸", folder: "📁", browse: "📂", audio: "🎵", svg: "✨", image: "🖼", video: "🎞", sfx: "🔊", piece: "🧩", warn: "⚠", get: "⬇" };
|
|
1213
|
+
const glyph = (name) => `<span class="gx gx-${name}">${GLYPHS[name]}</span>`;
|
|
1214
|
+
/** On a phone or tablet the same hint in touch words ("tap" for "click"; compact.js has the list). */
|
|
1215
|
+
const touchWords = (s) => (self.FableCutCompact && monCompact() ? FableCutCompact.words(s) : s);
|
|
1203
1216
|
function toast(msg) {
|
|
1204
1217
|
if (!els.toast) return;
|
|
1205
|
-
els.toast.textContent = msg;
|
|
1218
|
+
els.toast.textContent = touchWords(msg);
|
|
1206
1219
|
els.toast.classList.add("show");
|
|
1207
1220
|
clearTimeout(toastTimer);
|
|
1208
1221
|
toastTimer = setTimeout(() => els.toast.classList.remove("show"), 3200);
|
|
@@ -1479,10 +1492,11 @@ function syncExportFrameSel() {
|
|
|
1479
1492
|
return `<option value="${j}" ${sel ? "selected" : ""}>${a.label}</option>`;
|
|
1480
1493
|
}).join("");
|
|
1481
1494
|
if (ef && i < 0)
|
|
1482
|
-
html += `<option value="custom" selected>Custom · ${ef.w}×${ef.h}</option>`;
|
|
1495
|
+
html += `<option value="custom" selected>Custom · ${escapeHtml(ef.w)}×${escapeHtml(ef.h)}</option>`;
|
|
1483
1496
|
els.exportFrameSel.innerHTML = html;
|
|
1484
1497
|
}
|
|
1485
1498
|
function applyProject(data, opts = {}) {
|
|
1499
|
+
FableCutGuard.clean(data); // a project can come from anywhere (doc-guard.js)
|
|
1486
1500
|
// the Export dialog's music credits follow the timeline while it is open
|
|
1487
1501
|
queueMicrotask(() => { if (!$("exportSetup")?.classList.contains("hidden")) syncExportCredits(); });
|
|
1488
1502
|
if (state.compCtx && !opts.ctx && SeqLib.activeId(data) !== SeqLib.activeId(state.compCtx.root)) {
|
|
@@ -1977,6 +1991,14 @@ function mediaKindFromFile(file) {
|
|
|
1977
1991
|
if (["png", "jpg", "jpeg", "gif", "webp", "bmp", "avif"].includes(ext)) return "image";
|
|
1978
1992
|
return null;
|
|
1979
1993
|
}
|
|
1994
|
+
/** Why a file can't be used here, in words a person can act on. */
|
|
1995
|
+
function importWhy(file, kind) {
|
|
1996
|
+
const ext = (/\.([a-z0-9]+)$/i.exec(file.name) || [])[1] || "";
|
|
1997
|
+
if (/^hei[cf]$/i.test(ext) || /hei[cf]/i.test(file.type || "")) return "a HEIC photo, which this browser can't read. Save or share it as JPEG, or set the camera to JPEG";
|
|
1998
|
+
if (!kind) return `the editor doesn't know this type${ext ? ` (.${ext.toLowerCase()})` : ""}`;
|
|
1999
|
+
if (kind === "video") return "this browser can't play it. Camera clips are often HEVC (H.265): set the camera to H.264 (“Most compatible”), or convert this one";
|
|
2000
|
+
return "the file can't be read";
|
|
2001
|
+
}
|
|
1980
2002
|
async function importFiles(fileList) {
|
|
1981
2003
|
const files = [...fileList];
|
|
1982
2004
|
if (!files.length) return [];
|
|
@@ -1984,14 +2006,20 @@ async function importFiles(fileList) {
|
|
|
1984
2006
|
? runtime.importFolderId : null;
|
|
1985
2007
|
runtime.importFolderId = null;
|
|
1986
2008
|
let added = 0, skipped = 0;
|
|
1987
|
-
const addedMedia = [], gen = runtime.projectGen;
|
|
2009
|
+
const addedMedia = [], gen = runtime.projectGen, notes = []; // notes: what to know about a file (left out, or no picture)
|
|
2010
|
+
const tell = (i, name) => window.dispatchEvent(new CustomEvent("fablecut:importing", { detail: { i, n: files.length, name, notes: i < files.length ? [] : notes } }));
|
|
1988
2011
|
for (const file of files) {
|
|
2012
|
+
tell(files.indexOf(file), file.name);
|
|
1989
2013
|
const kind = mediaKindFromFile(file);
|
|
1990
|
-
if (!kind) { skipped++; continue; }
|
|
2014
|
+
if (!kind) { skipped++; notes.push({ name: file.name, why: importWhy(file, null) }); continue; }
|
|
1991
2015
|
let src, transient = false;
|
|
1992
2016
|
if (state.connected) {
|
|
1993
2017
|
try {
|
|
1994
2018
|
const res = await fetch("/api/upload?name=" + encodeURIComponent(file.name), { method: "POST", body: file });
|
|
2019
|
+
if (res.status === 507) { // no room for it: a clip that lives only in this tab would be lost with it
|
|
2020
|
+
notes.push({ name: file.name, why: (await res.json().catch(() => ({}))).error || "there is no room left to store it" });
|
|
2021
|
+
skipped++; continue;
|
|
2022
|
+
}
|
|
1995
2023
|
if (!res.ok) throw new Error("upload " + res.status);
|
|
1996
2024
|
src = (await res.json()).src;
|
|
1997
2025
|
} catch { src = URL.createObjectURL(file); transient = true; }
|
|
@@ -2003,7 +2031,8 @@ async function importFiles(fileList) {
|
|
|
2003
2031
|
await loadMediaMetadata(m);
|
|
2004
2032
|
if (kind === "video") grabThumb(m).catch(() => { });
|
|
2005
2033
|
ensureWave(m);
|
|
2006
|
-
} catch { skipped++; continue; }
|
|
2034
|
+
} catch { skipped++; notes.push({ name: file.name, why: importWhy(file, kind) }); continue; }
|
|
2035
|
+
if (kind === "video" && !m.width && m.duration > 0) notes.push({ name: file.name, why: "only its sound can be used: " + importWhy(file, kind) });
|
|
2007
2036
|
if (gen !== runtime.projectGen) { toast("Import stopped: another project was opened. The uploaded files are in media/"); break; }
|
|
2008
2037
|
project.media.push(m);
|
|
2009
2038
|
addedMedia.push(m);
|
|
@@ -2015,6 +2044,8 @@ async function importFiles(fileList) {
|
|
|
2015
2044
|
toast("Couldn't import — unsupported or unreadable file type");
|
|
2016
2045
|
else if (skipped)
|
|
2017
2046
|
toast(`Imported ${added}, skipped ${skipped}`);
|
|
2047
|
+
tell(files.length, "");
|
|
2048
|
+
if (added) window.dispatchEvent(new CustomEvent("fablecut:imported", { detail: { media: addedMedia, gen } }));
|
|
2018
2049
|
return addedMedia;
|
|
2019
2050
|
}
|
|
2020
2051
|
|
|
@@ -2103,7 +2134,7 @@ function renderBin() {
|
|
|
2103
2134
|
if (mediaOffline.size && binView.filter !== "offline") {
|
|
2104
2135
|
const warn = document.createElement("div");
|
|
2105
2136
|
warn.className = "bin-filterbar bin-offline-bar";
|
|
2106
|
-
warn.innerHTML = `<span
|
|
2137
|
+
warn.innerHTML = `<span>${glyph("warn")} ${mediaOffline.size} file${mediaOffline.size === 1 ? " is" : "s are"} offline</span>
|
|
2107
2138
|
<button type="button" class="btn tiny" data-show>Show</button><button type="button" class="btn tiny accent" data-relink>Relink…</button>`;
|
|
2108
2139
|
warn.querySelector("[data-show]").addEventListener("click", () => setBinFilter("offline"));
|
|
2109
2140
|
warn.querySelector("[data-relink]").addEventListener("click", () => openRelinkDialog());
|
|
@@ -2171,7 +2202,7 @@ function renderBin() {
|
|
|
2171
2202
|
item.dataset.mediaId = m.id;
|
|
2172
2203
|
item.style.setProperty("--bin-depth", flat ? 0 : depth);
|
|
2173
2204
|
const aux = runtime.mediaAux.get(m.id) || {};
|
|
2174
|
-
const icon = mediaKindIcon(m.kind, "
|
|
2205
|
+
const icon = mediaKindIcon(m.kind, "video");
|
|
2175
2206
|
const thumbSrc = aux.thumb || (m.kind === "image" || m.kind === "svg" ? m.src : null);
|
|
2176
2207
|
const uses = ctx.usage.get(m.id) || 0;
|
|
2177
2208
|
const folder = flat && m.folderId ? getFolder(m.folderId) : null;
|
|
@@ -2196,12 +2227,13 @@ function renderBin() {
|
|
|
2196
2227
|
<div class="bin-sub">${offline ? `<span class="bin-offline" title="The file is missing — right-click → Relink…">OFFLINE</span> ` : ""}${escapeHtml(sub)}</div>
|
|
2197
2228
|
${m.tags && m.tags.length ? `<div class="bin-tags">${m.tags.map((t) => `<span class="bin-tag">#${escapeHtml(t)}</span>`).join("")}</div>` : ""}
|
|
2198
2229
|
</div>
|
|
2230
|
+
<button type="button" class="btn tiny bin-add" title="Add at the playhead" aria-label="Add at the playhead">+</button>
|
|
2199
2231
|
<div class="bin-side">${favHtml}${usesHtml}${proxyBadgeHtml(m)}</div>
|
|
2200
2232
|
<span class="bin-del" title="Remove (and its clips)">✕</span>`;
|
|
2201
2233
|
}
|
|
2202
2234
|
const thumbEl = item.querySelector(".bin-thumb");
|
|
2203
2235
|
if (thumbSrc) thumbEl.style.backgroundImage = `url(${JSON.stringify(thumbSrc)})`;
|
|
2204
|
-
else thumbEl.
|
|
2236
|
+
else thumbEl.innerHTML = icon;
|
|
2205
2237
|
const nameEl = item.querySelector(".bin-name");
|
|
2206
2238
|
nameEl.textContent = m.name;
|
|
2207
2239
|
item.title = [m.name, offline ? "⚠ Offline: " + decodeURIComponent(String(m.src).split("?")[0]) + " is missing — right-click → Relink…" : "", MediaLib.describe(m), m.tags && m.tags.length ? m.tags.map((t) => "#" + t).join(" ") : ""].filter(Boolean).join("\n");
|
|
@@ -2236,6 +2268,7 @@ function renderBin() {
|
|
|
2236
2268
|
if (getSetting("linkSelect")) flashMonitorAttention();
|
|
2237
2269
|
});
|
|
2238
2270
|
item.addEventListener("contextmenu", (e) => { e.preventDefault(); e.stopPropagation(); showMediaMenu(e.clientX, e.clientY, m); });
|
|
2271
|
+
item.querySelector(".bin-add")?.addEventListener("click", (e) => { e.stopPropagation(); addClipFromMedia(m); });
|
|
2239
2272
|
item.querySelector(".bin-fav").addEventListener("click", (e) => { e.stopPropagation(); setMediaFavorite([m.id], !m.favorite); });
|
|
2240
2273
|
item.querySelector(".bin-uses").addEventListener("click", (e) => {
|
|
2241
2274
|
e.stopPropagation();
|
|
@@ -2259,7 +2292,7 @@ function renderBin() {
|
|
|
2259
2292
|
const count = mediaInFolder(f.id).length + folderChildren(f.id).length;
|
|
2260
2293
|
row.innerHTML = `
|
|
2261
2294
|
<button type="button" class="bin-folder-twist" title="${f.open ? "Collapse" : "Expand"}" aria-expanded="${f.open}">${f.open ? "▼" : "▶"}</button>
|
|
2262
|
-
<span class="bin-folder-icon"
|
|
2295
|
+
<span class="bin-folder-icon">${glyph("folder")}</span>
|
|
2263
2296
|
<span class="bin-folder-name"></span>
|
|
2264
2297
|
<span class="bin-folder-count">${count}</span>
|
|
2265
2298
|
<button type="button" class="bin-folder-add" title="New subfolder">+</button>
|
|
@@ -2596,6 +2629,7 @@ function showMediaMenu(x, y, m) {
|
|
|
2596
2629
|
toast(`Added ${m.name} to the collection “${col.name}”`);
|
|
2597
2630
|
}, { placeholder: "Selects, Interviews…", ok: "Create" }));
|
|
2598
2631
|
sep();
|
|
2632
|
+
if (monCompact() && project.folders.length) item("Move to folder…", () => FableCutCompact.moveToFolder(x, y, m.folderId || null, (id) => moveMediaToFolder(m.id, id)));
|
|
2599
2633
|
item("Remove from project", () => removeMediaFromBin(m));
|
|
2600
2634
|
document.body.appendChild(menu);
|
|
2601
2635
|
menu.id = "trackCtxMenu";
|
|
@@ -2680,6 +2714,7 @@ function goToPlacement(p) {
|
|
|
2680
2714
|
/* Reveal in project: show a clip's media (or comp) in the Project bin. */
|
|
2681
2715
|
function revealInProject(c) {
|
|
2682
2716
|
const id = c.kind === "comp" ? null : c.mediaId;
|
|
2717
|
+
if (self.FableCutCompact && monCompact()) FableCutCompact.openSheet("media");
|
|
2683
2718
|
if (state.binTab !== "project") setBinTab("project");
|
|
2684
2719
|
let sel;
|
|
2685
2720
|
if (id) {
|
|
@@ -3152,12 +3187,12 @@ function libKind(name) {
|
|
|
3152
3187
|
if (IMAGE_EXT.test(name)) return "image";
|
|
3153
3188
|
return null;
|
|
3154
3189
|
}
|
|
3155
|
-
/**
|
|
3190
|
+
/** Symbol (markup) shown for a bin/library item without a thumbnail preview. `other` is
|
|
3156
3191
|
* the fallback for kinds not explicitly mapped here (image/svg items always
|
|
3157
3192
|
* render a real thumbnail in both callers, so their icon is never actually
|
|
3158
3193
|
* shown). Shared by renderBin and renderLibrary. */
|
|
3159
3194
|
function mediaKindIcon(kind, other) {
|
|
3160
|
-
return
|
|
3195
|
+
return glyph(["audio", "svg", "image", "video"].includes(kind) ? kind : other);
|
|
3161
3196
|
}
|
|
3162
3197
|
/* Find-or-create the project media entry for a library file (dedup by src). */
|
|
3163
3198
|
function mediaForLibraryItem(f) {
|
|
@@ -3191,18 +3226,18 @@ function toggleSfxPreview(f, btn) {
|
|
|
3191
3226
|
const cur = runtime.sfxPreview;
|
|
3192
3227
|
if (cur && cur.dataset.src === f.src && !cur.paused) {
|
|
3193
3228
|
cur.pause();
|
|
3194
|
-
btn.
|
|
3229
|
+
btn.innerHTML = glyph("play");
|
|
3195
3230
|
return;
|
|
3196
3231
|
}
|
|
3197
3232
|
if (cur) { cur.pause(); }
|
|
3198
3233
|
musicPreviewStop();
|
|
3199
|
-
els.libList.querySelectorAll(".music-play").forEach((b) => (b.
|
|
3200
|
-
els.libList.querySelectorAll(".lib-play").forEach((b) => (b.
|
|
3234
|
+
els.libList.querySelectorAll(".music-play").forEach((b) => (b.innerHTML = glyph("play")));
|
|
3235
|
+
els.libList.querySelectorAll(".lib-play").forEach((b) => (b.innerHTML = glyph("play")));
|
|
3201
3236
|
const a = new Audio(f.src);
|
|
3202
3237
|
a.dataset.src = f.src;
|
|
3203
|
-
a.onended = () => { btn.
|
|
3238
|
+
a.onended = () => { btn.innerHTML = glyph("play"); };
|
|
3204
3239
|
a.play().catch(() => toast("Couldn't play " + f.name));
|
|
3205
|
-
btn.
|
|
3240
|
+
btn.innerHTML = glyph("pause");
|
|
3206
3241
|
runtime.sfxPreview = a;
|
|
3207
3242
|
}
|
|
3208
3243
|
function renderLibrary() {
|
|
@@ -3221,7 +3256,7 @@ function renderLibrary() {
|
|
|
3221
3256
|
els.libList.appendChild(head);
|
|
3222
3257
|
} else if (!files.length) {
|
|
3223
3258
|
els.libList.innerHTML = `<div class="bin-empty">
|
|
3224
|
-
<div class="bin-empty-icon">${dir === "sfx" ? "
|
|
3259
|
+
<div class="bin-empty-icon">${glyph(dir === "sfx" ? "sfx" : dir === "svg" ? "svg" : "piece")}</div>
|
|
3225
3260
|
<p>No assets yet.</p>
|
|
3226
3261
|
<p class="hint">Drop files into<br><b>library/${dir}/</b><br>— this list live-updates.</p></div>`;
|
|
3227
3262
|
return;
|
|
@@ -3232,18 +3267,18 @@ function renderLibrary() {
|
|
|
3232
3267
|
item.className = "bin-item lib-item";
|
|
3233
3268
|
item.draggable = true;
|
|
3234
3269
|
const visual = kind === "image" || kind === "svg";
|
|
3235
|
-
const icon = mediaKindIcon(kind, "
|
|
3270
|
+
const icon = mediaKindIcon(kind, "piece");
|
|
3236
3271
|
item.innerHTML = `
|
|
3237
3272
|
<div class="bin-thumb${kind === "svg" ? " svg" : ""}"></div>
|
|
3238
3273
|
<div class="bin-meta">
|
|
3239
3274
|
<div class="bin-name"></div>
|
|
3240
3275
|
<div class="bin-sub">${(f.size / 1024).toFixed(0)} KB</div>
|
|
3241
3276
|
</div>
|
|
3242
|
-
${dir === "sfx" ? `<button class="btn tiny lib-play" title="Preview"
|
|
3277
|
+
${dir === "sfx" ? `<button class="btn tiny lib-play" title="Preview">${glyph("play")}</button>` : ""}
|
|
3243
3278
|
<button class="btn tiny accent lib-add" title="Add at playhead">+</button>`;
|
|
3244
3279
|
const thumbEl = item.querySelector(".bin-thumb");
|
|
3245
3280
|
if (visual) thumbEl.style.backgroundImage = `url(${JSON.stringify(f.src)})`;
|
|
3246
|
-
else thumbEl.
|
|
3281
|
+
else thumbEl.innerHTML = icon;
|
|
3247
3282
|
const nameEl = item.querySelector(".bin-name");
|
|
3248
3283
|
nameEl.textContent = f.name;
|
|
3249
3284
|
nameEl.title = f.rel || f.name;
|
|
@@ -3336,17 +3371,17 @@ async function musicSearch(kind, more) {
|
|
|
3336
3371
|
}
|
|
3337
3372
|
function musicTogglePreview(t, btn) {
|
|
3338
3373
|
if (musicPreview && musicPreview.id === t.id) {
|
|
3339
|
-
musicPreviewStop(); btn.
|
|
3374
|
+
musicPreviewStop(); btn.innerHTML = glyph("play"); return;
|
|
3340
3375
|
}
|
|
3341
3376
|
musicPreviewStop();
|
|
3342
3377
|
if (runtime.sfxPreview) runtime.sfxPreview.pause();
|
|
3343
|
-
els.libList.querySelectorAll(".music-play, .lib-play").forEach((b) => (b.
|
|
3378
|
+
els.libList.querySelectorAll(".music-play, .lib-play").forEach((b) => (b.innerHTML = glyph("play")));
|
|
3344
3379
|
const a = new Audio(t.url);
|
|
3345
3380
|
// the list may have been redrawn since: reset whichever ▶ buttons are on screen now
|
|
3346
3381
|
const done = () => {
|
|
3347
3382
|
if (!musicPreview || musicPreview.audio !== a) return; // stopped or replaced meanwhile
|
|
3348
3383
|
musicPreview = null;
|
|
3349
|
-
els.libList.querySelectorAll(".music-play").forEach((b) => (b.
|
|
3384
|
+
els.libList.querySelectorAll(".music-play").forEach((b) => (b.innerHTML = glyph("play")));
|
|
3350
3385
|
};
|
|
3351
3386
|
a.onended = done;
|
|
3352
3387
|
a.play().catch((e) => {
|
|
@@ -3354,7 +3389,7 @@ function musicTogglePreview(t, btn) {
|
|
|
3354
3389
|
done();
|
|
3355
3390
|
toast("Couldn't play " + t.title);
|
|
3356
3391
|
});
|
|
3357
|
-
btn.
|
|
3392
|
+
btn.innerHTML = glyph("pause");
|
|
3358
3393
|
musicPreview = { id: t.id, audio: a };
|
|
3359
3394
|
}
|
|
3360
3395
|
/** Download a track into media/ and register it with its licence; place = add at the playhead too. */
|
|
@@ -3505,13 +3540,13 @@ function appendOnlineSearch(kind, focus) {
|
|
|
3505
3540
|
item.className = "bin-item lib-item music-item";
|
|
3506
3541
|
const busy = musicImporting.has(t.id);
|
|
3507
3542
|
item.innerHTML = `
|
|
3508
|
-
<button type="button" class="btn tiny music-play" title="Preview">${musicPreview && musicPreview.id === t.id ? "
|
|
3543
|
+
<button type="button" class="btn tiny music-play" title="Preview">${glyph(musicPreview && musicPreview.id === t.id ? "pause" : "play")}</button>
|
|
3509
3544
|
<div class="bin-meta">
|
|
3510
3545
|
<div class="bin-name"></div>
|
|
3511
3546
|
<div class="bin-sub"></div>
|
|
3512
3547
|
<div class="music-lic"></div>
|
|
3513
3548
|
</div>
|
|
3514
|
-
<button type="button" class="btn tiny music-get" title="Import into the Project bin"${busy ? " disabled" : ""}>${busy ? "…" : "
|
|
3549
|
+
<button type="button" class="btn tiny music-get" title="Import into the Project bin"${busy ? " disabled" : ""}>${busy ? "…" : glyph("get")}</button>
|
|
3515
3550
|
<button type="button" class="btn tiny accent lib-add" title="Import and add at the playhead"${busy ? " disabled" : ""}>+</button>`;
|
|
3516
3551
|
item.querySelector(".bin-name").textContent = t.title;
|
|
3517
3552
|
item.querySelector(".bin-name").title = t.title + (t.tags.length ? "\n#" + t.tags.join(" #") : "");
|
|
@@ -3619,8 +3654,8 @@ async function pjLoad() {
|
|
|
3619
3654
|
const res = await fetch("/api/projects?archived=" + (pj.view === "archived" ? "only" : "exclude"), { cache: "no-store" });
|
|
3620
3655
|
if (!res.ok) throw new Error();
|
|
3621
3656
|
const data = await res.json();
|
|
3622
|
-
pj.list = data.projects || [];
|
|
3623
|
-
pj.templates = data.templates || [];
|
|
3657
|
+
pj.list = FableCutGuard.clean(data.projects || []);
|
|
3658
|
+
pj.templates = FableCutGuard.clean(data.templates || []);
|
|
3624
3659
|
// syncFromServer owns runtime.projectId: it resets undo, comp and Source on a switch.
|
|
3625
3660
|
// On first use the list has just given the shown project.json its id: adopt it, if
|
|
3626
3661
|
// project.json is still the document this tab shows.
|
|
@@ -3871,7 +3906,7 @@ async function pjLoadVersions() {
|
|
|
3871
3906
|
const data = await res.json();
|
|
3872
3907
|
if (!res.ok) throw new Error(data.error);
|
|
3873
3908
|
if (!current()) return;
|
|
3874
|
-
pj.versions = data.versions || [];
|
|
3909
|
+
pj.versions = FableCutGuard.clean(data.versions || []);
|
|
3875
3910
|
} catch (e) {
|
|
3876
3911
|
if (!current()) return;
|
|
3877
3912
|
pj.versions = []; toast("Versions: " + (e.message || "couldn't read them"));
|
|
@@ -4401,7 +4436,8 @@ function addClipFromMedia(m, trackId, at) {
|
|
|
4401
4436
|
// plant a stereo placeholder now (so the drop isn't picture-only, and so the
|
|
4402
4437
|
// next pushUndo snapshot includes the AV link); reconcileAudioChannels upgrades
|
|
4403
4438
|
// or trims once decodeAudioData reports the real count.
|
|
4404
|
-
|
|
4439
|
+
// A file known to have no audio stream (a screen recording, a time-lapse) gets none.
|
|
4440
|
+
if (kind === "video" && m.audioChannels !== 0) {
|
|
4405
4441
|
c.props.volume = 0;
|
|
4406
4442
|
c.linkGroup = "lg_" + uid();
|
|
4407
4443
|
const nCh = m.channels > 0 ? m.channels : 2;
|
|
@@ -4457,7 +4493,7 @@ function insertSourceAtPlayhead() {
|
|
|
4457
4493
|
if (state.playing) pause();
|
|
4458
4494
|
if (state.source.playing) pauseSource();
|
|
4459
4495
|
pushUndo();
|
|
4460
|
-
const { clip: c, at } = EDIT.insertAt(m, inn, duration, state.time);
|
|
4496
|
+
const { clip: c, at } = EDIT.insertAt(m, inn, duration, state.time, m.audioChannels === 0 ? 0 : undefined);
|
|
4461
4497
|
if (c) selectClip(c.id);
|
|
4462
4498
|
state.time = +(at + duration).toFixed(4);
|
|
4463
4499
|
state.dirtyTimeline = true;
|
|
@@ -4484,7 +4520,7 @@ function replaceSourceAtPlayhead() {
|
|
|
4484
4520
|
if (state.playing) pause();
|
|
4485
4521
|
if (state.source.playing) pauseSource();
|
|
4486
4522
|
pushUndo();
|
|
4487
|
-
const { clip: c, at } = EDIT.overwriteAt(m, inn, duration, state.time);
|
|
4523
|
+
const { clip: c, at } = EDIT.overwriteAt(m, inn, duration, state.time, m.audioChannels === 0 ? 0 : undefined);
|
|
4488
4524
|
pruneSelection();
|
|
4489
4525
|
if (c) selectClip(c.id);
|
|
4490
4526
|
state.time = +(at + duration).toFixed(4);
|
|
@@ -4759,7 +4795,7 @@ function openMediaPicker(anchor, c) {
|
|
|
4759
4795
|
menu.className = "style-menu";
|
|
4760
4796
|
const browse = document.createElement("div");
|
|
4761
4797
|
browse.className = "style-opt media-opt";
|
|
4762
|
-
browse.
|
|
4798
|
+
browse.innerHTML = glyph("browse") + " Browse file…";
|
|
4763
4799
|
browse.addEventListener("click", () => {
|
|
4764
4800
|
close();
|
|
4765
4801
|
pickReplacementFile(c);
|
|
@@ -4915,6 +4951,7 @@ function gapSearchRange() {
|
|
|
4915
4951
|
return { t0: 0, t1: Math.max(projDur(), 0) };
|
|
4916
4952
|
}
|
|
4917
4953
|
function ensurePlayheadVisible() {
|
|
4954
|
+
if (tlCentred()) return; // it always is
|
|
4918
4955
|
const px = state.time * state.pps, sc = els.timelineScroll;
|
|
4919
4956
|
if (!sc) return;
|
|
4920
4957
|
if (px < sc.scrollLeft || px > sc.scrollLeft + sc.clientWidth - 40) {
|
|
@@ -5217,7 +5254,28 @@ els.timelineScroll.addEventListener("scroll", () => {
|
|
|
5217
5254
|
const inner = $("trackHeadInner");
|
|
5218
5255
|
if (inner) inner.style.transform = `translateY(${-els.timelineScroll.scrollTop}px)`;
|
|
5219
5256
|
});
|
|
5257
|
+
/* On a phone scrolling the timeline is scrubbing it: a finger hides what it
|
|
5258
|
+
points at, so the playhead never has to be grabbed. 0:00 sits at the left edge
|
|
5259
|
+
(TL_LEFT clears the track letters); as time goes on the playhead drifts to the
|
|
5260
|
+
middle (tlHeadX) and stays there, so there is no empty half screen before the
|
|
5261
|
+
first clip and the clips always follow the finger. Every conversion between
|
|
5262
|
+
clientX and a time goes through tlX(); elsewhere that is plain scrollLeft. */
|
|
5263
|
+
const TL_LEFT = 46, TL_DRIFT = 1 / 3; // px on screen per px of timeline until the middle is reached
|
|
5264
|
+
const TL_LEFT_TABLET = 24; // room for the left trim grip of a clip at 0:00
|
|
5265
|
+
const tlCentred = () => typeof FableCutLayout !== "undefined" && FableCutLayout.mode === "phone";
|
|
5266
|
+
const tlPad = () => (tlCentred() ? TL_LEFT : typeof FableCutLayout !== "undefined" && FableCutLayout.mode === "tablet" ? TL_LEFT_TABLET : 0);
|
|
5267
|
+
const tlX = () => els.timelineScroll.scrollLeft - tlPad();
|
|
5268
|
+
const tlHeadX = (u) => Math.min(els.timelineScroll.clientWidth / 2, TL_LEFT + u * TL_DRIFT); // u = time × pps
|
|
5269
|
+
/** A finger moved the clips dx px to the left: the time that puts the playhead at. */
|
|
5270
|
+
function scrubTimeline(dx) {
|
|
5271
|
+
const u = state.time * state.pps, mid = els.timelineScroll.clientWidth / 2, left = u - tlHeadX(u) + dx;
|
|
5272
|
+
let next = (left + TL_LEFT) / (1 - TL_DRIFT);
|
|
5273
|
+
if (TL_LEFT + next * TL_DRIFT > mid) next = left + mid;
|
|
5274
|
+
setTime(next / state.pps);
|
|
5275
|
+
followCentre();
|
|
5276
|
+
}
|
|
5220
5277
|
function contentWidth() {
|
|
5278
|
+
if (tlCentred()) return projDur() * state.pps + els.timelineScroll.clientWidth / 2; // the last frame can reach the middle
|
|
5221
5279
|
const minSec = (els.timelineScroll.clientWidth || 800) / state.pps;
|
|
5222
5280
|
return Math.max(projDur() + TIMELINE_PAD_SEC, minSec) * state.pps;
|
|
5223
5281
|
}
|
|
@@ -5297,7 +5355,7 @@ function clipKeyframesHtml(c) {
|
|
|
5297
5355
|
for (const { t, keys } of groups) {
|
|
5298
5356
|
if (t < -1e-6 || t > c.duration + 1e-6) continue;
|
|
5299
5357
|
const pct = Math.max(0, Math.min(100, (t / c.duration) * 100));
|
|
5300
|
-
const label = keys.join(", ") + " @ " + fmt(c.start + t);
|
|
5358
|
+
const label = escapeHtml(keys.join(", ") + " @ " + fmt(c.start + t));
|
|
5301
5359
|
const badge = keys.length > 1 ? `<span class="clip-kf-n">${keys.length}</span>` : "";
|
|
5302
5360
|
const multi = keys.length > 1 ? " multi" : "";
|
|
5303
5361
|
html += `<div class="clip-kf${multi}" style="left:${pct}%" data-t="${t}" title="${label}">${badge}</div>`;
|
|
@@ -5305,8 +5363,10 @@ function clipKeyframesHtml(c) {
|
|
|
5305
5363
|
return html + `</div>`;
|
|
5306
5364
|
}
|
|
5307
5365
|
function rebuildClips() {
|
|
5308
|
-
|
|
5366
|
+
fitTrackHeights();
|
|
5367
|
+
const w = contentWidth(), pad = tlPad();
|
|
5309
5368
|
els.tracksContent.style.width = w + "px";
|
|
5369
|
+
els.tracksContent.style.marginLeft = pad ? pad + "px" : "";
|
|
5310
5370
|
els.ruler.style.width = els.timelineScroll.clientWidth + "px";
|
|
5311
5371
|
for (const row of els.tracks.children) row.innerHTML = "";
|
|
5312
5372
|
const matted = project.clips.map((x) => [x, clipMatte(x)]).filter(([, m]) => m);
|
|
@@ -5755,7 +5815,7 @@ function drawRuler() {
|
|
|
5755
5815
|
if (rulerWorker) {
|
|
5756
5816
|
rulerWorker.postMessage({
|
|
5757
5817
|
type: "draw", w, h, dpr,
|
|
5758
|
-
sl:
|
|
5818
|
+
sl: tlX(), pps: state.pps,
|
|
5759
5819
|
markers: project.markers, markerColors: MARKER_COLORS,
|
|
5760
5820
|
inPoint: project.inPoint, outPoint: project.outPoint,
|
|
5761
5821
|
time: state.time, fps: projectFps(),
|
|
@@ -5772,7 +5832,7 @@ function drawRulerMainThread(w, h, dpr) {
|
|
|
5772
5832
|
const g = cv.getContext("2d");
|
|
5773
5833
|
g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
5774
5834
|
g.clearRect(0, 0, w, h);
|
|
5775
|
-
const sl =
|
|
5835
|
+
const sl = tlX(), pps = state.pps;
|
|
5776
5836
|
const steps = [0.1, 0.25, 0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300];
|
|
5777
5837
|
const step = steps.find((s) => s * pps >= 70) || 600;
|
|
5778
5838
|
const minor = step / 5;
|
|
@@ -5940,7 +6000,7 @@ function openSnapMenu(anchor) {
|
|
|
5940
6000
|
/* ── Pointer interactions on timeline ── */
|
|
5941
6001
|
function timeAtEvent(e) {
|
|
5942
6002
|
const rect = els.timelineScroll.getBoundingClientRect();
|
|
5943
|
-
return clamp((e.clientX - rect.left +
|
|
6003
|
+
return clamp((e.clientX - rect.left + tlX()) / state.pps, 0, 1e6);
|
|
5944
6004
|
}
|
|
5945
6005
|
function trackAtEvent(e) {
|
|
5946
6006
|
for (const row of els.tracks.children) {
|
|
@@ -5981,8 +6041,9 @@ function showTrimReadout(ev, text) {
|
|
|
5981
6041
|
document.body.appendChild(el);
|
|
5982
6042
|
}
|
|
5983
6043
|
el.textContent = text;
|
|
5984
|
-
|
|
5985
|
-
el.style.
|
|
6044
|
+
const finger = ev.pointerType === "touch";
|
|
6045
|
+
el.style.left = ev.clientX + (finger ? -40 : 14) + "px";
|
|
6046
|
+
el.style.top = ev.clientY + (finger ? -74 : 18) + "px";
|
|
5986
6047
|
el.hidden = false;
|
|
5987
6048
|
}
|
|
5988
6049
|
function hideTrimReadout() { if (runtime.trimReadout) runtime.trimReadout.hidden = true; }
|
|
@@ -6077,7 +6138,8 @@ els.tracksContent.addEventListener("contextmenu", (e) => {
|
|
|
6077
6138
|
e.preventDefault();
|
|
6078
6139
|
showClipCtxMenu(e.clientX, e.clientY, c);
|
|
6079
6140
|
});
|
|
6080
|
-
|
|
6141
|
+
/* (named: touch.js calls it once a finger's gesture is known to be an edit) */
|
|
6142
|
+
function timelinePointerDown(e) {
|
|
6081
6143
|
if (e.button !== 0) return;
|
|
6082
6144
|
// Clicking the timeline should release inspector text fields so shortcuts (z, s, …) work
|
|
6083
6145
|
if (isTypingTarget(document.activeElement) && els.inspector.contains(document.activeElement))
|
|
@@ -6137,7 +6199,8 @@ els.tracksContent.addEventListener("pointerdown", (e) => {
|
|
|
6137
6199
|
const mode = onHandle ? (edge === "l" ? "trim-l" : "trim-r") : "move";
|
|
6138
6200
|
// a plain click (no drag) on a multi-selection collapses it to that clip on release
|
|
6139
6201
|
startClipGesture(e, c, mode, !additive && state.selIds.size > 1);
|
|
6140
|
-
}
|
|
6202
|
+
}
|
|
6203
|
+
els.tracksContent.addEventListener("pointerdown", timelinePointerDown);
|
|
6141
6204
|
|
|
6142
6205
|
els.tracksContent.addEventListener("dblclick", (e) => {
|
|
6143
6206
|
const clipDiv = e.target.closest(".clip");
|
|
@@ -6376,9 +6439,10 @@ function startScrub(e) {
|
|
|
6376
6439
|
/* Marker under a ruler pointer event: the diamond row at the bottom, ±6 px. */
|
|
6377
6440
|
function markerAtRulerEvent(e) {
|
|
6378
6441
|
const r = els.ruler.getBoundingClientRect();
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6442
|
+
const finger = e.pointerType === "touch";
|
|
6443
|
+
if (!finger && e.clientY - r.top < RULER_H - 13) return null;
|
|
6444
|
+
const x = e.clientX - els.timelineScroll.getBoundingClientRect().left + tlX();
|
|
6445
|
+
let best = null, bd = finger ? 16 : 6;
|
|
6382
6446
|
for (const m of project.markers || []) {
|
|
6383
6447
|
const d = Math.abs(m.t * state.pps - x);
|
|
6384
6448
|
if (d <= bd) { bd = d; best = m; }
|
|
@@ -6566,6 +6630,7 @@ function seekToMarker(m) {
|
|
|
6566
6630
|
}
|
|
6567
6631
|
/* Scroll the timeline so time t is on screen (no-op when it already is). */
|
|
6568
6632
|
function revealTime(t) {
|
|
6633
|
+
if (tlCentred()) return; // the view follows the playhead
|
|
6569
6634
|
const sc = els.timelineScroll, px = t * state.pps;
|
|
6570
6635
|
if (px < sc.scrollLeft || px > sc.scrollLeft + sc.clientWidth - 40)
|
|
6571
6636
|
sc.scrollLeft = Math.max(0, px - sc.clientWidth / 3);
|
|
@@ -6778,18 +6843,20 @@ function setZoom(pps, anchorClientX) {
|
|
|
6778
6843
|
const scroller = els.timelineScroll;
|
|
6779
6844
|
const rect = scroller.getBoundingClientRect();
|
|
6780
6845
|
const ax = anchorClientX != null ? anchorClientX - rect.left : rect.width / 2;
|
|
6781
|
-
const tAtAnchor = (
|
|
6846
|
+
const tAtAnchor = (tlX() + ax) / state.pps;
|
|
6782
6847
|
state.pps = clamp(pps, ZOOM_MIN, ZOOM_MAX);
|
|
6783
6848
|
els.zoomSlider.value = state.pps;
|
|
6784
6849
|
state.dirtyTimeline = true;
|
|
6785
6850
|
rebuildClips();
|
|
6786
|
-
|
|
6851
|
+
if (tlCentred()) { followCentre(); return; } // zooms around the playhead
|
|
6852
|
+
scroller.scrollLeft = Math.max(0, tAtAnchor * state.pps - ax + tlPad());
|
|
6787
6853
|
}
|
|
6788
6854
|
/* Fit clip content into 95% of the viewport, then scroll to the start.
|
|
6789
6855
|
TIMELINE_PAD_SEC is scroll room added by contentWidth(), not part of the fit. */
|
|
6790
6856
|
function zoomToFit() {
|
|
6791
|
-
const w = els.timelineScroll.clientWidth || 800;
|
|
6857
|
+
const w = (els.timelineScroll.clientWidth || 800) - tlPad();
|
|
6792
6858
|
const span = Math.max(projDur(), 1);
|
|
6859
|
+
if (tlCentred()) setTime(0); // the view follows the playhead: all of it shows from the start
|
|
6793
6860
|
setZoom((TIMELINE_FIT_FILL * w) / span);
|
|
6794
6861
|
els.timelineScroll.scrollLeft = 0;
|
|
6795
6862
|
}
|
|
@@ -6819,8 +6886,9 @@ function zoomToRange(t0, t1) {
|
|
|
6819
6886
|
els.zoomSlider.value = pps;
|
|
6820
6887
|
rebuildClips();
|
|
6821
6888
|
const center = (t0 + t1) / 2;
|
|
6822
|
-
|
|
6823
|
-
|
|
6889
|
+
if (tlCentred()) { setTime(center); followCentre(); return; }
|
|
6890
|
+
const maxScroll = Math.max(0, contentWidth() + tlPad() - w);
|
|
6891
|
+
els.timelineScroll.scrollLeft = clamp(center * pps + tlPad() - w / 2, 0, maxScroll);
|
|
6824
6892
|
}
|
|
6825
6893
|
els.zoomSlider.addEventListener("input", () => setZoom(+els.zoomSlider.value));
|
|
6826
6894
|
$("btnZoomFit").addEventListener("click", zoomToFit);
|
|
@@ -6916,6 +6984,7 @@ function clipStatusBar(c) {
|
|
|
6916
6984
|
`</div>`;
|
|
6917
6985
|
}
|
|
6918
6986
|
function renderInspector(lite) {
|
|
6987
|
+
if (!lite) window.dispatchEvent(new Event("fablecut:selection")); // the compact tool bar follows it
|
|
6919
6988
|
if (colorState.open && !lite) renderColorPage();
|
|
6920
6989
|
const c = getClip(state.selId);
|
|
6921
6990
|
if (!c) {
|
|
@@ -6970,19 +7039,19 @@ function renderInspector(lite) {
|
|
|
6970
7039
|
};
|
|
6971
7040
|
let html = (state.selIds.size > 1
|
|
6972
7041
|
? `<div class="insp-multi">${state.selIds.size} clips selected — drag moves them together, Del deletes all. Fields below edit the primary (white-outlined) clip.</div>`
|
|
6973
|
-
: "") + clipStatusBar(c) + `<div class="insp-section"><h3>Clip — ${c.kind}</h3>
|
|
7042
|
+
: "") + clipStatusBar(c) + `<div class="insp-section"><h3>Clip — ${escapeHtml(c.kind)}</h3>
|
|
6974
7043
|
${row("Name", `<input type="text" data-k="name" value="${escapeHtml(c.name || "")}">`)}
|
|
6975
7044
|
${c.mediaId ? row("Source", `<button type="button" class="btn tiny style-picker-btn" data-media-open title="Replace this clip's media — keeps position, trim, keyframes and effects">${escapeHtml((getMedia(c.mediaId) || {}).name || "Missing media")} ▾</button>`) : ""}
|
|
6976
7045
|
${row("Start (s)", `<input type="number" data-k="start" step="0.01" value="${c.start.toFixed(2)}">`)}
|
|
6977
7046
|
${row("Length (s)", `<input type="number" data-k="duration" step="0.01" value="${c.duration.toFixed(2)}">`)}
|
|
6978
7047
|
</div>`;
|
|
6979
7048
|
const sel = (label, k, opts, cur) => row(label,
|
|
6980
|
-
`<select data-k="${k}">${opts.map((o) => `<option value="${o}" ${String(o) === String(cur) ? "selected" : ""}>${o}</option>`).join("")}</select>`, k);
|
|
7049
|
+
`<select data-k="${k}">${opts.map((o) => `<option value="${escapeHtml(o)}" ${String(o) === String(cur) ? "selected" : ""}>${escapeHtml(o)}</option>`).join("")}</select>`, k);
|
|
6981
7050
|
const check = (label, k, on) => row(label, `<input type="checkbox" data-k="${k}" ${on ? "checked" : ""}>`, k);
|
|
6982
7051
|
// track matte: the mode, and the track it comes from (auto = the video track above)
|
|
6983
7052
|
const matteRows = () => {
|
|
6984
7053
|
const others = videoTrackIds().filter((id) => id !== c.track), auto = Mask.matteTrackFor({ ...c, props: { matte: "alpha" } }, videoTrackIds());
|
|
6985
|
-
const opts = (cur) => [`<option value="" ${!cur ? "selected" : ""}>Above (${auto || "none"})</option>`, ...others.map((id) => `<option value="${id}" ${cur === id ? "selected" : ""}>${id}</option>`)].join("");
|
|
7054
|
+
const opts = (cur) => [`<option value="" ${!cur ? "selected" : ""}>Above (${escapeHtml(auto || "none")})</option>`, ...others.map((id) => `<option value="${escapeHtml(id)}" ${cur === id ? "selected" : ""}>${escapeHtml(id)}</option>`)].join("");
|
|
6986
7055
|
return row("Track matte", `<select data-k="matte">${["none", ...Mask.MATTES].map((o) => `<option value="${o}" ${(p.matte || "none") === o ? "selected" : ""}>${o.replace("-", " ")}</option>`).join("")}</select>`, "matte")
|
|
6987
7056
|
+ (p.matte ? row("Matte track", `<select data-k="matteTrack">${opts(p.matteTrack)}</select>`, "matteTrack")
|
|
6988
7057
|
+ (clipMatte(c) ? "" : `<div class="insp-note">No video track above to take the matte from — pick one.</div>`) : "");
|
|
@@ -7020,10 +7089,10 @@ function renderInspector(lite) {
|
|
|
7020
7089
|
if (c.kind === "video" || c.kind === "image" || c.kind === "svg" || c.kind === "comp") {
|
|
7021
7090
|
html += `<div class="insp-section"><h3>Layout</h3>
|
|
7022
7091
|
${sel("Fit", "fit", ["contain", "cover", "stretch", "none"], p.fit)}
|
|
7023
|
-
${row("Crop L/R %", `<input type="number" data-k="cropL" min="0" max="95" value="${p.cropL}" style="max-width:58px">
|
|
7024
|
-
<input type="number" data-k="cropR" min="0" max="95" value="${p.cropR}" style="max-width:58px">`, "", "cropL,cropR")}
|
|
7025
|
-
${row("Crop T/B %", `<input type="number" data-k="cropT" min="0" max="95" value="${p.cropT}" style="max-width:58px">
|
|
7026
|
-
<input type="number" data-k="cropB" min="0" max="95" value="${p.cropB}" style="max-width:58px">`, "", "cropT,cropB")}
|
|
7092
|
+
${row("Crop L/R %", `<input type="number" data-k="cropL" min="0" max="95" value="${escapeHtml(p.cropL)}" style="max-width:58px">
|
|
7093
|
+
<input type="number" data-k="cropR" min="0" max="95" value="${escapeHtml(p.cropR)}" style="max-width:58px">`, "", "cropL,cropR")}
|
|
7094
|
+
${row("Crop T/B %", `<input type="number" data-k="cropT" min="0" max="95" value="${escapeHtml(p.cropT)}" style="max-width:58px">
|
|
7095
|
+
<input type="number" data-k="cropB" min="0" max="95" value="${escapeHtml(p.cropB)}" style="max-width:58px">`, "", "cropT,cropB")}
|
|
7027
7096
|
${slider("cornerRadius", 0, 300, 1, p.cornerRadius, "px")}
|
|
7028
7097
|
${check("Flip H", "flipH", p.flipH)}
|
|
7029
7098
|
${check("Flip V", "flipV", p.flipV)}
|
|
@@ -7070,7 +7139,7 @@ function renderInspector(lite) {
|
|
|
7070
7139
|
}
|
|
7071
7140
|
if (c.kind === "video" || c.kind === "image") {
|
|
7072
7141
|
html += `<div class="insp-section"><h3>Keying / Cut-out</h3>
|
|
7073
|
-
${row("Key color", `<input type="color" data-k="chromaKey" value="${p.chromaKey || "#00ff00"}">
|
|
7142
|
+
${row("Key color", `<input type="color" data-k="chromaKey" value="${escapeHtml(p.chromaKey || "#00ff00")}">
|
|
7074
7143
|
<button class="btn tiny${p.chromaKey ? "" : " toggle on"}" data-action="keyoff" title="Disable chroma key">off</button>`, "", "chromaKey")}
|
|
7075
7144
|
${slider("chromaTolerance", 0, 100, 1, p.chromaTolerance)}
|
|
7076
7145
|
${slider("chromaSoftness", 0, 100, 1, p.chromaSoftness)}
|
|
@@ -7151,7 +7220,7 @@ function renderInspector(lite) {
|
|
|
7151
7220
|
const active = state.transFocus === (key === "transIn" ? "in" : "out");
|
|
7152
7221
|
return `<div class="insp-row${active ? " trans-active" : ""}"><label class="insp-reset" data-reset="${key}" title="Ctrl-click: reset · Shift-click: reset">${label}</label>
|
|
7153
7222
|
<span class="insp-ctrls"><select data-k="${key}">${TRANSITIONS.map((x) => `<option ${x === (tr?.type || "none") ? "selected" : ""}>${x}</option>`).join("")}</select>
|
|
7154
|
-
<input type="number" class="insp-dur" data-k="${key}Dur" step="0.1" min="0.1" value="${tr?.duration ?? 1}"></span></div>`;
|
|
7223
|
+
<input type="number" class="insp-dur" data-k="${key}Dur" step="0.1" min="0.1" value="${escapeHtml(tr?.duration ?? 1)}"></span></div>`;
|
|
7155
7224
|
};
|
|
7156
7225
|
const curveSel = (label, k, tr) => tr?.type === "fade" && c.kind === "audio"
|
|
7157
7226
|
? row(label, `<select data-k="${k}" title="Fade shape (audio)">${[["", "Smooth (eased)"], ...Object.entries(AUDIO_FADE_CURVES)].map(([v, l]) =>
|
|
@@ -7168,20 +7237,20 @@ function renderInspector(lite) {
|
|
|
7168
7237
|
</div>`;
|
|
7169
7238
|
if (c.kind === "text") {
|
|
7170
7239
|
const fontGroup = (label, fonts) => fonts.length
|
|
7171
|
-
? `<optgroup label="${label}">${fonts.map((f) => `<option ${f === p.font ? "selected" : ""}>${f}</option>`).join("")}</optgroup>` : "";
|
|
7240
|
+
? `<optgroup label="${label}">${fonts.map((f) => `<option ${f === p.font ? "selected" : ""}>${escapeHtml(f)}</option>`).join("")}</optgroup>` : "";
|
|
7172
7241
|
const known = [...SYSTEM_FONTS, ...runtime.customFonts, ...GOOGLE_FONTS, ...runtime.googleLoaded];
|
|
7173
7242
|
html += `<div class="insp-section"><h3>Text</h3>
|
|
7174
|
-
${row("Content", `<textarea data-k="text">${p.text}</textarea>`, "", "text")}
|
|
7243
|
+
${row("Content", `<textarea data-k="text">${escapeHtml(p.text)}</textarea>`, "", "text")}
|
|
7175
7244
|
${row(hasTextBox(p) && p.boxFit ? "Max size" : "Font size",
|
|
7176
7245
|
`<input type="range" data-k="fontSize" min="12" max="300" step="1" value="${fmtInspNum(p.fontSize, 1)}" title="Ctrl/Cmd-click: reset to default">
|
|
7177
7246
|
<span class="val" data-val="fontSize" data-unit="px">${fmtInspNum(p.fontSize, 1)}px</span>`, "fontSize")}
|
|
7178
7247
|
${row("Box W/H", `<span class="insp-ctrls">
|
|
7179
|
-
<input type="number" data-k="boxW" min="0" step="1" value="${p.boxW || 0}" title="Width in px (0 = no box — hug content)" style="max-width:64px">
|
|
7180
|
-
<input type="number" data-k="boxH" min="0" step="1" value="${p.boxH || 0}" title="Height in px (0 = no box — hug content)" style="max-width:64px">
|
|
7248
|
+
<input type="number" data-k="boxW" min="0" step="1" value="${escapeHtml(p.boxW || 0)}" title="Width in px (0 = no box — hug content)" style="max-width:64px">
|
|
7249
|
+
<input type="number" data-k="boxH" min="0" step="1" value="${escapeHtml(p.boxH || 0)}" title="Height in px (0 = no box — hug content)" style="max-width:64px">
|
|
7181
7250
|
</span>`, "", "boxW,boxH")}
|
|
7182
7251
|
${hasTextBox(p) ? check("Scale to fit", "boxFit", !!p.boxFit) : ""}
|
|
7183
|
-
${row("Color", `<span class="insp-ctrls"><input type="color" data-k="color" value="${p.color}">
|
|
7184
|
-
<input type="color" data-k="color2" value="${p.color2 || p.color}" title="Gradient bottom color">
|
|
7252
|
+
${row("Color", `<span class="insp-ctrls"><input type="color" data-k="color" value="${escapeHtml(p.color)}">
|
|
7253
|
+
<input type="color" data-k="color2" value="${escapeHtml(p.color2 || p.color)}" title="Gradient bottom color">
|
|
7185
7254
|
<button class="btn tiny${p.color2 ? "" : " toggle on"}" data-action="grad-off" title="Disable gradient">flat</button></span>`, "", "color,color2")}
|
|
7186
7255
|
${sel("Align", "align", ["left", "center", "right", "justify"], p.align)}
|
|
7187
7256
|
${hasTextBox(p) ? sel("V-align", "vAlign", ["top", "middle", "bottom"], p.vAlign || "middle") : ""}
|
|
@@ -7193,7 +7262,7 @@ function renderInspector(lite) {
|
|
|
7193
7262
|
${fontGroup("Library fonts", runtime.customFonts)}
|
|
7194
7263
|
${Object.entries(GOOGLE_FONT_GROUPS).map(([g, list]) => fontGroup("Google · " + g, list)).join("")}
|
|
7195
7264
|
${fontGroup("Google · loaded by name", [...runtime.googleLoaded].filter((f) => !GOOGLE_FONTS.includes(f)))}
|
|
7196
|
-
${known.includes(p.font) ? "" : `<option selected>${p.font}</option>`}
|
|
7265
|
+
${known.includes(p.font) ? "" : `<option selected>${escapeHtml(p.font)}</option>`}
|
|
7197
7266
|
</select>`, "", "font")}
|
|
7198
7267
|
${row("Google font", `<input type="text" data-gfont placeholder="Type any Google Font name…">
|
|
7199
7268
|
<button class="btn tiny" data-action="gfont-load">Load</button>`)}
|
|
@@ -7206,20 +7275,20 @@ function renderInspector(lite) {
|
|
|
7206
7275
|
</div>
|
|
7207
7276
|
<div class="insp-section"><h3>Text style</h3>
|
|
7208
7277
|
${slider("strokeWidth", 0, 20, 0.5, p.strokeWidth, "px")}
|
|
7209
|
-
${row("Stroke col.", `<input type="color" data-k="strokeColor" value="${p.strokeColor}">`, "", "strokeColor")}
|
|
7210
|
-
${row("Bg color", `<input type="color" data-k="bgColor" value="${p.bgColor}">`, "", "bgColor")}
|
|
7278
|
+
${row("Stroke col.", `<input type="color" data-k="strokeColor" value="${escapeHtml(p.strokeColor)}">`, "", "strokeColor")}
|
|
7279
|
+
${row("Bg color", `<input type="color" data-k="bgColor" value="${escapeHtml(p.bgColor)}">`, "", "bgColor")}
|
|
7211
7280
|
${slider("bgOpacity", 0, 1, 0.05, p.bgOpacity)}
|
|
7212
7281
|
${sel("Bg shape", "bgShape", ["lines", "box"], p.bgShape === "box" ? "box" : "lines")}
|
|
7213
7282
|
${slider("textShadow", 0, 40, 1, p.textShadow)}
|
|
7214
7283
|
${slider("glow", 0, 100, 1, p.glow)}
|
|
7215
|
-
${row("Glow color", `<input type="color" data-k="glowColor" value="${p.glowColor || p.color}">
|
|
7284
|
+
${row("Glow color", `<input type="color" data-k="glowColor" value="${escapeHtml(p.glowColor || p.color)}">
|
|
7216
7285
|
<button class="btn tiny${p.glowColor ? "" : " toggle on"}" data-action="glow-auto" title="Glow uses the text color">auto</button>`, "", "glowColor")}
|
|
7217
7286
|
</div>
|
|
7218
7287
|
<div class="insp-section"><h3>Title & caption</h3>
|
|
7219
7288
|
${row("Title style", `<button type="button" class="btn tiny style-picker-btn" data-style-open title="Pick a style — hover to preview it live">${(TITLE_STYLES[c.styleName] || {}).label || "Choose…"} ▾</button>
|
|
7220
7289
|
<button class="btn tiny" data-action="title-shuffle" title="Random style">Shuffle</button>`)}
|
|
7221
7290
|
${row("Animation", `<select data-k="textAnim">${TEXT_ANIMS.map((a) => `<option ${a === p.textAnim ? "selected" : ""}>${a}</option>`).join("")}</select>`, "", "textAnim")}
|
|
7222
|
-
${p.textAnim === "highlight" ? row("Highlight", `<input type="color" data-k="highlightColor" value="${p.highlightColor || "#ffd166"}" title="The colour of the word being said">`, "", "highlightColor") : ""}
|
|
7291
|
+
${p.textAnim === "highlight" ? row("Highlight", `<input type="color" data-k="highlightColor" value="${escapeHtml(p.highlightColor || "#ffd166")}" title="The colour of the word being said">`, "", "highlightColor") : ""}
|
|
7223
7292
|
${Array.isArray(p.wordTimes) && p.wordTimes.length ? `<div class="insp-note">${p.caption ? "Caption: its" : "Its"} ${p.wordTimes.length} words follow the speech${
|
|
7224
7293
|
String(p.text || "").split(/\s+/).filter(Boolean).length === p.wordTimes.length ? ", so Word rate doesn't apply"
|
|
7225
7294
|
: " — the text now has another number of words, so they are spread over the clip; Add captions again to re-time them"}.</div>`
|
|
@@ -7939,7 +8008,7 @@ function updateSourceScrub() {
|
|
|
7939
8008
|
}
|
|
7940
8009
|
function syncPlayButton() {
|
|
7941
8010
|
const on = isSourceMode() ? state.source.playing : state.playing;
|
|
7942
|
-
els.btnPlay.
|
|
8011
|
+
els.btnPlay.innerHTML = glyph(on ? "pause" : "play");
|
|
7943
8012
|
els.btnPlay.classList.toggle("on", on);
|
|
7944
8013
|
}
|
|
7945
8014
|
/** Brief white border flash over the canvas (Project → Source feedback). */
|
|
@@ -8224,6 +8293,7 @@ function beginTcEntry(el, kind, initial) {
|
|
|
8224
8293
|
input.spellcheck = false;
|
|
8225
8294
|
input.autocomplete = "off";
|
|
8226
8295
|
input.title = "Enter to go · Esc to cancel (see ? for formats)";
|
|
8296
|
+
if (window.matchMedia?.("(pointer: coarse)").matches) input.inputMode = "decimal";
|
|
8227
8297
|
input.value = initial ?? fmt(base);
|
|
8228
8298
|
// Sit exactly over the readout it replaces: same font, a hair of padding
|
|
8229
8299
|
// for relative "+30" entries, no taller than the line (IN/OUT rows stack).
|
|
@@ -10149,7 +10219,7 @@ function renderMixer() {
|
|
|
10149
10219
|
s.innerHTML = `
|
|
10150
10220
|
<div class="mix-name" title="${isMaster ? "Master bus — everything you hear and export" : isBus ? `Submix bus ${id} — double-click to rename` : `Track ${id}`}">${escapeHtml(label)}</div>
|
|
10151
10221
|
${!isMaster && !isBus ? `<select class="mix-out" title="Where this track goes: the master, or a submix bus"><option value="">→ Master</option>${buses.map((b) =>
|
|
10152
|
-
`<option value="${b.id}">→ ${escapeHtml(busLabel(b))}</option>`).join("")}</select>` : ""}
|
|
10222
|
+
`<option value="${escapeHtml(b.id)}">→ ${escapeHtml(busLabel(b))}</option>`).join("")}</select>` : ""}
|
|
10153
10223
|
${isMaster ? `<div class="mix-pan-row mix-lufs" title="Momentary loudness of the mix (post-fader)">— LUFS</div>`
|
|
10154
10224
|
: `<div class="mix-pan-row"><input type="range" class="mix-pan" min="-1" max="1" step="0.01" title="Track pan — double-click: center"><span class="mix-pan-val"></span></div>`}
|
|
10155
10225
|
<div class="mix-body">
|
|
@@ -12448,7 +12518,7 @@ function showSequenceMenu(x, y) {
|
|
|
12448
12518
|
item(`<span>Duplicate “${escapeHtml(open.name)}”</span>`, () => newSequence({ from: "open" }));
|
|
12449
12519
|
item(`<span>Rename “${escapeHtml(open.name)}”…</span>`, () => promptBinText(x, y, "Sequence name", open.name, (v) => renameSequence(openId, v), { max: 120, ok: "Rename" }));
|
|
12450
12520
|
item(`<span>Delete “${escapeHtml(open.name)}”…</span>`, (b) => {
|
|
12451
|
-
if (b.dataset.armed !== "1") { b.dataset.armed = "1"; b.querySelector("span").textContent = "Click again to delete it"; return; }
|
|
12521
|
+
if (b.dataset.armed !== "1") { b.dataset.armed = "1"; b.querySelector("span").textContent = touchWords("Click again to delete it"); return; }
|
|
12452
12522
|
hideTrackCtxMenu();
|
|
12453
12523
|
deleteSequence(openId);
|
|
12454
12524
|
}, rows.length < 2 ? "A project keeps at least one sequence" : null, true);
|
|
@@ -12598,7 +12668,7 @@ function makeCompItem(comp) {
|
|
|
12598
12668
|
item.draggable = true;
|
|
12599
12669
|
const used = CompLib.usages(state.compCtx ? state.compCtx.root : project, comp.id).length;
|
|
12600
12670
|
item.innerHTML = `<div class="bin-thumb comp-thumb">▣</div>
|
|
12601
|
-
<div class="bin-meta"><div class="bin-name"></div><div class="bin-sub">Composition · ${comp.width}×${comp.height} · ${comp.duration}s${used ? ` · used ${used}×` : ""}</div></div>
|
|
12671
|
+
<div class="bin-meta"><div class="bin-name"></div><div class="bin-sub">Composition · ${escapeHtml(`${comp.width}×${comp.height} · ${comp.duration}`)}s${used ? ` · used ${used}×` : ""}</div></div>
|
|
12602
12672
|
<button class="btn tiny accent lib-add" title="Add at the playhead">+</button>`;
|
|
12603
12673
|
item.querySelector(".bin-name").textContent = comp.name;
|
|
12604
12674
|
item.title = "Drag onto the timeline · double-click to open and edit";
|
|
@@ -12642,9 +12712,9 @@ function compSectionHtml(c, row) {
|
|
|
12642
12712
|
if (!comp) return `<div class="insp-section"><h3>Composition</h3><p class="cl-note">Its composition (${escapeHtml(c.compId || "?")}) is missing.</p></div>`;
|
|
12643
12713
|
return `<div class="insp-section" data-comp-section><h3>Composition</h3>
|
|
12644
12714
|
${row("Comp", `<span class="insp-ctrls"><input type="text" data-comp-name value="${escapeHtml(comp.name)}" maxlength="80" title="The composition's name (every clip using it shows it)"> <button type="button" class="btn tiny" data-comp-open title="Open it on the timeline (or double-click the clip)">Open</button></span>`)}
|
|
12645
|
-
${row("Size", `<span class="insp-ctrls"><input type="number" data-comp-w min="16" max="8192" value="${comp.width}" style="max-width:72px"> × <input type="number" data-comp-h min="16" max="8192" value="${comp.height}" style="max-width:72px"></span>`)}
|
|
12715
|
+
${row("Size", `<span class="insp-ctrls"><input type="number" data-comp-w min="16" max="8192" value="${escapeHtml(comp.width)}" style="max-width:72px"> × <input type="number" data-comp-h min="16" max="8192" value="${escapeHtml(comp.height)}" style="max-width:72px"></span>`)}
|
|
12646
12716
|
${row("Length (s)", `<input type="number" data-comp-dur min="0.05" step="0.01" value="${comp.duration}">`)}
|
|
12647
|
-
${row("Background", `<span class="insp-ctrls"><input type="color" data-comp-bg value="${comp.background || "#000000"}"><button type="button" class="btn tiny${comp.background ? "" : " toggle on"}" data-comp-bgoff title="Transparent: what is under the comp clip shows through">None</button></span>`)}
|
|
12717
|
+
${row("Background", `<span class="insp-ctrls"><input type="color" data-comp-bg value="${escapeHtml(comp.background || "#000000")}"><button type="button" class="btn tiny${comp.background ? "" : " toggle on"}" data-comp-bgoff title="Transparent: what is under the comp clip shows through">None</button></span>`)}
|
|
12648
12718
|
<p class="cl-note">The clip shows the comp from its In point (${(+c.in || 0).toFixed(2)} s). Every clip using this comp changes when you edit it.</p>
|
|
12649
12719
|
</div>`;
|
|
12650
12720
|
}
|
|
@@ -12666,7 +12736,7 @@ function bindCompControls(c) {
|
|
|
12666
12736
|
const Tpl = self.FableCutTemplates;
|
|
12667
12737
|
const savedLib = { presets: [], templates: [] }; // the user's own, from library/presets and library/templates
|
|
12668
12738
|
async function fetchSaved(kind) {
|
|
12669
|
-
try { const r = await fetch("/api/" + kind, { cache: "no-store" }); savedLib[kind] = r.ok ? await r.json() : []; }
|
|
12739
|
+
try { const r = await fetch("/api/" + kind, { cache: "no-store" }); savedLib[kind] = r.ok ? FableCutGuard.clean(await r.json()) : []; }
|
|
12670
12740
|
catch { savedLib[kind] = []; }
|
|
12671
12741
|
return savedLib[kind];
|
|
12672
12742
|
}
|
|
@@ -12755,7 +12825,7 @@ function templateSectionHtml(c, row) {
|
|
|
12755
12825
|
const v = Tpl.fieldValue(comp, f), label = escapeHtml(f.label);
|
|
12756
12826
|
if (f.type === "text") return row(label, `<textarea data-tf="${escapeHtml(f.key)}" rows="${String(v || "").length > 28 ? 2 : 1}" maxlength="2000">${escapeHtml(v || "")}</textarea>`);
|
|
12757
12827
|
if (f.type === "color") return row(label, `<input type="color" data-tf="${escapeHtml(f.key)}" value="${/^#[0-9a-f]{6}/i.test(v || "") ? v.slice(0, 7) : "#ffffff"}">`);
|
|
12758
|
-
return row(label, `<select data-tf="${escapeHtml(f.key)}" title="Import your picture (or drop it in the bin), then pick it here">${pics.map((m) => `<option value="${m.id}" ${m.id === v ? "selected" : ""}>${escapeHtml(m.name)}</option>`).join("")}</select>`);
|
|
12828
|
+
return row(label, `<select data-tf="${escapeHtml(f.key)}" title="Import your picture (or drop it in the bin), then pick it here">${pics.map((m) => `<option value="${escapeHtml(m.id)}" ${m.id === v ? "selected" : ""}>${escapeHtml(m.name)}</option>`).join("")}</select>`);
|
|
12759
12829
|
}).join("");
|
|
12760
12830
|
const sameShape = Math.abs(comp.width / comp.height - project.width / project.height) < 0.01;
|
|
12761
12831
|
return `<div class="insp-section" data-tpl-section><h3>Template</h3>
|
|
@@ -12881,10 +12951,18 @@ function isVisualClip(c) { return c && c.kind !== "adjust" && c.kind !== "audio"
|
|
|
12881
12951
|
clamped into the visible canvas (inset by its own size) so it stays visible
|
|
12882
12952
|
and grabbable when the clip's box extends past the frame. Drawing and
|
|
12883
12953
|
hit-testing both use these, so they can never disagree. */
|
|
12954
|
+
/* Sizes of the editing handles, in canvas px. A finger needs a fixed size on the
|
|
12955
|
+
screen however small the preview is shown. Only the editing overlay and its hit
|
|
12956
|
+
tests use these: nothing that is exported does. */
|
|
12957
|
+
const monScale = () => els.preview.width / Math.max(1, els.preview.getBoundingClientRect().width);
|
|
12958
|
+
const monCompact = () => typeof FableCutLayout !== "undefined" && FableCutLayout.mode !== "desktop";
|
|
12959
|
+
const monMark = (base) => (monCompact() ? Math.max(base, 5.5 * monScale()) : base);
|
|
12960
|
+
const monGap = (base) => (monCompact() ? Math.max(base, 38 * monScale()) : base); // knob to edge: two fingertips apart
|
|
12961
|
+
const monGrab = (base, e) => (monCompact() || (e && e.pointerType === "touch") ? Math.max(base, 20 * monScale()) : base);
|
|
12884
12962
|
function overlayHandles(b, W, H) {
|
|
12885
12963
|
const cs = Math.cos(b.rot), sn = Math.sin(b.rot);
|
|
12886
12964
|
const toScreen = (lx, ly) => ({ x: b.cx + lx * cs - ly * sn, y: b.cy + lx * sn + ly * cs });
|
|
12887
|
-
const hs = Math.max(6, W / 150), gap = Math.max(24, W / 34), m = hs * 1.4;
|
|
12965
|
+
const hs = monMark(Math.max(6, W / 150)), gap = monGap(Math.max(24, W / 34)), m = hs * 1.4;
|
|
12888
12966
|
const cl = (p) => ({ x: clamp(p.x, m, W - m), y: clamp(p.y, m, H - m) });
|
|
12889
12967
|
return {
|
|
12890
12968
|
hs,
|
|
@@ -12983,7 +13061,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
12983
13061
|
canvasDrag = null;
|
|
12984
13062
|
if (isVisualClip(cur) && activeAt(cur, state.time)) {
|
|
12985
13063
|
const b = clipBounds(cur, evalProps(cur, state.time), W, H), lp = toLocal(pt, b);
|
|
12986
|
-
const hd = overlayHandles(b, W, H), grab = hd.hs * 1.8;
|
|
13064
|
+
const hd = overlayHandles(b, W, H), grab = monGrab(hd.hs * 1.8, e);
|
|
12987
13065
|
if (runtime.anchorTool) { // Anchor tool: the anchor point follows the pointer, the picture stays put
|
|
12988
13066
|
const p0 = propsAtPlayhead(cur);
|
|
12989
13067
|
canvasDrag = { mode: "anchor", id: cur.id, p0, m: layerScreenMatrix(cur, p0, W, H, state.time).scale(Motion.contentScale(cur, p0)).inverse() };
|
|
@@ -12993,7 +13071,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
12993
13071
|
} else if (hd.corners.some((h) => Math.abs(pt.x - h.x) <= grab && Math.abs(pt.y - h.y) <= grab)) {
|
|
12994
13072
|
if (cur.kind === "text" && !cur.props.textPath) { // a title on a path scales; its box is the path's
|
|
12995
13073
|
canvasDrag = {
|
|
12996
|
-
...beginTextBoxDrag(cur, pt, W, H),
|
|
13074
|
+
...beginTextBoxDrag(cur, pt, W, H, hd.corners.findIndex((h) => Math.abs(pt.x - h.x) <= grab && Math.abs(pt.y - h.y) <= grab)),
|
|
12997
13075
|
seedBox: !hasTextBox(cur.props),
|
|
12998
13076
|
startClient: { x: e.clientX, y: e.clientY },
|
|
12999
13077
|
};
|
|
@@ -13044,7 +13122,7 @@ function updateCanvasCursor(e) {
|
|
|
13044
13122
|
if (runtime.anchorTool && isVisualClip(cur) && activeAt(cur, state.time) && !state.playing && !state.exporting) cursor = "crosshair";
|
|
13045
13123
|
else if (isVisualClip(cur) && activeAt(cur, state.time) && !state.playing && !state.exporting) {
|
|
13046
13124
|
const b = clipBounds(cur, evalProps(cur, state.time), W, H);
|
|
13047
|
-
const hd = overlayHandles(b, W, H), grab = hd.hs * 1.8;
|
|
13125
|
+
const hd = overlayHandles(b, W, H), grab = monGrab(hd.hs * 1.8, e);
|
|
13048
13126
|
const corner = hd.corners.find((h) => Math.abs(pt.x - h.x) <= grab && Math.abs(pt.y - h.y) <= grab);
|
|
13049
13127
|
const lp = toLocal(pt, b);
|
|
13050
13128
|
if (Math.hypot(pt.x - hd.rotate.x, pt.y - hd.rotate.y) <= grab) cursor = ROTATE_CURSOR;
|
|
@@ -13069,7 +13147,7 @@ els.preview.addEventListener("pointermove", (e) => {
|
|
|
13069
13147
|
canvasDidMove = true;
|
|
13070
13148
|
if (canvasDrag.seedBox) {
|
|
13071
13149
|
ensureTextBox(c);
|
|
13072
|
-
Object.assign(canvasDrag, beginTextBoxDrag(c, pt, W, H), { seedBox: false });
|
|
13150
|
+
Object.assign(canvasDrag, beginTextBoxDrag(c, pt, W, H, canvasDrag.corner), { seedBox: false });
|
|
13073
13151
|
}
|
|
13074
13152
|
}
|
|
13075
13153
|
if (canvasDrag.mode === "move") {
|
|
@@ -14042,7 +14120,7 @@ async function trackWithUi(c, label, job, after) {
|
|
|
14042
14120
|
try {
|
|
14043
14121
|
const r = await runTrack(c, { ...job, run, onProgress: (f) => {
|
|
14044
14122
|
run.pct = f;
|
|
14045
|
-
for (const el of els.inspector.querySelectorAll("[data-track-progress]")) el.textContent = `${label}: ${Math.round(f * 100)}% — Esc stops
|
|
14123
|
+
for (const el of els.inspector.querySelectorAll("[data-track-progress]")) el.textContent = touchWords(`${label}: ${Math.round(f * 100)}% — Esc stops`);
|
|
14046
14124
|
} });
|
|
14047
14125
|
if (r.samples.length < 2) { toast(r.lostAt != null ? "Lost the region on the next frame — try a spot with more detail, or a bigger region" : "Nothing to track there"); return r; }
|
|
14048
14126
|
if (getClip(c.id) !== c || trackStamp(c) !== stamp || (maskStamp != null && JSON.stringify(maskList(c)[job.mask] ?? null) !== maskStamp)) {
|
|
@@ -14106,7 +14184,7 @@ function trackSectionHtml(c) {
|
|
|
14106
14184
|
html += `<div class="cl-row"><button type="button" class="btn tiny" data-tact="back" ${run ? "disabled" : ""} title="Track from the playhead back to the clip's start">◀ Track back</button>
|
|
14107
14185
|
<button type="button" class="btn tiny" data-tact="fwd" ${run ? "disabled" : ""} title="Track from the playhead to the clip's end">Track on ▶</button>
|
|
14108
14186
|
<button type="button" class="btn tiny" data-tact="del" title="Delete this track (what follows it keeps its keys)">Delete</button></div>
|
|
14109
|
-
<div class="insp-row"><label title="A clip to pin to this track">Attach</label><select data-tattach title="A clip to pin to this track"><option value="">Pick a clip…</option>${others.map((x) => `<option value="${x.id}">${escapeHtml(x.track + " · " + (x.kind === "text" ? (x.props.text || "").split("\n")[0] : x.name || x.kind))}</option>`).join("")}</select></div>
|
|
14187
|
+
<div class="insp-row"><label title="A clip to pin to this track">Attach</label><select data-tattach title="A clip to pin to this track"><option value="">Pick a clip…</option>${others.map((x) => `<option value="${escapeHtml(x.id)}">${escapeHtml(x.track + " · " + (x.kind === "text" ? (x.props.text || "").split("\n")[0] : x.name || x.kind))}</option>`).join("")}</select></div>
|
|
14110
14188
|
<div class="cl-row"><button type="button" class="btn tiny" data-tact="attach" ${others.length ? "" : "disabled"} title="Key the clip's position (and scale / rotation when those are on) so it rides on the track, keeping where it is at the playhead">Attach to the track</button></div>
|
|
14111
14189
|
<p class="cl-note">${S.length} samples, ${S[0][0].toFixed(2)}–${S[S.length - 1][0].toFixed(2)} s of the clip. Attaching writes keyframes — edit them like any others.</p>`;
|
|
14112
14190
|
}
|
|
@@ -14367,7 +14445,7 @@ function clipMaskHandles(c) {
|
|
|
14367
14445
|
const A = Mask.anchors(m, B.bw, B.bh).map((a) => ({ a: B.toCanvas(a.x, a.y), i: B.toCanvas(a.ix, a.iy), o: B.toCanvas(a.ox, a.oy) }));
|
|
14368
14446
|
const top = m.shape === "bezier" ? Math.min(...m.points.map((p) => p[1])) : -m.h / 2;
|
|
14369
14447
|
const base = at(0, top), up = at(0, top - 0.01), d = Math.hypot(up.x - base.x, up.y - base.y) || 1;
|
|
14370
|
-
const W = els.preview.width, H = els.preview.height, gap = Math.max(24, W / 34), inset = Math.max(8, W / 110);
|
|
14448
|
+
const W = els.preview.width, H = els.preview.height, gap = monGap(Math.max(24, W / 34)), inset = Math.max(8, W / 110);
|
|
14371
14449
|
const knob = { x: clamp(base.x + (up.x - base.x) / d * gap, inset, W - inset), y: clamp(base.y + (up.y - base.y) / d * gap, inset, H - inset) };
|
|
14372
14450
|
const edges = m.shape === "bezier" ? [] : [["w", m.w / 2, 0], ["w", -m.w / 2, 0], ["h", 0, m.h / 2], ["h", 0, -m.h / 2]].map(([k, x, y]) => ({ k, ...at(x, y) }));
|
|
14373
14451
|
return { m, B, A, centre: at(0, 0), knob, knobBase: base, edges };
|
|
@@ -14382,7 +14460,7 @@ function strokeOutline(ctx, pts, closed) {
|
|
|
14382
14460
|
function drawClipMaskOverlay(c, W) {
|
|
14383
14461
|
const B = maskBox(c);
|
|
14384
14462
|
if (!B) return false;
|
|
14385
|
-
const lw = Math.max(1.5, W / 800), hs = Math.max(5, W / 170);
|
|
14463
|
+
const lw = Math.max(1.5, W / 800), hs = monMark(Math.max(5, W / 170));
|
|
14386
14464
|
ctx2d.save();
|
|
14387
14465
|
ctx2d.setTransform(1, 0, 0, 1, 0, 0);
|
|
14388
14466
|
ctx2d.lineJoin = "round";
|
|
@@ -14479,7 +14557,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
14479
14557
|
if (e.button !== 0 || isSourceMode()) return;
|
|
14480
14558
|
const c = getClip(state.selId);
|
|
14481
14559
|
if (!maskEditActive(c)) return;
|
|
14482
|
-
const B = maskBox(c), pt = canvasPt(e), bp = B.toBox(pt), W = els.preview.width, grab = Math.max(8, W / 110);
|
|
14560
|
+
const B = maskBox(c), pt = canvasPt(e), bp = B.toBox(pt), W = els.preview.width, grab = monGrab(Math.max(8, W / 110), e);
|
|
14483
14561
|
const near = (p) => Math.hypot(p.x - pt.x, p.y - pt.y) <= grab;
|
|
14484
14562
|
if (maskUi.tool) {
|
|
14485
14563
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
@@ -14596,7 +14674,7 @@ els.preview.addEventListener("pointercancel", endClipMaskDrag, true);
|
|
|
14596
14674
|
els.preview.addEventListener("dblclick", (e) => {
|
|
14597
14675
|
const c = getClip(state.selId);
|
|
14598
14676
|
if (!maskEditActive(c) || maskUi.tool) return;
|
|
14599
|
-
const h = clipMaskHandles(c), pt = canvasPt(e), grab = Math.max(8, els.preview.width / 110);
|
|
14677
|
+
const h = clipMaskHandles(c), pt = canvasPt(e), grab = monGrab(Math.max(8, els.preview.width / 110), e);
|
|
14600
14678
|
if (!h || h.m.shape !== "bezier") return;
|
|
14601
14679
|
const i = h.A.findIndex((p) => Math.hypot(p.a.x - pt.x, p.a.y - pt.y) <= grab);
|
|
14602
14680
|
if (i < 0) return;
|
|
@@ -14760,7 +14838,7 @@ function parentCandidates(c) {
|
|
|
14760
14838
|
const clipShortLabel = (x) => x.track + " · " + (x.kind === "text" ? (x.props.text || "").split("\n")[0] : x.name || x.kind);
|
|
14761
14839
|
function parentRowHtml(c) {
|
|
14762
14840
|
const cands = parentCandidates(c), cur = c.parent && getClip(c.parent);
|
|
14763
|
-
const opts = [`<option value="">None</option>`, ...cands.map((x) => `<option value="${x.id}" ${x.id === c.parent ? "selected" : ""}>${escapeHtml(clipShortLabel(x))}${x.kind === "null" ? " (null)" : ""}</option>`)];
|
|
14841
|
+
const opts = [`<option value="">None</option>`, ...cands.map((x) => `<option value="${escapeHtml(x.id)}" ${x.id === c.parent ? "selected" : ""}>${escapeHtml(clipShortLabel(x))}${x.kind === "null" ? " (null)" : ""}</option>`)];
|
|
14764
14842
|
if (c.parent && !cur) opts.push(`<option value="${escapeHtml(c.parent)}" selected>Missing clip</option>`);
|
|
14765
14843
|
return `<div class="insp-row"><label title="Move, turn and scale with another clip (its opacity and effects are not inherited)">Parent</label><select data-parent>${opts.join("")}</select></div>`;
|
|
14766
14844
|
}
|
|
@@ -15072,14 +15150,14 @@ function shapeHandles(c, W, H) {
|
|
|
15072
15150
|
const at = (x, y) => { const q = I.transformPoint(new DOMPoint(x, y)); return { x: q.x, y: q.y }; };
|
|
15073
15151
|
const corners = [[b.x0, b.y0], [b.x1, b.y0], [b.x1, b.y1], [b.x0, b.y1]].map(([x, y]) => ({ ...at(x, y), lx: x, ly: y }));
|
|
15074
15152
|
const topMid = at((b.x0 + b.x1) / 2, b.y0), up = at((b.x0 + b.x1) / 2, b.y0 - 1), d = Math.hypot(up.x - topMid.x, up.y - topMid.y) || 1;
|
|
15075
|
-
const gap = Math.max(24, W / 34), inset = Math.max(8, W / 110);
|
|
15153
|
+
const gap = monGap(Math.max(24, W / 34)), inset = Math.max(8, W / 110);
|
|
15076
15154
|
const knob = { x: clamp(topMid.x + (up.x - topMid.x) / d * gap, inset, W - inset), y: clamp(topMid.y + (up.y - topMid.y) / d * gap, inset, H - inset) };
|
|
15077
15155
|
const ol = it.type === "group" ? null : Motion.outline(it);
|
|
15078
15156
|
const A = ol ? ol.A.map((a) => ({ a: at(a.x, a.y), i: at(a.ix, a.iy), o: at(a.ox, a.oy) })) : [];
|
|
15079
15157
|
return { it, F, I, corners, topMid, knob, centre: at(0, 0), outline: ol, A, editable: it.type === "line" || it.type === "path" };
|
|
15080
15158
|
}
|
|
15081
15159
|
function drawShapeOverlay(c, W, H) {
|
|
15082
|
-
const lw = Math.max(1.5, W / 800), hs = Math.max(5, W / 170);
|
|
15160
|
+
const lw = Math.max(1.5, W / 800), hs = monMark(Math.max(5, W / 170));
|
|
15083
15161
|
const L = shapeLayerMatrix(c, W, H);
|
|
15084
15162
|
ctx2d.save();
|
|
15085
15163
|
ctx2d.setTransform(1, 0, 0, 1, 0, 0);
|
|
@@ -15163,7 +15241,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
15163
15241
|
if (e.button !== 0 || isSourceMode()) return;
|
|
15164
15242
|
const c = getClip(state.selId);
|
|
15165
15243
|
if (!shapeEditActive(c)) return;
|
|
15166
|
-
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = Math.max(8, W / 110);
|
|
15244
|
+
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = monGrab(Math.max(8, W / 110), e);
|
|
15167
15245
|
const near = (p) => Math.hypot(p.x - pt.x, p.y - pt.y) <= grab;
|
|
15168
15246
|
if (shapeUi.tool === "pen") {
|
|
15169
15247
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
@@ -15276,7 +15354,7 @@ els.preview.addEventListener("pointercancel", endShapeDrag, true);
|
|
|
15276
15354
|
els.preview.addEventListener("dblclick", (e) => {
|
|
15277
15355
|
const c = getClip(state.selId);
|
|
15278
15356
|
if (!shapeEditActive(c) || shapeUi.tool) return;
|
|
15279
|
-
const h = shapeHandles(c, els.preview.width, els.preview.height), pt = canvasPt(e), grab = Math.max(8, els.preview.width / 110);
|
|
15357
|
+
const h = shapeHandles(c, els.preview.width, els.preview.height), pt = canvasPt(e), grab = monGrab(Math.max(8, els.preview.width / 110), e);
|
|
15280
15358
|
if (!h || h.it.type !== "path") return;
|
|
15281
15359
|
const i = h.A.findIndex((p) => Math.hypot(p.a.x - pt.x, p.a.y - pt.y) <= grab);
|
|
15282
15360
|
if (i < 0) return;
|
|
@@ -15560,7 +15638,7 @@ function motionPathGeom(c, W, H, t) {
|
|
|
15560
15638
|
function drawMotionPathOverlay(c, W, H, t) {
|
|
15561
15639
|
if (!motionPathActive(c)) return;
|
|
15562
15640
|
if (pathUi.clip !== c.id) Object.assign(pathUi, { clip: c.id, key: -1, drag: null });
|
|
15563
|
-
const g = motionPathGeom(c, W, H, t), lw = Math.max(1.5, W / 800), hs = Math.max(5, W / 170);
|
|
15641
|
+
const g = motionPathGeom(c, W, H, t), lw = Math.max(1.5, W / 800), hs = monMark(Math.max(5, W / 170));
|
|
15564
15642
|
ctx2d.save();
|
|
15565
15643
|
ctx2d.setTransform(1, 0, 0, 1, 0, 0);
|
|
15566
15644
|
ctx2d.globalAlpha = 1; ctx2d.globalCompositeOperation = "source-over"; ctx2d.filter = "none";
|
|
@@ -15602,7 +15680,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
15602
15680
|
if (e.button !== 0 || isSourceMode()) return;
|
|
15603
15681
|
const c = getClip(state.selId);
|
|
15604
15682
|
if (!motionPathActive(c) || maskEditActive(c) || shapeEditActive(c)) return;
|
|
15605
|
-
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = Math.max(8, W / 110);
|
|
15683
|
+
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = monGrab(Math.max(8, W / 110), e);
|
|
15606
15684
|
const g = motionPathGeom(c, W, H, state.time);
|
|
15607
15685
|
const near = (q) => Math.hypot(q.x - pt.x, q.y - pt.y) <= grab;
|
|
15608
15686
|
let drag = null;
|
|
@@ -15668,7 +15746,7 @@ els.preview.addEventListener("pointercancel", endPathDrag, true);
|
|
|
15668
15746
|
els.preview.addEventListener("dblclick", (e) => {
|
|
15669
15747
|
const c = getClip(state.selId);
|
|
15670
15748
|
if (!motionPathActive(c) || maskEditActive(c) || shapeEditActive(c)) return;
|
|
15671
|
-
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = Math.max(8, W / 110);
|
|
15749
|
+
const W = els.preview.width, H = els.preview.height, pt = canvasPt(e), grab = monGrab(Math.max(8, W / 110), e);
|
|
15672
15750
|
const g = motionPathGeom(c, W, H, state.time), j = g.keys.findIndex((k) => Math.hypot(k.a.x - pt.x, k.a.y - pt.y) <= grab);
|
|
15673
15751
|
if (j < 0) return;
|
|
15674
15752
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
@@ -15916,17 +15994,17 @@ function ensureTextBox(c) {
|
|
|
15916
15994
|
c.props.boxH = Math.max(24, +(half.hh * 2).toFixed(1));
|
|
15917
15995
|
}
|
|
15918
15996
|
/* Pin the opposite corner for a boxed-text resize (call after any seed). */
|
|
15919
|
-
function beginTextBoxDrag(c, pt, W, H) {
|
|
15997
|
+
function beginTextBoxDrag(c, pt, W, H, corner = -1) { // corner: the one already taken, if any
|
|
15920
15998
|
const b2 = clipBounds(c, evalProps(c, state.time), W, H);
|
|
15921
15999
|
const hd2 = overlayHandles(b2, W, H);
|
|
15922
16000
|
const grab = hd2.hs * 1.8;
|
|
15923
|
-
const ci = hd2.corners.findIndex((h) => Math.abs(pt.x - h.x) <= grab && Math.abs(pt.y - h.y) <= grab);
|
|
16001
|
+
const ci = corner >= 0 ? corner : hd2.corners.findIndex((h) => Math.abs(pt.x - h.x) <= grab && Math.abs(pt.y - h.y) <= grab);
|
|
15924
16002
|
const signs = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
|
|
15925
16003
|
const [dsx, dsy] = signs[ci >= 0 ? ci : 0];
|
|
15926
16004
|
const cs = Math.cos(b2.rot), sn = Math.sin(b2.rot);
|
|
15927
16005
|
const ox = -dsx * b2.hw, oy = -dsy * b2.hh;
|
|
15928
16006
|
return {
|
|
15929
|
-
mode: "box", id: c.id, rot: b2.rot, dragSX: dsx, dragSY: dsy,
|
|
16007
|
+
mode: "box", id: c.id, corner: ci, rot: b2.rot, dragSX: dsx, dragSY: dsy,
|
|
15930
16008
|
fix: { x: b2.cx + ox * cs - oy * sn, y: b2.cy + ox * sn + oy * cs },
|
|
15931
16009
|
aspect: Math.max(0.05, (b2.hw * 2) / Math.max(1e-6, b2.hh * 2)),
|
|
15932
16010
|
};
|
|
@@ -16357,6 +16435,11 @@ async function loadProjectFonts() {
|
|
|
16357
16435
|
try { await document.fonts.ready; } catch { }
|
|
16358
16436
|
}
|
|
16359
16437
|
|
|
16438
|
+
/* Phone: the scroll position follows from the playhead's time. */
|
|
16439
|
+
function followCentre() {
|
|
16440
|
+
const sc = els.timelineScroll, u = state.time * state.pps, x = Math.max(0, u + TL_LEFT - tlHeadX(u));
|
|
16441
|
+
if (Math.abs(sc.scrollLeft - x) > 0.6) sc.scrollLeft = x;
|
|
16442
|
+
}
|
|
16360
16443
|
/* ── Main loop ── */
|
|
16361
16444
|
let lastTs = null;
|
|
16362
16445
|
let exportWindow = null;
|
|
@@ -16456,7 +16539,7 @@ function loop(ts) {
|
|
|
16456
16539
|
}
|
|
16457
16540
|
// keep playhead visible
|
|
16458
16541
|
const px = state.time * state.pps, sc = els.timelineScroll;
|
|
16459
|
-
if (px < sc.scrollLeft || px > sc.scrollLeft + sc.clientWidth - 40)
|
|
16542
|
+
if (!tlCentred() && (px < sc.scrollLeft || px > sc.scrollLeft + sc.clientWidth - 40))
|
|
16460
16543
|
sc.scrollLeft = Math.max(0, px - 60);
|
|
16461
16544
|
}
|
|
16462
16545
|
const draw = frameDue(ts);
|
|
@@ -16472,6 +16555,7 @@ function loop(ts) {
|
|
|
16472
16555
|
if (state.dirtyTimeline) rebuildClips();
|
|
16473
16556
|
if (trState.open) transcriptTick();
|
|
16474
16557
|
watchCaptions(ts);
|
|
16558
|
+
if (tlCentred()) followCentre();
|
|
16475
16559
|
const phX = Math.round(state.time * state.pps);
|
|
16476
16560
|
if (phX !== playheadPx) {
|
|
16477
16561
|
playheadPx = phX;
|
|
@@ -17428,10 +17512,14 @@ function exportWatchdog(seconds, onStall, { minMs = 60000, msPerSecond = 100, hi
|
|
|
17428
17512
|
fail(err);
|
|
17429
17513
|
}, Math.min(1000, limit / 4));
|
|
17430
17514
|
const moved = () => { movedAt = performance.now(); };
|
|
17515
|
+
// a phone stops a tab in the background, timers and all: coming back, the export gets its whole limit again
|
|
17516
|
+
const back = () => { if (!document.hidden) moved(); };
|
|
17517
|
+
const page = typeof document !== "undefined" && document.addEventListener ? document : null;
|
|
17518
|
+
if (page) for (const ev of ["visibilitychange", "resume"]) page.addEventListener(ev, back);
|
|
17431
17519
|
return {
|
|
17432
17520
|
moved,
|
|
17433
17521
|
guard(p) { return Promise.race([Promise.resolve(p).then((v) => { moved(); return v; }), stalled]); },
|
|
17434
|
-
stop() { if (timer) clearInterval(timer); timer = 0; },
|
|
17522
|
+
stop() { if (timer) clearInterval(timer); timer = 0; if (page) for (const ev of ["visibilitychange", "resume"]) page.removeEventListener(ev, back); },
|
|
17435
17523
|
};
|
|
17436
17524
|
}
|
|
17437
17525
|
/* Sequential /frame POSTs, batched. Concurrent bodies can still race on ffmpeg
|
|
@@ -18156,7 +18244,7 @@ async function fastExport(opts = {}) {
|
|
|
18156
18244
|
const signal = exportAbort.signal;
|
|
18157
18245
|
if (!opts.silent) showExportOverlay();
|
|
18158
18246
|
els.exportProgress.style.width = "0%";
|
|
18159
|
-
els.exportNote.textContent = "Rendering frames → ffmpeg. You can switch tabs; export continues.";
|
|
18247
|
+
els.exportNote.textContent = touchWords("Rendering frames → ffmpeg. You can switch tabs; export continues.");
|
|
18160
18248
|
restoreExportVideoState();
|
|
18161
18249
|
const deliveries = opts.deliveries || (opts.delivery ? [{ delivery: opts.delivery, name: opts.name || undefined }] : null);
|
|
18162
18250
|
const delivery = deliveries ? deliveries[0].delivery : null;
|
|
@@ -18898,7 +18986,7 @@ async function webCodecsExport(name) {
|
|
|
18898
18986
|
const signal = exportAbort.signal;
|
|
18899
18987
|
showExportOverlay();
|
|
18900
18988
|
els.exportProgress.style.width = "0%";
|
|
18901
|
-
els.exportNote.textContent = "Encoding with WebCodecs → ffmpeg mux. You can switch tabs; export continues.";
|
|
18989
|
+
els.exportNote.textContent = touchWords("Encoding with WebCodecs → ffmpeg mux. You can switch tabs; export continues.");
|
|
18902
18990
|
restoreExportVideoState();
|
|
18903
18991
|
const { start: t0, end: t1, frames } = beginExportWindow();
|
|
18904
18992
|
const fps = projectFps();
|
|
@@ -19386,6 +19474,7 @@ function cmdkCollect() {
|
|
|
19386
19474
|
for (const h of document.querySelectorAll("#inspector .insp-section > h3")) {
|
|
19387
19475
|
const name = h.textContent.replace(/\s+/g, " ").trim();
|
|
19388
19476
|
add({ label: name, group: "Inspector", keywords: ["inspector", "section", "clip"], run: () => {
|
|
19477
|
+
if (self.FableCutCompact && monCompact()) { FableCutCompact.openSheet("inspector", { section: name }); return; }
|
|
19389
19478
|
setSideTab("inspector");
|
|
19390
19479
|
// the tab rebuilds the Inspector: find the section in the new one
|
|
19391
19480
|
const live = [...document.querySelectorAll("#inspector .insp-section > h3")].find((x) => x.textContent.replace(/\s+/g, " ").trim() === name);
|
|
@@ -19568,6 +19657,7 @@ function onSettingsTabTrap(e) {
|
|
|
19568
19657
|
}
|
|
19569
19658
|
}
|
|
19570
19659
|
function openSettings() {
|
|
19660
|
+
if ($("setLayout") && typeof FableCutLayout !== "undefined") $("setLayout").value = FableCutLayout.override || "";
|
|
19571
19661
|
const cb = $("setLinkSelect");
|
|
19572
19662
|
if (cb) cb.checked = !!getSetting("linkSelect");
|
|
19573
19663
|
const ask = $("setExportAsk");
|
|
@@ -19589,6 +19679,7 @@ $("btnCloseSettings").addEventListener("click", closeSettings);
|
|
|
19589
19679
|
$("settingsOverlay").addEventListener("click", (e) => {
|
|
19590
19680
|
if (e.target === $("settingsOverlay")) closeSettings();
|
|
19591
19681
|
});
|
|
19682
|
+
$("setLayout")?.addEventListener("change", (e) => FableCutLayout.set(e.target.value || null));
|
|
19592
19683
|
$("setExportAsk")?.addEventListener("change", (e) => setSetting("exportAsk", !!e.target.checked));
|
|
19593
19684
|
$("setLinkSelect").addEventListener("change", (e) => {
|
|
19594
19685
|
setSetting("linkSelect", !!e.target.checked);
|
|
@@ -19683,7 +19774,7 @@ function syncAspectSel() {
|
|
|
19683
19774
|
const i = ASPECT_PRESETS.findIndex((a) => a.w === project.width && a.h === project.height);
|
|
19684
19775
|
els.aspectSel.innerHTML =
|
|
19685
19776
|
ASPECT_PRESETS.map((a, j) => `<option value="${j}" ${j === i ? "selected" : ""}>${a.label}</option>`).join("") +
|
|
19686
|
-
(i < 0 ? `<option value="custom" selected>Custom · ${project.width}×${project.height}</option>` : "");
|
|
19777
|
+
(i < 0 ? `<option value="custom" selected>Custom · ${escapeHtml(project.width)}×${escapeHtml(project.height)}</option>` : "");
|
|
19687
19778
|
}
|
|
19688
19779
|
function syncFpsSel() {
|
|
19689
19780
|
if (!els.fpsSel) return;
|
|
@@ -20275,6 +20366,8 @@ const TL_H_KEY = "fablecut-timeline-h";
|
|
|
20275
20366
|
const TL_H_MIN = 180;
|
|
20276
20367
|
const UPPER_MIN = 140;
|
|
20277
20368
|
function availableTimelineMax() {
|
|
20369
|
+
// a tablet always keeps more than half for the preview and its panel
|
|
20370
|
+
if (typeof FableCutLayout !== "undefined" && FableCutLayout.mode === "tablet") return Math.floor(window.innerHeight * 0.46);
|
|
20278
20371
|
const app = $("app").getBoundingClientRect();
|
|
20279
20372
|
const topbar = document.querySelector(".topbar")?.getBoundingClientRect();
|
|
20280
20373
|
const topbarH = topbar ? topbar.height : 46;
|
|
@@ -20294,6 +20387,7 @@ window.addEventListener("keyup", (e) => {
|
|
|
20294
20387
|
});
|
|
20295
20388
|
window.addEventListener("blur", () => { runtime.kHeld = false; });
|
|
20296
20389
|
function setTimelineHeight(px) {
|
|
20390
|
+
if (tlCentred()) return px;
|
|
20297
20391
|
const h = clamp(Math.round(px), TL_H_MIN, Math.max(TL_H_MIN, availableTimelineMax()));
|
|
20298
20392
|
$("app").style.setProperty("--timeline-h", h + "px");
|
|
20299
20393
|
state.dirtyTimeline = true;
|
|
@@ -20325,9 +20419,24 @@ function syncTrackSizeButtons() {
|
|
|
20325
20419
|
document.body.classList.toggle("track-size-l", state.trackSize === "l");
|
|
20326
20420
|
}
|
|
20327
20421
|
function applyTrackHeights() {
|
|
20328
|
-
const
|
|
20422
|
+
const phone = tlCentred(), low = phone && FableCutLayout.landscape; // a phone on its side has room for small rows only
|
|
20423
|
+
const preset = (phone ? TRACK_SIZE_PHONE : TRACK_SIZE_PRESETS)[low ? "s" : state.trackSize] || TRACK_SIZE_PRESETS.l;
|
|
20424
|
+
const used = phone ? new Set(project.clips.map((c) => c.track)) : null;
|
|
20329
20425
|
for (const t of TRACKS) {
|
|
20330
20426
|
t.h = t.kind === "audio" ? preset.hAudio : preset.hVideo;
|
|
20427
|
+
if (phone && !used.has(t.id) && !runtime.showEmptyTracks && !runtime.keepEmptyTracks) t.h = TRACK_H_EMPTY;
|
|
20428
|
+
}
|
|
20429
|
+
}
|
|
20430
|
+
/* Phones show an empty track as a thin line; it opens up when a clip lands on
|
|
20431
|
+
it or while one is being carried. Sizes the rows in place. */
|
|
20432
|
+
function fitTrackHeights() {
|
|
20433
|
+
if (!tlCentred()) return;
|
|
20434
|
+
applyTrackHeights();
|
|
20435
|
+
for (const t of TRACKS) {
|
|
20436
|
+
const row = els.tracks.querySelector(`[data-track="${t.id}"]`), head = els.trackHeaders.querySelector(`.track-head[data-track="${t.id}"]`);
|
|
20437
|
+
if (!row) continue;
|
|
20438
|
+
if (head) { head.style.height = t.h + "px"; head.classList.toggle("thin", t.h === TRACK_H_EMPTY); }
|
|
20439
|
+
row.style.height = t.h + "px";
|
|
20331
20440
|
}
|
|
20332
20441
|
}
|
|
20333
20442
|
/* Switch S/M/L track density, rebuild the timeline, and grow/shrink the pane
|
|
@@ -20608,7 +20717,7 @@ function bindColorPage(c) {
|
|
|
20608
20717
|
cv.addEventListener("pointermove", (e) => {
|
|
20609
20718
|
const d = colorState.drag;
|
|
20610
20719
|
if (!d || d.w !== w) return;
|
|
20611
|
-
const k = WHEEL_RIM[w] / Math.max(20, d.R) * (e.shiftKey ? 0.2 : 1);
|
|
20720
|
+
const k = WHEEL_RIM[w] / Math.max(20, d.R) * (e.shiftKey || runtime.fineWheels ? 0.2 : 1);
|
|
20612
20721
|
let cb = d.cb + (e.clientX - d.x) * k, cr = d.cr - (e.clientY - d.y) * k;
|
|
20613
20722
|
const r = Math.hypot(cb, cr) / WHEEL_RIM[w];
|
|
20614
20723
|
if (r > 1) { cb /= r; cr /= r; }
|
|
@@ -20834,7 +20943,8 @@ function bindCurveEditor(c, guard) {
|
|
|
20834
20943
|
drawCurveEditor(c); // fresh hit map: the panel may have resized, or no frame has drawn it yet
|
|
20835
20944
|
const r = cv.getBoundingClientRect(), m = cv._map, px = e.clientX - r.left, py = e.clientY - r.top;
|
|
20836
20945
|
const pts = curvePoints(c, colorState.curveTab, colorState.curveCh);
|
|
20837
|
-
const
|
|
20946
|
+
const off = pts.map(([x, v]) => Math.hypot(m.X(x) / m.dpr - px, m.Y(v) / m.dpr - py)), near = Math.min(...off);
|
|
20947
|
+
const i = near < (monCompact() ? 22 : 8) ? off.indexOf(near) : -1;
|
|
20838
20948
|
return { pts, i, data: m.toData(px, py), px };
|
|
20839
20949
|
};
|
|
20840
20950
|
cv.addEventListener("pointerdown", (e) => {
|
|
@@ -21254,7 +21364,7 @@ function maskEditing(c) {
|
|
|
21254
21364
|
function drawMaskOverlay(c, W) {
|
|
21255
21365
|
const h = maskHandles(c);
|
|
21256
21366
|
if (!h) return false;
|
|
21257
|
-
const lw = Math.max(1.5, W / 800), hs = Math.max(5, W / 170);
|
|
21367
|
+
const lw = Math.max(1.5, W / 800), hs = monMark(Math.max(5, W / 170));
|
|
21258
21368
|
ctx2d.save();
|
|
21259
21369
|
ctx2d.setTransform(1, 0, 0, 1, 0, 0);
|
|
21260
21370
|
const pts = maskOutline(c, h);
|
|
@@ -21302,7 +21412,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
21302
21412
|
if (!maskEditing(c)) return;
|
|
21303
21413
|
const h = maskHandles(c);
|
|
21304
21414
|
if (!h) return;
|
|
21305
|
-
const pt = canvasPt(e), W = els.preview.width, grab = Math.max(8, W / 110);
|
|
21415
|
+
const pt = canvasPt(e), W = els.preview.width, grab = monGrab(Math.max(8, W / 110), e);
|
|
21306
21416
|
const near = (p) => Math.hypot(p.x - pt.x, p.y - pt.y) <= grab;
|
|
21307
21417
|
const { m, sp } = h, a = sp.aspect, uv = sp.toUv(pt);
|
|
21308
21418
|
let drag = null;
|
|
@@ -21386,7 +21496,7 @@ els.preview.addEventListener("pointercancel", endMaskDrag, true);
|
|
|
21386
21496
|
els.preview.addEventListener("dblclick", (e) => {
|
|
21387
21497
|
const c = getClip(state.selId);
|
|
21388
21498
|
if (!maskEditing(c)) return;
|
|
21389
|
-
const h = maskHandles(c), pt = canvasPt(e), grab = Math.max(8, els.preview.width / 110);
|
|
21499
|
+
const h = maskHandles(c), pt = canvasPt(e), grab = monGrab(Math.max(8, els.preview.width / 110), e);
|
|
21390
21500
|
const i = h ? h.points.findIndex((p) => Math.hypot(p.x - pt.x, p.y - pt.y) <= grab) : -1;
|
|
21391
21501
|
if (i < 0) return;
|
|
21392
21502
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
@@ -21551,6 +21661,17 @@ for (const b of document.querySelectorAll("#wsSwitch [data-ws]"))
|
|
|
21551
21661
|
b.addEventListener("click", () => setWorkspace(b.dataset.ws));
|
|
21552
21662
|
|
|
21553
21663
|
initPanelSplit();
|
|
21664
|
+
/* Another layout (a rotation, a resized window, the setting): rows and the
|
|
21665
|
+
split get that layout's sizes; selection, playhead, undo and whatever is
|
|
21666
|
+
open are untouched. */
|
|
21667
|
+
window.addEventListener("fablecut:layout", () => {
|
|
21668
|
+
applyTrackHeights();
|
|
21669
|
+
buildTrackDOM();
|
|
21670
|
+
if (!tlCentred()) setTimelineHeight(parseFloat(localStorage.getItem(TL_H_KEY)) || defaultTimelineHeight());
|
|
21671
|
+
rebuildClips();
|
|
21672
|
+
if (tlCentred()) followCentre(); else ensurePlayheadVisible();
|
|
21673
|
+
noteActivity();
|
|
21674
|
+
});
|
|
21554
21675
|
buildTrackDOM();
|
|
21555
21676
|
rebuildClips();
|
|
21556
21677
|
renderBin();
|