Skip to content
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
91 changes: 49 additions & 42 deletions apps/desktop/src/routes/editor/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,50 +146,57 @@ export function Player() {
};

// Register keyboard shortcuts in one place
useEditorShortcuts(
() => document.activeElement === document.body,
[
{
combo: "S",
handler: () =>
setEditorState(
"timeline",
"interactMode",
editorState.timeline.interactMode === "split" ? "seek" : "split",
),
},
{
combo: "Mod+=",
handler: () =>
editorState.timeline.transform.updateZoom(
editorState.timeline.transform.zoom / 1.1,
editorState.playbackTime,
),
},
{
combo: "Mod+-",
handler: () =>
editorState.timeline.transform.updateZoom(
editorState.timeline.transform.zoom * 1.1,
editorState.playbackTime,
),
},
{
combo: "Space",
handler: async () => {
const prevTime = editorState.previewTime;

if (!editorState.playing) {
if (prevTime !== null) setEditorState("playbackTime", prevTime);

await commands.seekTo(Math.floor(editorState.playbackTime * FPS));
}
useEditorShortcuts(() => {
const el = document.activeElement;
if (!el) return true;
const tagName = el.tagName.toLowerCase();
const isContentEditable = el.getAttribute("contenteditable") === "true";
return !(
tagName === "input" ||
tagName === "textarea" ||
isContentEditable
);
}, [
{
combo: "S",
handler: () =>
setEditorState(
"timeline",
"interactMode",
editorState.timeline.interactMode === "split" ? "seek" : "split",
),
},
{
combo: "Mod+=",
handler: () =>
editorState.timeline.transform.updateZoom(
editorState.timeline.transform.zoom / 1.1,
editorState.playbackTime,
),
},
{
combo: "Mod+-",
handler: () =>
editorState.timeline.transform.updateZoom(
editorState.timeline.transform.zoom * 1.1,
editorState.playbackTime,
),
},
{
combo: "Space",
handler: async () => {
const prevTime = editorState.previewTime;

if (!editorState.playing) {
if (prevTime !== null) setEditorState("playbackTime", prevTime);

await commands.seekTo(Math.floor(editorState.playbackTime * FPS));
}

await handlePlayPauseClick();
},
await handlePlayPauseClick();
},
],
);
},
]);

return (
<div class="flex flex-col flex-1 rounded-xl border bg-gray-1 dark:bg-gray-2 border-gray-3">
Expand Down
135 changes: 72 additions & 63 deletions apps/desktop/src/routes/editor/Timeline/ClipTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,30 +309,34 @@ export function ClipTrack(
if (m.type === "single") return m.value;
})()}
>
{(marker) => (
<div class="overflow-hidden -top-8 z-10 h-7 rounded-full -translate-x-1/2">
<CutOffsetButton
value={(() => {
const m = marker();
return m.type === "time" ? m.time : 0;
})()}
onClick={() => {
setProject(
"timeline",
"segments",
produce((s) => {
if (marker().type === "reset") {
s[i() - 1].end = s[i()].end;
s.splice(i(), 1);
} else {
s[i() - 1].end = s[i()].start;
}
}),
);
}}
/>
</div>
)}
{(markerValue) => {
const value = createMemo(() => {
const m = markerValue();
return m.type === "time" ? m.time : 0;
});

return (
<div class="overflow-hidden -top-8 z-10 h-7 rounded-full -translate-x-1/2">
<CutOffsetButton
value={value()}
onClick={() => {
setProject(
"timeline",
"segments",
produce((s) => {
if (markerValue().type === "reset") {
s[i() - 1].end = s[i()].end;
s.splice(i(), 1);
} else {
s[i() - 1].end = s[i()].start;
}
}),
);
}}
/>
</div>
);
}}
</Match>
<Match
when={(() => {
Expand All @@ -345,16 +349,16 @@ export function ClipTrack(
return m.right;
})()}
>
{(marker) => {
const markerValue = marker();
{(markerValue) => {
const value = createMemo(() => {
const m = markerValue();
return m.type === "time" ? m.time : 0;
});

return (
<div class="flex absolute -top-8 flex-row w-0 h-7 rounded-full">
<CutOffsetButton
value={
markerValue.type === "time"
? markerValue.time
: 0
}
value={value()}
class="-left-px absolute rounded-r-full !pl-1.5 rounded-tl-full"
onClick={() => {
setProject(
Expand Down Expand Up @@ -684,34 +688,38 @@ export function ClipTrack(
return m.left;
})()}
>
{(marker) => (
<div
class="absolute w-0 z-10 h-full *:absolute"
style={{
transform: `translateX(${segmentX() + segmentWidth()}px)`,
}}
>
<div class="w-[2px] bottom-0 -top-2 rounded-full from-red-300 to-transparent bg-gradient-to-b -translate-x-1/2" />
<div class="flex absolute -top-8 flex-row w-0 h-7 rounded-full">
<CutOffsetButton
value={(() => {
const m = marker();
return m.type === "time" ? m.time : 0;
})()}
class="-right-px absolute rounded-l-full !pr-1.5 rounded-tr-full"
onClick={() => {
setProject(
"timeline",
"segments",
i(),
"end",
segmentRecording().display.duration,
);
}}
/>
{(markerValue) => {
const value = createMemo(() => {
const m = markerValue();
return m.type === "time" ? m.time : 0;
});

return (
<div
class="absolute w-0 z-10 h-full *:absolute"
style={{
transform: `translateX(${segmentX() + segmentWidth()}px)`,
}}
>
<div class="w-[2px] bottom-0 -top-2 rounded-full from-red-300 to-transparent bg-gradient-to-b -translate-x-1/2" />
<div class="flex absolute -top-8 flex-row w-0 h-7 rounded-full">
<CutOffsetButton
value={value()}
class="-right-px absolute rounded-l-full !pr-1.5 rounded-tr-full"
onClick={() => {
setProject(
"timeline",
"segments",
i(),
"end",
segmentRecording().display.duration,
);
}}
/>
</div>
</div>
</div>
)}
);
}}
</Show>
</>
);
Expand Down Expand Up @@ -770,11 +778,12 @@ function CutOffsetButton(props: {
)}
onClick={() => props.onClick?.()}
>
{props.value === 0 ? (
<IconCapScissors class="size-3.5" />
) : (
formatTime(props.value)
)}
<Show
when={props.value !== 0}
fallback={<IconCapScissors class="size-3.5" />}
>
{formatTime(props.value)}
</Show>
</button>
);
}
Expand Down