diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index bb41f3d..36596dc 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -604,6 +604,21 @@ fn hide_overlay(app: AppHandle) -> Result<(), String> { win.hide().map_err(|e| e.to_string()) } +#[tauri::command] +fn set_overlay_size(app: AppHandle, width: u32, height: u32) -> Result<(), String> { + use tauri::{LogicalSize, Size}; + let win = app + .get_webview_window("overlay") + .ok_or_else(|| "overlay window not found".to_string())?; + // Add the titlebar + border to the logical content size so the captured + // region matches the requested preset. + let final_w = width as f64 + (OVERLAY_BORDER_LOGICAL_PX * 2.0); + let final_h = + height as f64 + OVERLAY_TITLEBAR_LOGICAL_PX + (OVERLAY_BORDER_LOGICAL_PX * 2.0); + win.set_size(Size::Logical(LogicalSize::new(final_w, final_h))) + .map_err(|e| e.to_string()) +} + #[tauri::command] fn get_overlay_rect(app: AppHandle) -> Result { let win = app @@ -857,6 +872,7 @@ pub fn run() { open_url, show_overlay, hide_overlay, + set_overlay_size, get_overlay_rect, ]) .run(tauri::generate_context!()) diff --git a/src/lib/Main.svelte b/src/lib/Main.svelte index 4dcfe51..0a383f5 100644 --- a/src/lib/Main.svelte +++ b/src/lib/Main.svelte @@ -271,10 +271,20 @@ capture frame: {useFrame ? "on" : "off"} + {#if useFrame} +
+ preset: + + + + +
+ {/if}

{#if useFrame} The green frame stays visible during recording but is excluded from - the capture itself. Drag it to position the region. + the capture itself. Drag it to position the region, or pick a preset + above for common dimensions. {:else} Captures your full primary monitor. Toggle the capture frame on to record a region instead. @@ -617,6 +627,17 @@ border-color: #4a8; color: #4a8; } + .presets { + display: flex; + align-items: center; + gap: 0.4rem; + margin: 0.75rem 0 0; + justify-content: center; + } + .presets-label { + font-size: 0.8rem; + color: #888; + } button.stop { background: #c33; border-color: #c33; diff --git a/src/lib/api.ts b/src/lib/api.ts index 76c639d..94c115c 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -109,6 +109,8 @@ export const api = { revealInExplorer: (path: string) => invoke("reveal_in_explorer", { path }), showOverlay: () => invoke("show_overlay"), hideOverlay: () => invoke("hide_overlay"), + setOverlaySize: (width: number, height: number) => + invoke("set_overlay_size", { width, height }), getOverlayRect: () => invoke("get_overlay_rect"), extractThumbnails: (fps: number) => invoke("extract_thumbnails", { fps }),