Skip to content

Commit

Permalink
feat/unmark-mark-clips-lossless-export
Browse files Browse the repository at this point in the history
  • Loading branch information
k1nho committed Jun 15, 2024
1 parent c3a62c3 commit e291d65
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,16 @@ 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("Unmark All Clips (Lossless Export)", keys.Shift("u"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_UNMARK_ALL_LOSSLESS)
})

timelineMenu.AddText("Change Project", keys.Shift("b"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_CHANGE_ROUTE, "main")
})
Expand Down
28 changes: 28 additions & 0 deletions frontend/src/components/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
InsertInterval,
RenameVideoNode,
ToggleLossless,
MarkAllLossless,
UnmarkAllLossless,
} from "../../wailsjs/go/main/App";
import RenameIcon from "../icons/RenameIcon.svelte";
import SearchList from "../components/SearchList.svelte";
Expand Down Expand Up @@ -69,6 +71,8 @@
setTrackTime,
renameClipInTrack,
toggleLosslessMarkofClip,
markAllLossless,
unmarkAllLossless,
resetTrackStore,
} = trackStore;
Expand Down Expand Up @@ -396,10 +400,32 @@
ToggleLossless($videoNodePos)
.then(() => {
toggleLosslessMarkofClip(0, $videoNodePos);
setActionMsg("-- MARKED --");
})
.catch((err) => setActionMsg(err));
}
});
EventsOn("evt_mark_all_lossless", () => {
MarkAllLossless()
.then(() => {
markAllLossless();
setActionMsg("-- MARKED CLIPS --");
})
.catch((err) => setActionMsg(err));
});
EventsOn("evt_unmark_all_lossless", () => {
UnmarkAllLossless()
.then(() => {
unmarkAllLossless();
setActionMsg("-- UNMARKED CLIPS --");
})
.catch((err) => setActionMsg(err));
});
onDestroy(() => {
EventsOff(
"evt_open_rename_clip_modal",
Expand All @@ -411,6 +437,8 @@
"evt_zoom_timeline",
"evt_saved_timeline",
"evt_toggle_lossless",
"evt_mark_all_lossless",
"evt_unmark_all_lossless",
);
resetTrackStore();
resetToolingStore();
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,26 @@ function createTracksStore() {
});
};

const markAllLossless = () => {
update((tracks) => {
if (!tracks[0]) return tracks;
for (let track of tracks[0]) {
track.losslessexport = true;
}
return tracks;
});
};

const unmarkAllLossless = () => {
update((tracks) => {
if (!tracks[0]) return tracks;
for (let track of tracks[0]) {
track.losslessexport = false;
}
return tracks;
});
};

const resetTrackStore = () => {
set([]);
setTrackTime(0);
Expand All @@ -250,6 +270,8 @@ function createTracksStore() {
removeRIDReferencesFromTrack,
renameClipInTrack,
toggleLosslessMarkofClip,
markAllLossless,
unmarkAllLossless,
trackDuration,
resetTrackStore,
};
Expand Down
4 changes: 4 additions & 0 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export function LoadProjectFiles():Promise<Array<main.Video>>;

export function LoadTimeline():Promise<video.Timeline>;

export function MarkAllLossless():Promise<void>;

export function OpenFile(arg1:string):Promise<void>;

export function ReadGaharaWorkspace():Promise<Array<string>>;
Expand All @@ -63,3 +65,5 @@ export function SetProjectDirectory(arg1:string):Promise<void>;
export function SplitInterval(arg1:string,arg2:number,arg3:number,arg4:number):Promise<Array<video.VideoNode>>;

export function ToggleLossless(arg1:number):Promise<void>;

export function UnmarkAllLossless():Promise<void>;
8 changes: 8 additions & 0 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -121,3 +125,7 @@ export function SplitInterval(arg1, arg2, arg3, arg4) {
export function ToggleLossless(arg1) {
return window['go']['main']['App']['ToggleLossless'](arg1);
}

export function UnmarkAllLossless() {
return window['go']['main']['App']['UnmarkAllLossless']();
}
29 changes: 29 additions & 0 deletions internal/video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ 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_UNMARK_ALL_LOSSLESS: umarks all the video nodes marked as lossless
EVT_UNMARK_ALL_LOSSLESS = "evt_unmark_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)
Expand Down Expand Up @@ -242,6 +246,31 @@ 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) UnmarkAllLossless() 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 = false
}

return nil

}

func (tl *Timeline) Split(eventType string, pos int, start, end float64) ([]VideoNode, error) {
nodes := []VideoNode{}
if pos < 0 || pos >= len(tl.VideoNodes) {
Expand Down
8 changes: 8 additions & 0 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ func (a *App) ToggleLossless(pos int) error {
return a.Timeline.ToggleLossless(pos)
}

func (a *App) MarkAllLossless() error {
return a.Timeline.MarkAllLossless()
}

func (a *App) UnmarkAllLossless() error {
return a.Timeline.UnmarkAllLossless()
}

// ResetTimeline: cleanup timeline state in memory
func (a *App) ResetTimeline() {
a.Timeline = video.NewTimeline()
Expand Down

0 comments on commit e291d65

Please sign in to comment.