Added support for coloring Rekordbox hotcues

This commit is contained in:
patben8 committed 2026-10-01 10:54:14 +02:00
1 parent 9be2c029b2
commit 08c53e1150
19 files changed
+337 -45

No files matched your search

+3
View File
@@ -819,6 +819,9 @@ export const api = {
}),
setCueType: (trackId: string, slot: number, type: CueType) =>
send<TrackCues>('PATCH', '/api/tracks/cue', { track_id: trackId, slot, type }),
/** Recolour a cue from `capabilities.cues.palette`; null = uncoloured. */
setCueColor: (trackId: string, slot: number, color: string | null) =>
send<TrackCues>('PATCH', '/api/tracks/cue/color', { track_id: trackId, slot, color }),
deleteCue: (trackId: string, slot: number) =>
send<TrackCues>(
'DELETE',
+74
View File
@@ -10,6 +10,14 @@ export type MenuItem =
// Toggles in place and leaves the menu open, so several can be flipped in one go.
| { label: string; checked: boolean; onToggle: () => void }
| { heading: string; empty?: string }
// A grid of colour swatches plus an uncoloured choice (`selected` null).
// Picking one closes the menu, like a plain item.
| {
swatches: string[]
selected: string | null
onPick: (color: string | null) => void
disabled?: boolean
}
| { separator: true }
interface Props {
@@ -143,6 +151,16 @@ function MenuPanel({
</button>
)
}
if ('swatches' in item) {
return (
<SwatchGrid
key={i}
item={item}
onEnter={() => setOpen(null)}
onPicked={onClose}
/>
)
}
if ('heading' in item) {
return (
<div key={i}>
@@ -201,3 +219,59 @@ function MenuPanel({
</>
)
}
function SwatchGrid({
item,
onEnter,
onPicked,
}: {
item: Extract<MenuItem, { swatches: string[] }>
onEnter: () => void
onPicked: () => void
}) {
const selected = item.selected?.toUpperCase() ?? null
const pick = (color: string | null) => {
item.onPick(color)
onPicked()
}
// An outline, not a ring: a ring is a box-shadow, which the swatch's glow overrides.
const ring = (on: boolean) =>
on ? 'outline outline-2 outline-offset-2 outline-white' : 'enabled:hover:scale-110'
return (
<div className="px-3 pb-2 pt-1" onMouseEnter={onEnter}>
<div className="grid w-max grid-cols-8 gap-1.5">
{item.swatches.map((color) => (
<button
key={color}
role="menuitemradio"
aria-checked={selected === color.toUpperCase()}
aria-label={color}
title={color}
disabled={item.disabled}
onClick={() => pick(color)}
className={`h-4 w-4 rounded-full transition-transform disabled:cursor-default disabled:opacity-40 ${ring(
selected === color.toUpperCase(),
)}`}
style={{ background: color, boxShadow: `0 0 6px ${color}` }}
/>
))}
</div>
<button
role="menuitemradio"
aria-checked={selected === null}
disabled={item.disabled}
onClick={() => pick(null)}
className={`mt-2 flex items-center gap-2 rounded-[8px] text-xs disabled:cursor-default disabled:text-faint ${
selected === null ? 'text-text' : 'text-muted hover:text-text'
}`}
>
<span
className={`block h-3 w-3 rounded-full border border-ink-600 ${
selected === null ? 'outline outline-2 outline-offset-1 outline-white' : ''
}`}
/>
Default
</button>
</div>
)
}
+1 -1
View File
@@ -12,7 +12,7 @@ interface Props {
selectedSlot: number | null
onSlotPress: (slot: number) => void
onSlotRelease: (slot: number) => void
/** Right-click on a pad: the deck opens its Type / Rename / Delete menu. */
/** Right-click on a pad: the deck opens its Type / Colour / Rename / Delete menu. */
onSlotMenu: (slot: number, x: number, y: number) => void
/** The pad whose name is being edited in place, if any. */
renamingSlot: number | null
+24 -1
View File
@@ -866,6 +866,19 @@ export function PrepStrip({
}
}
// Only a fixed palette is offered: a platform with free RGB would need a
// picker of its own, and none that stores free RGB is writable yet.
const cuePalette = caps.cues.color === 'palette' ? caps.cues.palette : []
const setSlotColor = async (slot: number, color: string | null) => {
if (!track) return
if (refuseCueEdit()) return
try {
applyCueEdit(await api.setCueColor(track.id, slot, color))
} catch (e) {
onError?.((e as Error).message)
}
}
const deleteHotcueSlot = async (slot: number) => {
const existing = hotcueAt(slot)
if (!track || !existing) return // nothing to remove in an empty slot
@@ -1125,7 +1138,7 @@ export function PrepStrip({
: ''
// The pad's right-click menu: its type (as one-click choices, the current one
// ticked), Rename, Delete. A cue the adapter will not edit gets the same menu
// ticked), its colour where the platform has a palette, Rename, Delete. A cue the adapter will not edit gets the same menu
// disabled, so the reason is visible instead of the menu silently not opening.
const padMenuItems = (slot: number): MenuItem[] => {
const cue = hotcueAt(slot)
@@ -1154,6 +1167,16 @@ export function PrepStrip({
} else {
items.push({ heading: `Hotcue ${slotLabel(slot)}` })
}
if (cuePalette.length > 0) {
items.push({ separator: true })
items.push({ heading: 'Colour' })
items.push({
swatches: cuePalette,
selected: cue.color,
disabled: locked,
onPick: (color) => color !== cue.color && void setSlotColor(slot, color),
})
}
if (locked) items.push({ heading: 'Managed by the DJ app — not editable here' })
items.push({ separator: true })
items.push({