mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Added support for flexible beatgrids
This commit is contained in:
1 parent
3f51444e2a
commit
dd97f27ac7
20 files changed
+2176
-346
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { CuePoint } from '../api'
|
||||
import { contrastText, cueColor } from '../lib/cues'
|
||||
import { contrastText, cueColor, GRID_MARKER_COLOR } from '../lib/cues'
|
||||
|
||||
interface Props {
|
||||
cues: CuePoint[]
|
||||
@@ -17,14 +17,21 @@ const SLOTS = [0, 1, 2, 3, 4, 5, 6, 7] // Traktor hotcue slots → labelled 1–
|
||||
* (pointer capture, so a release outside the button still fires) so the parent
|
||||
* can implement momentary "cue preview" (play while held). Press creates when
|
||||
* empty and jumps/triggers when assigned; release ends any preview.
|
||||
*
|
||||
* A slot may be held by a grid marker's companion cue (Traktor writes one beside
|
||||
* most of its own markers). Those belong to the beatgrid, so they are shown with
|
||||
* the marker colour and a ⊞ instead of a number, and pressing one only seeks —
|
||||
* the backend refuses hotcue edits on them, and showing that up front is better
|
||||
* than surfacing the refusal as an error.
|
||||
*/
|
||||
export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Props) {
|
||||
return (
|
||||
<div className="flex flex-1 items-stretch gap-px">
|
||||
{SLOTS.map((slot) => {
|
||||
const cue = cues.find((c) => c.hotcue === slot) ?? null
|
||||
const selected = selectedSlot === slot
|
||||
const color = cue ? cueColor(cue) : null
|
||||
const isMarker = cue?.grid_marker != null
|
||||
const selected = selectedSlot === slot && !isMarker
|
||||
const color = cue ? (isMarker ? GRID_MARKER_COLOR : cueColor(cue)) : null
|
||||
return (
|
||||
<button
|
||||
key={slot}
|
||||
@@ -38,11 +45,13 @@ export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Pr
|
||||
onPointerUp={() => onSlotRelease(slot)}
|
||||
onPointerCancel={() => onSlotRelease(slot)}
|
||||
title={
|
||||
cue
|
||||
? cue.name && cue.name !== 'n.n.'
|
||||
? `${slot + 1}: ${cue.name}`
|
||||
: `Hotcue ${slot + 1}`
|
||||
: `Hotcue ${slot + 1} — click to set at playhead`
|
||||
isMarker
|
||||
? `Beatgrid marker ${(cue!.grid_marker ?? 0) + 1} — managed by the grid controls`
|
||||
: cue
|
||||
? cue.name && cue.name !== 'n.n.'
|
||||
? `${slot + 1}: ${cue.name}`
|
||||
: `Hotcue ${slot + 1}`
|
||||
: `Hotcue ${slot + 1} — click to set at playhead`
|
||||
}
|
||||
style={color ? { backgroundColor: color, color: contrastText(color) } : undefined}
|
||||
className={
|
||||
@@ -51,7 +60,7 @@ export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Pr
|
||||
(selected ? ' ring-2 ring-inset ring-white/80' : '')
|
||||
}
|
||||
>
|
||||
{slot + 1}
|
||||
{isMarker ? '⊞' : slot + 1}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user