gif retry respects budget priority (resolution=only adjust fps, framerate=only adjust resolution, balanced=adjust both), gif colors factored into size estimate, overlay queries aspect ratio from rust on resize instead of relying on cross-window events

This commit is contained in:
2026-05-27 21:34:52 +03:00
parent 2d060fe8f9
commit 1c89bb6b0f
4 changed files with 44 additions and 38 deletions
+13 -19
View File
@@ -15,6 +15,7 @@
let timer: number | null = null
let lockedRatio: number | null = null
let resizeDebounce: number | null = null
let enforcing = false
onMount(() => {
const updateSize = async () => {
@@ -23,11 +24,19 @@
width = Math.round(sz.width / sf)
height = Math.round(sz.height / sf)
}
// Query aspect ratio from Rust on startup
const syncRatio = async () => {
try { lockedRatio = await invoke<number | null>("get_overlay_aspect") } catch {}
}
updateSize()
syncRatio()
let cleanup: (() => void)[] = []
win.onResized(async () => {
if (enforcing) return
await updateSize()
// Re-sync ratio in case it changed
await syncRatio()
if (lockedRatio === null) return
if (resizeDebounce !== null) clearTimeout(resizeDebounce)
resizeDebounce = window.setTimeout(async () => {
@@ -35,30 +44,15 @@
const targetH = Math.round(width / ratio)
const minH = 90
const clampedH = Math.max(minH, targetH)
if (Math.abs(clampedH - height) > 1) {
if (Math.abs(clampedH - height) > 2) {
enforcing = true
try {
await win.setSize({ type: "Logical", width, height: clampedH })
await updateSize()
} catch {}
enforcing = false
}
}, 150)
}).then(fn => cleanup.push(fn))
listen<{ ratio: number | null }>("overlay-aspect-lock", async (e) => {
lockedRatio = e.payload.ratio
if (lockedRatio !== null) {
// Enforce ratio on current size immediately
await updateSize()
const targetH = Math.round(width / lockedRatio)
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 {}
}
}
}, 80)
}).then(fn => cleanup.push(fn))
listen<{ phase: "idle"|"recording"|"paused"; fps: number }>(