aspect ratio presets for capture frame
This commit is contained in:
@@ -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<CaptureRect, String> {
|
||||
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!())
|
||||
|
||||
Reference in New Issue
Block a user