Go to a shot by clicking its row; move shots up and down

Clicking anywhere on a shot row (its number, title or summary line), or
pressing Enter or Space on its title, now selects the shot and loads it,
which is what the row's LOAD button did; the LOAD button is gone. In its
place, up and down arrows swap the shot with its neighbour through
SceneDirector.moveShot, which saves the project and publishes shot-moved.
The arrows are disabled at the ends and while the scene plays, and neither
they nor DEL load the shot.
This commit is contained in:
Sameh Khamis committed 2026-11-17 20:37:29 -08:00
1 parent 09cead6a0e
commit 6b78d72f52
24 files changed
+312 -74

No files matched your search

+27
View File
@@ -492,6 +492,8 @@ export class SceneDirector {
download: () => this.downloadLastRunMetadata(),
load: (sceneId, shotId) => this.loadShot(sceneId, shotId),
deleteShot: (sceneId, shotId) => this.deleteShot(sceneId, shotId),
moveShot: (sceneId, shotId, index) =>
this.moveShot(sceneId, shotId, index),
},
});
}
@@ -1225,6 +1227,31 @@ export class SceneDirector {
if (inStories) this._publish({ type: 'stories-changed' });
}
/**
* Move a shot to another place in its scene's playback order, the shots
* between shifting over (the shot list's up and down buttons swap it with
* its neighbour). Not while the scene plays.
* @param {string} sceneId
* @param {string} shotId
* @param {number} index Its new place, kept within the scene's shots.
* @returns {boolean} Whether it moved.
*/
moveShot(sceneId, shotId, index) {
if (this._running || !Number.isInteger(index)) return false;
const { scene, shot } = this._getShot(sceneId, shotId);
if (!scene || !shot) return false;
const from = scene.shots.indexOf(shot);
const to = Math.max(0, Math.min(scene.shots.length - 1, index));
if (from === to) return false;
const shots = scene.shots.filter((item) => item !== shot);
shots.splice(to, 0, shot);
scene.shots = shots;
this._saveProject();
this._shotOutcome('shot-moved', scene, shot, to);
if (scene.stories) this._publish({ type: 'stories-changed' });
return true;
}
/**
* Load a single shot: apply its visual state, enable/disable layers, and fly
* the camera to the shot's position. Blocked while a scene run is active.
+37
View File
@@ -1869,6 +1869,43 @@ test('Scene snapshots are immutable and editing outcomes retain the affected sho
} finally { restore(); }
});
test('moveShot reorders a scene, saves it and publishes shot-moved; not past the ends, not while playing', async () => {
const { director, restore } = makeDirector();
try {
director._activeRun = null;
const seen = [];
director.subscribe(({ change }) => { if (change) seen.push(change); });
const order = () => director._project.scenes[0].shots.map(({ id }) => id);
const saved = () =>
JSON.parse(localStorage.getItem('godsEyeView.sceneProject.v2'))
.scenes[0].shots.map(({ id }) => id);
assert.equal(director.moveShot('scene-1', 'shot-b', 0), true);
assert.deepEqual(order(), ['shot-b', 'shot-a']);
assert.deepEqual(saved(), ['shot-b', 'shot-a']);
const moved = seen.find(({ type }) => type === 'shot-moved');
assert.equal(moved.shot.id, 'shot-b');
assert.equal(moved.index, 0);
// The view's action is the same edit.
seen.length = 0;
director._controls.actions.moveShot('scene-1', 'shot-b', 1);
assert.deepEqual(order(), ['shot-a', 'shot-b']);
assert.deepEqual(seen.map(({ type }) => type), ['shot-moved']);
// Past an end it stays at the end; at its place, unknown, or playing, nothing moves.
assert.equal(director.moveShot('scene-1', 'shot-b', 5), false);
assert.equal(director.moveShot('scene-1', 'shot-a', -1), false);
assert.equal(director.moveShot('scene-1', 'missing', 0), false);
assert.equal(director.moveShot('scene-1', 'shot-a', 0.5), false);
director._running = true;
assert.equal(director.moveShot('scene-1', 'shot-b', 0), false);
director._running = false;
assert.deepEqual(order(), ['shot-a', 'shot-b']);
await director.destroy();
} finally { restore(); }
});
test('Scene load outcomes exclude superseded and disposed completions', async () => {
const { director, styleManager, restore } = makeDirector();
try {