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 d7bbecb
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/components/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -69,6 +70,7 @@
setTrackTime,
renameClipInTrack,
toggleLosslessMarkofClip,
markAllLossless,
resetTrackStore,
} = trackStore;
Expand Down Expand Up @@ -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",
Expand All @@ -411,6 +421,7 @@
"evt_zoom_timeline",
"evt_saved_timeline",
"evt_toggle_lossless",
"evt_mark_all_lossless",
);
resetTrackStore();
resetToolingStore();
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -250,6 +260,7 @@ function createTracksStore() {
removeRIDReferencesFromTrack,
renameClipInTrack,
toggleLosslessMarkofClip,
markAllLossless,
trackDuration,
resetTrackStore,
};
Expand Down
2 changes: 2 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 Down
4 changes: 4 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
15 changes: 15 additions & 0 deletions internal/video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d7bbecb

Please sign in to comment.