Added full support for memory-cues

This commit is contained in:
patben8 committed 2026-10-16 14:50:46 +02:00
1 parent 0ced274f73
commit 19a604f730
74 files changed
+2083 -274

No files matched your search

+32 -2
View File
@@ -125,8 +125,8 @@ export type TrackField =
export interface CuePoint {
name: string | null
type: CueType
/** Memory cues have no bank slot. Only Rekordbox has them, so they are
* preserved and shown but not editable anywhere yet. */
/** A memory cue has no bank slot (Rekordbox / OneLibrary memory cues,
* Traktor's cues on no pad) and is addressed by `id`, not `slot`. */
role: CueRole
start: number // seconds
length: number // seconds (>0 for loops)
@@ -139,6 +139,10 @@ export interface CuePoint {
/** Index of the grid marker this cue mirrors, where the platform pairs them.
* A display hint only; null on platforms that do not. */
grid_marker: number | null
/** The handle the memory-cue commands take; null on a hot cue (addressed by
* slot). Opaque, and may change when THIS cue is edited — always use the
* fresh TrackCues a command returns. */
id: string | null
}
/** One beatgrid marker. Its position in the list IS its index/identity. */
@@ -208,7 +212,11 @@ export interface CueCapabilities {
hotcue_slots: number
slot_labels: 'number' | 'letter'
memory_cues: boolean
/** Per track; null = no limit. rekordbox stops at 10 without saying so. */
max_memory_cues: number | null
/** A memory cue's colours are its own palette, not `palette`. */
memory_color: 'none' | 'palette'
memory_palette: string[]
types: CueType[]
color: 'none' | 'free' | 'palette'
palette: string[]
@@ -1141,6 +1149,28 @@ export const api = {
'DELETE',
`/api/tracks/cue?track_id=${encodeURIComponent(trackId)}&slot=${slot}`,
),
/** A memory cue (a memory loop when `length` > 0). Refused past
* `capabilities.cues.max_memory_cues`. */
addMemoryCue: (trackId: string, start: number, type: CueType, length = 0) =>
send<TrackCues>('POST', '/api/tracks/memory-cue', { track_id: trackId, start, type, length }),
/** `cueId` is `CuePoint.id`; null / '' clears the name. */
renameMemoryCue: (trackId: string, cueId: string, name: string | null) =>
send<TrackCues>('PATCH', '/api/tracks/memory-cue', { track_id: trackId, cue_id: cueId, name }),
/** A point type from `capabilities.cues.types`; a memory loop is not retyped. */
setMemoryCueType: (trackId: string, cueId: string, type: CueType) =>
send<TrackCues>('PATCH', '/api/tracks/memory-cue/type', { track_id: trackId, cue_id: cueId, type }),
/** From `capabilities.cues.memory_palette`; null = uncoloured. */
setMemoryCueColor: (trackId: string, cueId: string, color: string | null) =>
send<TrackCues>('PATCH', '/api/tracks/memory-cue/color', {
track_id: trackId,
cue_id: cueId,
color,
}),
deleteMemoryCue: (trackId: string, cueId: string) =>
send<TrackCues>(
'DELETE',
`/api/tracks/memory-cue?track_id=${encodeURIComponent(trackId)}&cue_id=${encodeURIComponent(cueId)}`,
),
/** Retempo and/or move one marker. `index` is its position in grid_markers;
* a move is clamped between its neighbours rather than reordering them. */
setGridMarker: (trackId: string, index: number, patch: { bpm?: number; start?: number }) =>
+4 -42
View File
@@ -1,7 +1,8 @@
import { useRef, useState, type CSSProperties } from 'react'
import type { CSSProperties } from 'react'
import type { CuePoint } from '../api'
import { CUE_TYPE_LABELS, cueColor, cueIcon, withAlpha } from '../lib/cues'
import { Icon } from '../lib/icons'
import { RenameField } from './RenameField'
interface Props {
cues: CuePoint[]
@@ -155,7 +156,7 @@ export function HotcueBar({
* backlit controller pad reads. Selection brightens the tint and rings it in
* the colour itself, so it stays legible whichever colour the cue is.
*/
function padStyle(color: string, selected: boolean): CSSProperties {
export function padStyle(color: string, selected: boolean): CSSProperties {
return {
// The cue colour sits on a DARK GROUND (the last layer), not on bare glass:
// over a bright or warm ambient wash a thin tint alone came out the same hue
@@ -178,47 +179,8 @@ function padStyle(color: string, selected: boolean): CSSProperties {
/** A cue colour lifted toward white, for the pad's number: the raw colour is
* too dark to read as text on its own tint (blue especially). */
function lighten(hex: string, amount = 0.35): string {
export function lighten(hex: string, amount = 0.35): string {
const v = parseInt(hex.slice(1, 7), 16)
const mix = (c: number) => Math.round(c + (255 - c) * amount)
return `rgb(${mix(v >> 16)},${mix((v >> 8) & 255)},${mix(v & 255)})`
}
/** The pad's name, edited in place. Enter or clicking away commits; Esc cancels. */
function RenameField({
initial,
onCommit,
onCancel,
}: {
initial: string
onCommit: (name: string) => void
onCancel: () => void
}) {
const [val, setVal] = useState(initial)
// Enter commits and unmounts the field, which can fire a trailing blur.
const done = useRef(false)
const finish = (commit: boolean) => {
if (done.current) return
done.current = true
if (commit && val.trim() !== initial) onCommit(val.trim())
else onCancel()
}
return (
<input
autoFocus
value={val}
onChange={(e) => setVal(e.target.value)}
onFocus={(e) => e.currentTarget.select()}
onBlur={() => finish(true)}
// The pad is a button: keep its press/preview handlers out of the field.
onPointerDown={(e) => e.stopPropagation()}
onPointerUp={(e) => e.stopPropagation()}
onKeyDown={(e) => {
e.stopPropagation() // digits and Space must type, not trigger the deck
if (e.key === 'Enter') finish(true)
else if (e.key === 'Escape') finish(false)
}}
className="w-full min-w-0 rounded bg-well px-1 text-[11px] leading-4 text-text outline-none ring-1 ring-accent"
/>
)
}
+10 -17
View File
@@ -1,4 +1,5 @@
import { Icon } from '../lib/icons'
import { ModeSwitch } from './ModeSwitch'
/** One size, 1/32 → 32 beats, shared by beat loops AND beat jump: the number a
* DJ has in their head ("4 beats") should not differ between the two. */
@@ -90,25 +91,17 @@ export function LoopControls({
// A beat jump needs a grid; moving a manual loop does not.
const canMove = ready && (loopActive || hasGrid)
const tab = (m: LoopMode, text: string, title: string) => (
<button
onClick={() => onMode(m)}
title={title}
aria-pressed={mode === m}
className={`h-[17px] rounded-[7px] px-[7px] text-[9px] font-bold tracking-[0.08em] transition-colors ${
mode === m ? 'btn-primary' : 'text-faint hover:text-text'
}`}
>
{text}
</button>
)
return (
<div className="flex shrink-0 items-center gap-2">
<div role="group" aria-label="Loop mode" className="well flex h-10 flex-col justify-center gap-0.5 rounded-[10px] p-0.5">
{tab('beat', 'BEAT', 'Beat loops, sized in beats')}
{tab('manual', 'MAN', 'Manual loops: set IN and OUT')}
</div>
<ModeSwitch
label="Loop mode"
value={mode}
onChange={onMode}
options={[
{ value: 'beat', text: 'BEAT', title: 'Beat loops, sized in beats' },
{ value: 'manual', text: 'MAN', title: 'Manual loops: set IN and OUT' },
]}
/>
{mode === 'beat' ? (
<div role="group" aria-label="Loop size" className={`${CLUSTER} font-mono`}>
+132
View File
@@ -0,0 +1,132 @@
import type { CuePoint } from '../api'
import { cueColor, cueIcon } from '../lib/cues'
import { Icon } from '../lib/icons'
import { lighten, padStyle } from './HotcueBar'
import { RenameField } from './RenameField'
interface Props {
/** The track's cues; only the memory cues are shown, in time order. */
cues: CuePoint[]
/** The deck's CUE point, so the memory cue it sits on reads as selected. */
cuePoint: number
onCall: (cue: CuePoint) => void
/** Right-click: the deck opens its Rename / Colour / Delete menu. */
onMenu: (cue: CuePoint, x: number, y: number) => void
onAdd: () => void
/** Why + MEMORY cannot add one (read-only library, the platform's cap), or null. */
addRefusal: string | null
/** The memory cue whose name is being edited in place, if any. */
renamingId: string | null
onRenameCommit: (cue: CuePoint, name: string) => void
onRenameCancel: () => void
}
/** `m:ss.s` — a chip's label when the cue has no name. */
function shortTime(secs: number): string {
const m = Math.floor(secs / 60)
const s = secs - m * 60
return `${m}:${s.toFixed(1).padStart(4, '0')}`
}
/** `m:ss.mmm` — the full position, for the chip's tooltip. */
function fullTime(secs: number): string {
const m = Math.floor(secs / 60)
const s = secs - m * 60
return `${m}:${s.toFixed(3).padStart(6, '0')}`
}
const named = (cue: CuePoint) => !!cue.name && cue.name !== 'n.n.'
/**
* The memory-cue bank: what the hot cue pads become in Memory mode. Memory cues
* have no pads, so this is + Memory, then a strip of chips in TIME order,
* scrolling sideways when it outgrows the row.
*
* Clicking a chip CALLS the cue, CDJ-style: the deck jumps there and makes it
* the CUE point (a memory loop also engages) — unlike a hot cue pad, it is not
* a trigger to perform with. Right-click edits it, as on a pad.
*/
export function MemoryCueStrip({
cues,
cuePoint,
onCall,
onMenu,
onAdd,
addRefusal,
renamingId,
onRenameCommit,
onRenameCancel,
}: Props) {
const memory = cues.filter((c) => c.role === 'memory').sort((a, b) => a.start - b.start)
return (
// At least one chip always shows (~6rem): the row's breakpoints fold the
// tempo group before the strip gets that narrow.
<div className="flex min-w-[12rem] flex-1 items-center gap-1.5">
<button
type="button"
onClick={onAdd}
aria-disabled={addRefusal != null}
title={addRefusal ?? 'Store a memory cue at the playhead (a memory loop when a loop is on)'}
className={
'btn-glass flex h-11 shrink-0 items-center gap-1 rounded-xl px-2.5 text-[11px] font-semibold ' +
(addRefusal != null ? 'cursor-not-allowed opacity-45' : '')
}
>
<Icon name="plus" size={13} strokeWidth={2.2} />
Memory
</button>
<div
className="flex min-w-[5.5rem] flex-1 items-center gap-1.5 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
// A vertical wheel scrolls the strip sideways: a mouse has no other way.
onWheel={(e) => {
if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) e.currentTarget.scrollLeft += e.deltaY
}}
>
{memory.length === 0 && (
<span className="px-1 text-[11px] text-faint">
No memory cues — + Memory stores one at the playhead
</span>
)}
{memory.map((cue) => {
const color = cueColor(cue)
const selected = Math.abs(cue.start - cuePoint) < 0.0015
const locked = !cue.editable
const key = cue.id ?? `${cue.start}:${cue.type}`
return (
<button
key={key}
type="button"
onClick={() => onCall(cue)}
onContextMenu={(e) => {
e.preventDefault()
onMenu(cue, e.clientX, e.clientY)
}}
title={`${named(cue) ? `${cue.name} · ` : ''}${fullTime(cue.start)}${
cue.type === 'loop' ? ` · loop ${cue.length.toFixed(2)} s` : ''
}${locked ? ' · not editable here' : ''}`}
style={padStyle(color, selected)}
className="flex h-11 max-w-[9rem] shrink-0 items-center gap-1.5 rounded-xl px-2.5 text-left transition-[filter] hover:brightness-115"
>
<span className="flex shrink-0" style={{ color: lighten(color) }}>
<Icon name={locked ? 'lock' : cue.type === 'loop' ? 'loop' : cueIcon(cue)} size={13} strokeWidth={2.1} />
</span>
{renamingId != null && renamingId === cue.id ? (
<RenameField
initial={named(cue) ? cue.name! : ''}
onCommit={(name) => onRenameCommit(cue, name)}
onCancel={onRenameCancel}
/>
) : (
<span
className={`truncate text-[11px] leading-none ${named(cue) ? 'text-text' : 'font-mono text-text/80'}`}
>
{named(cue) ? cue.name : shortTime(cue.start)}
</span>
)}
</button>
)
})}
</div>
</div>
)
}
+38
View File
@@ -0,0 +1,38 @@
/**
* The deck's two-way mode switch: two small stacked tabs in a well, the chosen
* one lit. BEAT / MAN (loops) and HOT / MEM (the cue bank) are both this.
*/
export function ModeSwitch<T extends string>({
label,
value,
options,
onChange,
}: {
/** Names the group for assistive tech ("Loop mode", "Cue bank"). */
label: string
value: T
options: { value: T; text: string; title: string }[]
onChange: (value: T) => void
}) {
return (
<div
role="group"
aria-label={label}
className="well flex h-10 shrink-0 flex-col justify-center gap-0.5 rounded-[10px] p-0.5"
>
{options.map((o) => (
<button
key={o.value}
onClick={() => onChange(o.value)}
title={o.title}
aria-pressed={value === o.value}
className={`h-[17px] rounded-[7px] px-[7px] text-[9px] font-bold tracking-[0.08em] transition-colors ${
value === o.value ? 'btn-primary' : 'text-faint hover:text-text'
}`}
>
{o.text}
</button>
))}
</div>
)
}
+199 -15
View File
@@ -32,6 +32,8 @@ import { TrackInfoDialog } from './TrackInfoDialog'
import { ContextMenu, type MenuItem } from './ContextMenu'
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
import { HotcueBar } from './HotcueBar'
import { MemoryCueStrip } from './MemoryCueStrip'
import { ModeSwitch } from './ModeSwitch'
import { LoopControls, LOOP_SIZES, type LoopMode } from './LoopControls'
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC, type StemLane } from './MainWaveform'
import { OverviewWaveform } from './OverviewWaveform'
@@ -156,6 +158,10 @@ export function PrepStrip({
const [gridMode, setGridMode] = useState(false)
const [padMenu, setPadMenu] = useState<{ slot: number; x: number; y: number } | null>(null)
const [renamingSlot, setRenamingSlot] = useState<number | null>(null)
// Hot / Memory: which bank the pads' place in the row shows (persisted).
const [bankMode, setBankMode] = useState<'hot' | 'memory'>('hot')
const [memoryMenu, setMemoryMenu] = useState<{ cue: CuePoint; x: number; y: number } | null>(null)
const [renamingMemory, setRenamingMemory] = useState<string | null>(null)
// Loop state (transient — persisted only when saved as a hotcue later).
const [loopRegion, setLoopRegion] = useState<{ start: number; end: number } | null>(null)
@@ -220,6 +226,18 @@ export function PrepStrip({
writePrefs({ beatSize })
}, [beatSize, writePrefs])
// Hot / Memory bank, remembered the same way (decided 2026-10-16).
const bankHydratedRef = useRef(false)
useEffect(() => {
if (bankHydratedRef.current || !prefsQuery.data) return
bankHydratedRef.current = true
if ((prefsQuery.data as { cueBankMode?: unknown }).cueBankMode === 'memory') setBankMode('memory')
}, [prefsQuery.data])
useEffect(() => {
if (!bankHydratedRef.current) return // don't clobber saved prefs pre-hydration
writePrefs({ cueBankMode: bankMode })
}, [bankMode, writePrefs])
const getCtx = (): AudioContext => {
if (!audioCtxRef.current) {
audioCtxRef.current = new (window.AudioContext ??
@@ -267,6 +285,8 @@ export function PrepStrip({
setSelectedSlot(null)
setPadMenu(null)
setRenamingSlot(null)
setMemoryMenu(null)
setRenamingMemory(null)
setLoopRegion(null)
setLoopActive(false)
setActiveBeats(null)
@@ -830,11 +850,18 @@ export function PrepStrip({
const eng = playbackRef.current
if (!eng || !eng.ready) return
getCtx()
// A loop hotcue jumps to its start AND engages a loop of its length — the
// new loop FIRST, so the seek is not wrapped back into the old one. The loop
// controls follow it: a beat-sized loop takes over the shared size (so −/+
// resize THIS loop), and one of no preset size shows in MAN, where its
// toggle is.
enterCue(cue)
seek(cue.start)
// Paused at press → momentary preview: play while held.
if (!eng.playing) beginPreview(`hc:${slot}`, cue.start)
}
// Before jumping to a cue: a loop cue engages a loop of its length — the new
// loop FIRST, so the seek is not wrapped back into the old one. The loop
// controls follow it: a beat-sized loop takes over the shared size (so −/+
// resize THIS loop), and one of no preset size shows in MAN, where its toggle
// is. A point cue outside an engaged loop leaves it.
const enterCue = (cue: CuePoint) => {
if (cue.type === 'loop' && cue.length > 0) {
const beats = beatsForLoop(cue.start, cue.length)
engagLoop(cue.start, cue.start + cue.length, beats)
@@ -847,9 +874,6 @@ export function PrepStrip({
} else {
leaveLoopFor(cue.start)
}
seek(cue.start)
// Paused at press → momentary preview: play while held.
if (!eng.playing) beginPreview(`hc:${slot}`, cue.start)
}
// Hotcue slot released (mouse/touch up, or key up). Ends its momentary preview.
@@ -937,6 +961,125 @@ export function PrepStrip({
}
}
// ---- memory cues --------------------------------------------------------
// Cues on no pad, listed in time order (MemoryCueStrip). Calling one is
// CDJ-style: jump there and make it the CUE point — paused stays paused,
// playing keeps playing; a memory loop also engages (decided 2026-10-16).
const showMemory = caps.cues.memory_cues && bankMode === 'memory'
const memoryPalette = caps.cues.memory_color === 'palette' ? caps.cues.memory_palette : []
const memoryCount = cueData?.cues.filter((c) => c.role === 'memory' && c.editable).length ?? 0
const memoryCap = caps.cues.max_memory_cues
const memoryAddRefusal = !canEditCues
? (readOnlyNotice(caps) ?? `Cues cannot be edited on ${caps.save.app_name} libraries yet.`)
: memoryCap != null && memoryCount >= memoryCap
? `${caps.save.app_name} keeps at most ${memoryCap} memory cues per track`
: null
const callMemoryCue = (cue: CuePoint) => {
const eng = playbackRef.current
if (!eng || !eng.ready) return
getCtx()
enterCue(cue)
seek(cue.start)
setCuePoint(cue.start)
}
// + Memory: at the (snapped) playhead, or the engaged loop as a memory loop.
const addMemoryCue = async () => {
if (!track) return
if (memoryAddRefusal) {
onError?.(memoryAddRefusal)
return
}
try {
if (loopActive && loopRegion) {
const len = loopRegion.end - loopRegion.start
applyCueEdit(await api.addMemoryCue(track.id, loopRegion.start, 'loop', len))
} else {
const t = snapTime(playbackRef.current?.getPosition() ?? current)
applyCueEdit(await api.addMemoryCue(track.id, t, 'cue'))
}
} catch (e) {
onError?.((e as Error).message)
}
}
const editMemoryCue = async (edit: () => Promise<TrackCues>) => {
if (!track || refuseCueEdit()) return
try {
applyCueEdit(await edit())
} catch (e) {
onError?.((e as Error).message)
}
}
const memoryMenuItems = (cue: CuePoint): MenuItem[] => {
const id = cue.id
const locked = !cue.editable || id == null
const items: MenuItem[] = []
// Its type as one-click choices, as on a pad — where the platform has more
// than one point type (Traktor); a loop stays a loop.
if (cue.type === 'loop') {
items.push({ heading: 'Memory loop' })
} else if (pointCueTypes.length > 1) {
items.push({ heading: 'Memory cue · Type' })
for (const t of pointCueTypes) {
const color = cueTypeColor(t)
items.push({
label: CUE_TYPE_LABELS[t],
icon: (
<span
className="block h-2 w-2 rounded-full"
style={{ background: color, boxShadow: `0 0 6px ${color}` }}
/>
),
hint: t === cue.type ? '✓' : undefined,
disabled: locked,
onClick: () =>
t !== cue.type &&
id != null &&
void editMemoryCue(() => api.setMemoryCueType(track!.id, id, t)),
})
}
} else {
items.push({ heading: 'Memory cue' })
}
if (memoryPalette.length > 0) {
items.push({ separator: true })
items.push({ heading: 'Colour' })
items.push({
swatches: memoryPalette,
selected: cue.color,
disabled: locked,
onPick: (color) =>
color !== cue.color &&
id != null &&
void editMemoryCue(() => api.setMemoryCueColor(track!.id, id, color)),
})
}
if (locked) items.push({ heading: 'Managed by the DJ app — not editable here' })
items.push({ separator: true })
items.push({
label: 'Rename…',
disabled: locked,
onClick: () => !refuseCueEdit() && setRenamingMemory(id),
})
items.push({
label: 'Delete',
danger: true,
disabled: locked,
onClick: () => id != null && void editMemoryCue(() => api.deleteMemoryCue(track!.id, id)),
})
return items
}
const renameMemoryCue = (cue: CuePoint, name: string) => {
setRenamingMemory(null)
if (cue.id == null) return
const id = cue.id
void editMemoryCue(() => api.renameMemoryCue(track!.id, id, name || null))
}
// ---- beatgrid ---------------------------------------------------------
// Which marker the grid controls act on is derived from the playhead — there
// is no separate selection state to keep in sync.
@@ -1471,10 +1614,11 @@ export function PrepStrip({
A container, so the row gives way in stages as the window narrows
instead of the pads sliding under the tempo group: the pads drop
their names first (each pad queries its own width, see HotcueBar),
then below 74rem the tempo group folds into one BPM button, and below
60rem the Grid toggle keeps only its icon. Those are the row's
then below 77rem the tempo group folds into one BPM button, and below
63rem the Grid toggle keeps only its icon. Those are the row's
measured widths just before the pad bank would hit its minimum (with
a lockable grid's extra Lock button), so move them with the controls. */}
a lockable grid's extra Lock button, and the Hot / Mem toggle's
~3rem with its gap), so move them with the controls. */}
<div className="@container flex h-11 shrink-0 items-center gap-3">
<button
onClick={toggle}
@@ -1533,6 +1677,23 @@ export function PrepStrip({
onMove={moveOrJump}
/>
{DIVIDER}
{caps.cues.memory_cues && !gridMode && (
<ModeSwitch
label="Cue bank"
value={bankMode}
options={[
{ value: 'hot', text: 'HOT', title: 'Hot cues: the pads' },
{ value: 'memory', text: 'MEM', title: 'Memory cues: call one to make it the CUE point' },
]}
onChange={(m) => {
setBankMode(m)
setPadMenu(null)
setMemoryMenu(null)
setRenamingSlot(null)
setRenamingMemory(null)
}}
/>
)}
{gridMode ? (
<GridEditStrip
markerIndex={activeMarkerIndex}
@@ -1550,6 +1711,18 @@ export function PrepStrip({
onDeleteGrid={deleteGrid}
onReset={resetGrid}
/>
) : showMemory ? (
<MemoryCueStrip
cues={cueData?.cues ?? []}
cuePoint={cuePoint}
onCall={callMemoryCue}
onMenu={(cue, x, y) => setMemoryMenu({ cue, x, y })}
onAdd={() => void addMemoryCue()}
addRefusal={memoryAddRefusal}
renamingId={renamingMemory}
onRenameCommit={renameMemoryCue}
onRenameCancel={() => setRenamingMemory(null)}
/>
) : (
<HotcueBar
cues={cueData?.cues ?? []}
@@ -1568,8 +1741,8 @@ export function PrepStrip({
/>
)}
{DIVIDER}
<TempoControls {...tempoProps} className="@max-[74rem]:hidden" />
<TempoFold locked={tempoProps.locked} className="hidden @max-[74rem]:flex">
<TempoControls {...tempoProps} className="@max-[77rem]:hidden" />
<TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex">
<TempoControls {...tempoProps} />
</TempoFold>
<button
@@ -1577,22 +1750,33 @@ export function PrepStrip({
setGridMode((g) => !g)
setPadMenu(null)
setRenamingSlot(null)
setMemoryMenu(null)
setRenamingMemory(null)
}}
aria-pressed={gridMode}
disabled={!track}
title={gridMode ? 'Back to the hotcue pads' : 'Edit the beatgrid: markers, phase, reset'}
aria-label="Grid"
className={`flex h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-semibold transition-colors disabled:opacity-40 @max-[60rem]:w-10 @max-[60rem]:justify-center @max-[60rem]:px-0 ${
className={`flex h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-semibold transition-colors disabled:opacity-40 @max-[63rem]:w-10 @max-[63rem]:justify-center @max-[63rem]:px-0 ${
gridMode
? 'bg-gold/15 text-gold shadow-[inset_0_0_0_1px_rgb(255_200_97/0.5),0_0_16px_-4px_rgb(255_200_97/0.6)]'
: 'btn-glass text-text'
}`}
>
<Icon name="grid" size={14} />
<span className="@max-[60rem]:hidden">Grid</span>
<span className="@max-[63rem]:hidden">Grid</span>
</button>
</div>
{memoryMenu && (
<ContextMenu
key={`m:${memoryMenu.cue.id}:${memoryMenu.x}:${memoryMenu.y}`}
x={memoryMenu.x}
y={memoryMenu.y}
items={memoryMenuItems(memoryMenu.cue)}
onClose={() => setMemoryMenu(null)}
/>
)}
{padMenu && (
<ContextMenu
key={`${padMenu.slot}:${padMenu.x}:${padMenu.y}`}
+42
View File
@@ -0,0 +1,42 @@
import { useRef, useState } from 'react'
/** A pad's or memory cue's name, edited in place. Enter or clicking away
* commits; Esc cancels. Keys stay in the field, so digits and Space type
* rather than trigger the deck. */
export function RenameField({
initial,
onCommit,
onCancel,
}: {
initial: string
onCommit: (name: string) => void
onCancel: () => void
}) {
const [val, setVal] = useState(initial)
// Enter commits and unmounts the field, which can fire a trailing blur.
const done = useRef(false)
const finish = (commit: boolean) => {
if (done.current) return
done.current = true
if (commit && val.trim() !== initial) onCommit(val.trim())
else onCancel()
}
return (
<input
autoFocus
value={val}
onChange={(e) => setVal(e.target.value)}
onFocus={(e) => e.currentTarget.select()}
onBlur={() => finish(true)}
// The pad is a button: keep its press/preview handlers out of the field.
onPointerDown={(e) => e.stopPropagation()}
onPointerUp={(e) => e.stopPropagation()}
onKeyDown={(e) => {
e.stopPropagation() // digits and Space must type, not trigger the deck
if (e.key === 'Enter') finish(true)
else if (e.key === 'Escape') finish(false)
}}
className="w-full min-w-0 rounded bg-well px-1 text-[11px] leading-4 text-text outline-none ring-1 ring-accent"
/>
)
}
+3 -2
View File
@@ -11,7 +11,7 @@ const TYPE_COLORS: Record<CueType, string> = {
load: '#ffd23d', // yellow
loop: '#3ddc84', // green
}
const MEMORY_COLOR = '#9aa1b2' // gray
const MEMORY_COLOR = '#9aa1b2' // gray: an unknown type
export const CUE_TYPE_LABELS: Record<CueType, string> = {
cue: 'Cue',
@@ -43,7 +43,8 @@ const TYPE_ICONS: Record<CueType, IconName> = {
*/
export function cueColor(cue: CuePoint): string {
if (cue.color) return cue.color
if (cue.role === 'memory') return MEMORY_COLOR
// A memory cue's type colours it just as a hot cue's does (decided
// 2026-10-16) — Traktor draws both by type. Mirrors `core/cue_colors.py`.
return TYPE_COLORS[cue.type] ?? MEMORY_COLOR
}
+2
View File
@@ -143,6 +143,8 @@ export const MOUSE: { title: string; rows: MouseGesture[] }[] = [
{ gesture: 'Click', on: 'stem button', text: 'Mute or unmute that stem' },
{ mod: 'mod', gesture: 'Click', on: 'stem button', text: 'Solo that stem' },
{ gesture: 'Right-click', on: 'pad', text: 'Hotcue type, colour, rename, delete' },
{ gesture: 'Click', on: 'memory cue', text: 'Jump there and make it the CUE point (a memory loop engages)' },
{ gesture: 'Right-click', on: 'memory cue', text: 'Memory cue type, colour, rename, delete' },
],
},
{