Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement view change keybinds #38

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ func (a *App) SetDefaultAppMenu() {
wruntime.MenuUpdateApplicationMenu(a.ctx)
}

// EnableExportMenus: it enables the menus for the export layout view
func (a *App) EnableExportMenus() {
exportMenu := menu.NewMenu()
exportMenu.AddText("Back to Project", keys.Shift("b"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_CHANGE_ROUTE, "video")
})

appMenu := a.AppMenu()
appMenu.Items = append(appMenu.Items, &menu.MenuItem{
Label: "Export",
SubMenu: exportMenu,
})
wruntime.MenuSetApplicationMenu(a.ctx, appMenu)
wruntime.MenuUpdateApplicationMenu(a.ctx)
}

// EnableVideoMenus: It enables the menus for the video layout view
func (a *App) EnableVideoMenus() {
timelineMenu := menu.NewMenu()
Expand All @@ -280,6 +296,13 @@ func (a *App) EnableVideoMenus() {
timelineMenu.AddText("Mark/Unmark Lossless Export", keys.Key("m"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_TOGGLE_LOSSLESS)
})
timelineMenu.AddText("Change Project", keys.Shift("b"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_CHANGE_ROUTE, "main")
})

timelineMenu.AddText("Export Project", keys.Shift("e"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_CHANGE_ROUTE, "export")
})
timelineMenu.AddText("Toggle Vim Mode", keys.CmdOrCtrl("i"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_TOGGLE_VIM_MODE)
wruntime.EventsEmit(a.ctx, video.EVT_TRACK_MOVE, 0)
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<script lang="ts">
import VideoLayout from "./VideoLayout.svelte";
import MainMenuLayout from "./MainMenuLayout.svelte";
import { router } from "./stores";
import { exportOptionsStore, router } from "./stores";
import ExportMenuLayout from "./ExportMenuLayout.svelte";
import { EventsOff, EventsOn } from "../wailsjs/runtime/runtime";
import { onDestroy } from "svelte";
const { route, setRoute } = router;
const { isProcessingVid } = exportOptionsStore;

const { route } = router;
EventsOn("evt_change_route", (to: string) => {
switch ($route) {
case "video":
setRoute(to);
break;
case "export":
if (!$isProcessingVid) setRoute(to);
}
});

onDestroy(() => {
EventsOff("evt_change_route");
});
</script>

<div class="h-screen">
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/ExportMenuLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
FFmpegQuery,
ToggleLossless,
OpenFile,
EnableExportMenus,
} from "../wailsjs/go/main/App";
import { exportOptionsStore, router, projectName } from "./stores";
import { onDestroy, onMount } from "svelte";
Expand Down Expand Up @@ -54,6 +55,7 @@
videoNodes = [...timeline.video_nodes];
})
.catch(() => console.log("could not load timeline"));
EnableExportMenus();
});

$: {
Expand Down Expand Up @@ -123,21 +125,21 @@
setProgressPercentage(0);
setIsProcessingVid(false);
});
EventsOn("evt_export_msg", (msg: string) => {
setProcessingMsg(msg);
});
EventsOn("evt_ffmpeg_result", (result: any) => {
addProcessingResult(result);
});
EventsOn("evt_export_msg", (msg: string) => {
setProcessingMsg(msg);
});

onDestroy(() => {
resetExportOptionsStore();
EventsOff(
"evt_encoding_progress",
"evt_ffmpeg_exec_ended",
"evt_ffmpeg_result",
"evt_export_msg",
);
resetExportOptionsStore();
});
</script>

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/VideoLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
setVideoFilesError,
resetVideoFiles,
} = videoFiles;
const { setRoute } = router;
const { setRoute, route } = router;
const { actionMessage, setActionMsg } = toolingStore;

onMount(() => {
Expand Down Expand Up @@ -124,7 +124,7 @@
});

onDestroy(() => {
SetDefaultAppMenu();
if ($route === "main") SetDefaultAppMenu();
EventsOff(
"evt_proxy_file_created",
"evt_error_msg",
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 @@ -14,6 +14,8 @@ export function DeleteProjectFile(arg1:string):Promise<void>;

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

export function EnableExportMenus():Promise<void>;

export function EnableVideoMenus():Promise<void>;

export function FFmpegQuery(arg1:string,arg2:video.ProcessingOpts):Promise<void>;
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 @@ -22,6 +22,10 @@ export function DeleteRIDReferences(arg1) {
return window['go']['main']['App']['DeleteRIDReferences'](arg1);
}

export function EnableExportMenus() {
return window['go']['main']['App']['EnableExportMenus']();
}

export function EnableVideoMenus() {
return window['go']['main']['App']['EnableVideoMenus']();
}
Expand Down
3 changes: 2 additions & 1 deletion internal/video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const (
QUERY_CREATE_PROXY_FILE = "q_create_proxy_file"
QUERY_CREATE_THUMBNAIL = "q_create_thumbnail"
// Epsilon: margin for floating point checks
Epsilon = 1e-6
Epsilon = 1e-6
EVT_CHANGE_ROUTE = "evt_change_route"
// EVT_FFMPEG_RESULT: signals the result of a FFmpeg query in the form of a VideoProcessingResult
EVT_FFMPEG_RESULT = "evt_ffmpeg_result"
// EVT_FFMPEG_EXEC_ENDED: signals that the ffmpeg query has ended (does not indicate success of the query)
Expand Down
Loading