/** * TrackHeader - Заголовок трека с элементами управления */ import { Eye, EyeOff, Image, Lock, Mic, Music, Type, Unlock, Video, Volume2, VolumeX } from "lucide-react" import React from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Slider } from "@/components/ui/slider" import { cn } from "@/lib/utils" import { TimelineTrack, TrackType } from "../../types" interface TrackHeaderProps { track: TimelineTrack isSelected?: boolean onUpdate?: (updates: Partial) => void } // Иконки для разных типов треков const TRACK_TYPE_ICONS: Record> = { video: Video, audio: Music, image: Image, title: Type, subtitle: Type, music: Music, voiceover: Mic, sfx: Music, ambient: Music, } // Цвета для разных типов треков const TRACK_TYPE_COLORS: Record = { video: "text-blue-500", audio: "text-green-500", image: "text-purple-500", title: "text-orange-500", subtitle: "text-yellow-500", music: "text-pink-500", voiceover: "text-cyan-500", sfx: "text-red-500", ambient: "text-gray-500", } export function TrackHeader({ track, isSelected, onUpdate }: TrackHeaderProps) { const [isEditing, setIsEditing] = React.useState(false) const [editName, setEditName] = React.useState(track.name) const IconComponent = TRACK_TYPE_ICONS[track.type] const iconColor = TRACK_TYPE_COLORS[track.type] const handleNameSubmit = () => { onUpdate?.({ name: editName.trim() || track.name }) setIsEditing(false) } const handleKeyPress = (e: React.KeyboardEvent) => { if (e.key === "Enter") { handleNameSubmit() } else if (e.key === "Escape") { setEditName(track.name) setIsEditing(false) } } const toggleMute = () => { onUpdate?.({ isMuted: !track.isMuted }) } const toggleLock = () => { onUpdate?.({ isLocked: !track.isLocked }) } const toggleVisibility = () => { onUpdate?.({ isHidden: !track.isHidden }) } const handleVolumeChange = (value: number[]) => { onUpdate?.({ volume: value[0] }) } return (
{/* Верхняя часть - иконка типа и название */}
{/* Иконка типа трека */}
{track.type}
{/* Название трека */} {isEditing ? ( setEditName(e.target.value)} onBlur={handleNameSubmit} onKeyDown={handleKeyPress} className="h-6 text-xs" autoFocus /> ) : (
setIsEditing(true)} title="Нажмите для редактирования" > {track.name}
)}
{/* Средняя часть - слайдер громкости (для аудио треков) */} {(track.type === "audio" || track.type === "music" || track.type === "voiceover" || track.type === "sfx" || track.type === "ambient") && (
Громкость: {Math.round(track.volume * 100)}%
)} {/* Нижняя часть - кнопки управления */}
{/* Кнопка видимости */} {/* Кнопка блокировки */} {/* Кнопка отключения звука (для аудио треков) */} {(track.type === "audio" || track.type === "music" || track.type === "voiceover" || track.type === "sfx" || track.type === "ambient") && ( )}
) }