import { memo } from "react"; import type { TimelineTheme } from "./timelineTheme"; import type { TimelineRangeSelection } from "./timelineEditing"; import { GUTTER, RULER_H, formatTimelineTickLabel } from "./timelineLayout"; import type { MusicBeatAnalysis } from "@hyperframes/core/beats"; interface TimelineRulerProps { major: number[]; minor: number[]; pps: number; trackContentWidth: number; totalH: number; effectiveDuration: number; majorTickInterval: number; shiftHeld: boolean; rangeSelection: TimelineRangeSelection | null; theme: TimelineTheme; beatAnalysis?: MusicBeatAnalysis | null; } export const TimelineRuler = memo(function TimelineRuler({ major, minor, pps, trackContentWidth, totalH, effectiveDuration, majorTickInterval, shiftHeld, rangeSelection, theme, beatAnalysis, }: TimelineRulerProps) { const beatTimes = beatAnalysis?.beatTimes ?? []; const beatStrengths = beatAnalysis?.beatStrengths ?? []; // Only draw beat lines when they'd be at least 5px apart const avgBeatInterval = beatTimes.length > 1 ? (beatTimes[beatTimes.length - 1]! - beatTimes[0]!) / (beatTimes.length - 1) : null; const showBeats = avgBeatInterval !== null && avgBeatInterval * pps >= 5; return ( <> {/* Grid lines (major ticks + beat lines) — behind the tracks (background). Opaque track rows hide them; only the beat dots show on tracks. */} {/* Ruler */}