Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Improve area selection (#1236)
Oscar Beaumont1581b9afbb48
diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex ec340b8cf..b5f4e3d96 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -21,6 +21,7 @@"@radix-ui/colors": "^3.0.0","@rive-app/canvas": "^2.26.7","@solid-primitives/bounds": "^0.0.122",+ "@solid-primitives/broadcast-channel": "^0.1.1","@solid-primitives/context": "^0.2.3","@solid-primitives/date": "^2.0.23","@solid-primitives/deep": "^0.2.9",diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex 524541418..47828293a 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -300,6 +300,9 @@ impl ShowCapWindow {let Some(display) = scap_targets::Display::from_id(display_id) else {return Err(tauri::Error::WindowNotFound);};+ let is_hovered_display = scap_targets::Display::get_containing_cursor()+ .map(|d| d.id())+ == Some(display.id());let title = CapWindowId::TargetSelectOverlay {display_id: display_id.clone(),@@ -310,7 +313,7 @@ impl ShowCapWindow {let mut window_builder = self.window_builder(app,- format!("/target-select-overlay?displayId={display_id}"),+ format!("/target-select-overlay?displayId={display_id}&isHoveredDisplay={is_hovered_display}"),).maximized(false).resizable(false)diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsxindex 90258054d..cecab14f9 100644--- a/apps/desktop/src/routes/target-select-overlay.tsx+++ b/apps/desktop/src/routes/target-select-overlay.tsx@@ -1,8 +1,10 @@import { Button } from "@cap/ui-solid";+import { makeBroadcastChannel } from "@solid-primitives/broadcast-channel";import {createEventListener,createEventListenerMap,} from "@solid-primitives/event-listener";+import { createWritableMemo } from "@solid-primitives/memo";import { useSearchParams } from "@solidjs/router";import { createQuery, useMutation } from "@tanstack/solid-query";import { emit } from "@tauri-apps/api/event";@@ -10,12 +12,13 @@ import { CheckMenuItem, Menu, Submenu } from "@tauri-apps/api/menu";import { cx } from "cva";import {type ComponentProps,- createEffect,+ createMemo,createRoot,createSignal,type JSX,Match,onCleanup,+ onMount,Show,Suspense,Switch,@@ -37,6 +40,19 @@ import {useRecordingOptions,} from "./(window-chrome)/OptionsContext";+const MIN_WIDTH = 200;+const MIN_HEIGHT = 100;++const EMPTY_BOUNDS = () => ({+ position: { x: 0, y: 0 },+ size: { width: 0, height: 0 },+});++const DEFAULT_BOUNDS = {+ position: { x: 100, y: 100 },+ size: { width: 400, height: 300 },+};+const capitalize = (str: string) => {return str.charAt(0).toUpperCase() + str.slice(1);};@@ -50,7 +66,11 @@ export default function () {}function Inner() {- const [params] = useSearchParams<{ displayId: DisplayId }>();+ const [params] = useSearchParams<{+ displayId: DisplayId;+ isHoveredDisplay: string;+ }>();+ const isHoveredDisplay = params.isHoveredDisplay === "true";const { rawOptions, setOptions } = createOptionsQuery();const [toggleModeSelect, setToggleModeSelect] = createSignal(false);@@ -93,37 +113,17 @@ function Inner() {params.displayId !== undefined && rawOptions.targetMode === "display",}));- const [bounds, _setBounds] = createStore({- position: { x: 0, y: 0 },- size: { width: 400, height: 300 },- });+ const [bounds, setBounds] = createStore(+ structuredClone(isHoveredDisplay ? DEFAULT_BOUNDS : EMPTY_BOUNDS()),+ );- const setBounds = (newBounds: typeof bounds) => {- const clampedBounds = {- position: {- x: Math.max(0, newBounds.position.x),- y: Math.max(0, newBounds.position.y),- },- size: {- width: Math.max(- 150,- Math.min(- window.innerWidth - Math.max(0, newBounds.position.x),- newBounds.size.width,- ),- ),- height: Math.max(- 150,- Math.min(- window.innerHeight - Math.max(0, newBounds.position.y),- newBounds.size.height,- ),- ),- },- };-- _setBounds(clampedBounds);- };+ const { postMessage, onMessage } = makeBroadcastChannel<{ type: "reset" }>(+ "target_select_overlay",+ );+ createEventListener(window, "mousedown", () =>+ postMessage({ type: "reset" }),+ );+ onMessage(() => setBounds(EMPTY_BOUNDS()));// We do this so any Cap window, (or external in the case of a bug) that are focused can trigger the close shortcutconst unsubOnEscapePress = events.onEscapePress.listen(() => {@@ -255,446 +255,523 @@ function Inner() {</Show></Match><Match when={rawOptions.targetMode === "area"}>- {(_) => (- <Show- when={targetUnderCursor.display_id === params.displayId}- fallback={- <div class="w-screen h-screen flex flex-col items-center justify-center data-[over='true']:bg-blue-600/40 transition-colors relative cursor-crosshair bg-black/50" />- }- >- {(_) => {- const [dragging, setDragging] = createSignal(false);- // Track whether the controls should be placed above the selection to avoid window bottom overflow- const [placeControlsAbove, setPlaceControlsAbove] =- createSignal(false);- let controlsEl: HTMLDivElement | undefined;-- // Recompute placement when bounds change or window resizes- createEffect(() => {- // Read reactive dependencies- const top = bounds.position.y;- const height = bounds.size.height;- // Measure controls height (fallback to 64px if not yet mounted)- const ctrlH = controlsEl?.offsetHeight ?? 64;- const margin = 16;-- const wouldOverflow =- top + height + margin + ctrlH > window.innerHeight;- setPlaceControlsAbove(wouldOverflow);- });+ {(_) => {+ const [state, setState] = createSignal<+ "creating" | "dragging" | undefined+ >();++ // Initialize hasArea based on whether bounds have meaningful dimensions+ const [hasArea, setHasArea] = createWritableMemo(+ () => bounds.size.width > 0 && bounds.size.height > 0,+ );+ // Track whether the controls should be placed above the selection to avoid window bottom overflow+ let controlsEl: HTMLDivElement | undefined;++ const [controlsHeight, setControlsHeight] = createSignal<+ number | undefined+ >(undefined);+ // Recompute placement when bounds change or window resizes+ const placeControlsAbove = createMemo(() => {+ const top = bounds.position.y;+ const height = bounds.size.height;+ // Measure controls height (fallback to 64px if not yet mounted)+ const ctrlH = controlsHeight() ?? 64;+ const margin = 16;++ const wouldOverflow =+ top + height + margin + ctrlH > window.innerHeight;+ return wouldOverflow;+ });+ onMount(() => setControlsHeight(controlsEl?.offsetHeight));+ createEventListener(window, "resize", () =>+ setControlsHeight(controlsEl?.offsetHeight),+ );++ function createOnMouseDown(+ onDrag: (+ startBounds: typeof bounds,+ delta: { x: number; y: number },+ ) => void,+ ) {+ return (downEvent: MouseEvent) => {+ const startBounds = {+ position: { ...bounds.position },+ size: { ...bounds.size },+ };++ let animationFrame: number | null = null;- // Handle window resize to keep placement responsivecreateRoot((dispose) => {- const onResize = () => {- const ctrlH = controlsEl?.offsetHeight ?? 64;- const margin = 16;- const wouldOverflow =- bounds.position.y + bounds.size.height + margin + ctrlH >- window.innerHeight;- setPlaceControlsAbove(wouldOverflow);- };- window.addEventListener("resize", onResize);- onCleanup(() => {- window.removeEventListener("resize", onResize);- dispose();+ createEventListenerMap(window, {+ mouseup: () => {+ if (animationFrame) cancelAnimationFrame(animationFrame);+ dispose();+ },+ mousemove: (moveEvent) => {+ if (animationFrame) cancelAnimationFrame(animationFrame);++ animationFrame = requestAnimationFrame(() => {+ onDrag(startBounds, {+ x: moveEvent.clientX - downEvent.clientX, // Remove Math.max constraint+ y: moveEvent.clientY - downEvent.clientY, // Remove Math.max constraint+ });+ });+ },});});+ };+ }- function createOnMouseDown(- onDrag: (- startBounds: typeof bounds,- delta: { x: number; y: number },- ) => void,- ) {- return (downEvent: MouseEvent) => {- const startBounds = {- position: { ...bounds.position },- size: { ...bounds.size },- };-- let animationFrame: number | null = null;-- createRoot((dispose) => {- createEventListenerMap(window, {- mouseup: () => {- if (animationFrame)- cancelAnimationFrame(animationFrame);- dispose();- },- mousemove: (moveEvent) => {- if (animationFrame)- cancelAnimationFrame(animationFrame);-- animationFrame = requestAnimationFrame(() => {- onDrag(startBounds, {- x: moveEvent.clientX - downEvent.clientX, // Remove Math.max constraint- y: moveEvent.clientY - downEvent.clientY, // Remove Math.max constraint- });- });- },- });- });- };- }-- function ResizeHandles() {- return (- <>- {/* Top Left Button */}- <ResizeHandle- class="cursor-nw-resize"- style={{- left: `${bounds.position.x + 1}px`,- top: `${bounds.position.y + 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const width = startBounds.size.width - delta.x;- const limitedWidth = Math.max(width, 150);-- const height = startBounds.size.height - delta.y;- const limitedHeight = Math.max(height, 150);-- setBounds({- position: {- x:- startBounds.position.x +- delta.x -- (limitedWidth - width),- y:- startBounds.position.y +- delta.y -- (limitedHeight - height),- },- size: {- width: limitedWidth,- height: limitedHeight,- },- });- })}- />-- {/* Top Right Button */}- <ResizeHandle- class="cursor-ne-resize"- style={{- left: `${bounds.position.x + bounds.size.width - 1}px`,- top: `${bounds.position.y + 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const width = startBounds.size.width + delta.x;- const limitedWidth = Math.max(width, 150);-- const height = startBounds.size.height - delta.y;- const limitedHeight = Math.max(height, 150);-- setBounds({- position: {- x: startBounds.position.x,- y:- startBounds.position.y +- delta.y -- (limitedHeight - height),- },- size: {- width: limitedWidth,- height: limitedHeight,- },- });- })}- />+ function ResizeHandles() {+ return (+ <>+ {/* Top Left Button */}+ <ResizeHandle+ class="cursor-nw-resize"+ style={{+ left: `${bounds.position.x + 1}px`,+ top: `${bounds.position.y + 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const width = startBounds.size.width - delta.x;+ const limitedWidth = Math.max(width, MIN_WIDTH);++ const height = startBounds.size.height - delta.y;+ const limitedHeight = Math.max(height, MIN_HEIGHT);++ setBounds({+ position: {+ x:+ startBounds.position.x ++ delta.x -+ (limitedWidth - width),+ y:+ startBounds.position.y ++ delta.y -+ (limitedHeight - height),+ },+ size: {+ width: limitedWidth,+ height: limitedHeight,+ },+ });+ })(e);+ }}+ />- {/* Bottom Left Button */}- <ResizeHandle- class="cursor-sw-resize"- style={{- left: `${bounds.position.x + 1}px`,- top: `${bounds.position.y + bounds.size.height - 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const width = startBounds.size.width - delta.x;- const limitedWidth = Math.max(width, 150);+ {/* Top Right Button */}+ <ResizeHandle+ class="cursor-ne-resize"+ style={{+ left: `${bounds.position.x + bounds.size.width - 1}px`,+ top: `${bounds.position.y + 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const width = startBounds.size.width + delta.x;+ const limitedWidth = Math.max(width, MIN_WIDTH);++ const height = startBounds.size.height - delta.y;+ const limitedHeight = Math.max(height, MIN_HEIGHT);++ setBounds({+ position: {+ x: startBounds.position.x,+ y:+ startBounds.position.y ++ delta.y -+ (limitedHeight - height),+ },+ size: {+ width: limitedWidth,+ height: limitedHeight,+ },+ });+ })(e);+ }}+ />- const height = startBounds.size.height + delta.y;- const limitedHeight = Math.max(height, 150);+ {/* Bottom Left Button */}+ <ResizeHandle+ class="cursor-sw-resize"+ style={{+ left: `${bounds.position.x + 1}px`,+ top: `${bounds.position.y + bounds.size.height - 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const width = startBounds.size.width - delta.x;+ const limitedWidth = Math.max(width, MIN_WIDTH);++ const height = startBounds.size.height + delta.y;+ const limitedHeight = Math.max(height, MIN_HEIGHT);++ setBounds({+ position: {+ x:+ startBounds.position.x ++ delta.x -+ (limitedWidth - width),+ y: startBounds.position.y,+ },+ size: {+ width: limitedWidth,+ height: limitedHeight,+ },+ });+ })(e);+ }}+ />- setBounds({- position: {- x:- startBounds.position.x +- delta.x -- (limitedWidth - width),- y: startBounds.position.y,- },- size: {- width: limitedWidth,- height: limitedHeight,- },- });- })}- />+ {/* Bottom Right Button */}+ <ResizeHandle+ class="cursor-se-resize"+ style={{+ left: `${bounds.position.x + bounds.size.width - 1}px`,+ top: `${bounds.position.y + bounds.size.height - 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const width = startBounds.size.width + delta.x;+ const limitedWidth = Math.max(width, MIN_WIDTH);++ const height = startBounds.size.height + delta.y;+ const limitedHeight = Math.max(height, MIN_HEIGHT);++ setBounds({+ position: {+ x: startBounds.position.x,+ y: startBounds.position.y,+ },+ size: {+ width: limitedWidth,+ height: limitedHeight,+ },+ });+ })(e);+ }}+ />- {/* Bottom Right Button */}- <ResizeHandle- class="cursor-se-resize"- style={{- left: `${bounds.position.x + bounds.size.width - 1}px`,- top: `${bounds.position.y + bounds.size.height - 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const width = startBounds.size.width + delta.x;- const limitedWidth = Math.max(width, 150);-- const height = startBounds.size.height + delta.y;- const limitedHeight = Math.max(height, 150);-- setBounds({- position: {- x: startBounds.position.x,- y: startBounds.position.y,- },- size: {- width: limitedWidth,- height: limitedHeight,- },- });- })}- />+ {/* Top Edge Button */}+ <ResizeHandle+ class="cursor-n-resize"+ style={{+ left: `${bounds.position.x + bounds.size.width / 2}px`,+ top: `${bounds.position.y + 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const height = startBounds.size.height - delta.y;+ const limitedHeight = Math.max(height, MIN_HEIGHT);++ setBounds({+ position: {+ x: startBounds.position.x,+ y:+ startBounds.position.y ++ delta.y -+ (limitedHeight - height),+ },+ size: {+ width: startBounds.size.width,+ height: limitedHeight,+ },+ });+ })(e);+ }}+ />- {/* Top Edge Button */}- <ResizeHandle- class="cursor-n-resize"- style={{- left: `${bounds.position.x + bounds.size.width / 2}px`,- top: `${bounds.position.y + 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const height = startBounds.size.height - delta.y;- const limitedHeight = Math.max(height, 150);+ {/* Right Edge Button */}+ <ResizeHandle+ class="cursor-e-resize"+ style={{+ left: `${bounds.position.x + bounds.size.width - 1}px`,+ top: `${bounds.position.y + bounds.size.height / 2}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ setBounds({+ position: {+ x: startBounds.position.x,+ y: startBounds.position.y,+ },+ size: {+ width: Math.max(+ MIN_WIDTH,+ startBounds.size.width + delta.x,+ ),+ height: startBounds.size.height,+ },+ });+ })(e);+ }}+ />- setBounds({- position: {- x: startBounds.position.x,- y:- startBounds.position.y +- delta.y -- (limitedHeight - height),- },- size: {- width: startBounds.size.width,- height: limitedHeight,- },- });- })}- />+ {/* Bottom Edge Button */}+ <ResizeHandle+ class="cursor-s-resize"+ style={{+ left: `${bounds.position.x + bounds.size.width / 2}px`,+ top: `${bounds.position.y + bounds.size.height - 1}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ setBounds({+ position: {+ x: startBounds.position.x,+ y: startBounds.position.y,+ },+ size: {+ width: startBounds.size.width,+ height: Math.max(+ MIN_HEIGHT,+ startBounds.size.height + delta.y,+ ),+ },+ });+ })(e);+ }}+ />- {/* Right Edge Button */}- <ResizeHandle- class="cursor-e-resize"- style={{- left: `${bounds.position.x + bounds.size.width - 1}px`,- top: `${bounds.position.y + bounds.size.height / 2}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- setBounds({- position: {- x: startBounds.position.x,- y: startBounds.position.y,- },- size: {- width: Math.max(- 150,- startBounds.size.width + delta.x,- ),- height: startBounds.size.height,- },- });- })}- />+ {/* Left Edge Button */}+ <ResizeHandle+ class="cursor-w-resize"+ style={{+ left: `${bounds.position.x + 1}px`,+ top: `${bounds.position.y + bounds.size.height / 2}px`,+ }}+ onMouseDown={(e) => {+ e.stopPropagation();+ createOnMouseDown((startBounds, delta) => {+ const width = startBounds.size.width - delta.x;+ const limitedWidth = Math.max(MIN_WIDTH, width);++ setBounds({+ position: {+ x:+ startBounds.position.x ++ delta.x -+ (limitedWidth - width),+ y: startBounds.position.y,+ },+ size: {+ width: limitedWidth,+ height: startBounds.size.height,+ },+ });+ })(e);+ }}+ />+ </>+ );+ }- {/* Bottom Edge Button */}- <ResizeHandle- class="cursor-s-resize"- style={{- left: `${bounds.position.x + bounds.size.width / 2}px`,- top: `${bounds.position.y + bounds.size.height - 1}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- setBounds({- position: {- x: startBounds.position.x,- y: startBounds.position.y,- },- size: {- width: startBounds.size.width,- height: Math.max(- 150,- startBounds.size.height + delta.y,- ),- },- });- })}- />+ function Occluders() {+ return (+ <>+ {/* Left */}+ <div+ class="absolute top-0 bottom-0 left-0 bg-black/50"+ style={{ width: `${bounds.position.x}px` }}+ />+ {/* Right */}+ <div+ class="absolute top-0 right-0 bottom-0 bg-black/50"+ style={{+ width: `${+ window.innerWidth -+ (bounds.size.width + bounds.position.x)+ }px`,+ }}+ />+ {/* Top center */}+ <div+ class="absolute top-0 bg-black/50"+ style={{+ left: `${bounds.position.x}px`,+ width: `${bounds.size.width}px`,+ height: `${bounds.position.y}px`,+ }}+ />+ {/* Bottom center */}+ <div+ class="absolute bottom-0 bg-black/50"+ style={{+ left: `${bounds.position.x}px`,+ width: `${bounds.size.width}px`,+ height: `${+ window.innerHeight -+ (bounds.size.height + bounds.position.y)+ }px`,+ }}+ />+ </>+ );+ }- {/* Left Edge Button */}- <ResizeHandle- class="cursor-w-resize"- style={{- left: `${bounds.position.x + 1}px`,- top: `${bounds.position.y + bounds.size.height / 2}px`,- }}- onMouseDown={createOnMouseDown((startBounds, delta) => {- const width = startBounds.size.width - delta.x;- const limitedWidth = Math.max(150, width);+ return (+ <div+ class="w-screen h-screen flex flex-col items-center justify-center data-[over='true']:bg-blue-600/40 transition-colors relative cursor-crosshair"+ onMouseDown={(downEvent) => {+ // Start creating a new area+ downEvent.preventDefault();+ postMessage({ type: "reset" });+ setState("creating");+ setHasArea(false);++ const startX = downEvent.clientX;+ const startY = downEvent.clientY;++ setBounds({+ position: { x: startX, y: startY },+ size: { width: 0, height: 0 },+ });- setBounds({- position: {+ createRoot((dispose) => {+ createEventListenerMap(window, {+ mousemove: (moveEvent) => {+ const width = Math.abs(moveEvent.clientX - startX);+ const height = Math.abs(moveEvent.clientY - startY);+ const x = Math.min(startX, moveEvent.clientX);+ const y = Math.min(startY, moveEvent.clientY);++ setBounds({+ position: { x, y },+ size: { width, height },+ });+ },+ mouseup: () => {+ setState(undefined);+ // Only set hasArea if we created a meaningful area+ if (bounds.size.width > 10 && bounds.size.height > 10) {+ setHasArea(true);+ } else {+ // Reset to no area if too small+ setBounds(EMPTY_BOUNDS());+ }+ dispose();+ },+ });+ });+ }}+ >+ <Occluders />++ <Show when={hasArea()}>+ <div+ class={cx(+ "flex absolute flex-col items-center",+ state() === "dragging" ? "cursor-grabbing" : "cursor-grab",+ )}+ style={{+ width: `${bounds.size.width}px`,+ height: `${bounds.size.height}px`,+ left: `${bounds.position.x}px`,+ top: `${bounds.position.y}px`,+ }}+ onMouseDown={(downEvent) => {+ downEvent.stopPropagation();+ setState("dragging");+ const startPosition = { ...bounds.position };++ createRoot((dispose) => {+ createEventListenerMap(window, {+ mousemove: (moveEvent) => {+ const newPosition = {x:- startBounds.position.x +- delta.x -- (limitedWidth - width),- y: startBounds.position.y,- },- size: {- width: limitedWidth,- height: startBounds.size.height,- },- });- })}- />- </>- );- }-- function Occluders() {- return (- <>- {/* Left */}- <div- class="absolute top-0 bottom-0 left-0 bg-black/50"- style={{ width: `${bounds.position.x}px` }}- />- {/* Right */}- <div- class="absolute top-0 right-0 bottom-0 bg-black/50"- style={{- width: `${- window.innerWidth -- (bounds.size.width + bounds.position.x)- }px`,- }}- />- {/* Top center */}- <div- class="absolute top-0 bg-black/50"- style={{- left: `${bounds.position.x}px`,- width: `${bounds.size.width}px`,- height: `${bounds.position.y}px`,- }}- />- {/* Bottom center */}- <div- class="absolute bottom-0 bg-black/50"- style={{- left: `${bounds.position.x}px`,- width: `${bounds.size.width}px`,- height: `${- window.innerHeight -- (bounds.size.height + bounds.position.y)- }px`,- }}- />- </>- );- }-- return (- <div class="w-screen h-screen flex flex-col items-center justify-center data-[over='true']:bg-blue-600/40 transition-colors relative cursor-crosshair">- <Occluders />-+ startPosition.x ++ moveEvent.clientX -+ downEvent.clientX,+ y:+ startPosition.y ++ moveEvent.clientY -+ downEvent.clientY,+ };++ if (newPosition.x < 0) newPosition.x = 0;+ if (newPosition.y < 0) newPosition.y = 0;+ if (+ newPosition.x + bounds.size.width >+ window.innerWidth+ )+ newPosition.x =+ window.innerWidth - bounds.size.width;+ if (+ newPosition.y + bounds.size.height >+ window.innerHeight+ )+ newPosition.y =+ window.innerHeight - bounds.size.height;++ setBounds("position", newPosition);+ },+ mouseup: () => {+ setState(undefined);+ dispose();+ },+ });+ });+ }}+ ><div+ ref={controlsEl}class={cx(- "flex absolute flex-col items-center",- dragging() ? "cursor-grabbing" : "cursor-grab",+ "flex absolute flex-col items-center m-2",+ placeControlsAbove() ? "bottom-full" : "top-full",)}- style={{- width: `${bounds.size.width}px`,- height: `${bounds.size.height}px`,- left: `${bounds.position.x}px`,- top: `${bounds.position.y}px`,- }}- onMouseDown={(downEvent) => {- setDragging(true);- const startPosition = { ...bounds.position };-- createRoot((dispose) => {- createEventListenerMap(window, {- mousemove: (moveEvent) => {- const newPosition = {- x:- startPosition.x +- moveEvent.clientX -- downEvent.clientX,- y:- startPosition.y +- moveEvent.clientY -- downEvent.clientY,- };-- if (newPosition.x < 0) newPosition.x = 0;- if (newPosition.y < 0) newPosition.y = 0;- if (- newPosition.x + bounds.size.width >- window.innerWidth- )- newPosition.x =- window.innerWidth - bounds.size.width;- if (- newPosition.y + bounds.size.height >- window.innerHeight- )- newPosition.y =- window.innerHeight - bounds.size.height;-- _setBounds("position", newPosition);- },- mouseup: () => {- setDragging(false);- dispose();- },- });- });- }}+ style={{ width: `${bounds.size.width}px` }}>- <div- ref={controlsEl}- class={cx(- "flex absolute flex-col items-center m-2",- placeControlsAbove() ? "bottom-full" : "top-full",- )}- style={{ width: `${bounds.size.width}px` }}- >- <RecordingControls- target={{- variant: "area",- screen: params.displayId!,- bounds,- }}- />- <ShowCapFreeWarning- isInstantMode={rawOptions.mode === "instant"}- />- </div>+ <RecordingControls+ target={{+ variant: "area",+ screen: params.displayId!,+ bounds,+ }}+ />+ <ShowCapFreeWarning+ isInstantMode={rawOptions.mode === "instant"}+ /></div>-- <ResizeHandles />-- <p class="z-10 text-xl">Click and drag area to record</p></div>- );- }}- </Show>- )}++ <ResizeHandles />+ </Show>++ <Show when={state() === "creating"}>+ <div+ class="absolute border-2 border-blue-500 bg-blue-500/20 pointer-events-none"+ style={{+ left: `${bounds.position.x}px`,+ top: `${bounds.position.y}px`,+ width: `${bounds.size.width}px`,+ height: `${bounds.size.height}px`,+ }}+ />+ </Show>++ <Show when={!state()}>+ <Show when={!hasArea()}>+ <p class="z-10 text-xl pointer-events-none text-white">+ Click and drag to select area+ </p>+ </Show>+ <Show when={hasArea()}>+ <p class="z-10 text-xl pointer-events-none text-white absolute bottom-4">+ Click and drag to create new area+ </p>+ </Show>+ </Show>+ </div>+ );+ }}</Match></Switch>);@@ -709,6 +786,12 @@ function RecordingControls(props: {const generalSetings = generalSettingsStore.createQuery();+ const isAreaTooSmall = () => {+ if (props.target.variant !== "area") return false;+ const { width, height } = props.target.bounds.size;+ return width < MIN_WIDTH || height < MIN_HEIGHT;+ };+const menuModes = async () =>await Menu.new({items: [@@ -775,7 +858,22 @@ function RecordingControls(props: {}));return (- <>+ <Show+ when={!isAreaTooSmall()}+ fallback={+ <div class="flex flex-col gap-2 items-center p-2 my-2.5 rounded-xl border w-52 bg-red-500/80 border-red-500/60 text-white">+ <div class="flex gap-2 items-center">+ <IconCapInfo class="will-change-transform size-4" />+ <p class="text-sm font-medium">Area Too Small</p>+ </div>+ <p class="text-xs text-center tabular-nums">+ Selection must be at least {MIN_WIDTH}x{MIN_HEIGHT} pixels+ {props.target.variant === "area" &&+ ` (currently ${props.target.bounds.size.width}x${props.target.bounds.size.height})`}+ </p>+ </div>+ }+ ><div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4"><divonClick={() => {@@ -857,7 +955,7 @@ function RecordingControls(props: {<span class="font-medium">{capitalize(rawOptions.mode)} Mode</span>?</p></div>- </>+ </Show>);}diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 6c370f546..db21f744e 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -76,9 +76,11 @@ declare global {const IconLucideHardDrive: typeof import('~icons/lucide/hard-drive.jsx')['default']const IconLucideLayout: typeof import('~icons/lucide/layout.jsx')['default']const IconLucideLoaderCircle: typeof import('~icons/lucide/loader-circle.jsx')['default']+ const IconLucideMaximize: typeof import('~icons/lucide/maximize.jsx')['default']const IconLucideMessageSquarePlus: typeof import('~icons/lucide/message-square-plus.jsx')['default']const IconLucideMicOff: typeof import('~icons/lucide/mic-off.jsx')['default']const IconLucideMonitor: typeof import('~icons/lucide/monitor.jsx')['default']+ const IconLucideRatio: typeof import('~icons/lucide/ratio.jsx')['default']const IconLucideRectangleHorizontal: typeof import('~icons/lucide/rectangle-horizontal.jsx')['default']const IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw.jsx')['default']const IconLucideSearch: typeof import('~icons/lucide/search.jsx')['default']diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2165747bc..a08cf69e6 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -65,6 +65,9 @@ importers:'@solid-primitives/bounds':specifier: ^0.0.122version: 0.0.122([email protected])+ '@solid-primitives/broadcast-channel':+ specifier: ^0.1.1+ version: 0.1.1([email protected])'@solid-primitives/context':specifier: ^0.2.3version: 0.2.3([email protected])@@ -6243,6 +6246,11 @@ packages:peerDependencies:solid-js: ^1.6.12+ '@solid-primitives/[email protected]':+ resolution: {integrity: sha512-7wjQvY320E8elCcuruoJJohDHLzw6l7tAvHXZez5FAolb9BGsk3sPJ9wKDHsdRx0ww2cPg8GeUrGFdJ+5CnCxA==}+ peerDependencies:+ solid-js: ^1.6.12+'@solid-primitives/[email protected]':resolution: {integrity: sha512-6/e8qu9qJf48FJ+sxc/B782NdgFw5TvI8+r6U0gHizumfZcWZg8FAJqvRZAiwlygkUNiTQOGTeO10LVbMm0kvg==}peerDependencies:@@ -6487,10 +6495,10 @@ packages:react-dom:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-Lr/nVrkZLzMBs1CIvIc0ddr2UyWRmqnoYalBLUKraGZUCOfCzpJ3ywzfj3lMhfOR4456Lld0X9SFd04DQFHDnQ==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-ZPxqgoofi2yfJRQkkEBINSzPjkhrgfh4HsPs4fsbPt3jfVyfP4Wic7vHep4UlR1os2iL2MTRLcapkkiajoztWQ==}peerDependencies:- storybook: ^10.0.0-beta.10+ storybook: ^10.0.0-beta.13vite: ^5.0.0 || ^6.0.0 || ^7.0.0'@storybook/[email protected]':@@ -6501,12 +6509,12 @@ packages:prettier:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-sKCnWOHU97799zj6RoZuFygJCKPPUmohYZsESPddWQm6tHckjmKp1k4ISvd7Z5MIBwiEPYCnppQDDH1mOG6SPw==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-mjdDsl5MAn6bLZHHInut+TQjYUJDdErpXnYlXPLvZRoaCxqxLN2O2sf5LmxAP9SRjEdKnsLFvBwMCJxVcav/lQ==}peerDependencies:esbuild: '*'rollup: '*'- storybook: ^10.0.0-beta.10+ storybook: ^10.0.0-beta.13vite: '*'webpack: '*'peerDependenciesMeta:@@ -13597,7 +13605,7 @@ packages:resolution: {integrity: sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==}engines: {node: '>=6.4.0 <13 || >=14'}- deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net+ deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.netresolution: {integrity: sha512-erY3HFDG0dPnhw4U+udPfrzXa4xhSG+n4rxfRuZWCUvjFWwKl+OxWf/7zk50s84/fAAs7vf5QAb9uRa0cCykxw==}@@ -20734,6 +20742,10 @@ snapshots:'@solid-primitives/utils': 6.3.1([email protected])solid-js: 1.9.6+ '@solid-primitives/[email protected]([email protected])':+ dependencies:+ solid-js: 1.9.6+'@solid-primitives/[email protected]([email protected])':dependencies:solid-js: 1.9.6@@ -21034,9 +21046,9 @@ snapshots:react: 19.1.1react-dom: 19.1.1([email protected])- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':dependencies:- '@storybook/csf-plugin': 10.0.0-beta.10([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))+ '@storybook/csf-plugin': 10.0.0-beta.13([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))storybook: 8.6.12([email protected])ts-dedent: 2.2.0@@ -21066,7 +21078,7 @@ snapshots:- supports-color- utf-8-validate- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':dependencies:storybook: 8.6.12([email protected])unplugin: 2.3.10@@ -29669,7 +29681,7 @@ snapshots:[email protected](@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected])):dependencies:- '@storybook/builder-vite': 10.0.0-beta.10([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))+ '@storybook/builder-vite': 10.0.0-beta.13([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))'@storybook/types': 9.0.0-alpha.1([email protected]([email protected]))magic-string: 0.30.17solid-js: 1.9.6