diff --git a/packages/studio/src/components/editor/DomEditGestureReadout.test.tsx b/packages/studio/src/components/editor/DomEditGestureReadout.test.tsx index 317532b597..5a6a5c7475 100644 --- a/packages/studio/src/components/editor/DomEditGestureReadout.test.tsx +++ b/packages/studio/src/components/editor/DomEditGestureReadout.test.tsx @@ -3,7 +3,11 @@ import React, { act, type ComponentProps } from "react"; import { createRoot, type Root } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import { DomEditGestureReadout } from "./DomEditGestureReadout"; -import { createGestureReadout, updateGestureReadout } from "./domEditGestureReadoutState"; +import { + createGestureReadout, + updateGestureReadout, + updateGestureReadoutAngle, +} from "./domEditGestureReadoutState"; const frames = vi.hoisted(() => ({ update: () => {} })); vi.mock("./overlayFrameLoop", () => ({ @@ -23,7 +27,16 @@ afterEach(() => { vi.clearAllMocks(); }); -function mount(kind: "drag" | "resize" | "rotate") { +function mount( + kind: "drag" | "resize" | "rotate", + { + overlayWidth = 500, + height = 60, + stageHeight = 400, + angle = undefined as number | undefined, + localAngle = undefined as number | undefined, + } = {}, +) { const host = document.createElement("div"); const overlay = document.createElement("div"); const iframe = document.createElement("iframe"); @@ -40,9 +53,8 @@ function mount(kind: "drag" | "resize" | "rotate") { let x = 70.25; let y = 40.75; const width = 100; - const height = 60; - overlay.getBoundingClientRect = () => new DOMRect(20, 30, 500, 400); - iframe.getBoundingClientRect = () => new DOMRect(20, 30, 500, 400); + overlay.getBoundingClientRect = () => new DOMRect(20, 30, overlayWidth, 400); + iframe.getBoundingClientRect = () => new DOMRect(20, 30, overlayWidth, stageHeight); composition.getBoundingClientRect = () => new DOMRect(0, 0, 1000, 800); element.getBoundingClientRect = () => new DOMRect(x, y, width, height); Object.defineProperties(element, { @@ -59,6 +71,7 @@ function mount(kind: "drag" | "resize" | "rotate") { height: height / 2, editScaleX: 0.5, editScaleY: 0.5, + angle, }), }, }; @@ -72,10 +85,11 @@ function mount(kind: "drag" | "resize" | "rotate") { height: height / 2, editScaleX: 0.5, editScaleY: 0.5, + angle: localAngle ?? angle, }, text, ); - update(kind === "resize" ? "100 × 60" : kind === "rotate" ? "0°" : undefined); + update(kind === "resize" ? "W 100 · H 60" : kind === "rotate" ? "↻ 0°" : undefined); root = createRoot(host); act(() => root?.render( @@ -113,6 +127,13 @@ function mount(kind: "drag" | "resize" | "rotate") { }; } +/** The chip's fields as [name, figure] pairs. */ +const fields = (label: Element) => + [...label.querySelectorAll(":scope > span.flex")].map((field) => [ + field.children[0]?.textContent, + field.children[1]?.textContent, + ]); + describe("gesture readout", () => { it("adds no layout reads while drawing and stays hidden on a plain press", () => { const view = mount("drag"); @@ -125,7 +146,10 @@ describe("gesture readout", () => { view.move(120, 70); view.draw(); view.draw(); - expect(view.label.textContent).toBe("Canvas X 120 · Y 70"); + expect(fields(view.label)).toEqual([ + ["X", "120"], + ["Y", "70"], + ]); expect(measure).not.toHaveBeenCalled(); for (const measurement of view.measurements) expect(measurement).not.toHaveBeenCalled(); measure.mockRestore(); @@ -134,10 +158,16 @@ describe("gesture readout", () => { it("shows rounded composition coordinates during a move, accounting for preview zoom", () => { const view = mount("drag"); view.draw(); - expect(view.label.textContent).toBe("Canvas X 70 · Y 41"); + expect(fields(view.label)).toEqual([ + ["X", "70"], + ["Y", "41"], + ]); view.move(120.25, 70.75); view.draw(); - expect(view.label.textContent).toBe("Canvas X 120 · Y 71"); + expect(fields(view.label)).toEqual([ + ["X", "120"], + ["Y", "71"], + ]); expect(view.doc.querySelector("[data-dom-edit-gesture-readout]")).toBeNull(); view.end(); expect(view.label.style.display).toBe("none"); @@ -145,33 +175,187 @@ describe("gesture readout", () => { it("shows the actual size draft during resize and hides on release", () => { const view = mount("resize"); view.draw(); - expect(view.label.textContent).toBe("100 × 60"); - view.update("144 × 87"); + expect(fields(view.label)).toEqual([ + ["W", "100"], + ["H", "60"], + ]); + view.update("W 144 · H 87"); view.draw(); - expect(view.label.textContent).toBe("144 × 87"); + expect(fields(view.label)).toEqual([ + ["W", "144"], + ["H", "87"], + ]); view.end(); expect(view.label.style.display).toBe("none"); }); it("reads the live angle during rotation and hides on cancellation", () => { const view = mount("rotate"); - view.update("32°"); + view.update("↻ 32°"); view.draw(); - expect(view.label.textContent).toBe("32°"); - view.update("-46°"); + expect(fields(view.label)).toEqual([["↻", "32°"]]); + view.update("↻ -46°"); view.draw(); - expect(view.label.textContent).toBe("-46°"); + expect(fields(view.label)).toEqual([["↻", "-46°"]]); view.end(); expect(view.label.style.display).toBe("none"); }); + it("sits below the element, centred, clear of the text toolbar above it", () => { + const view = mount("drag"); + view.move(300, 200); + view.draw(); + expect(view.label.style.left).toBe("175px"); + expect(view.label.style.top).toBe("138px"); + expect(view.label.style.transform).toBe("translateX(-50%)"); + }); + it("goes beside the element when there is no room below it", () => { + const view = mount("drag"); + view.move(300, 700); + view.draw(); + expect(view.label.style.left).toBe("208px"); + expect(view.label.style.top).toBe("349px"); + expect(view.label.style.transform).toBe("none"); + view.move(880, 700); + view.draw(); + expect(view.label.style.left).toBe("432px"); + expect(view.label.style.transform).toBe("translateX(-100%)"); + }); + it("goes above the toolbar's band when neither below nor either side has room", () => { + const view = mount("drag", { overlayWidth: 150 }); + view.move(100, 700); + view.draw(); + expect(view.label.style.top).toBe("266px"); + expect(view.label.style.transform).toBe("translateX(-50%)"); + }); + it("is not placed below an element whose toolbar has dropped below it", () => { + const view = mount("drag"); + view.move(300, 10); + view.draw(); + expect(view.label.style.transform).toBe("translateX(-100%)"); + expect(view.label.style.left).toBe("142px"); + }); + it("keeps its side for the whole gesture while that side still fits", () => { + const view = mount("drag"); + view.move(300, 700); + view.draw(); + expect(view.label.style.transform).toBe("none"); + view.move(300, 200); + view.draw(); + expect(view.label.style.left).toBe("208px"); + expect(view.label.style.top).toBe("99px"); + view.move(900, 200); + view.draw(); + expect(view.label.style.transform).toBe("translateX(-50%)"); + }); it("clamps the label inside the visible overlay at either edge", () => { const view = mount("drag"); view.move(900, -100); view.draw(); - expect(view.label.style.left).toBe("496px"); - expect(view.label.style.top).toBe("4px"); + expect(view.label.style.top).toBe("40px"); view.move(-900, 900); view.draw(); - expect(view.label.style.left).toBe("4px"); - expect(view.label.style.top).toBe("396px"); + expect(view.label.style.left).toBe("78px"); + expect(view.label.style.top).toBe("364px"); + }); + it("while rotating, places from the rotated box and keeps the angle apart from the size", () => { + const view = mount("rotate"); + const readout = view.gestureRef.current?.readout; + updateGestureReadoutAngle(readout, 90); + expect(readout?.rect.width).toBe(50); + expect(readout?.rect.angle).toBe(90); + updateGestureReadoutAngle(readout, 0); + expect(readout?.rect.angle).toBe(0); + expect(readout?.text).toBe("↻ 0°"); + }); + it("clears an element that was already rotated when it is dragged", () => { + const view = mount("drag", { angle: 90 }); + view.move(300, 200); + view.draw(); + expect(view.label.style.top).toBe("148px"); + }); + it("uses the painted angle, not the element's own, under a rotated parent", () => { + const counter = mount("drag", { angle: 0, localAngle: -90 }); + counter.move(300, 200); + counter.draw(); + expect(counter.label.style.top).toBe("138px"); + const parentOnly = mount("drag", { angle: 90, localAngle: 0 }); + parentOnly.move(300, 200); + parentOnly.draw(); + expect(parentOnly.label.style.top).toBe("148px"); + }); + it("turns the painted angle by the change in the element's own angle while rotating", () => { + const view = mount("rotate", { angle: 90, localAngle: 0 }); + const readout = view.gestureRef.current?.readout; + updateGestureReadoutAngle(readout, 30, 0); + expect(readout?.rect.angle).toBe(120); + expect(readout?.text).toBe("↻ 30°"); + }); + it("clears an element that was already rotated when it is resized", () => { + const view = mount("resize", { angle: 90 }); + view.move(300, 200); + view.draw(); + expect(view.label.style.top).toBe("148px"); + }); + it("never puts a side chip off the stage, left or right, even when that side was kept", () => { + const first = mount("drag"); + first.move(-900, 700); + first.draw(); + expect(first.label.style.transform).toBe("translateX(-50%)"); + const second = mount("drag"); + second.move(1800, 700); + second.draw(); + expect(second.label.style.transform).toBe("translateX(-50%)"); + const keptRight = mount("drag"); + keptRight.move(300, 700); + keptRight.draw(); + expect(keptRight.label.style.transform).toBe("none"); + keptRight.move(-900, 700); + keptRight.draw(); + expect(keptRight.label.style.transform).toBe("translateX(-50%)"); + const keptLeft = mount("drag"); + keptLeft.move(880, 700); + keptLeft.draw(); + expect(keptLeft.label.style.transform).toBe("translateX(-100%)"); + keptLeft.move(1800, 700); + keptLeft.draw(); + expect(keptLeft.label.style.transform).toBe("translateX(-50%)"); + }); + const inside = (label: HTMLElement, top: number, bottom: number) => { + const y = Number.parseFloat(label.style.top); + expect(y).toBeGreaterThanOrEqual(top); + expect(y + 32).toBeLessThanOrEqual(bottom); + }; + it("stays inside the stage when the element touches the bottom edge", () => { + const view = mount("drag"); + view.move(300, 740); + view.draw(); + inside(view.label, 4, 396); + }); + it("stays inside the stage when the element touches the top edge", () => { + const view = mount("drag"); + view.move(300, 0); + view.draw(); + inside(view.label, 4, 396); + }); + it("stays inside the stage for an element as tall as the stage", () => { + const view = mount("drag", { height: 800 }); + view.move(300, 0); + view.draw(); + inside(view.label, 4, 396); + const narrow = mount("drag", { height: 800, overlayWidth: 150 }); + narrow.move(100, 0); + narrow.draw(); + inside(narrow.label, 4, 396); + }); + it("lands below the preview toolbar when the element is larger than the stage", () => { + const view = mount("drag", { height: 800, overlayWidth: 150 }); + view.move(100, 0); + view.draw(); + expect(Number.parseFloat(view.label.style.top)).toBeGreaterThanOrEqual(40); + }); + it("bounds the chip by the stage, not the larger canvas area around it", () => { + const view = mount("drag", { stageHeight: 300 }); + view.move(300, 500); + view.draw(); + inside(view.label, 4, 296); }); }); diff --git a/packages/studio/src/components/editor/DomEditGestureReadout.tsx b/packages/studio/src/components/editor/DomEditGestureReadout.tsx index 67608c8f31..50caea0503 100644 --- a/packages/studio/src/components/editor/DomEditGestureReadout.tsx +++ b/packages/studio/src/components/editor/DomEditGestureReadout.tsx @@ -1,5 +1,6 @@ import { useRef, type RefObject } from "react"; import { useMountEffect } from "../../hooks/useMountEffect"; +import { placeChip } from "./domEditGestureReadoutPlacement"; import type { GestureState } from "./domEditOverlayGestures"; import { subscribeOverlayFrame } from "./overlayFrameLoop"; @@ -11,22 +12,39 @@ interface DomEditGestureReadoutProps { iframeRef: RefObject; } -function positionGestureReadout(label: HTMLDivElement, gesture: ReadoutGesture): void { +function positionGestureReadout( + label: HTMLDivElement, + gesture: ReadoutGesture, + text: string, +): void { const readout = gesture.readout; if (!readout) return; - const bounds = readout.basis.overlayRect; - const rect = readout.rect; - const minX = Math.max(0, -bounds.left) + 4; - const minY = Math.max(0, -bounds.top) + 4; - const maxX = Math.min(bounds.width, readout.viewportWidth - bounds.left) - 4; - const maxY = Math.min(bounds.height, readout.viewportHeight - bounds.top) - 4; - const x = Math.max(minX, Math.min(maxX, rect.left + rect.width + 8)); - const y = Math.max(minY, Math.min(maxY, rect.top - 8)); - label.style.left = `${x}px`; - label.style.top = `${y}px`; - label.style.maxWidth = `${Math.max(0, maxX - minX)}px`; - // CSS resolves the label's own size without a synchronous layout read after its text changes. - label.style.transform = `translate(max(-100%, ${minX - x}px), max(-100%, ${minY - y}px))`; + const placed = placeChip(readout, text); + readout.side = placed.side; + label.style.left = `${placed.left}px`; + label.style.top = `${placed.top}px`; + label.style.transform = placed.transform; +} + +function renderFields(label: HTMLDivElement, text: string): void { + const fields = text.split(" · ").flatMap((field, index) => { + const [name = "", ...value] = field.split(" "); + const cells = document.createElement("span"); + cells.className = "flex items-baseline gap-1.5"; + const key = document.createElement("span"); + key.className = "text-text-4"; + key.textContent = name; + const figure = document.createElement("span"); + figure.className = "min-w-[4ch] text-right font-medium"; + figure.textContent = value.join(" "); + cells.append(key, figure); + if (index === 0) return [cells]; + const divider = document.createElement("span"); + divider.className = "h-3.5 w-px bg-border"; + return [divider, cells]; + }); + label.replaceChildren(...fields); + label.dataset.readoutText = text; } export function DomEditGestureReadout({ gestureRef }: DomEditGestureReadoutProps) { @@ -41,9 +59,9 @@ export function DomEditGestureReadout({ gestureRef }: DomEditGestureReadoutProps label.style.display = "none"; return; } - if (label.textContent !== text) label.textContent = text; - label.style.display = "block"; - positionGestureReadout(label, gesture); + if (label.dataset.readoutText !== text) renderFields(label, text); + label.style.display = "flex"; + positionGestureReadout(label, gesture, text); }), ); return ( @@ -51,7 +69,7 @@ export function DomEditGestureReadout({ gestureRef }: DomEditGestureReadoutProps ref={labelRef} aria-hidden="true" data-dom-edit-gesture-readout="true" - className="pointer-events-none absolute z-50 overflow-hidden rounded bg-studio-surface px-2 py-1 font-mono text-xs whitespace-nowrap text-studio-text shadow-md" + className="pointer-events-none absolute z-50 flex h-8 items-center gap-2 rounded-lg border border-border bg-raised px-3 text-xs whitespace-nowrap text-studio-text tabular-nums shadow-[0_8px_24px_rgba(0,0,0,0.55)]" style={{ display: "none" }} /> ); diff --git a/packages/studio/src/components/editor/InlineTextToolbar.tsx b/packages/studio/src/components/editor/InlineTextToolbar.tsx index 7b633a599d..0d051fcc7b 100644 --- a/packages/studio/src/components/editor/InlineTextToolbar.tsx +++ b/packages/studio/src/components/editor/InlineTextToolbar.tsx @@ -24,9 +24,9 @@ import type { InlineTextEditSession } from "../../hooks/useInlineTextEdit"; const READ_PROPERTIES = ["color", "font-weight", "font-style", "text-decoration-line"]; /** Enough above the text to clear it, without leaving the element behind. */ -const GAP_PX = 10; +export const GAP_PX = 10; /** h-6 controls + p-1 + the border. Used only to keep an above-toolbar onscreen. */ -const TOOLBAR_HEIGHT_PX = 34; +export const TOOLBAR_HEIGHT_PX = 34; const DEFAULT_COLOR = "#ffffff"; interface ToolbarPlacement { diff --git a/packages/studio/src/components/editor/domEditGestureReadoutPlacement.ts b/packages/studio/src/components/editor/domEditGestureReadoutPlacement.ts new file mode 100644 index 0000000000..3e54fb4e24 --- /dev/null +++ b/packages/studio/src/components/editor/domEditGestureReadoutPlacement.ts @@ -0,0 +1,144 @@ +import type { GestureReadoutSide, GestureReadoutState } from "./domEditGestureReadoutState"; +import type { OverlayRect } from "./domEditOverlayGeometry"; +import { GAP_PX as TOOLBAR_GAP_PX, TOOLBAR_HEIGHT_PX } from "./InlineTextToolbar"; + +const GAP_PX = 8; +const EDGE_PX = 4; +const SNAP_TOOLBAR_BAND_PX = 36; +const SNAP_TOOLBAR_WIDTH_PX = 180; +const CHIP_HEIGHT_PX = 32; +const CHAR_PX = 8; +const CHIP_PADDING_PX = 36; + +const SIDES: readonly GestureReadoutSide[] = ["below", "right", "left", "above"]; + +interface Box { + minX: number; + minY: number; + maxX: number; + maxY: number; + toolbarBottom: number; + toolbarLeft: number; +} + +interface Spot { + x: number; + y: number; + fits: boolean; +} + +export interface ChipPlacement { + side: GestureReadoutSide; + left: number; + top: number; + transform: string; +} + +function visibleBox(readout: GestureReadoutState): Box { + const bounds = readout.basis.overlayRect; + const stage = readout.basis.iframeRect; + const stageLeft = stage.left - bounds.left; + const stageTop = stage.top - bounds.top; + const minY = Math.max(0, -bounds.top, stageTop) + EDGE_PX; + const maxX = + Math.min(bounds.width, readout.viewportWidth - bounds.left, stageLeft + stage.width) - EDGE_PX; + return { + minX: Math.max(0, -bounds.left, stageLeft) + EDGE_PX, + minY, + toolbarBottom: minY + SNAP_TOOLBAR_BAND_PX, + toolbarLeft: maxX - SNAP_TOOLBAR_WIDTH_PX, + maxX, + maxY: + Math.min(bounds.height, readout.viewportHeight - bounds.top, stageTop + stage.height) - + EDGE_PX, + }; +} + +function clearOfToolbar(box: Box, right: number, top: number): boolean { + return right <= box.toolbarLeft || top >= box.toolbarBottom; +} + +function paintedBox(rect: OverlayRect): OverlayRect { + const radians = ((rect.angle ?? 0) * Math.PI) / 180; + const cos = Math.abs(Math.cos(radians)); + const sin = Math.abs(Math.sin(radians)); + const width = rect.width * cos + rect.height * sin; + const height = rect.width * sin + rect.height * cos; + return { + ...rect, + left: rect.left + (rect.width - width) / 2, + top: rect.top + (rect.height - height) / 2, + width, + height, + }; +} + +function fitsBeside(box: Box, x0: number, x1: number, top: number): boolean { + const inside = + x0 >= box.minX && x1 <= box.maxX && top >= box.minY && top + CHIP_HEIGHT_PX <= box.maxY; + return inside && clearOfToolbar(box, x1, top); +} + +function chipSpots( + readout: GestureReadoutState, + box: Box, + width: number, +): Record { + const rect = paintedBox(readout.rect); + const right = rect.left + rect.width; + const bottom = rect.top + rect.height; + const centre = rect.left + rect.width / 2; + const middle = rect.top + rect.height / 2 - CHIP_HEIGHT_PX / 2; + const toolbarBelow = + readout.basis.overlayRect.top + rect.top - TOOLBAR_GAP_PX < TOOLBAR_HEIGHT_PX; + const toolbarBand = toolbarBelow ? 0 : TOOLBAR_GAP_PX + TOOLBAR_HEIGHT_PX; + return { + below: { + x: centre, + y: bottom + GAP_PX, + fits: !toolbarBelow && bottom + GAP_PX + CHIP_HEIGHT_PX <= box.maxY, + }, + right: { + x: right + GAP_PX, + y: middle, + fits: fitsBeside(box, right + GAP_PX, right + GAP_PX + width, middle), + }, + left: { + x: rect.left - GAP_PX, + y: middle, + fits: fitsBeside(box, rect.left - GAP_PX - width, rect.left - GAP_PX, middle), + }, + above: { x: centre, y: rect.top - GAP_PX - toolbarBand - CHIP_HEIGHT_PX, fits: true }, + }; +} + +function chooseSide( + kept: GestureReadoutSide | undefined, + spots: Record, +): GestureReadoutSide { + if (kept && spots[kept].fits) return kept; + return SIDES.find((side) => spots[side].fits) ?? "above"; +} + +const TRANSFORMS: Record = { + below: "translateX(-50%)", + above: "translateX(-50%)", + left: "translateX(-100%)", + right: "none", +}; + +export function placeChip(readout: GestureReadoutState, text: string): ChipPlacement { + const box = visibleBox(readout); + const width = text.length * CHAR_PX + CHIP_PADDING_PX; + const spots = chipSpots(readout, box, width); + const side = chooseSide(readout.side, spots); + const spot = spots[side]; + const centred = TRANSFORMS[side] === "translateX(-50%)"; + const left = centred + ? Math.max(box.minX + width / 2, Math.min(box.maxX - width / 2, spot.x)) + : spot.x; + const chipRight = side === "right" ? left + width : side === "left" ? left : left + width / 2; + const floor = clearOfToolbar(box, chipRight, box.minY) ? box.minY : box.toolbarBottom; + const top = Math.min(box.maxY - CHIP_HEIGHT_PX, Math.max(floor, spot.y)); + return { side, left, top, transform: TRANSFORMS[side] }; +} diff --git a/packages/studio/src/components/editor/domEditGestureReadoutState.ts b/packages/studio/src/components/editor/domEditGestureReadoutState.ts index a1e91bd60f..dcb7881c0e 100644 --- a/packages/studio/src/components/editor/domEditGestureReadoutState.ts +++ b/packages/studio/src/components/editor/domEditGestureReadoutState.ts @@ -1,5 +1,6 @@ import { computeOverlayRootScale, type OverlayRootScale } from "./domEditOverlayBasis"; import type { OverlayRect } from "./domEditOverlayGeometry"; +export type GestureReadoutSide = "below" | "right" | "left" | "above"; export interface GestureReadoutState { basis: OverlayRootScale; @@ -7,6 +8,8 @@ export interface GestureReadoutState { viewportHeight: number; text: string; rect: OverlayRect; + baseRect: OverlayRect; + side?: GestureReadoutSide; } export function createGestureReadout( @@ -23,27 +26,34 @@ export function createGestureReadout( viewportHeight: window.innerHeight, text: "", rect, + baseRect: rect, }; } +function setReadout(readout: GestureReadoutState, rect: OverlayRect, text?: string): void { + const { basis } = readout; + const x = (rect.left - (basis.iframeRect.left - basis.overlayRect.left)) / basis.rootScaleX; + const y = (rect.top - (basis.iframeRect.top - basis.overlayRect.top)) / basis.rootScaleY; + readout.text = text ?? `X ${Math.round(x)} · Y ${Math.round(y)}`; + readout.rect = rect; +} + export function updateGestureReadout( readout: GestureReadoutState | undefined, rect: OverlayRect, text?: string, ): void { - if (!readout) return; - const { basis } = readout; - const x = (rect.left - (basis.iframeRect.left - basis.overlayRect.left)) / basis.rootScaleX; - const y = (rect.top - (basis.iframeRect.top - basis.overlayRect.top)) / basis.rootScaleY; - readout.text = text ?? `Canvas X ${Math.round(x)} · Y ${Math.round(y)}`; - readout.rect = rect; + if (readout) setReadout(readout, { ...rect, angle: readout.baseRect.angle }, text); } export function updateGestureReadoutAngle( readout: GestureReadoutState | undefined, angle: number, + startAngle = 0, ): void { - if (readout) updateGestureReadout(readout, readout.rect, `${Math.round(angle)}°`); + if (!readout) return; + const turned = (readout.baseRect.angle ?? 0) + angle - startAngle; + setReadout(readout, { ...readout.baseRect, angle: turned }, `↻ ${Math.round(angle)}°`); } export function updateGestureReadoutSize( @@ -51,5 +61,5 @@ export function updateGestureReadoutSize( rect: OverlayRect, size: { width: number; height: number }, ): void { - updateGestureReadout(readout, rect, `${Math.round(size.width)} × ${Math.round(size.height)}`); + updateGestureReadout(readout, rect, `W ${Math.round(size.width)} · H ${Math.round(size.height)}`); } diff --git a/packages/studio/src/components/editor/useDomEditOverlayGestures.ts b/packages/studio/src/components/editor/useDomEditOverlayGestures.ts index 6898a8a0df..3ee28a45be 100644 --- a/packages/studio/src/components/editor/useDomEditOverlayGestures.ts +++ b/packages/studio/src/components/editor/useDomEditOverlayGestures.ts @@ -165,7 +165,7 @@ export function createDomEditOverlayGestureHandlers(opts: UseDomEditOverlayGestu actualAngle: g.actualRotation, snap: e.shiftKey, }); - readout.updateGestureReadoutAngle(g.readout, rotated.angle); + readout.updateGestureReadoutAngle(g.readout, rotated.angle, g.actualRotation); applyRotationDraft(sel.element, rotated.angle, g.plainRotation); return; }