Skip to content

Commit

Permalink
upt
Browse files Browse the repository at this point in the history
  • Loading branch information
k1nho committed Aug 28, 2024
1 parent a98b72a commit b8dc50a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func (a *App) AddTrack() {
a.Timeline.AddTrack()
}

func (a *App) RemoveTrack(id int) error {
return a.Timeline.RemoveTrack(id)
func (a *App) RemoveTrack(tid int) error {
return a.Timeline.RemoveTrack(tid)
}

func (a *App) OpenFile(filepath string) error {
Expand Down Expand Up @@ -405,6 +405,10 @@ func (a *App) EnableVideoMenus() {
vimCommandsMenu.AddText("Add Timeline Track", keys.Shift("t"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_ADD_TRACK)
})
vimCommandsMenu.AddText("Remove Timeline Track", keys.Shift("d"), func(cd *menu.CallbackData) {
wruntime.EventsEmit(a.ctx, video.EVT_REMOVE_TRACK)
})

vimCommandsMenu.AddText("Save Timeline", keys.Shift("w"), func(cd *menu.CallbackData) {
err := a.SaveTimeline()
if err != nil {
Expand Down
21 changes: 19 additions & 2 deletions frontend/src/ToolingLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
AddTrack,
RemoveInterval,
RemoveTrack,
SplitInterval,
} from "../wailsjs/go/main/App";
import TrashIcon from "./icons/TrashIcon.svelte";
Expand All @@ -31,8 +32,12 @@
setClipRegister,
setActionMsg,
} = toolingStore;
const { addTrack, removeVideoFromTrack, removeAndAddIntervalToTrack } =
trackStore;
const {
addTrack,
removeTrack,
removeVideoFromTrack,
removeAndAddIntervalToTrack,
} = trackStore;
let executeEdit = false;
Expand All @@ -46,6 +51,13 @@
});
}
function handleRemoveTrack() {
const tid = $trackCursorIdx;
RemoveTrack(tid).then(() => {
removeTrack(tid);
});
}
function handleTwoCut() {
if ($editMode === "timeline" && $timelineNode) {
SplitInterval(
Expand Down Expand Up @@ -128,12 +140,17 @@
EventsOn("evt_add_track", () => {
handleAddTrack();
});
EventsOn("evt_remove_track", () => {
handleRemoveTrack();
});
onDestroy(() => {
EventsOff(
"evt_toggle_vim_mode",
"evt_change_vim_mode",
"evt_splitclip_edit",
"evt_execute_edit",
"evt_add_track",
"evt_remove_track",
);
});
</script>
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ function createTracksStore() {
});
}

function removeTrack(tid: number) {
update((tracks) => {
if (tid >= 0 && tid < tracks.length) {
tracks.splice(tid, 1);
}
return tracks;
});
}

function addVideoToTrack(
tid: number,
pos: number,
Expand Down Expand Up @@ -302,6 +311,7 @@ function createTracksStore() {
getClipPosInTrack,
setTrackTime,
addTrack,
removeTrack,
addVideoToTrack,
removeVideoFromTrack,
removeAndAddIntervalToTrack,
Expand Down
2 changes: 2 additions & 0 deletions internal/video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const (
EVT_YANK_CLIP = "evt_yank_clip"
// EVT_ADD_TRACK: adds a new track
EVT_ADD_TRACK = "evt_add_track"
// EVT_REMOVE_TRACK: removes a track
EVT_REMOVE_TRACK = "evt_remove_track"
// EVT_OPEN_RENAME_CLIP_MODAL: opens the rename clip modal
EVT_OPEN_RENAME_CLIP_MODAL = "evt_open_rename_clip_modal"
// EVT_INTERVAL_CUT: interval cut event
Expand Down

0 comments on commit b8dc50a

Please sign in to comment.