mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Fixed hot cue scaling
This commit is contained in:
1 parent
84947bb0bb
commit
90beeef226
4 files changed
+138
-28
No files matched your search
@@ -438,7 +438,12 @@ Two independent apps that talk over HTTP:
|
|||||||
`OverviewWaveform`, which frames the main view's visible range around the
|
`OverviewWaveform`, which frames the main view's visible range around the
|
||||||
playhead (it takes `secPerView` for exactly that). **Controls**: play, CUE, `LoopControls`, then EITHER
|
playhead (it takes `secPerView` for exactly that). **Controls**: play, CUE, `LoopControls`, then EITHER
|
||||||
`HotcueBar` OR — in **Grid mode** — `GridEditStrip`, then `TempoControls`
|
`HotcueBar` OR — in **Grid mode** — `GridEditStrip`, then `TempoControls`
|
||||||
(±0.01 / ±0.25, ÷2 ×2, tap, lock) and the Grid toggle. Every grid control acts
|
(±0.01 / ±0.25, ÷2 ×2, tap, lock) and the Grid toggle. The row is a
|
||||||
|
**container** and gives way in stages instead of overlapping: each pad
|
||||||
|
queries its own width and drops its name below 4rem (the bank never goes
|
||||||
|
below `PAD_MIN` per pad), then the tempo group folds into `TempoFold`'s
|
||||||
|
portalled popover, then Grid keeps only its icon. The two row breakpoints
|
||||||
|
are measured widths — move them if controls are added to the row. Every grid control acts
|
||||||
on the marker **governing the playhead**, since a beatgrid is a marker list
|
on the marker **governing the playhead**, since a beatgrid is a marker list
|
||||||
and there is no separate marker selection; see "Beatgrid" below.
|
and there is no separate marker selection; see "Beatgrid" below.
|
||||||
- **One size for loops AND beat jump** (`beatSize`, 1/32–32, persisted as
|
- **One size for loops AND beat jump** (`beatSize`, 1/32–32, persisted as
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||||
|
import { createPortal } from 'react-dom'
|
||||||
import { askConfirm } from '../lib/confirm'
|
import { askConfirm } from '../lib/confirm'
|
||||||
import { Icon } from '../lib/icons'
|
import { Icon } from '../lib/icons'
|
||||||
import { MIN_TAPS, RESET_MS, TapTempo } from '../lib/tapTempo'
|
import { MIN_TAPS, RESET_MS, TapTempo } from '../lib/tapTempo'
|
||||||
@@ -8,7 +9,8 @@ import { MIN_TAPS, RESET_MS, TapTempo } from '../lib/tapTempo'
|
|||||||
// BpmReadout — the header's BPM: shows the governing marker's tempo, and
|
// BpmReadout — the header's BPM: shows the governing marker's tempo, and
|
||||||
// is where an exact BPM is typed (click it).
|
// is where an exact BPM is typed (click it).
|
||||||
// TempoControls — the everyday tempo tools, always on the control row:
|
// TempoControls — the everyday tempo tools, always on the control row:
|
||||||
// nudge ±0.01 / ±0.25, ÷2 ×2, tap tempo, lock.
|
// nudge ±0.01 / ±0.25, ÷2 ×2, tap tempo, lock. On a
|
||||||
|
// narrow window they fold into TempoFold's popover.
|
||||||
// GridEditStrip — only in Grid mode, in place of the hotcue pads: step
|
// GridEditStrip — only in Grid mode, in place of the hotcue pads: step
|
||||||
// between markers, nudge the marker ±1 / ±10 ms, add or
|
// between markers, nudge the marker ±1 / ±10 ms, add or
|
||||||
// delete a marker, delete the grid, reset it.
|
// delete a marker, delete the grid, reset it.
|
||||||
@@ -129,6 +131,7 @@ export function TempoControls({
|
|||||||
onHalve,
|
onHalve,
|
||||||
onDouble,
|
onDouble,
|
||||||
onToggleLock,
|
onToggleLock,
|
||||||
|
className = '',
|
||||||
}: {
|
}: {
|
||||||
bpm: number | null
|
bpm: number | null
|
||||||
locked: boolean
|
locked: boolean
|
||||||
@@ -143,6 +146,7 @@ export function TempoControls({
|
|||||||
onHalve: () => void
|
onHalve: () => void
|
||||||
onDouble: () => void
|
onDouble: () => void
|
||||||
onToggleLock: () => void
|
onToggleLock: () => void
|
||||||
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
// One run of taps; its reading is shown on the button, so a press that is
|
// One run of taps; its reading is shown on the button, so a press that is
|
||||||
// not yet enough to commit still visibly counts.
|
// not yet enough to commit still visibly counts.
|
||||||
@@ -169,7 +173,7 @@ export function TempoControls({
|
|||||||
const off = bpm == null
|
const off = bpm == null
|
||||||
const of = flexible ? ` of marker ${markerIndex + 1}` : ''
|
const of = flexible ? ` of marker ${markerIndex + 1}` : ''
|
||||||
return (
|
return (
|
||||||
<div role="group" aria-label="Tempo" className="glass-group flex h-10 shrink-0 items-center gap-0.5 rounded-xl px-1">
|
<div role="group" aria-label="Tempo" className={`glass-group flex h-10 shrink-0 items-center gap-0.5 rounded-xl px-1 ${className}`}>
|
||||||
<button className={`${T_BTN} w-7`} onClick={() => onNudgeBpm(-0.25)} disabled={off} title={`BPM −0.25${of}`}>−−</button>
|
<button className={`${T_BTN} w-7`} onClick={() => onNudgeBpm(-0.25)} disabled={off} title={`BPM −0.25${of}`}>−−</button>
|
||||||
<button className={`${T_BTN} w-[22px]`} onClick={() => onNudgeBpm(-0.01)} disabled={off} title={`BPM −0.01${of}`}>−</button>
|
<button className={`${T_BTN} w-[22px]`} onClick={() => onNudgeBpm(-0.01)} disabled={off} title={`BPM −0.01${of}`}>−</button>
|
||||||
<button className={`${T_BTN} w-[22px]`} onClick={() => onNudgeBpm(0.01)} disabled={off} title={`BPM +0.01${of}`}>+</button>
|
<button className={`${T_BTN} w-[22px]`} onClick={() => onNudgeBpm(0.01)} disabled={off} title={`BPM +0.01${of}`}>+</button>
|
||||||
@@ -200,6 +204,81 @@ export function TempoControls({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TempoControls folded into one button, for a control row too narrow to hold
|
||||||
|
* them beside the pads. The popover holds the same controls rather than a
|
||||||
|
* reduced set, and stays open while you tap — only a click elsewhere, Esc, or
|
||||||
|
* a window resize (which can unfold the row under it) closes it. Portalled,
|
||||||
|
* like every overlay: the deck's panel is a stacking context.
|
||||||
|
*/
|
||||||
|
export function TempoFold({
|
||||||
|
locked,
|
||||||
|
className = '',
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
locked: boolean
|
||||||
|
className?: string
|
||||||
|
children: ReactNode
|
||||||
|
}) {
|
||||||
|
const [pos, setPos] = useState<{ x: number; y: number } | null>(null)
|
||||||
|
const buttonRef = useRef<HTMLButtonElement>(null)
|
||||||
|
const popRef = useRef<HTMLDivElement>(null)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!pos) return
|
||||||
|
const close = () => setPos(null)
|
||||||
|
const onDown = (e: MouseEvent) => {
|
||||||
|
const t = e.target as Node
|
||||||
|
if (!popRef.current?.contains(t) && !buttonRef.current?.contains(t)) close()
|
||||||
|
}
|
||||||
|
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close()
|
||||||
|
document.addEventListener('mousedown', onDown)
|
||||||
|
window.addEventListener('keydown', onKey)
|
||||||
|
window.addEventListener('resize', close)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousedown', onDown)
|
||||||
|
window.removeEventListener('keydown', onKey)
|
||||||
|
window.removeEventListener('resize', close)
|
||||||
|
}
|
||||||
|
}, [pos])
|
||||||
|
const toggle = () => {
|
||||||
|
if (pos) return setPos(null)
|
||||||
|
const r = buttonRef.current!.getBoundingClientRect()
|
||||||
|
// Right-aligned under the button: it sits near the row's right end, so
|
||||||
|
// hanging left keeps the popover on screen.
|
||||||
|
setPos({ x: window.innerWidth - r.right, y: r.bottom + 6 })
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
ref={buttonRef}
|
||||||
|
onClick={toggle}
|
||||||
|
aria-expanded={pos != null}
|
||||||
|
title="Tempo — nudge, halve/double, tap, lock"
|
||||||
|
className={`h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 font-mono text-xs font-semibold ${
|
||||||
|
pos ? 'is-selected text-text' : 'btn-glass text-text'
|
||||||
|
} ${className}`}
|
||||||
|
>
|
||||||
|
{locked && <Icon name="lock" size={12} strokeWidth={2.2} />}
|
||||||
|
BPM
|
||||||
|
<Icon name="chevronDown" size={12} strokeWidth={2.4} />
|
||||||
|
</button>
|
||||||
|
{pos &&
|
||||||
|
createPortal(
|
||||||
|
<div
|
||||||
|
ref={popRef}
|
||||||
|
role="dialog"
|
||||||
|
aria-label="Tempo"
|
||||||
|
className="glass-overlay fixed z-[70] !rounded-2xl p-1.5"
|
||||||
|
style={{ right: pos.x, top: pos.y }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** Grid mode: everything that fixes a grid, in place of the pads. */
|
/** Grid mode: everything that fixes a grid, in place of the pads. */
|
||||||
export function GridEditStrip({
|
export function GridEditStrip({
|
||||||
markerIndex,
|
markerIndex,
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ interface Props {
|
|||||||
onRenameCancel: () => void
|
onRenameCancel: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The narrowest a pad gets (a letter-only square) and the gap between pads.
|
||||||
|
const PAD_MIN = 40
|
||||||
|
const PAD_GAP = 6
|
||||||
|
|
||||||
const READONLY_LABELS: Record<string, string> = {
|
const READONLY_LABELS: Record<string, string> = {
|
||||||
platform_managed: 'Managed by the DJ app — not editable here',
|
platform_managed: 'Managed by the DJ app — not editable here',
|
||||||
}
|
}
|
||||||
@@ -51,8 +55,13 @@ export function HotcueBar({
|
|||||||
return (
|
return (
|
||||||
// The group takes the row's spare width; each pad is capped, so on a wide
|
// The group takes the row's spare width; each pad is capped, so on a wide
|
||||||
// window the pads keep a pad's proportions and the space is left empty
|
// window the pads keep a pad's proportions and the space is left empty
|
||||||
// rather than stretching them into bars.
|
// rather than stretching them into bars. It never goes below a bank of
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-1.5">
|
// PAD_MIN pads: squeezed further, the pads' padding spilled them out of
|
||||||
|
// the group and over the tempo controls.
|
||||||
|
<div
|
||||||
|
className="flex flex-1 items-center gap-1.5"
|
||||||
|
style={{ minWidth: slotCount * PAD_MIN + (slotCount - 1) * PAD_GAP }}
|
||||||
|
>
|
||||||
{Array.from({ length: slotCount }, (_, i) => i).map((slot) => {
|
{Array.from({ length: slotCount }, (_, i) => i).map((slot) => {
|
||||||
const cue = cues.find((c) => c.role === 'hotcue' && c.slot === slot) ?? null
|
const cue = cues.find((c) => c.role === 'hotcue' && c.slot === slot) ?? null
|
||||||
// Gate on `editable`, never on why: a platform-owned cue is a read-only
|
// Gate on `editable`, never on why: a platform-owned cue is a read-only
|
||||||
@@ -91,7 +100,11 @@ export function HotcueBar({
|
|||||||
}
|
}
|
||||||
style={color ? padStyle(color, selected) : undefined}
|
style={color ? padStyle(color, selected) : undefined}
|
||||||
className={
|
className={
|
||||||
'relative flex h-11 min-w-0 max-w-[7.5rem] flex-1 flex-col items-start justify-center gap-1 rounded-xl px-2.5 text-left transition-[filter,background-color] ' +
|
// Each pad is a container, so it decides for itself when it is
|
||||||
|
// too narrow for a name — under 4rem wide (2.75rem inside its
|
||||||
|
// padding, which is what a container query measures) it is a
|
||||||
|
// letter-only square, whatever the bank size or the rest of the row.
|
||||||
|
'@container relative flex h-11 min-w-0 max-w-[7.5rem] flex-1 flex-col items-start justify-center gap-1 rounded-xl px-2.5 text-left transition-[filter,background-color] ' +
|
||||||
(color
|
(color
|
||||||
? 'hover:brightness-115'
|
? 'hover:brightness-115'
|
||||||
: // An empty pad gets the same dark ground, so the row reads as
|
: // An empty pad gets the same dark ground, so the row reads as
|
||||||
@@ -101,7 +114,7 @@ export function HotcueBar({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className="font-mono text-[11px] font-bold leading-none"
|
className="font-mono text-[11px] font-bold leading-none @max-[2.75rem]:self-center"
|
||||||
style={color ? { color: lighten(color) } : undefined}
|
style={color ? { color: lighten(color) } : undefined}
|
||||||
>
|
>
|
||||||
{locked ? <Icon name="lock" size={11} strokeWidth={2.2} /> : slotLabel(slot)}
|
{locked ? <Icon name="lock" size={11} strokeWidth={2.2} /> : slotLabel(slot)}
|
||||||
@@ -116,7 +129,7 @@ export function HotcueBar({
|
|||||||
// A cue without a name shows its type, dimmed, rather than a
|
// A cue without a name shows its type, dimmed, rather than a
|
||||||
// blank line — the pad still says what it holds.
|
// blank line — the pad still says what it holds.
|
||||||
<span
|
<span
|
||||||
className={`w-full truncate text-[11px] leading-none ${
|
className={`w-full truncate text-[11px] leading-none @max-[2.75rem]:hidden ${
|
||||||
cue && cue.name && cue.name !== 'n.n.' ? 'text-text' : 'text-text/60'
|
cue && cue.name && cue.name !== 'n.n.' ? 'text-text' : 'text-text/60'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
@@ -126,7 +139,7 @@ export function HotcueBar({
|
|||||||
{/* The type icon, top right on the number's line — the name below
|
{/* The type icon, top right on the number's line — the name below
|
||||||
is free to run the full width. */}
|
is free to run the full width. */}
|
||||||
{icon && color && (
|
{icon && color && (
|
||||||
<span className="absolute right-2 top-[7px] flex" style={{ color: lighten(color) }}>
|
<span className="absolute right-2 top-[7px] flex @max-[2.75rem]:hidden" style={{ color: lighten(color) }}>
|
||||||
<Icon name={icon} size={14} strokeWidth={2} />
|
<Icon name={icon} size={14} strokeWidth={2} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { ScratchEngine } from '../lib/scratchEngine'
|
|||||||
import { PlaybackEngine } from '../lib/playbackEngine'
|
import { PlaybackEngine } from '../lib/playbackEngine'
|
||||||
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
||||||
import { ContextMenu, type MenuItem } from './ContextMenu'
|
import { ContextMenu, type MenuItem } from './ContextMenu'
|
||||||
import { BpmReadout, GridEditStrip, TempoControls } from './GridControls'
|
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
|
||||||
import { HotcueBar } from './HotcueBar'
|
import { HotcueBar } from './HotcueBar'
|
||||||
import { LoopControls, LOOP_SIZES, type LoopMode } from './LoopControls'
|
import { LoopControls, LOOP_SIZES, type LoopMode } from './LoopControls'
|
||||||
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC } from './MainWaveform'
|
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC } from './MainWaveform'
|
||||||
@@ -1158,6 +1158,20 @@ export function PrepStrip({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DIVIDER = <span aria-hidden className="h-7 w-px shrink-0 bg-line" />
|
const DIVIDER = <span aria-hidden className="h-7 w-px shrink-0 bg-line" />
|
||||||
|
// Rendered twice — inline on a wide row, inside TempoFold on a narrow one.
|
||||||
|
const tempoProps = {
|
||||||
|
bpm: activeMarker?.bpm ?? null,
|
||||||
|
locked: cueData?.grid_locked ?? false,
|
||||||
|
lockable: caps.grid.lockable,
|
||||||
|
flexible: markerCount > 1,
|
||||||
|
markerIndex: activeMarkerIndex,
|
||||||
|
onTapStart: tapStart,
|
||||||
|
onTapBpm: (bpm: number) => commitBpm(bpm, tapAnchorRef.current),
|
||||||
|
onNudgeBpm: nudgeBpm,
|
||||||
|
onHalve: halveBpm,
|
||||||
|
onDouble: doubleBpm,
|
||||||
|
onToggleLock: toggleLock,
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
|
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
|
||||||
@@ -1311,8 +1325,15 @@ export function PrepStrip({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ---- Controls: transport · loop/jump · pads or grid · tempo ---- */}
|
{/* ---- Controls: transport · loop/jump · pads or grid · tempo ----
|
||||||
<div className="flex h-11 shrink-0 items-center gap-3">
|
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
|
||||||
|
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. */}
|
||||||
|
<div className="@container flex h-11 shrink-0 items-center gap-3">
|
||||||
<button
|
<button
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
disabled={!ready}
|
disabled={!ready}
|
||||||
@@ -1405,19 +1426,10 @@ export function PrepStrip({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{DIVIDER}
|
{DIVIDER}
|
||||||
<TempoControls
|
<TempoControls {...tempoProps} className="@max-[74rem]:hidden" />
|
||||||
bpm={activeMarker?.bpm ?? null}
|
<TempoFold locked={tempoProps.locked} className="hidden @max-[74rem]:flex">
|
||||||
locked={cueData?.grid_locked ?? false}
|
<TempoControls {...tempoProps} />
|
||||||
lockable={caps.grid.lockable}
|
</TempoFold>
|
||||||
flexible={markerCount > 1}
|
|
||||||
markerIndex={activeMarkerIndex}
|
|
||||||
onTapStart={tapStart}
|
|
||||||
onTapBpm={(bpm) => commitBpm(bpm, tapAnchorRef.current)}
|
|
||||||
onNudgeBpm={nudgeBpm}
|
|
||||||
onHalve={halveBpm}
|
|
||||||
onDouble={doubleBpm}
|
|
||||||
onToggleLock={toggleLock}
|
|
||||||
/>
|
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setGridMode((g) => !g)
|
setGridMode((g) => !g)
|
||||||
@@ -1427,14 +1439,15 @@ export function PrepStrip({
|
|||||||
aria-pressed={gridMode}
|
aria-pressed={gridMode}
|
||||||
disabled={!track}
|
disabled={!track}
|
||||||
title={gridMode ? 'Back to the hotcue pads' : 'Edit the beatgrid: markers, phase, reset'}
|
title={gridMode ? 'Back to the hotcue pads' : 'Edit the beatgrid: markers, phase, reset'}
|
||||||
className={`flex h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-semibold transition-colors disabled:opacity-40 ${
|
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 ${
|
||||||
gridMode
|
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)]'
|
? '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'
|
: 'btn-glass text-text'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Icon name="grid" size={14} />
|
<Icon name="grid" size={14} />
|
||||||
Grid
|
<span className="@max-[60rem]:hidden">Grid</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user