import { X } from "lucide-react" import { useEffect, useRef, useState } from "react" import { Button } from "@/components/ui/button" import { HistogramScope } from "./histogram-scope" import { VectorscopeScope } from "./vectorscope-scope" import { WaveformScope } from "./waveform-scope" interface ScopeViewerProps { type: "waveform" | "vectorscope" | "histogram" refreshRate: number isFullscreen?: boolean onClose?: () => void } export function ScopeViewer({ type, refreshRate, isFullscreen = false, onClose }: ScopeViewerProps) { const containerRef = useRef(null) const [dimensions, setDimensions] = useState({ width: 320, height: 240 }) // Обновление размеров при изменении контейнера useEffect(() => { if (!containerRef.current) return const updateDimensions = () => { if (containerRef.current) { const { width, height } = containerRef.current.getBoundingClientRect() setDimensions({ width: Math.max(320, width), height: isFullscreen ? Math.max(480, height - 60) : 240, }) } } updateDimensions() const resizeObserver = new ResizeObserver(updateDimensions) resizeObserver.observe(containerRef.current) return () => { resizeObserver.disconnect() } }, [isFullscreen]) return (
{/* Кнопка закрытия для полноэкранного режима */} {isFullscreen && onClose && (
)} {/* Рендер соответствующего скопа */}
{type === "waveform" && ( )} {type === "vectorscope" && ( )} {type === "histogram" && ( )}
) }