mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved hotcue icons
This commit is contained in:
1 parent
c1f121ae1d
commit
c6aaded26d
5 files changed
+33
-18
No files matched your search
@@ -500,6 +500,9 @@ export default function App() {
|
|||||||
setSource({ kind: 'all' })
|
setSource({ kind: 'all' })
|
||||||
setSelected(new Set())
|
setSelected(new Set())
|
||||||
setBatchJob(null) // the backend cancels it; its result is for the old library
|
setBatchJob(null) // the backend cancels it; its result is for the old library
|
||||||
|
// The deck starts empty: its track belongs to the old library.
|
||||||
|
setPrepTrack(null)
|
||||||
|
setPlayRequest(0)
|
||||||
setFilters(emptyFilters)
|
setFilters(emptyFilters)
|
||||||
setSorting([])
|
setSorting([])
|
||||||
qc.invalidateQueries() // refetch everything for the newly-opened collection
|
qc.invalidateQueries() // refetch everything for the newly-opened collection
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useRef, useState, type CSSProperties } from 'react'
|
import { useRef, useState, type CSSProperties } from 'react'
|
||||||
import type { CuePoint } from '../api'
|
import type { CuePoint } from '../api'
|
||||||
import { CUE_TYPE_LABELS, cueColor, cueGlyph, withAlpha } from '../lib/cues'
|
import { CUE_TYPE_LABELS, cueColor, cueIcon, withAlpha } from '../lib/cues'
|
||||||
import { Icon } from '../lib/icons'
|
import { Icon } from '../lib/icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -60,7 +60,7 @@ export function HotcueBar({
|
|||||||
const locked = cue != null && !cue.editable
|
const locked = cue != null && !cue.editable
|
||||||
const selected = selectedSlot === slot && !locked
|
const selected = selectedSlot === slot && !locked
|
||||||
const color = cue ? cueColor(cue) : null
|
const color = cue ? cueColor(cue) : null
|
||||||
const glyph = cue ? cueGlyph(cue) : ''
|
const icon = cue && !locked ? cueIcon(cue) : null
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={slot}
|
key={slot}
|
||||||
@@ -123,12 +123,11 @@ export function HotcueBar({
|
|||||||
{cue ? (cue.name && cue.name !== 'n.n.' ? cue.name : CUE_TYPE_LABELS[cue.type]) : 'Empty'}
|
{cue ? (cue.name && cue.name !== 'n.n.' ? cue.name : CUE_TYPE_LABELS[cue.type]) : 'Empty'}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{glyph && (
|
{/* The type icon, top right on the number's line — the name below
|
||||||
<span
|
is free to run the full width. */}
|
||||||
className="absolute right-1.5 top-1 text-[9px] leading-none opacity-90"
|
{icon && color && (
|
||||||
style={{ color: color ?? undefined }}
|
<span className="absolute right-2 top-[7px] flex" style={{ color: lighten(color) }}>
|
||||||
>
|
<Icon name={icon} size={14} strokeWidth={2} />
|
||||||
{glyph}
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -432,8 +432,12 @@ export function PrepStrip({
|
|||||||
// A library row's play button bumps `playRequest`: load (if needed) + play.
|
// A library row's play button bumps `playRequest`: load (if needed) + play.
|
||||||
// If the requested track is already loaded and ready, start immediately;
|
// If the requested track is already loaded and ready, start immediately;
|
||||||
// otherwise flag it and the analysis effect starts playback once ready.
|
// otherwise flag it and the analysis effect starts playback once ready.
|
||||||
|
// Only a CHANGE is a request: the deck unmounts behind the library picker,
|
||||||
|
// and remounting with a non-zero count must not start playback.
|
||||||
|
const seenPlayRequestRef = useRef(playRequest)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (playRequest === 0) return
|
if (playRequest === seenPlayRequestRef.current) return
|
||||||
|
seenPlayRequestRef.current = playRequest
|
||||||
pendingPlayRef.current = true
|
pendingPlayRef.current = true
|
||||||
const eng = playbackRef.current
|
const eng = playbackRef.current
|
||||||
if (loadedIdRef.current === trackId && eng?.ready) {
|
if (loadedIdRef.current === trackId && eng?.ready) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { CuePoint, CueType } from '../api'
|
import type { CuePoint, CueType } from '../api'
|
||||||
import { BEATS_PER_BAR, type BeatGrid } from './beatgrid'
|
import { BEATS_PER_BAR, type BeatGrid } from './beatgrid'
|
||||||
|
import type { IconName } from './icons'
|
||||||
|
|
||||||
// Fallback colour by cue type, used when the platform stored none.
|
// Fallback colour by cue type, used when the platform stored none.
|
||||||
const TYPE_COLORS: Record<CueType, string> = {
|
const TYPE_COLORS: Record<CueType, string> = {
|
||||||
@@ -20,14 +21,14 @@ export const CUE_TYPE_LABELS: Record<CueType, string> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A second, always-present channel for type. Colour used to be type-derived and
|
// A second, always-present channel for type. Colour used to be type-derived and
|
||||||
// therefore always carried it; now that a user's stored colour wins, the glyph
|
// therefore always carried it; now that a user's stored colour wins, the icon
|
||||||
// is what keeps a fade-in distinguishable from a plain cue.
|
// is what keeps a fade-in distinguishable from a plain cue.
|
||||||
const TYPE_GLYPHS: Record<CueType, string> = {
|
const TYPE_ICONS: Record<CueType, IconName> = {
|
||||||
cue: '',
|
cue: 'cueFlag',
|
||||||
fade_in: '▶',
|
fade_in: 'fadeIn',
|
||||||
fade_out: '◀',
|
fade_out: 'fadeOut',
|
||||||
load: '⏏',
|
load: 'eject',
|
||||||
loop: '⟳',
|
loop: 'loop',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,8 +50,11 @@ export function cueTypeColor(type: CueType): string {
|
|||||||
return TYPE_COLORS[type] ?? MEMORY_COLOR
|
return TYPE_COLORS[type] ?? MEMORY_COLOR
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cueGlyph(cue: CuePoint): string {
|
/** The pad icon for a cue: its type — or the grid icon for a cue that marks a
|
||||||
return TYPE_GLYPHS[cue.type] ?? ''
|
* beatgrid marker (Traktor's white companion), since that is what it is. */
|
||||||
|
export function cueIcon(cue: CuePoint): IconName {
|
||||||
|
if (cue.grid_marker != null) return 'grid'
|
||||||
|
return TYPE_ICONS[cue.type] ?? 'cueFlag'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withAlpha(hex: string, a: number): string {
|
export function withAlpha(hex: string, a: number): string {
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ const PATHS = {
|
|||||||
),
|
),
|
||||||
pencil: <path d="M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4" strokeLinejoin="round" />,
|
pencil: <path d="M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4" strokeLinejoin="round" />,
|
||||||
plus: <path d="M12 5v14M5 12h14" />,
|
plus: <path d="M12 5v14M5 12h14" />,
|
||||||
|
// Cue types, for the hotcue pads.
|
||||||
|
cueFlag: <path d="M6 21V4M6 4h11l-3 4 3 4H6" strokeLinejoin="round" />,
|
||||||
|
fadeIn: <path d="M3 19L21 5v14z" strokeLinejoin="round" />,
|
||||||
|
fadeOut: <path d="M3 5l18 14H3z" strokeLinejoin="round" />,
|
||||||
|
eject: <path d="M12 4l8 9H4zM4 18h16" strokeLinejoin="round" />,
|
||||||
grid: <path d="M5 3v18M10 3v18M15 3v18M20 3v18" />,
|
grid: <path d="M5 3v18M10 3v18M15 3v18M20 3v18" />,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user