diff --git a/app.go b/app.go index cab11e1..7bee719 100644 --- a/app.go +++ b/app.go @@ -401,6 +401,10 @@ func (a *App) EnableVideoMenus() { vimCommandsMenu.AddText("Zoom Out Timeline", keys.Shift("-"), func(cd *menu.CallbackData) { wruntime.EventsEmit(a.ctx, video.EVT_ZOOM_TIMELINE, "out") }) + + vimCommandsMenu.AddText("Add Timeline Track", keys.Shift("t"), func(cd *menu.CallbackData) { + wruntime.EventsEmit(a.ctx, video.EVT_ADD_TRACK) + }) vimCommandsMenu.AddText("Save Timeline", keys.Shift("w"), func(cd *menu.CallbackData) { err := a.SaveTimeline() if err != nil { diff --git a/frontend/src/ToolingLayout.svelte b/frontend/src/ToolingLayout.svelte index 0640c14..c0f5443 100644 --- a/frontend/src/ToolingLayout.svelte +++ b/frontend/src/ToolingLayout.svelte @@ -124,6 +124,10 @@ EventsOn("evt_execute_edit", () => { if ($vimMode) handleEditAction(); }); + + EventsOn("evt_add_track", () => { + handleAddTrack(); + }); onDestroy(() => { EventsOff( "evt_toggle_vim_mode", diff --git a/frontend/src/components/Timeline.svelte b/frontend/src/components/Timeline.svelte index 99c5054..ea3bfca 100644 --- a/frontend/src/components/Timeline.svelte +++ b/frontend/src/components/Timeline.svelte @@ -24,11 +24,16 @@ } from "../../wailsjs/go/main/App"; import RenameIcon from "../icons/RenameIcon.svelte"; import SearchList from "../components/SearchList.svelte"; - import { NODE_AUDIO, NODE_PLACEHOLDER, NODE_VIDEO } from "../lib/utils"; + import { NODE_AUDIO, NODE_PLACEHOLDER } from "../lib/utils"; import VideoNode from "./VideoNode.svelte"; import AudioNode from "./AudioNode.svelte"; import PlaceholderNode from "./PlaceholderNode.svelte"; - import { isNodeVideo, type TimelineNode } from "../lib/timeline"; + import { + scrollToNode, + isNodeVideo, + type TimelineNode, + scrollToTrack, + } from "../lib/timeline"; const { isOpen, close, open } = createBooleanStore(false); const { setVideoSrc, currentTime, setCurrentTime } = videoStore; @@ -325,23 +330,9 @@ } } - function scrollToNode(node: HTMLDivElement) { - const timelineContainer = document.getElementById("timeline"); - const timelineRect = timelineContainer.getBoundingClientRect(); - const nodeRect = node.getBoundingClientRect(); - - const isNodeVisible = - nodeRect.left >= timelineRect.left && - nodeRect.right <= timelineRect.right; - - if (!isNodeVisible) { - const scrollX = - nodeRect.left - timelineRect.left + timelineContainer.scrollLeft; - timelineContainer.scrollTo({ - left: scrollX, - behavior: "smooth", - }); - } + function handleKeybindTrackMove() { + const trackNode = document.getElementById(`track-${$trackCursorIdx}`); + if (trackNode) scrollToTrack(trackNode); } EventsOn("evt_open_rename_clip_modal", () => { @@ -358,6 +349,7 @@ moveTrackCursor(inc); moveClipCursor(0); handleKeybindTrackClipMove(); + handleKeybindTrackMove(); }); EventsOn("evt_clip_move", (inc: number) => { moveClipCursor(inc); @@ -394,7 +386,7 @@ InsertInterval( $trackCursorIdx, $timelineNodePos, - NODE_VIDEO, + $timelineNode.type, $clipRegister.rid, $clipRegister.name, $clipRegister.start, @@ -473,7 +465,7 @@