import { SkipBack, StepForward, Play, Pause, RotateCcw } from 'lucide-react'; import { useProcessStore } from '../../store/processStore'; import { useSimulationStore, type SimStatus } from '../../store/simulationStore'; import { useUiStore, SPEED_OPTIONS } from '../../store/uiStore'; import IconButton from '../shared/IconButton'; const SPEED_LABELS: Record = { 0.25: '0.25×', 0.5: '0.5×', 1: '1×', 2: '2×', 4: '4×', }; const statusLabel: Record = { idle: 'Ready', paused: 'Paused', running: 'Running', finished: 'Finished', }; const statusDotClass: Record = { idle: 'bg-slate-500', paused: 'bg-amber-400', running: 'bg-emerald-400 animate-pulse', finished: 'bg-blue-400', }; const ControlBar = () => { const processes = useProcessStore(s => s.processes); const config = useProcessStore(s => s.config); const status = useSimulationStore(s => s.status); const ticks = useSimulationStore(s => s.ticks); const { init, stepOnce, play, pause, reset } = useSimulationStore(); const speed = useUiStore(s => s.speed); const setSpeed = useUiStore(s => s.setSpeed); const currentTick = ticks.length; const isIdle = status === 'idle'; const isRunning = status === 'running'; const isFinished = status === 'finished'; const canPlay = (status === 'paused' || status === 'idle') && !isFinished && processes.length > 0; const handlePlay = () => { if (isIdle) { init(processes, config); } play(); }; const handleStep = () => { if (isIdle) { init(processes, config); } stepOnce(); }; const handleReset = () => { if (isIdle) return; reset(); }; return (
{/* Left group: simulation controls */}
{/* Reset */} {/* Step */} {/* Play / Pause */} {isRunning ? ( ) : ( )}
{/* Divider */} ); }; export default ControlBar;