import React, { useState } from 'react'; import Image from 'next/image'; import useNavigationStore from '@/app/store/navigationStore'; import type { Zone } from '@/app/types'; interface ToolbarButton { icon: string; label: string; onClick: () => void; onMouseDown?: () => void; onMouseUp?: () => void; active?: boolean; children?: ToolbarButton[]; } interface SceneToolbarProps { onZoomIn?: () => void; onZoomOut?: () => void; onTopView?: () => void; onPan?: () => void; onSelectModel?: (modelPath: string) => void; panActive?: boolean; navMenuActive?: boolean; onToggleSensorHighlights?: () => void; sensorHighlightsActive?: boolean; } const SceneToolbar: React.FC = ({ onZoomIn, onZoomOut, onTopView, onPan, onSelectModel, panActive = false, navMenuActive = false, onToggleSensorHighlights, sensorHighlightsActive = true, }) => { const [isZoomOpen, setIsZoomOpen] = useState(false); const { showMonitoring, openMonitoring, closeMonitoring, currentZones, loadZones, currentObject } = useNavigationStore(); const handleToggleNavMenu = () => { if (showMonitoring) { closeMonitoring(); } else { openMonitoring(); } }; const defaultButtons: ToolbarButton[] = [ { icon: '/icons/Zoom.png', label: 'Масштаб', onClick: () => setIsZoomOpen(!isZoomOpen), active: isZoomOpen, children: [ { icon: '/icons/plus.svg', label: 'Приблизить', onClick: onZoomIn || (() => {}), }, { icon: '/icons/minus.svg', label: 'Отдалить', onClick: onZoomOut || (() => {}), }, ] }, { icon: '/icons/Video.png', label: 'Вид сверху', onClick: onTopView || (() => console.log('Top View')), }, { icon: '/icons/Pointer.png', label: 'Панорамирование', onClick: onPan || (() => console.log('Pan')), active: panActive, }, { icon: '/icons/Eye.png', label: 'Подсветка датчиков', onClick: onToggleSensorHighlights || (() => console.log('Toggle Sensor Highlights')), active: sensorHighlightsActive, }, { icon: '/icons/Layers.png', label: 'Уровни', onClick: handleToggleNavMenu, active: navMenuActive, }, ]; return (
{defaultButtons.map((button, index) => (
{button.active && button.children && (
{button.children.map((childButton, childIndex) => ( ))}
)}
))}
); }; export default SceneToolbar;