From c6aaded26da72460b29c243c857e33b7c1cfea6e Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Fri, 25 Sep 2026 17:16:16 +0200 Subject: [PATCH] Improved hotcue icons --- frontend/src/App.tsx | 3 +++ frontend/src/components/HotcueBar.tsx | 15 +++++++-------- frontend/src/components/PrepStrip.tsx | 6 +++++- frontend/src/lib/cues.ts | 22 +++++++++++++--------- frontend/src/lib/icons.tsx | 5 +++++ 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8347ecd..aca44e0 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -500,6 +500,9 @@ export default function App() { setSource({ kind: 'all' }) setSelected(new Set()) setBatchJob(null) // the backend cancels it; its result is for the old library + // The deck starts empty: its track belongs to the old library. + setPrepTrack(null) + setPlayRequest(0) setFilters(emptyFilters) setSorting([]) qc.invalidateQueries() // refetch everything for the newly-opened collection diff --git a/frontend/src/components/HotcueBar.tsx b/frontend/src/components/HotcueBar.tsx index 32d69da..89de0f6 100644 --- a/frontend/src/components/HotcueBar.tsx +++ b/frontend/src/components/HotcueBar.tsx @@ -1,6 +1,6 @@ import { useRef, useState, type CSSProperties } from 'react' import type { CuePoint } from '../api' -import { CUE_TYPE_LABELS, cueColor, cueGlyph, withAlpha } from '../lib/cues' +import { CUE_TYPE_LABELS, cueColor, cueIcon, withAlpha } from '../lib/cues' import { Icon } from '../lib/icons' interface Props { @@ -60,7 +60,7 @@ export function HotcueBar({ const locked = cue != null && !cue.editable const selected = selectedSlot === slot && !locked const color = cue ? cueColor(cue) : null - const glyph = cue ? cueGlyph(cue) : '' + const icon = cue && !locked ? cueIcon(cue) : null return ( diff --git a/frontend/src/components/PrepStrip.tsx b/frontend/src/components/PrepStrip.tsx index 6f34622..f78ecb4 100644 --- a/frontend/src/components/PrepStrip.tsx +++ b/frontend/src/components/PrepStrip.tsx @@ -432,8 +432,12 @@ export function PrepStrip({ // A library row's play button bumps `playRequest`: load (if needed) + play. // If the requested track is already loaded and ready, start immediately; // otherwise flag it and the analysis effect starts playback once ready. + // Only a CHANGE is a request: the deck unmounts behind the library picker, + // and remounting with a non-zero count must not start playback. + const seenPlayRequestRef = useRef(playRequest) useEffect(() => { - if (playRequest === 0) return + if (playRequest === seenPlayRequestRef.current) return + seenPlayRequestRef.current = playRequest pendingPlayRef.current = true const eng = playbackRef.current if (loadedIdRef.current === trackId && eng?.ready) { diff --git a/frontend/src/lib/cues.ts b/frontend/src/lib/cues.ts index 247b3c8..b0a4f23 100644 --- a/frontend/src/lib/cues.ts +++ b/frontend/src/lib/cues.ts @@ -1,5 +1,6 @@ import type { CuePoint, CueType } from '../api' import { BEATS_PER_BAR, type BeatGrid } from './beatgrid' +import type { IconName } from './icons' // Fallback colour by cue type, used when the platform stored none. const TYPE_COLORS: Record = { @@ -20,14 +21,14 @@ export const CUE_TYPE_LABELS: Record = { } // A second, always-present channel for type. Colour used to be type-derived and -// therefore always carried it; now that a user's stored colour wins, the glyph +// therefore always carried it; now that a user's stored colour wins, the icon // is what keeps a fade-in distinguishable from a plain cue. -const TYPE_GLYPHS: Record = { - cue: '', - fade_in: '▶', - fade_out: '◀', - load: '⏏', - loop: '⟳', +const TYPE_ICONS: Record = { + cue: 'cueFlag', + fade_in: 'fadeIn', + fade_out: 'fadeOut', + load: 'eject', + loop: 'loop', } /** @@ -49,8 +50,11 @@ export function cueTypeColor(type: CueType): string { return TYPE_COLORS[type] ?? MEMORY_COLOR } -export function cueGlyph(cue: CuePoint): string { - return TYPE_GLYPHS[cue.type] ?? '' +/** The pad icon for a cue: its type — or the grid icon for a cue that marks a + * beatgrid marker (Traktor's white companion), since that is what it is. */ +export function cueIcon(cue: CuePoint): IconName { + if (cue.grid_marker != null) return 'grid' + return TYPE_ICONS[cue.type] ?? 'cueFlag' } export function withAlpha(hex: string, a: number): string { diff --git a/frontend/src/lib/icons.tsx b/frontend/src/lib/icons.tsx index 04cae20..cb77220 100644 --- a/frontend/src/lib/icons.tsx +++ b/frontend/src/lib/icons.tsx @@ -85,6 +85,11 @@ const PATHS = { ), pencil: , plus: , + // Cue types, for the hotcue pads. + cueFlag: , + fadeIn: , + fadeOut: , + eject: , grid: , } as const