mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 18:22:53 +01:00
Added shortcuts menu
This commit is contained in:
1 parent
b4dc8949de
commit
950352f7ec
3 files changed
+157
-2
No files matched your search
@@ -342,7 +342,7 @@ Two independent apps that talk over HTTP:
|
||||
same menu and the row's hover buttons, which share one set of actions.
|
||||
A Traktor folder's id is its PATH of names, so the `PATCH`/`DELETE`
|
||||
playlist routes take a `:path` param, a folder name may not contain `/`,
|
||||
and renaming onto a sibling folder's name is refused), `SaveBar` (+ the settings gear beside it), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
|
||||
and renaming onto a sibling folder's name is refused), `SaveBar` (+ the settings gear beside it, whose menu opens `ShortcutsDialog` — the shortcut list is written out BY HAND, so a new or changed shortcut in `PrepStrip` / `TrackTable` must be added there too), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
|
||||
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
|
||||
devices. TanStack Table + **virtualized** grid; per-row play button,
|
||||
configurable columns, header sorting, inline double-click editing, and
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { ShortcutsDialog } from './ShortcutsDialog'
|
||||
|
||||
interface Props {
|
||||
onOpenPathMapping: () => void
|
||||
@@ -7,9 +8,11 @@ interface Props {
|
||||
}
|
||||
|
||||
/** Overflow menu for low-frequency, collection-level settings. Currently holds
|
||||
* path remapping; the natural home for future advanced settings. */
|
||||
* path remapping and the shortcut list; the natural home for future advanced
|
||||
* settings. The shortcuts dialog is owned here, since nothing else opens it. */
|
||||
export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [showShortcuts, setShowShortcuts] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -63,8 +66,19 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
Point the collection at moved or relocated files
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setShowShortcuts(true)
|
||||
setOpen(false)
|
||||
}}
|
||||
className={item}
|
||||
>
|
||||
<span className="text-sm text-text">View Shortcuts</span>
|
||||
<span className="text-[11px] text-faint">Every keyboard shortcut in one list</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{showShortcuts && <ShortcutsDialog onClose={() => setShowShortcuts(false)} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
// Cmd on macOS, Ctrl elsewhere — the handlers accept either, but a list that
|
||||
// says "Cmd/Ctrl" everywhere is harder to scan than one that names your key.
|
||||
const IS_MAC = /Mac|iPhone|iPad/.test(navigator.userAgent)
|
||||
const MOD = IS_MAC ? '⌘' : 'Ctrl'
|
||||
|
||||
type Row = { keys: string[][]; action: string }
|
||||
type Section = { title: string; rows: Row[] }
|
||||
|
||||
/** Hotcue keys are digits in pad order, 0 being the tenth, so the list follows
|
||||
* the loaded library's bank size rather than hard-coding eight. */
|
||||
function hotcueKeys(slots: number): string {
|
||||
const n = Math.min(slots, 10)
|
||||
if (n <= 0) return '1'
|
||||
if (n <= 9) return `1–${n}`
|
||||
return '1–9, 0'
|
||||
}
|
||||
|
||||
function sections(slots: number): Section[] {
|
||||
const pads = hotcueKeys(slots)
|
||||
return [
|
||||
{
|
||||
title: 'Deck',
|
||||
rows: [
|
||||
{ keys: [['Space']], action: 'Play / pause' },
|
||||
{ keys: [['C']], action: 'CUE — jump back, set, or hold to preview' },
|
||||
{ keys: [['←'], ['→']], action: 'Beat jump back / forward' },
|
||||
{ keys: [[MOD, '↓'], [MOD, '↑']], action: 'Smaller / larger beat jump' },
|
||||
{ keys: [['Shift', '←'], ['Shift', '→']], action: 'Previous / next grid marker' },
|
||||
{ keys: [[pads]], action: 'Hotcue — set if empty, else jump (hold to preview)' },
|
||||
{ keys: [['Shift', pads]], action: 'Delete hotcue' },
|
||||
{ keys: [['Drag waveform']], action: 'Scratch' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Track list',
|
||||
rows: [
|
||||
{ keys: [['Enter']], action: 'Load and play the highlighted track' },
|
||||
{ keys: [['↑'], ['↓']], action: 'Move the selection' },
|
||||
{ keys: [['Shift', '↑'], ['Shift', '↓']], action: 'Extend the selection' },
|
||||
{ keys: [[MOD, 'A']], action: 'Select all' },
|
||||
{ keys: [['Esc']], action: 'Clear the selection' },
|
||||
{ keys: [['Delete']], action: 'Remove from this playlist' },
|
||||
{ keys: [['Shift', 'Click']], action: 'Select a range' },
|
||||
{ keys: [[MOD, 'Click']], action: 'Add to / remove from the selection' },
|
||||
{ keys: [['Double-click']], action: 'Edit a cell' },
|
||||
{ keys: [['Right-click']], action: 'Track menu (header: choose columns)' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Sidebar',
|
||||
rows: [{ keys: [['Right-click']], action: 'New playlist or folder, rename, delete' }],
|
||||
},
|
||||
{
|
||||
title: 'Fields & dialogs',
|
||||
rows: [
|
||||
{ keys: [['Enter']], action: 'Save the edit / confirm' },
|
||||
{ keys: [['Esc']], action: 'Cancel / close' },
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
function Keys({ combo }: { combo: string[] }) {
|
||||
return (
|
||||
<span className="inline-flex items-center gap-0.5">
|
||||
{combo.map((k, i) => (
|
||||
<kbd
|
||||
key={i}
|
||||
className="min-w-[1.5rem] rounded border border-line bg-ink-800 px-1.5 py-0.5 text-center font-sans text-[11px] text-text"
|
||||
>
|
||||
{k}
|
||||
</kbd>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** Every keyboard shortcut (and the mouse gestures that go with them), from the
|
||||
* settings menu. Keep in step with the handlers in `PrepStrip` and `TrackTable`
|
||||
* — this list is written out by hand, not derived from them. */
|
||||
export function ShortcutsDialog({ onClose }: Props) {
|
||||
const slots = useCaps().cues.hotcue_slots
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div
|
||||
className="flex max-h-full w-full max-w-lg flex-col overflow-hidden rounded-xl border border-line bg-ink-900 shadow-2xl"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Keyboard Shortcuts</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
aria-label="Close"
|
||||
className="rounded px-1.5 text-muted hover:bg-ink-800 hover:text-text"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-5 overflow-y-auto px-5 py-4">
|
||||
{sections(slots).map((s) => (
|
||||
<section key={s.title}>
|
||||
<div className="mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-faint">
|
||||
{s.title}
|
||||
</div>
|
||||
<div className="divide-y divide-line/60">
|
||||
{s.rows.map((r, i) => (
|
||||
<div key={i} className="flex items-center justify-between gap-4 py-1.5">
|
||||
<span className="text-sm text-muted">{r.action}</span>
|
||||
<span className="flex shrink-0 items-center gap-1.5">
|
||||
{r.keys.map((combo, j) => (
|
||||
<Keys key={j} combo={combo} />
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user