Implemented time readout accuracy setting

This commit is contained in:
patben8 committed 2026-10-15 17:42:26 +02:00
1 parent 16c3552be6
commit 77b063ba0e
3 files changed
+42 -9

No files matched your search

+1 -1
View File
@@ -893,7 +893,7 @@ Two independent apps that talk over HTTP:
/ Try again (`backend_restart`). The shell has no timeout of its own. Before
ready it answers quit requests itself — nothing can be unsaved — and stops
at ready so it never races `QuitGuard`), `SaveBar` (+ "Discard changes…" when
dirty, and the settings gear beside it, whose menu (or `?` anywhere) opens `ShortcutsDialog` — a KEYBOARD MAP (decided 2026-10-15): keys lit in the colour of what they do, a caption explaining the key pointed at or pressed (pressing explains, it never acts: a capture-phase listener keeps the deck's and table's keys from firing), holding or picking ⇧ / Cmd-Ctrl relights it with that layer, mouse gestures listed beneath. It shrinks to fit the dialog and drops the words on the keys when too small. Its content is `lib/shortcuts.ts`, written out BY HAND, so a new or changed shortcut in `PrepStrip` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder`. The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
dirty, and the settings gear beside it, whose menu (or `?` anywhere) opens `ShortcutsDialog` — a KEYBOARD MAP (decided 2026-10-15): keys lit in the colour of what they do, a caption explaining the key pointed at or pressed (pressing explains, it never acts: a capture-phase listener keeps the deck's and table's keys from firing), holding or picking ⇧ / Cmd-Ctrl relights it with that layer, mouse gestures listed beneath. It shrinks to fit the dialog and drops the words on the keys when too small. Its content is `lib/shortcuts.ts`, written out BY HAND, so a new or changed shortcut in `PrepStrip` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder` — and `timeReadoutDecimals` (0–3, default 1: the deck's ELAPSED / REMAIN, truncated, never rounded). The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
devices. TanStack Table + **virtualized** grid; per-row play button,
configurable columns, header sorting, inline double-click editing, and
+25
View File
@@ -14,6 +14,8 @@ export const APP_SETTING_DEFAULTS = {
expandPlaylistFolders: false,
/** Read by the backend when an export runs (`main.run_export`). */
exportRootFolder: false,
/** Decimal places on the deck's ELAPSED / REMAIN readouts (0–3). */
timeReadoutDecimals: 1,
}
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
@@ -29,6 +31,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
const qc = useQueryClient()
const expandFolders = useAppSetting('expandPlaylistFolders')
const exportRootFolder = useAppSetting('exportRootFolder')
const timeDecimals = useAppSetting('timeReadoutDecimals')
const [error, setError] = useState<string | null>(null)
useEffect(() => {
@@ -95,6 +98,28 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
</span>
</label>
</section>
<section className="space-y-2">
<h3 className="text-[11px] font-semibold uppercase tracking-wider text-faint">Deck</h3>
<label className="flex items-start justify-between gap-4">
<span className="min-w-0">
<span className="block text-sm text-text">Time readout precision</span>
<span className="block text-xs text-faint">
Decimal places on the Elapsed and Remain readouts. 1 shows tenths, 3 milliseconds.
</span>
</span>
<select
className="shrink-0 rounded-lg well px-2 py-1 text-sm text-text outline-none"
value={timeDecimals}
onChange={(e) => void set({ timeReadoutDecimals: Number(e.target.value) })}
>
{['00:00', '00:00.0', '00:00.00', '00:00.000'].map((sample, n) => (
<option key={n} value={n}>
{n} — {sample}
</option>
))}
</select>
</label>
</section>
{error && <div className="text-xs text-pink">{error}</div>}
</div>
<div className="flex justify-end gap-2 border-t border-line px-5 py-3">
+16 -8
View File
@@ -35,6 +35,7 @@ import { HotcueBar } from './HotcueBar'
import { LoopControls, LOOP_SIZES, type LoopMode } from './LoopControls'
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC, type StemLane } from './MainWaveform'
import { OverviewWaveform } from './OverviewWaveform'
import { useAppSetting } from './AppSettings'
import { usePrefsWriter } from '../lib/prefs'
/** Keys that mute stems 1-4 (Shift = solo), by `KeyboardEvent.code`. */
@@ -66,13 +67,19 @@ interface Props {
onEditTags?: (track: Track) => void
}
/** m:ss.t — the deck's readouts show tenths, as a CDJ does. */
function fmtTenths(secs: number): string {
/** mm:ss.f — tenths by default, as a CDJ does; `places` is the
* `timeReadoutDecimals` setting (0 drops the fraction). Truncates, never
* rounds, so the readout never shows a second before it has been reached. */
function fmtTime(secs: number, places: number): string {
if (!isFinite(secs) || secs < 0) secs = 0
const tenths = Math.floor(secs * 10)
const m = Math.floor(tenths / 600)
const s = Math.floor((tenths % 600) / 10)
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}.${tenths % 10}`
const scale = 10 ** places
// The epsilon keeps e.g. 0.3 s from reading 0.299 at 3 places.
const units = Math.floor(secs * scale + 1e-6)
const whole = Math.floor(units / scale)
const m = Math.floor(whole / 60)
const s = whole % 60
const frac = places > 0 ? `.${(units % scale).toString().padStart(places, '0')}` : ''
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}${frac}`
}
/**
@@ -117,6 +124,7 @@ export function PrepStrip({
// which the pointer's :active alone cannot, since the key never touches it.
const [cueHeld, setCueHeld] = useState(false)
const [current, setCurrent] = useState(0)
const timeDecimals = useAppSetting('timeReadoutDecimals')
const [duration, setDuration] = useState(0)
const [ready, setReady] = useState(false)
const [cols, setCols] = useState<WaveColumn[] | null>(null)
@@ -1338,12 +1346,12 @@ export function PrepStrip({
<div className="well flex h-11 shrink-0 items-stretch rounded-xl">
<div className="flex flex-col justify-center gap-px px-4">
<span className="text-[10px] tracking-[0.08em] text-faint">ELAPSED</span>
<span className="font-mono text-[17px] font-medium">{fmtTenths(current)}</span>
<span className="font-mono text-[17px] font-medium">{fmtTime(current, timeDecimals)}</span>
</div>
<span aria-hidden className="my-2 w-px bg-line" />
<div className="flex flex-col justify-center gap-px px-4">
<span className="text-[10px] tracking-[0.08em] text-faint">REMAIN</span>
<span className="font-mono text-[17px] font-medium">−{fmtTenths(Math.max(0, duration - current))}</span>
<span className="font-mono text-[17px] font-medium">−{fmtTime(Math.max(0, duration - current), timeDecimals)}</span>
</div>
<span aria-hidden className="my-2 w-px bg-line" />
<div className="flex flex-col justify-center gap-px px-4">