Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

use editor render options when exporting

Brendan Allanb5669f3094ae
diff --git a/apps/desktop-solid/src-tauri/src/lib.rs b/apps/desktop-solid/src-tauri/src/lib.rs
index 75ec6ffb3..47e107cac 100644
--- a/apps/desktop-solid/src-tauri/src/lib.rs
+++ b/apps/desktop-solid/src-tauri/src/lib.rs
@@ -900,28 +900,14 @@ async fn render_to_file(
project: ProjectConfiguration,
progress_channel: tauri::ipc::Channel<RenderProgress>,
) {
- let video_dir = app
- .path()
- .app_data_dir()
- .unwrap()
- .join("recordings")
- .join(format!("{video_id}.cap"));
-
- let screen_recording_path = video_dir.join("content/display.mp4");
- let camera_recording_path = video_dir.join("content/camera.mp4");
+ let editor_instance = EditorInstance::get(&app, video_id).await;
cap_rendering::render_video_to_file(
- RenderOptions {
- screen_recording_path: screen_recording_path.clone(),
- camera_recording_path: camera_recording_path.clone(),
- camera_size: (1920, 1080),
- screen_size: (3456, 2234),
- output_size: (1920, 1080),
- },
+ editor_instance.render_constants.options.clone(),
project,
output_path,
- OnTheFlyVideoDecoderActor::new(screen_recording_path),
- OnTheFlyVideoDecoderActor::new(camera_recording_path),
+ editor_instance.screen_decoder.clone(),
+ editor_instance.camera_decoder.clone(),
move |current_frame| {
progress_channel
.send(RenderProgress::FrameRendered { current_frame })
diff --git a/apps/desktop-solid/src/routes/prev-recordings.tsx b/apps/desktop-solid/src/routes/prev-recordings.tsx
index 2bdb65b52..40b45a105 100644
--- a/apps/desktop-solid/src/routes/prev-recordings.tsx
+++ b/apps/desktop-solid/src/routes/prev-recordings.tsx
@@ -2,6 +2,7 @@ import { createQuery } from "@tanstack/solid-query";
import { convertFileSrc } from "@tauri-apps/api/core";
import { cx } from "cva";
import {
+ type Accessor,
type ComponentProps,
For,
Show,
@@ -14,9 +15,9 @@ import createPresence from "solid-presence";
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
import Tooltip from "@corvu/tooltip";
import { Button } from "@cap/ui-solid";
+import { createElementBounds } from "@solid-primitives/bounds";
import { commands, events } from "../utils/tauri";
-import { getCurrentWindow } from "@tauri-apps/api/window";
export default function () {
const recordings = createQuery(() => ({
@@ -44,6 +45,8 @@ export default function () {
const visibleRecordings = () =>
showAll() ? recordings.data : recordings.data?.slice(0, 5);
+ createFakeWindowBounds(showMoreRef, () => "show-more-btn");
+
return (
<div class="w-screen h-[100vh] bg-transparent relative">
<div class="absolute left-0 bottom-0 flex flex-col-reverse pl-[40px] pb-[80px] gap-4 h-full overflow-y-auto">
@@ -98,24 +101,7 @@ export default function () {
});
});
- createEffect(
- on([i, showMoreRef], () => {
- const bounds = ref()?.getBoundingClientRect();
- const showMoreBounds = showMoreRef()?.getBoundingClientRect();
- if (!bounds || !showMoreBounds) return;
-
- commands.setFakeWindowBounds(recording, {
- x: bounds.x,
- y: bounds.y,
- width: bounds.width,
- height: bounds.height + showMoreBounds.height,
- });
- })
- );
-
- onCleanup(() => {
- commands.removeFakeWindow(recording);
- });
+ createFakeWindowBounds(ref, () => recording);
return (
<Show when={present()}>
@@ -177,7 +163,7 @@ export default function () {
removedCount() === visibleRecordings()?.length &&
!hasClosedWindow()
) {
- commands.closePreviousRecordingsWindow();
+ window.close();
setHasClosedWindow(true);
}
}}
@@ -368,3 +354,23 @@ const TooltipIconButton = (
</Tooltip>
);
};
+
+function createFakeWindowBounds(
+ ref: () => HTMLElement | undefined | null,
+ key: Accessor<string>
+) {
+ const bounds = createElementBounds(ref);
+
+ createEffect(() => {
+ commands.setFakeWindowBounds(key(), {
+ x: bounds.left ?? 0,
+ y: bounds.top ?? 0,
+ width: bounds.width ?? 0,
+ height: bounds.height ?? 0,
+ });
+ });
+
+ onCleanup(() => {
+ commands.removeFakeWindow(key());
+ });
+}