Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(desktop): render caption overlay and simplify crop dialog flow

Richie McIlroy9ac7339e6a34
diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsx
index 529a18554..550c27e33 100644
--- a/apps/desktop/src/routes/editor/Player.tsx
+++ b/apps/desktop/src/routes/editor/Player.tsx
@@ -11,6 +11,7 @@ import Tooltip from "~/components/Tooltip";
import { captionsStore } from "~/store/captions";
import { commands } from "~/utils/tauri";
import AspectRatioSelect from "./AspectRatioSelect";
+import { CaptionOverlay } from "./CaptionOverlay";
import { createCaptionTrackSegments } from "./captions";
import {
type EditorPreviewQuality,
@@ -33,14 +34,6 @@ import {
import { useEditorShortcuts } from "./useEditorShortcuts";
import { formatTime } from "./utils";
-function logCropProfile(
- stage: string,
- data: Record<string, number | string | boolean | null> = {},
-) {
- if (!import.meta.env.DEV) return;
- console.info("[crop-profile]", stage, data);
-}
-
export function PlayerContent() {
const {
project,
@@ -51,7 +44,6 @@ export function PlayerContent() {
setEditorState,
zoomOutLimit,
setProject,
- canvasControls,
previewResolutionBase,
previewQuality,
setPreviewQuality,
@@ -158,31 +150,7 @@ export function PlayerContent() {
};
const cropDialogHandler = async () => {
- const startedAt = performance.now();
const display = editorInstance.recordings.segments[0].display;
- const controls = canvasControls();
- let previewUrl: string | null = null;
- logCropProfile("click", {
- recordingDurationSec: Math.round(editorInstance.recordingDuration),
- playbackTimeSec: Number(editorState.playbackTime.toFixed(3)),
- displayWidth: display.width,
- displayHeight: display.height,
- wasPlaying: editorState.playing,
- });
- if (controls?.hasRenderedFrame()) {
- try {
- const previewFrame = await controls.captureFrame();
- if (previewFrame) {
- previewUrl = URL.createObjectURL(previewFrame);
- }
- } catch (error) {
- console.warn("Preview frame capture failed:", error);
- }
- }
- logCropProfile("preview-frame-captured", {
- elapsedMs: Number((performance.now() - startedAt).toFixed(2)),
- available: previewUrl !== null,
- });
setDialog({
open: true,
type: "crop",
@@ -195,15 +163,8 @@ export function PlayerContent() {
y: display.height,
}),
},
- previewUrl,
- });
- logCropProfile("dialog-opened", {
- elapsedMs: Number((performance.now() - startedAt).toFixed(2)),
});
await commands.stopPlayback();
- logCropProfile("playback-stopped", {
- elapsedMs: Number((performance.now() - startedAt).toFixed(2)),
- });
setEditorState("playing", false);
};
@@ -403,6 +364,7 @@ export function PlayerContent() {
await commands.stopPlayback();
setEditorState("playing", false);
setEditorState("playbackTime", 0);
+ editorState.timeline.transform.setPosition(0);
}}
>
<IconCapPrev class="text-gray-12 size-3" />
@@ -662,6 +624,7 @@ function PreviewCanvas() {
/>
<Show when={hasFrame()}>
<MaskOverlay size={size()} />
+ <CaptionOverlay size={size()} />
<TextOverlay size={size()} />
<SplitScreenOverlay size={size()} />
<PerformanceOverlay size={size()} />