fps selector on idle screen, lower gif fps minimum, 16:9 preset, aspect ratio lock on frame resize, gif budget mode (resolution/framerate/balanced priority), fix asset protocol scope

This commit is contained in:
2026-05-27 19:35:40 +03:00
parent e4141f8be8
commit 2b3f7e433c
7 changed files with 220 additions and 41 deletions
+28 -2
View File
@@ -13,6 +13,8 @@
let fps: number = $state(30)
let elapsed: number = $state(0)
let timer: number | null = null
let lockedRatio: number | null = null
let resizeDebounce: number | null = null
onMount(() => {
const updateSize = async () => {
@@ -24,7 +26,27 @@
updateSize()
let cleanup: (() => void)[] = []
win.onResized(updateSize).then(fn => cleanup.push(fn))
win.onResized(async () => {
await updateSize()
if (lockedRatio === null) return
if (resizeDebounce !== null) clearTimeout(resizeDebounce)
resizeDebounce = window.setTimeout(async () => {
const ratio = lockedRatio!
const targetH = Math.round(width / ratio)
const minH = 90
const clampedH = Math.max(minH, targetH)
if (Math.abs(clampedH - height) > 1) {
try {
await win.setSize({ type: "Logical", width, height: clampedH })
await updateSize()
} catch {}
}
}, 150)
}).then(fn => cleanup.push(fn))
listen<{ ratio: number | null }>("overlay-aspect-lock", (e) => {
lockedRatio = e.payload.ratio
}).then(fn => cleanup.push(fn))
listen<{ phase: "idle"|"recording"|"paused"; fps: number }>(
"recording-state", (e) => {
@@ -49,7 +71,11 @@
try { await invoke("close_window_picker") } catch {}
}).then(fn => cleanup.push(fn))
return () => { stopTimer(); cleanup.forEach(fn => fn()) }
return () => {
stopTimer()
if (resizeDebounce !== null) clearTimeout(resizeDebounce)
cleanup.forEach(fn => fn())
}
})
function startTimer() {