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:
+28
-2
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user