region capture overlay window
This commit is contained in:
+43
-3
@@ -25,6 +25,7 @@
|
||||
let targetMB: number = $state(8)
|
||||
let exportResult: ExportResult | null = $state(null)
|
||||
let errMsg: string | null = $state(null)
|
||||
let useFrame: boolean = $state(false)
|
||||
|
||||
onMount(async () => {
|
||||
config = await api.getConfig()
|
||||
@@ -46,15 +47,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleFrame() {
|
||||
useFrame = !useFrame
|
||||
try {
|
||||
if (useFrame) await api.showOverlay()
|
||||
else await api.hideOverlay()
|
||||
} catch (e) {
|
||||
errMsg = String(e)
|
||||
useFrame = false
|
||||
}
|
||||
}
|
||||
|
||||
async function startRec() {
|
||||
errMsg = null
|
||||
elapsed = 0
|
||||
let crop = null
|
||||
if (useFrame) {
|
||||
try {
|
||||
crop = await api.getOverlayRect()
|
||||
await api.hideOverlay()
|
||||
} catch (e) {
|
||||
errMsg = String(e)
|
||||
return
|
||||
}
|
||||
}
|
||||
try {
|
||||
await api.startCapture()
|
||||
await api.startCapture({ crop })
|
||||
phase = "recording"
|
||||
tick()
|
||||
} catch (e) {
|
||||
errMsg = String(e)
|
||||
if (useFrame) {
|
||||
await api.showOverlay().catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +152,18 @@
|
||||
{#if phase === "idle"}
|
||||
<section class="controls">
|
||||
<button class="primary big" onclick={startRec}>start recording</button>
|
||||
<button class:on={useFrame} onclick={toggleFrame}>
|
||||
{useFrame ? "hide capture frame" : "show capture frame"}
|
||||
</button>
|
||||
</section>
|
||||
<p class="hint">
|
||||
Captures your primary monitor. Region capture and the draggable overlay
|
||||
come next.
|
||||
{#if useFrame}
|
||||
Drag the green frame on screen to position the region you want to
|
||||
capture. The frame hides automatically while recording.
|
||||
{:else}
|
||||
Captures your full primary monitor. Click "show capture frame" to draw
|
||||
a region instead.
|
||||
{/if}
|
||||
</p>
|
||||
{:else if phase === "recording"}
|
||||
<section class="recording">
|
||||
@@ -288,6 +321,8 @@
|
||||
.controls {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
.recording {
|
||||
@@ -326,6 +361,11 @@
|
||||
padding: 0.75rem 1.75rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
button.on {
|
||||
background: #1a2a24;
|
||||
border-color: #4a8;
|
||||
color: #4a8;
|
||||
}
|
||||
button.stop {
|
||||
background: #c33;
|
||||
border-color: #c33;
|
||||
|
||||
Reference in New Issue
Block a user