diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-06-24 01:49:12 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-06-24 01:49:12 +0200 |
| commit | 5bff26d3e51d775bb44b6c9fa1337570642d284d (patch) | |
| tree | d82908098f4f1438fbd578b063c97ace94460694 /apps/web/src/stores/timeline-store.ts | |
| parent | 69566ffa83b9f192397073f37de0d9a8a9437fef (diff) | |
| parent | a6a520db70ef639e066d1012fa2ecf7e26c53049 (diff) | |
| download | opencut-5bff26d3e51d775bb44b6c9fa1337570642d284d.tar.gz | |
Merge branch 'main' of https://github.com/mazeincoding/AppCut
Diffstat (limited to 'apps/web/src/stores/timeline-store.ts')
| -rw-r--r-- | apps/web/src/stores/timeline-store.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts index c569ae11..4b55a53d 100644 --- a/apps/web/src/stores/timeline-store.ts +++ b/apps/web/src/stores/timeline-store.ts @@ -21,6 +21,13 @@ export interface TimelineTrack { interface TimelineStore {
tracks: TimelineTrack[];
+ // Multi-selection
+ selectedClips: { trackId: string; clipId: string }[];
+ selectClip: (trackId: string, clipId: string, multi?: boolean) => void;
+ deselectClip: (trackId: string, clipId: string) => void;
+ clearSelectedClips: () => void;
+ setSelectedClips: (clips: { trackId: string; clipId: string }[]) => void;
+
// Actions
addTrack: (type: "video" | "audio" | "effects") => string;
removeTrack: (trackId: string) => void;
@@ -50,6 +57,33 @@ interface TimelineStore { export const useTimelineStore = create<TimelineStore>((set, get) => ({
tracks: [],
+ selectedClips: [],
+
+ selectClip: (trackId, clipId, multi = false) => {
+ set((state) => {
+ const exists = state.selectedClips.some(
+ (c) => c.trackId === trackId && c.clipId === clipId
+ );
+ if (multi) {
+ // Toggle selection
+ return exists
+ ? { selectedClips: state.selectedClips.filter((c) => !(c.trackId === trackId && c.clipId === clipId)) }
+ : { selectedClips: [...state.selectedClips, { trackId, clipId }] };
+ } else {
+ return { selectedClips: [{ trackId, clipId }] };
+ }
+ });
+ },
+ deselectClip: (trackId, clipId) => {
+ set((state) => ({
+ selectedClips: state.selectedClips.filter((c) => !(c.trackId === trackId && c.clipId === clipId)),
+ }));
+ },
+ clearSelectedClips: () => {
+ set({ selectedClips: [] });
+ },
+
+ setSelectedClips: (clips) => set({ selectedClips: clips }),
addTrack: (type) => {
const newTrack: TimelineTrack = {
|
