From d7bbecbe1c8f8803e10b38c12ad2caa32aaf3e64 Mon Sep 17 00:00:00 2001 From: k1nho Date: Sat, 15 Jun 2024 15:23:20 -0400 Subject: [PATCH] feat/unmark-mark-clips-lossless-export --- app.go | 5 ++++- frontend/src/components/Timeline.svelte | 11 +++++++++++ frontend/src/stores.ts | 11 +++++++++++ frontend/wailsjs/go/main/App.d.ts | 2 ++ frontend/wailsjs/go/main/App.js | 4 ++++ internal/video/video.go | 15 +++++++++++++++ video.go | 4 ++++ 7 files changed, 51 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index 1916d3f..cb60743 100644 --- a/app.go +++ b/app.go @@ -303,9 +303,12 @@ func (a *App) EnableVideoMenus() { timelineMenu.AddText("Rename Clip", keys.CmdOrCtrl("r"), func(cd *menu.CallbackData) { wruntime.EventsEmit(a.ctx, video.EVT_OPEN_RENAME_CLIP_MODAL) }) - timelineMenu.AddText("Mark/Unmark Lossless Export", keys.Key("m"), func(cd *menu.CallbackData) { + timelineMenu.AddText("Mark/Unmark Clip (Lossless Export)", keys.Key("m"), func(cd *menu.CallbackData) { wruntime.EventsEmit(a.ctx, video.EVT_TOGGLE_LOSSLESS) }) + timelineMenu.AddText("Mark All Clips (Lossless Export)", keys.Shift("m"), func(cd *menu.CallbackData) { + wruntime.EventsEmit(a.ctx, video.EVT_MARK_ALL_LOSSLESS) + }) timelineMenu.AddText("Change Project", keys.Shift("b"), func(cd *menu.CallbackData) { wruntime.EventsEmit(a.ctx, video.EVT_CHANGE_ROUTE, "main") }) diff --git a/frontend/src/components/Timeline.svelte b/frontend/src/components/Timeline.svelte index 9a3eb15..c61d150 100644 --- a/frontend/src/components/Timeline.svelte +++ b/frontend/src/components/Timeline.svelte @@ -18,6 +18,7 @@ InsertInterval, RenameVideoNode, ToggleLossless, + MarkAllLossless, } from "../../wailsjs/go/main/App"; import RenameIcon from "../icons/RenameIcon.svelte"; import SearchList from "../components/SearchList.svelte"; @@ -69,6 +70,7 @@ setTrackTime, renameClipInTrack, toggleLosslessMarkofClip, + markAllLossless, resetTrackStore, } = trackStore; @@ -400,6 +402,14 @@ .catch((err) => setActionMsg(err)); } }); + + EventsOn("evt_mark_all_lossless", () => { + MarkAllLossless() + .then(() => { + markAllLossless(); + }) + .catch((err) => setActionMsg(err)); + }); onDestroy(() => { EventsOff( "evt_open_rename_clip_modal", @@ -411,6 +421,7 @@ "evt_zoom_timeline", "evt_saved_timeline", "evt_toggle_lossless", + "evt_mark_all_lossless", ); resetTrackStore(); resetToolingStore(); diff --git a/frontend/src/stores.ts b/frontend/src/stores.ts index f07cb28..98c8098 100644 --- a/frontend/src/stores.ts +++ b/frontend/src/stores.ts @@ -234,6 +234,16 @@ function createTracksStore() { }); }; + const markAllLossless = () => { + update((tracks) => { + if (!tracks[0]) return tracks; + for (let track of tracks[0]) { + track.losslessexport = true; + } + return tracks; + }); + }; + const resetTrackStore = () => { set([]); setTrackTime(0); @@ -250,6 +260,7 @@ function createTracksStore() { removeRIDReferencesFromTrack, renameClipInTrack, toggleLosslessMarkofClip, + markAllLossless, trackDuration, resetTrackStore, }; diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index 7b56d7a..a5ce988 100755 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -40,6 +40,8 @@ export function LoadProjectFiles():Promise>; export function LoadTimeline():Promise; +export function MarkAllLossless():Promise; + export function OpenFile(arg1:string):Promise; export function ReadGaharaWorkspace():Promise>; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index 7e46ff3..3690ad7 100755 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -74,6 +74,10 @@ export function LoadTimeline() { return window['go']['main']['App']['LoadTimeline'](); } +export function MarkAllLossless() { + return window['go']['main']['App']['MarkAllLossless'](); +} + export function OpenFile(arg1) { return window['go']['main']['App']['OpenFile'](arg1); } diff --git a/internal/video/video.go b/internal/video/video.go index 66851a3..547417d 100644 --- a/internal/video/video.go +++ b/internal/video/video.go @@ -52,6 +52,8 @@ const ( EVT_INSERTCLIP_EDIT = "evt_insertclip_edit" //EVT_TOGGLE_LOSSLESS: toggles the video node status to be exported as lossless EVT_TOGGLE_LOSSLESS = "evt_toggle_lossless" + // EVT_MARK_ALL_LOSSLESS: marks all the video nodes as lossless + EVT_MARK_ALL_LOSSLESS = "evt_mark_all_lossless" // EVT_EXECUTE_EDIT: execute the current edit EVT_EXECUTE_EDIT = "evt_execute_edit" // EVT_PLAY_TRACK: plays the clips on the track (starting from current pos and clip time) @@ -242,6 +244,19 @@ func (tl *Timeline) ToggleLossless(pos int) error { return nil } +func (tl *Timeline) MarkAllLossless() error { + if len(tl.VideoNodes) == 0 { + return fmt.Errorf("there are no video clips to mark") + } + + for i := range tl.VideoNodes { + tl.VideoNodes[i].LosslessExport = true + } + + return nil + +} + func (tl *Timeline) Split(eventType string, pos int, start, end float64) ([]VideoNode, error) { nodes := []VideoNode{} if pos < 0 || pos >= len(tl.VideoNodes) { diff --git a/video.go b/video.go index 13f7661..851ba46 100644 --- a/video.go +++ b/video.go @@ -346,6 +346,10 @@ func (a *App) ToggleLossless(pos int) error { return a.Timeline.ToggleLossless(pos) } +func (a *App) MarkAllLossless() error { + return a.Timeline.MarkAllLossless() +} + // ResetTimeline: cleanup timeline state in memory func (a *App) ResetTimeline() { a.Timeline = video.NewTimeline()