mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
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:
1 parent
09cead6a0e
commit
6b78d72f52
24 files changed
+312
-74
No files matched your search
@@ -48,6 +48,8 @@ export class SceneControls {
|
||||
this.run('renameShot', sceneId, shotId, title),
|
||||
load: (sceneId, shotId) => this.run('load', sceneId, shotId),
|
||||
remove: (sceneId, shotId) => this.deleteShot(sceneId, shotId),
|
||||
move: (sceneId, shotId, index) =>
|
||||
this.run('moveShot', sceneId, shotId, index),
|
||||
create: () => this.createScene(),
|
||||
deleteScene: () => this.deleteSelectedScene(),
|
||||
stories: () => this.run('stories'),
|
||||
@@ -110,6 +112,7 @@ export class SceneControls {
|
||||
'shot-captured',
|
||||
'shot-updated',
|
||||
'shot-renamed',
|
||||
'shot-moved',
|
||||
'shot-deleted',
|
||||
'project-imported',
|
||||
].includes(type)
|
||||
|
||||
@@ -98,6 +98,7 @@ function fixture() {
|
||||
'download',
|
||||
'load',
|
||||
'deleteShot',
|
||||
'moveShot',
|
||||
].map((name) => [
|
||||
name,
|
||||
(...args) => {
|
||||
@@ -219,22 +220,30 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
await nextTick();
|
||||
const row = f.elements.shots.children[0];
|
||||
const label = f.label();
|
||||
const load = row.children[0].children[1].children[0];
|
||||
const [up, down, del] = row.children[0].children[1].children;
|
||||
f.elements.capture.click();
|
||||
f.elements.start.click();
|
||||
// A click on the row goes to the shot: selected and loaded.
|
||||
label.click();
|
||||
label.dispatchEvent(new Event('dblclick'));
|
||||
await nextTick();
|
||||
label.children[0].value = 'Renamed';
|
||||
// A click in the name being typed goes nowhere.
|
||||
label.children[0].click();
|
||||
label.children[0].dispatchEvent(new Event('blur'));
|
||||
load.click();
|
||||
assert.deepEqual(f.calls, [
|
||||
['capture'],
|
||||
['start', 'scene-a'],
|
||||
['selectShot', 'shot-a'],
|
||||
['renameShot', 'scene-a', 'shot-a', 'Renamed'],
|
||||
['load', 'scene-a', 'shot-a'],
|
||||
['renameShot', 'scene-a', 'shot-a', 'Renamed'],
|
||||
]);
|
||||
// A lone shot has nowhere to move; the buttons never load it.
|
||||
assert.equal(up.disabled, true);
|
||||
assert.equal(down.disabled, true);
|
||||
window.confirm = () => false;
|
||||
del.click();
|
||||
assert.equal(f.calls.length, 5);
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
assertSameNode(f.elements.shots.children[0], row);
|
||||
@@ -246,7 +255,10 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
f.owner.destroy();
|
||||
await nextTick();
|
||||
f.label().click();
|
||||
assert.deepEqual(f.calls.at(-1), ['selectShot', 'shot-a']);
|
||||
assert.deepEqual(f.calls.slice(-2), [
|
||||
['selectShot', 'shot-a'],
|
||||
['load', 'scene-a', 'shot-a'],
|
||||
]);
|
||||
newer.destroy();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.shots.children.length, 0);
|
||||
@@ -255,6 +267,68 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
}
|
||||
});
|
||||
|
||||
test('a shot row goes to its shot from the keyboard, and its up and down buttons swap it with a neighbour', async () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
f.state.scenes[0].shots.push(
|
||||
{ id: 'shot-b', title: 'Shot B', durationSec: 4, holdSec: 0 },
|
||||
{ id: 'shot-c', title: 'Shot C', durationSec: 4, holdSec: 0 },
|
||||
);
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
const rows = () => [...f.elements.shots.children];
|
||||
const buttons = (index) => rows()[index].querySelectorAll('button');
|
||||
const label = (index) => rows()[index].querySelector('.scene-shot-label');
|
||||
|
||||
// The title is the row's keyboard control, described by its summary.
|
||||
const second = label(1);
|
||||
assert.equal(second.getAttribute('role'), 'button');
|
||||
assert.equal(second.getAttribute('tabindex'), '0');
|
||||
const meta = document.getElementById(
|
||||
second.getAttribute('aria-describedby'),
|
||||
);
|
||||
assert.ok(meta.classList.contains('scene-shot-meta'));
|
||||
for (const key of ['Enter', ' '])
|
||||
second.dispatchEvent(
|
||||
Object.assign(new Event('keydown', { bubbles: true }), { key }),
|
||||
);
|
||||
second.dispatchEvent(
|
||||
Object.assign(new Event('keydown', { bubbles: true }), { key: 'a' }),
|
||||
);
|
||||
assert.deepEqual(f.calls, [
|
||||
['selectShot', 'shot-b'],
|
||||
['load', 'scene-a', 'shot-b'],
|
||||
['selectShot', 'shot-b'],
|
||||
['load', 'scene-a', 'shot-b'],
|
||||
]);
|
||||
|
||||
// Up and down, labelled, disabled at the ends; neither loads the shot.
|
||||
f.calls.length = 0;
|
||||
const [firstUp, firstDown] = buttons(0);
|
||||
assert.equal(firstUp.getAttribute('aria-label'), 'Move up');
|
||||
assert.equal(firstDown.getAttribute('aria-label'), 'Move down');
|
||||
assert.equal(firstUp.disabled, true);
|
||||
assert.equal(firstDown.disabled, false);
|
||||
assert.equal(buttons(2)[1].disabled, true);
|
||||
assert.equal(buttons(2)[0].disabled, false);
|
||||
buttons(1)[0].click();
|
||||
buttons(1)[1].click();
|
||||
assert.deepEqual(f.calls, [
|
||||
['moveShot', 'scene-a', 'shot-b', 0],
|
||||
['moveShot', 'scene-a', 'shot-b', 2],
|
||||
]);
|
||||
|
||||
// Not while the scene plays.
|
||||
f.state.running = true;
|
||||
f.owner.setButtons(true);
|
||||
await nextTick();
|
||||
assert.ok(rows().every((_, index) => buttons(index)[0].disabled));
|
||||
assert.ok(rows().every((_, index) => buttons(index)[1].disabled));
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('Scene Escape and recording presentation follow playback and release on destruction', async () => {
|
||||
const f = fixture();
|
||||
const escape = () =>
|
||||
|
||||
@@ -8,6 +8,8 @@ import { computed, markRaw, shallowRef } from 'vue';
|
||||
* @property {(sceneId: string, shotId: string, title: string) => void} rename
|
||||
* @property {(sceneId: string, shotId: string) => void} load
|
||||
* @property {(sceneId: string, shotId: string) => void} remove
|
||||
* @property {(sceneId: string, shotId: string, index: number) => void} move
|
||||
* Move a shot to `index` in its scene's playback order.
|
||||
* @property {(file: File) => Promise<void>|void} importFile A chosen file.
|
||||
* @property {() => void} create, deleteScene, stories, thumb, capture, update,
|
||||
* start, stop, next, export, download The panel's buttons.
|
||||
|
||||
@@ -345,6 +345,7 @@ html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
}
|
||||
|
||||
.scene-shot-row {
|
||||
cursor: pointer;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 9px;
|
||||
padding: 8px 10px;
|
||||
@@ -398,6 +399,11 @@ html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
color: var(--scene-quiet);
|
||||
}
|
||||
|
||||
.scene-shot-label:focus-visible {
|
||||
outline: 1px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.scene-shot-row.active .scene-shot-label::before {
|
||||
color: var(--accent);
|
||||
}
|
||||
@@ -422,9 +428,20 @@ html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
|
||||
.scene-shot-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
/* Up and down: the glyph as tall as DEL's word. */
|
||||
.scene-shot-move {
|
||||
padding: 3px 4px;
|
||||
}
|
||||
|
||||
.scene-shot-move .ui-icon {
|
||||
display: block;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.scene-progress {
|
||||
margin-top: 8px;
|
||||
width: 100%;
|
||||
|
||||
@@ -86,7 +86,7 @@ async function importChosen(event) {
|
||||
<UiButton id="scene-update-shot-btn" type="button" :disabled="off('update')" @click="scenes.act('update')" class="gev-action-button scene-btn" :title="t('Replace the selected shot with the current view')">{{ t('UPDATE SHOT') }}</UiButton>
|
||||
</div>
|
||||
<SceneShotList />
|
||||
<p class="scene-shot-hint">{{ t('Click a shot to select it, double-click to rename.') }}</p>
|
||||
<p class="scene-shot-hint">{{ t('Click a shot to go to it, double-click to rename.') }}</p>
|
||||
<p class="scene-step-heading">{{ t('PREVIEW') }}</p>
|
||||
<div class="scene-controls">
|
||||
<UiButton variant="primary" id="scene-start-btn" type="button" class="gev-action-button scene-btn scene-btn-primary" :title="t('Play from this scene through the rest of the project')" :disabled="off('start')" @click="scenes.act('start')">{{ scene?.playLabel ?? t('PLAY', { context: 'scene' }) }}</UiButton>
|
||||
|
||||
@@ -4,14 +4,19 @@ import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { describeShot } from '../scenePresentation.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
import { useSceneStore } from '../stores/scenes.js';
|
||||
import UiEmpty from '../kit/UiEmpty.vue';
|
||||
|
||||
// The selected scene's shots. Rows keep their identity across selection so a
|
||||
// click followed by a double-click lands on the same label.
|
||||
// click followed by a double-click lands on the same label. A click anywhere
|
||||
// on a row (or Enter or Space on its title) goes to the shot: it is selected
|
||||
// and loaded. The row's buttons move it up or down, or delete it.
|
||||
const store = useSceneStore();
|
||||
const { scenes, selectedSceneId, selectedShotId, attached } =
|
||||
const { scenes, selectedSceneId, selectedShotId, attached, panel } =
|
||||
storeToRefs(store);
|
||||
const running = computed(() => !!panel.value?.running);
|
||||
const list = ref(null);
|
||||
const scene = computed(
|
||||
() => scenes.value.find((item) => item.id === selectedSceneId.value) ?? null,
|
||||
);
|
||||
@@ -41,6 +46,38 @@ function act(name, shot, ...args) {
|
||||
if (scene.value) store.act(name, scene.value.id, shot.id, ...args);
|
||||
}
|
||||
|
||||
/** What on a row is not for going to the shot: its buttons and the name being typed. */
|
||||
const NOT_GOING = '.scene-shot-actions, .scene-shot-rename';
|
||||
|
||||
/** Go to a shot: select it and load its look, layers and camera. */
|
||||
function go(shot, event) {
|
||||
if (isEditing(shot) || !scene.value || event?.target?.closest?.(NOT_GOING))
|
||||
return;
|
||||
store.act('select', shot.id);
|
||||
act('load', shot);
|
||||
}
|
||||
|
||||
function onLabelKey(shot, event) {
|
||||
if (event.key !== 'Enter' && event.key !== ' ') return;
|
||||
event.preventDefault();
|
||||
go(shot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap a shot with its neighbour (`step` -1 up, 1 down). The focus stays on
|
||||
* the button pressed, or moves to the other one once the shot reaches an end.
|
||||
*/
|
||||
async function move(shot, index, step) {
|
||||
act('move', shot, index + step);
|
||||
await nextTick();
|
||||
const row = [...(list.value?.children ?? [])].find(
|
||||
(item) => item.dataset.sceneShotId === shot.id,
|
||||
);
|
||||
const [up, down] = row?.querySelectorAll('.scene-shot-move') ?? [];
|
||||
const pressed = step < 0 ? up : down;
|
||||
(pressed && !pressed.disabled ? pressed : step < 0 ? down : up)?.focus();
|
||||
}
|
||||
|
||||
async function startRename(shot) {
|
||||
if (isEditing(shot) || !scene.value) return;
|
||||
editing.value = { sceneId: scene.value.id, shotId: shot.id };
|
||||
@@ -72,7 +109,7 @@ function onRenameKey(shot, event) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="scene-shot-list" class="scene-shot-list ui-scroll">
|
||||
<div id="scene-shot-list" ref="list" class="scene-shot-list ui-scroll">
|
||||
<template v-if="attached">
|
||||
<UiEmpty
|
||||
v-if="!scene?.shots.length"
|
||||
@@ -81,17 +118,22 @@ function onRenameKey(shot, event) {
|
||||
/>
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="shot in scene.shots"
|
||||
v-for="(shot, index) in scene.shots"
|
||||
:key="shot.id"
|
||||
class="scene-shot-row"
|
||||
:class="{ active: shot.id === selectedShotId }"
|
||||
:data-scene-shot-id="shot.id"
|
||||
@click="go(shot, $event)"
|
||||
>
|
||||
<div class="scene-shot-top">
|
||||
<div
|
||||
class="scene-shot-label"
|
||||
:title="t('Double-click to rename')"
|
||||
@click="store.act('select', shot.id)"
|
||||
:role="isEditing(shot) ? undefined : 'button'"
|
||||
:tabindex="isEditing(shot) ? undefined : 0"
|
||||
:aria-current="shot.id === selectedShotId ? 'true' : undefined"
|
||||
:aria-describedby="`scene-shot-meta-${shot.id}`"
|
||||
:title="t('Go to this shot. Double-click to rename.')"
|
||||
@keydown="onLabelKey(shot, $event)"
|
||||
@dblclick="startRename(shot)"
|
||||
><input
|
||||
v-if="isEditing(shot)"
|
||||
@@ -103,12 +145,21 @@ function onRenameKey(shot, event) {
|
||||
@blur="finishRename(shot, $event.target, true)"
|
||||
/><template v-else>{{ shownTitle(shot) }}</template></div
|
||||
>
|
||||
<div class="scene-shot-actions">
|
||||
<div class="scene-shot-actions" @dblclick.stop>
|
||||
<UiButton
|
||||
class="gev-action-button gev-action-button--compact scene-shot-btn"
|
||||
@click="act('load', shot)"
|
||||
>{{ t('LOAD') }}</UiButton
|
||||
>
|
||||
class="gev-action-button gev-action-button--compact scene-shot-btn scene-shot-move"
|
||||
:label="t('Move up')"
|
||||
:disabled="running || index === 0"
|
||||
@click="move(shot, index, -1)"
|
||||
><UiIcon name="arrow_upward" :size="12"
|
||||
/></UiButton>
|
||||
<UiButton
|
||||
class="gev-action-button gev-action-button--compact scene-shot-btn scene-shot-move"
|
||||
:label="t('Move down')"
|
||||
:disabled="running || index === scene.shots.length - 1"
|
||||
@click="move(shot, index, 1)"
|
||||
><UiIcon name="arrow_downward" :size="12"
|
||||
/></UiButton>
|
||||
<UiButton
|
||||
tone="alert"
|
||||
class="gev-action-button gev-action-button--danger gev-action-button--compact scene-shot-btn scene-shot-danger"
|
||||
@@ -117,7 +168,9 @@ function onRenameKey(shot, event) {
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="scene-shot-meta">{{ describeShot(shot) }}</div>
|
||||
<div :id="`scene-shot-meta-${shot.id}`" class="scene-shot-meta">
|
||||
{{ describeShot(shot) }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user