2025-07-10 21:24:47 +02:00
|
|
|
|
"use client";
|
|
|
|
|
|
|
2025-07-26 11:35:52 +02:00
|
|
|
|
import { FPS_PRESETS } from "@/constants/timeline-constants";
|
2025-07-10 21:24:47 +02:00
|
|
|
|
import { useAspectRatio } from "@/hooks/use-aspect-ratio";
|
2025-07-26 11:35:52 +02:00
|
|
|
|
import { useMediaStore } from "@/stores/media-store";
|
|
|
|
|
|
import { useProjectStore } from "@/stores/project-store";
|
|
|
|
|
|
import { useTimelineStore } from "@/stores/timeline-store";
|
2025-07-10 21:24:47 +02:00
|
|
|
|
import { Label } from "../../ui/label";
|
|
|
|
|
|
import { ScrollArea } from "../../ui/scroll-area";
|
2025-07-12 12:48:31 +02:00
|
|
|
|
import {
|
|
|
|
|
|
Select,
|
|
|
|
|
|
SelectContent,
|
|
|
|
|
|
SelectItem,
|
|
|
|
|
|
SelectTrigger,
|
|
|
|
|
|
SelectValue,
|
|
|
|
|
|
} from "../../ui/select";
|
2025-07-26 11:35:52 +02:00
|
|
|
|
import { AudioProperties } from "./audio-properties";
|
|
|
|
|
|
import { MediaProperties } from "./media-properties";
|
|
|
|
|
|
import { TextProperties } from "./text-properties";
|
2025-07-10 21:24:47 +02:00
|
|
|
|
|
|
|
|
|
|
export function PropertiesPanel() {
|
2025-07-12 12:48:31 +02:00
|
|
|
|
const { activeProject, updateProjectFps } = useProjectStore();
|
2025-07-10 21:24:47 +02:00
|
|
|
|
const { getDisplayName, canvasSize } = useAspectRatio();
|
|
|
|
|
|
const { selectedElements, tracks } = useTimelineStore();
|
|
|
|
|
|
const { mediaItems } = useMediaStore();
|
|
|
|
|
|
|
2025-07-12 12:48:31 +02:00
|
|
|
|
const handleFpsChange = (value: string) => {
|
|
|
|
|
|
const fps = parseFloat(value);
|
|
|
|
|
|
if (!isNaN(fps) && fps > 0) {
|
|
|
|
|
|
updateProjectFps(fps);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-10 21:24:47 +02:00
|
|
|
|
const emptyView = (
|
|
|
|
|
|
<div className="space-y-4 p-5">
|
|
|
|
|
|
{/* Media Properties */}
|
|
|
|
|
|
<div className="flex flex-col gap-3">
|
|
|
|
|
|
<PropertyItem label="Name:" value={activeProject?.name || ""} />
|
|
|
|
|
|
<PropertyItem label="Aspect ratio:" value={getDisplayName()} />
|
|
|
|
|
|
<PropertyItem
|
|
|
|
|
|
label="Resolution:"
|
|
|
|
|
|
value={`${canvasSize.width} × ${canvasSize.height}`}
|
|
|
|
|
|
/>
|
2025-07-25 07:56:05 -05:00
|
|
|
|
<div className="flex flex-col gap-1">
|
2025-07-12 12:48:31 +02:00
|
|
|
|
<Label className="text-xs text-muted-foreground">Frame rate:</Label>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
value={(activeProject?.fps || 30).toString()}
|
|
|
|
|
|
onValueChange={handleFpsChange}
|
|
|
|
|
|
>
|
|
|
|
|
|
<SelectTrigger className="w-32 h-6 text-xs">
|
|
|
|
|
|
<SelectValue />
|
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
|
<SelectContent>
|
|
|
|
|
|
{FPS_PRESETS.map(({ value, label }) => (
|
|
|
|
|
|
<SelectItem key={value} value={value} className="text-xs">
|
|
|
|
|
|
{label}
|
|
|
|
|
|
</SelectItem>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</SelectContent>
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</div>
|
2025-07-10 21:24:47 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<ScrollArea className="h-full bg-panel rounded-sm">
|
|
|
|
|
|
{selectedElements.length > 0
|
|
|
|
|
|
? selectedElements.map(({ trackId, elementId }) => {
|
|
|
|
|
|
const track = tracks.find((t) => t.id === trackId);
|
|
|
|
|
|
const element = track?.elements.find((e) => e.id === elementId);
|
|
|
|
|
|
|
|
|
|
|
|
if (element?.type === "text") {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div key={elementId}>
|
|
|
|
|
|
<TextProperties element={element} trackId={trackId} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (element?.type === "media") {
|
|
|
|
|
|
const mediaItem = mediaItems.find(
|
|
|
|
|
|
(item) => item.id === element.mediaId
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (mediaItem?.type === "audio") {
|
2025-07-26 11:35:52 +02:00
|
|
|
|
return <AudioProperties key={elementId} element={element} />;
|
2025-07-10 21:24:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div key={elementId}>
|
|
|
|
|
|
<MediaProperties element={element} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
})
|
|
|
|
|
|
: emptyView}
|
|
|
|
|
|
</ScrollArea>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PropertyItem({ label, value }: { label: string; value: string }) {
|
|
|
|
|
|
return (
|
2025-07-26 11:35:52 +02:00
|
|
|
|
<div className="grid justify-between grid-cols-6">
|
|
|
|
|
|
<Label className="text-xs text-muted-foreground col-span-2">
|
|
|
|
|
|
{label}
|
|
|
|
|
|
</Label>
|
|
|
|
|
|
<span className="text-xs text-right col-span-4 truncate" title={value}>
|
2025-07-22 12:43:27 +02:00
|
|
|
|
{value}
|
|
|
|
|
|
</span>
|
2025-07-10 21:24:47 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|