Skip to content

Commit ae91433

Browse files
feat(studio): let a host make the timeline read-only while seek, scroll and zoom stay live (#4749)
* feat(studio): let a host make the timeline read-only while seek, scroll and zoom stay live Timeline takes readOnly and onReadOnlyPress. In read-only the subtree sees no edit callbacks, every clip is locked, and each refused press (clip drag, clip/lane/keyframe menu, drop, eye, razor, beat dot, FX) reports once through onReadOnlyPress. * refactor(studio): route read-only refusals through one helper and share the keyframed test fixture Keeps the provider hook under the complexity limit, drops the comments the ratchet counted, and reuses the ruler test's keyframed card instead of copying it. The provider keeps one tree shape in both modes so toggling read-only keeps scroll and zoom. * fix(studio): switching the timeline to read-only drops edits already in flight On the switch into read-only the timeline cancels an active clip drag or resize, beat drag and keyframe retime without committing, and closes the clip, gap and keyframe menus. A keyframe-diamond drag and an automation-lane point drag or double-click now report through onReadOnlyPress too, and the refusal stays one stable function however the host writes its callback.
1 parent 5461e0a commit ae91433

17 files changed

Lines changed: 903 additions & 57 deletions

‎packages/studio/src/player/components/BeatStrip.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
resolveTimelineAutoScrollLoopAction,
1313
} from "./timelineEditing";
1414
import { getTimelineElementIndexes } from "../lib/timelineElementIndexes";
15+
import { useTimelineReadOnlyPress } from "./timelineReadOnly";
1516

1617
export const BEAT_BAND_H = 14; // dark band height at top of track
1718
const BEAT_HIT_W = 24; // grab width per beat (px) — ≥24px pointer target
@@ -88,7 +89,7 @@ function claimBeatDrag(pointerId?: number): BeatDragActor | null {
8889
return actor;
8990
}
9091

91-
function cancelBeatDrag(): void {
92+
export function cancelBeatDrag(): void {
9293
claimBeatDrag();
9394
}
9495

@@ -377,6 +378,7 @@ export const BeatStrip = memo(function BeatStrip({
377378
);
378379
const sessionEpoch = usePlayerStore((state) => state.timelineSessionEpoch);
379380
const projectId = usePlayerStore((state) => state.timelineProjectId);
381+
const readOnlyPress = useTimelineReadOnlyPress();
380382

381383
if (!beatTimes || beatsTooDense(beatTimes, pps)) return null;
382384
const activeBeatIndex = activeActor
@@ -420,7 +422,7 @@ export const BeatStrip = memo(function BeatStrip({
420422
top: 0,
421423
width: BEAT_HIT_W,
422424
height: BEAT_BAND_H,
423-
cursor: "ew-resize",
425+
cursor: readOnlyPress ? "default" : "ew-resize",
424426
pointerEvents: "auto",
425427
touchAction: "none",
426428
}}
@@ -429,13 +431,14 @@ export const BeatStrip = memo(function BeatStrip({
429431
// selection (which otherwise "selects" the whole panel mid-drag).
430432
e.preventDefault();
431433
e.stopPropagation();
434+
if (readOnlyPress) return readOnlyPress();
432435
// ⌥ starts no drag: the delete lands on release below, so a
433436
// slipped ⌥-drag abandons instead of destroying the beat.
434437
if (e.altKey) return;
435438
beginBeatDrag(e, t, pps);
436439
}}
437440
onClick={(e) => {
438-
if (!e.altKey) return;
441+
if (!e.altKey || readOnlyPress) return;
439442
// ⌥-click deletes. Deliberately NOT double-click: a stuttered drag
440443
// attempt reads as a double-click and would destroy the beat.
441444
e.stopPropagation();

0 commit comments

Comments
 (0)