visual picker: marching ants, DWM-aware overlay sizing
This commit is contained in:
+36
-9
@@ -14,17 +14,28 @@
|
||||
let scale: number = $state(1)
|
||||
let originX: number = $state(0)
|
||||
let originY: number = $state(0)
|
||||
let dpr: number = $state(1)
|
||||
let innerW: number = $state(0)
|
||||
let innerH: number = $state(0)
|
||||
|
||||
onMount(() => {
|
||||
const win = getCurrentWebviewWindow()
|
||||
let unlistenHover: (() => void) | null = null
|
||||
let unlistenMoved: (() => void) | null = null
|
||||
|
||||
void (async () => {
|
||||
const refreshOrigin = async () => {
|
||||
scale = await win.scaleFactor()
|
||||
const pos = await win.outerPosition()
|
||||
const pos = await win.innerPosition()
|
||||
originX = pos.x
|
||||
originY = pos.y
|
||||
dpr = window.devicePixelRatio
|
||||
innerW = window.innerWidth
|
||||
innerH = window.innerHeight
|
||||
}
|
||||
|
||||
void (async () => {
|
||||
await refreshOrigin()
|
||||
unlistenMoved = await win.onMoved(refreshOrigin)
|
||||
unlistenHover = await listen<Rect>("picker-hover", (e) => {
|
||||
hover = e.payload
|
||||
})
|
||||
@@ -32,6 +43,7 @@
|
||||
|
||||
return () => {
|
||||
unlistenHover?.()
|
||||
unlistenMoved?.()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -52,7 +64,14 @@
|
||||
<div class="dims">{hover.width} x {hover.height}</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="hint">click a window to snap. Esc to cancel.</div>
|
||||
<div class="hint">
|
||||
origin=({originX},{originY}) scale={scale} dpr={dpr} inner={innerW}x{innerH} ·
|
||||
{#if hover}
|
||||
hover {hover.width}x{hover.height} @ ({hover.x},{hover.y})
|
||||
{:else}
|
||||
move mouse over a window. Esc to cancel.
|
||||
{/if}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
@@ -73,18 +92,26 @@
|
||||
.dim {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(10, 14, 12, 0.18);
|
||||
background: rgba(10, 14, 12, 0.15);
|
||||
}
|
||||
.frame {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
border: 2px dashed #4a8;
|
||||
background: rgba(74, 170, 136, 0.08);
|
||||
animation: march 0.6s linear infinite;
|
||||
pointer-events: none;
|
||||
background-color: transparent;
|
||||
background-image:
|
||||
linear-gradient(90deg, #4a8 50%, transparent 50%),
|
||||
linear-gradient(90deg, #4a8 50%, transparent 50%),
|
||||
linear-gradient(0deg, #4a8 50%, transparent 50%),
|
||||
linear-gradient(0deg, #4a8 50%, transparent 50%);
|
||||
background-position: 0 0, 0 100%, 0 0, 100% 0;
|
||||
background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
|
||||
background-size: 12px 2px, 12px 2px, 2px 12px, 2px 12px;
|
||||
animation: march 0.4s linear infinite;
|
||||
}
|
||||
@keyframes march {
|
||||
to { background-position: 16px 0; }
|
||||
to {
|
||||
background-position: 12px 0, -12px 100%, 0 -12px, 100% 12px;
|
||||
}
|
||||
}
|
||||
.dims {
|
||||
position: absolute;
|
||||
|
||||
Reference in New Issue
Block a user