The Timeline ruler's existing s/fr toggle (store.editor.timelineDisplayMode)
now drives every time display and time input across the editor. Mixing
"frames here, seconds there" was inconsistent — pick the unit once, see
it everywhere.
New composable (src/composables/useTimeFormat.ts):
- formatTime(seconds, opts) → "1.42s" or "42 fr" (short variant drops
trailing zeros for ruler-style ticks).
- timeToInputValue / inputValueToSeconds — paired conversions used at
every <input type="number"> bound to a time. Storage stays in seconds
(renderer + .ruw files unchanged); conversion happens at the UI edge.
- inputStep ('0.01' / '1') and unitLabel ('seconds' / 'frames') for
consistent input attributes / labels.
Surfaces switched over:
- App.vue topbar playhead + duration.
- PropertiesPanel keyframe-here label (`@ 1.50s` → `@ 45 fr`).
- FullscreenPreview time label.
- AssetSidebar clip + audio asset durations.
- Timeline audio clip + clip trim tooltips (route through formatKfTime,
which already honoured the toggle).
- DocumentDrawer scene duration input — step + min flip with the mode,
label gets a (seconds)/(frames) suffix.
- ScriptFrameDialog time input — same flip.
- ActionEditor jumpTo time input — same flip. (jumpToFrame stays as
frames since "frame" is its semantic, not a unit choice.)
- Kaleido offset on ClipInstance — now follows the global toggle too,
was hardcoded frames before. The frames-by-default UX comes from
the user defaulting to 'frames' on the ruler; switching to seconds
shows the same offset in seconds without losing precision.
Number-input audit (cleaning up "ewig viele Nachkommastellen"):
- ScriptFrameDialog time: rounded display to ≤3 decimals at the edge.
- ActionEditor jumpTo time: same.
- PropertiesPanel kaleido pivot X/Y (ClipInstance): rounded to int.
- RangeSlider strokeWidth format: snapped to 0.5 increments.
Number-input widths (capping the panel sprawl):
- PropertiesPanel inputs: max-width 96px + tabular-nums; .row inputs
(side-by-side pivot X/Y, transform X/Y) keep flex-share.
- ActionEditor .params input[type='number']: explicit 96px.
- ScriptFrameDialog .row input[type='number']: explicit 96px.
- DocumentDrawer + ExportDialog: already had explicit widths.
Tests (6 new under "time format — global seconds/frames toggle"):
- useTimeFormat composable roundtrips through both modes at fps=30.
- PropertiesPanel keyframe label flips on mode change.
- DocumentDrawer duration input flips step + value (2s ↔ 60fr).
- ActionEditor jumpTo flips step + value (1s ↔ 24fr at fps=24).
- Kaleido offset display switches between modes for the same stored
value (0.5s ↔ 15fr).
- Kaleido offset write-back: typing "30" in frames mode at fps=30
stores exactly 1.0s.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
187 lines
4.3 KiB
Vue
187 lines
4.3 KiB
Vue
<script setup lang="ts">
|
|
import { computed, ref, watch } from 'vue'
|
|
import { PhTrash } from '@phosphor-icons/vue'
|
|
import { useSceneStore } from '@/stores/scene'
|
|
import { t } from '@/i18n'
|
|
import { Modal } from '@/components/ui'
|
|
import ActionEditor from './ActionEditor.vue'
|
|
import type { Action } from '@/types/scene'
|
|
import { useTimeFormat } from '@/composables/useTimeFormat'
|
|
|
|
const { timeToInputValue, inputValueToSeconds, inputStep, unitLabel } = useTimeFormat()
|
|
|
|
const props = defineProps<{
|
|
modelValue: boolean
|
|
frameId: string | null
|
|
}>()
|
|
const emit = defineEmits<{ 'update:modelValue': [value: boolean] }>()
|
|
|
|
const store = useSceneStore()
|
|
|
|
const frame = computed(() => {
|
|
if (!props.frameId) return null
|
|
return store.scene.scriptFrames?.find((f) => f.id === props.frameId) ?? null
|
|
})
|
|
|
|
// Local working copy so edits don't commit until the user closes.
|
|
const localTime = ref(0)
|
|
const localActions = ref<Action[]>([])
|
|
const localLabel = ref('')
|
|
|
|
watch(
|
|
[() => props.modelValue, () => props.frameId],
|
|
([open, fid]) => {
|
|
if (!open || !fid) return
|
|
const f = store.scene.scriptFrames?.find((x) => x.id === fid)
|
|
if (!f) return
|
|
localTime.value = f.time
|
|
localActions.value = f.actions.map((a) => ({ ...a }))
|
|
localLabel.value = f.label ?? ''
|
|
},
|
|
{ immediate: true },
|
|
)
|
|
|
|
function commit() {
|
|
if (!props.frameId) return
|
|
const f = frame.value
|
|
if (!f) return
|
|
if (Math.abs(f.time - localTime.value) > 1e-4) {
|
|
store.setScriptFrameTime(f.id, localTime.value)
|
|
}
|
|
store.setScriptFrameActions(f.id, localActions.value)
|
|
const nextLabel = localLabel.value.trim()
|
|
if (nextLabel && nextLabel !== f.label) f.label = nextLabel
|
|
else if (!nextLabel && f.label) delete f.label
|
|
}
|
|
|
|
function close() {
|
|
commit()
|
|
emit('update:modelValue', false)
|
|
}
|
|
|
|
function removeFrame() {
|
|
if (!props.frameId) return
|
|
store.removeScriptFrame(props.frameId)
|
|
emit('update:modelValue', false)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Modal
|
|
:model-value="modelValue"
|
|
size="md"
|
|
:title="t('scriptFrameDialog.title')"
|
|
@update:model-value="(v) => (v ? null : close())"
|
|
>
|
|
<div v-if="frame" class="body">
|
|
<div class="row">
|
|
<label>
|
|
{{ t('scriptFrameDialog.time') }} ({{ unitLabel }})
|
|
<input
|
|
type="number"
|
|
:step="inputStep"
|
|
min="0"
|
|
:value="timeToInputValue(localTime)"
|
|
@input="localTime = inputValueToSeconds(Number(($event.target as HTMLInputElement).value))"
|
|
/>
|
|
</label>
|
|
<label class="grow">
|
|
{{ t('scriptFrameDialog.label') }}
|
|
<input
|
|
type="text"
|
|
:value="localLabel"
|
|
:placeholder="t('scriptFrameDialog.labelPlaceholder')"
|
|
@input="localLabel = ($event.target as HTMLInputElement).value"
|
|
/>
|
|
</label>
|
|
</div>
|
|
<ActionEditor
|
|
:actions="localActions"
|
|
@update:actions="localActions = $event"
|
|
/>
|
|
</div>
|
|
<template #footer>
|
|
<button class="btn danger" @click="removeFrame">
|
|
<PhTrash :size="12" />
|
|
{{ t('scriptFrameDialog.remove') }}
|
|
</button>
|
|
<span class="spacer"></span>
|
|
<button class="btn primary" @click="close">{{ t('scriptFrameDialog.done') }}</button>
|
|
</template>
|
|
</Modal>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
padding: 12px 14px;
|
|
}
|
|
|
|
.row {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: flex-end;
|
|
}
|
|
|
|
.row label {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 3px;
|
|
font-size: 11px;
|
|
color: var(--text-dim);
|
|
}
|
|
|
|
.row label.grow {
|
|
flex: 1;
|
|
}
|
|
|
|
.row input {
|
|
background: var(--bg);
|
|
border: 1px solid var(--border);
|
|
color: var(--text);
|
|
padding: 4px 7px;
|
|
border-radius: var(--radius-sm);
|
|
font-size: 12px;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.row input[type='number'] {
|
|
width: 96px;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
padding: 5px 10px;
|
|
background: var(--panel);
|
|
border: 1px solid var(--border);
|
|
color: var(--text);
|
|
border-radius: var(--radius-sm);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.btn:hover {
|
|
background: var(--panel-hover);
|
|
}
|
|
|
|
.btn.primary {
|
|
background: var(--accent);
|
|
border-color: var(--accent);
|
|
color: #fff;
|
|
}
|
|
|
|
.btn.danger:hover {
|
|
background: var(--danger-soft);
|
|
color: var(--danger);
|
|
border-color: var(--danger);
|
|
}
|
|
|
|
.spacer {
|
|
flex: 1;
|
|
}
|
|
</style>
|