Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Add layers panel toggle and improve aspect ratio constraints
Richie McIlroy01520895cd9e
diff --git a/apps/desktop/src/routes/screenshot-editor/AnnotationConfig.tsx b/apps/desktop/src/routes/screenshot-editor/AnnotationConfig.tsxindex 129104c0a..8faefea29 100644--- a/apps/desktop/src/routes/screenshot-editor/AnnotationConfig.tsx+++ b/apps/desktop/src/routes/screenshot-editor/AnnotationConfig.tsx@@ -13,6 +13,7 @@ export function AnnotationConfigBar() {setAnnotations,projectHistory,setSelectedAnnotationId,+ layersPanelOpen,} = useScreenshotEditorContext();const selected = createMemo(() =>@@ -35,7 +36,12 @@ export function AnnotationConfigBar() {const maskType = () => ann().maskType ?? "blur";const maskLevel = () => ann().maskLevel ?? 16;return (- <div class="w-full border-b border-gray-3 bg-gray-1 dark:bg-gray-2 animate-in fade-in slide-in-from-top-1 duration-150">+ <div+ class={cx(+ "absolute top-14 right-0 z-10 border-b border-gray-3 bg-gray-1 dark:bg-gray-2 animate-in fade-in slide-in-from-top-1 duration-150 transition-[left]",+ layersPanelOpen() ? "left-56" : "left-0",+ )}+ ><div class="flex items-center justify-center gap-6 px-4 h-11"><Show when={!isMask}><ConfigItem label={type === "text" ? "Color" : "Stroke"}>diff --git a/apps/desktop/src/routes/screenshot-editor/AnnotationLayer.tsx b/apps/desktop/src/routes/screenshot-editor/AnnotationLayer.tsxindex a6cfb321d..1fcc612fd 100644--- a/apps/desktop/src/routes/screenshot-editor/AnnotationLayer.tsx+++ b/apps/desktop/src/routes/screenshot-editor/AnnotationLayer.tsx@@ -243,12 +243,12 @@ export function AnnotationLayer(props: {let width = currentX - temp.x;let height = currentY - temp.y;- if (e.shiftKey) {- if (- temp.type === "rectangle" ||- temp.type === "circle" ||- temp.type === "mask"- ) {+ if (temp.type === "circle" && !e.shiftKey) {+ const size = Math.max(Math.abs(width), Math.abs(height));+ width = width < 0 ? -size : size;+ height = height < 0 ? -size : size;+ } else if (e.shiftKey) {+ if (temp.type === "rectangle" || temp.type === "mask") {const size = Math.max(Math.abs(width), Math.abs(height));width = width < 0 ? -size : size;height = height < 0 ? -size : size;@@ -333,19 +333,25 @@ export function AnnotationLayer(props: {newH = original.height - dy;}- // Shift constraint during resize- if (- e.shiftKey &&- (original.type === "rectangle" || original.type === "circle")- ) {- // This is complex for corner resizing, simplifying:- // Just force aspect ratio based on original- const _ratio = original.width / original.height;- if (state.handle.includes("e") || state.handle.includes("w")) {- // Width driven, adjust height- // This is tricky with 8 handles. Skipping proper aspect resize for now to save time/complexity- // Or simple implementation:+ const shouldConstrainCircle =+ original.type === "circle" && !e.shiftKey;+ const shouldConstrainRectangle =+ original.type === "rectangle" && e.shiftKey;++ if (shouldConstrainCircle || shouldConstrainRectangle) {+ const size = Math.max(Math.abs(newW), Math.abs(newH));+ const signW = newW < 0 ? -1 : 1;+ const signH = newH < 0 ? -1 : 1;++ if (state.handle.includes("w")) {+ newX = original.x + original.width - signW * size;}+ if (state.handle.includes("n")) {+ newY = original.y + original.height - signH * size;+ }++ newW = signW * size;+ newH = signH * size;}}diff --git a/apps/desktop/src/routes/screenshot-editor/AnnotationTools.tsx b/apps/desktop/src/routes/screenshot-editor/AnnotationTools.tsxindex c4eeacacf..37c0ed861 100644--- a/apps/desktop/src/routes/screenshot-editor/AnnotationTools.tsx+++ b/apps/desktop/src/routes/screenshot-editor/AnnotationTools.tsx@@ -4,14 +4,32 @@ import Tooltip from "~/components/Tooltip";import IconLucideArrowUpRight from "~icons/lucide/arrow-up-right";import IconLucideCircle from "~icons/lucide/circle";import IconLucideEyeOff from "~icons/lucide/eye-off";+import IconLucideLayers from "~icons/lucide/layers";import IconLucideMousePointer2 from "~icons/lucide/mouse-pointer-2";import IconLucideSquare from "~icons/lucide/square";import IconLucideType from "~icons/lucide/type";import { type AnnotationType, useScreenshotEditorContext } from "./context";export function AnnotationTools() {+ const { layersPanelOpen, setLayersPanelOpen } = useScreenshotEditorContext();+return (<div class="flex items-center gap-1">+ <Tooltip content="Layers" kbd={["L"]}>+ <button+ type="button"+ onClick={() => setLayersPanelOpen(!layersPanelOpen())}+ class={cx(+ "flex items-center justify-center rounded-[0.5rem] transition-all size-8",+ layersPanelOpen()+ ? "bg-blue-3 text-blue-11"+ : "bg-transparent hover:bg-gray-3 text-gray-11",+ )}+ >+ <IconLucideLayers class="size-4" />+ </button>+ </Tooltip>+ <div class="w-px h-4 bg-gray-4 mx-1" /><ToolButtontool="select"icon={IconLucideMousePointer2}