Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(cursor): arrow and hand by default, bigger centred cursor previews
EtienneLescot09710c5f83f9
diff --git a/electron/native-bridge/services/compositorViewService.ts b/electron/native-bridge/services/compositorViewService.tsindex ccf01c723..4a765db2b 100644--- a/electron/native-bridge/services/compositorViewService.ts+++ b/electron/native-bridge/services/compositorViewService.ts@@ -176,7 +176,7 @@ export function resolveSceneAssetPaths(sceneJson: string): string {if (scene.cursor && typeof scene.cursor.theme === "string") {scene.cursor.cursorSprites = resolveCursorSpritePaths(scene.cursor.theme,- readCursorAsArrow(scene.cursor.asArrow),+ readCursorAsArrow(scene.cursor.asArrow, undefined, []),scene.cursor.model3d === true,);changed = true;diff --git a/src/components/ai-edition/CursorPane.levels.test.tsx b/src/components/ai-edition/CursorPane.levels.test.tsxindex 5074a08f0..6260ba373 100644--- a/src/components/ai-edition/CursorPane.levels.test.tsx+++ b/src/components/ai-edition/CursorPane.levels.test.tsx@@ -118,8 +118,22 @@ describe("CursorPane cursor types", () => {expect(within(group).getByRole("img", { name: "Arrow" }).tagName).toBe("SPAN");});+ // Out of the box only the two cursors a viewer follows keep their own art.+ it("lights only the arrow and the hand by default", async () => {+ renderWithRecording({}, ["arrow", "pointer", "text", "resize-ew"]);+ const group = await screen.findByRole("group", { name: "Cursor types" });+ const buttons = [...group.querySelectorAll("button")];+ expect(+ buttons.map((b) => [b.getAttribute("aria-label"), b.getAttribute("aria-pressed")]),+ ).toEqual([+ ["Hand", "true"],+ ["Text", "false"],+ ["Resize", "false"],+ ]);+ });+it("draws a type as the arrow on a click, and as recorded on the next", async () => {- renderWithRecording({}, ["arrow", "resize-ns", "pointer"]);+ renderWithRecording({ cursorAsArrow: [] }, ["arrow", "resize-ns", "pointer"]);const resize = await screen.findByRole("button", { name: "Resize" });fireEvent.click(resize);const asArrow = () => useProjectStore.getState().document?.legacyEditor?.cursorAsArrow;diff --git a/src/components/ai-edition/NewEditorShell.module.css b/src/components/ai-edition/NewEditorShell.module.cssindex e2892b6f1..23d695982 100644--- a/src/components/ai-edition/NewEditorShell.module.css+++ b/src/components/ai-edition/NewEditorShell.module.css@@ -1446,6 +1446,15 @@ textarea.control {background: var(--accent-soft);color: var(--fg);}+/* A cursor pictured in its cell (style and type pickers), sized by the cell rather than in+ pixels: the art keeps the same share of it at any pane width. */+.cursorSprite {+ width: 60%;+ height: auto;+ aspect-ratio: 1;+ object-fit: contain;+ pointer-events: none;+}/* The cursor types (CursorPane): a dimmed type is drawn as the arrow. The arrow's own cell is nota control, it is what the others become. */.cursorCellOff img { opacity: 0.35; transition: opacity 150ms ease; }diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex e48823a6a..0fafc82f5 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -48,7 +48,6 @@ import {useState,} from "react";import { toast } from "sonner";-import defaultCursorPreviewUrl from "@/assets/cursors/Cursor=Default.svg";import { toFileUrl } from "@/components/video-editor/projectPersistence";import {WALLPAPER_MOTIONS,@@ -112,6 +111,7 @@ import {CURSOR_KINDS,CURSOR_THEMES,type CursorKind,+ DEFAULT_CURSOR_SPRITES,DEFAULT_CURSOR_THEME_ID,resolveCursorSprites,themePickerPreviewAssets,@@ -3653,23 +3653,18 @@ export function CursorPane() {// handlers below push diffs live. Sizes are sent as direct scales (1 = fixture default).// Synchro initiale : cf. NativeCompositorOverlay (`pushAllNativeParams`).- // Built-in "Default" plus each bundled theme, previewed by its main arrow only.+ // Built-in "Default" plus each bundled theme, previewed by its main arrow only: the sprite the+ // compositor draws, centred on its art. The default's SVG drew its arrow in the lower-right+ // corner of an empty square, off the centre of its cell.const cursorThemeOptions = useMemo(- () => [- {- id: DEFAULT_CURSOR_THEME_ID,- name: ts("cursor.themeDefault"),- previewUrl: defaultCursorPreviewUrl,- },- ...CURSOR_THEMES.map((theme) => {- const { arrow } = themePickerPreviewAssets(theme);- return {- id: theme.id,- name: theme.name,- previewUrl: arrow ? safeAssetUrl(arrow) : defaultCursorPreviewUrl,- };- }),- ],+ () =>+ [null, ...CURSOR_THEMES].map((theme) => ({+ id: theme?.id ?? DEFAULT_CURSOR_THEME_ID,+ name: theme?.name ?? ts("cursor.themeDefault"),+ previewUrl: safeAssetUrl(+ themePickerPreviewAssets(theme).arrow || DEFAULT_CURSOR_SPRITES.arrow.assetPath,+ ),+ })),[ts],);@@ -3764,10 +3759,8 @@ export function CursorPane() {<imgsrc={option.previewUrl}alt=""- width={20}- height={20}+ className={styles.cursorSprite}draggable={false}- style={{ objectFit: "contain", pointerEvents: "none" }}/></button>);@@ -3816,10 +3809,8 @@ export function CursorPane() {<imgsrc={safeAssetUrl(cursorSprites.arrow.assetPath)}alt=""- width={20}- height={20}+ className={styles.cursorSprite}draggable={false}- style={{ objectFit: "contain", pointerEvents: "none" }}/></span>{recordedKinds.map(({ kind, type }) => {@@ -3847,10 +3838,8 @@ export function CursorPane() {<imgsrc={safeAssetUrl(cursorSprites[type].assetPath)}alt=""- width={20}- height={20}+ className={styles.cursorSprite}draggable={false}- style={{ objectFit: "contain", pointerEvents: "none" }}/></button>);diff --git a/src/components/video-editor/editorDefaults.ts b/src/components/video-editor/editorDefaults.tsindex 13afdb5d5..4c3a2589a 100644--- a/src/components/video-editor/editorDefaults.ts+++ b/src/components/video-editor/editorDefaults.ts@@ -82,7 +82,7 @@ export const DEFAULT_CURSOR_SETTINGS: CursorVisualSettings & { show: boolean; thmotionBlur: DEFAULT_CURSOR_MOTION_BLUR,clickBounce: DEFAULT_CURSOR_CLICK_BOUNCE,model3d: DEFAULT_CURSOR_MODEL3D,- asArrow: [],+ asArrow: DEFAULT_PROJECT_APPEARANCE.cursor.asArrow,clickImpact: false,theme: DEFAULT_CURSOR_THEME_ID,};diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.tsindex 9977eac3c..6347822b7 100644--- a/src/components/video-editor/projectPersistence.ts+++ b/src/components/video-editor/projectPersistence.ts@@ -511,8 +511,8 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro...(isFiniteNumber(editor.cursorClickBounce)? { cursorClickBounce: editor.cursorClickBounce }: {}),- ...(editor.cursorAsArrow !== undefined- ? { cursorAsArrow: readCursorAsArrow(editor.cursorAsArrow) }+ ...(Array.isArray(editor.cursorAsArrow)+ ? { cursorAsArrow: readCursorAsArrow(editor.cursorAsArrow, undefined, []) }: {}),...(typeof editor.cursorAlwaysArrow === "boolean"? { cursorAlwaysArrow: editor.cursorAlwaysArrow }diff --git a/src/lib/ai-edition/store/editorSettings.test.ts b/src/lib/ai-edition/store/editorSettings.test.tsindex afe28f1ef..b31ca9e93 100644--- a/src/lib/ai-edition/store/editorSettings.test.ts+++ b/src/lib/ai-edition/store/editorSettings.test.ts@@ -185,7 +185,9 @@ describe("patchEditorSettings", () => {});it("stores the cursor kinds drawn as the arrow, and drops the switch they replace", () => {- expect(getEditorSettings(baseDoc).cursor.asArrow).toEqual([]);+ expect(getEditorSettings(baseDoc).cursor.asArrow).toEqual(+ DEFAULT_EDITOR_SETTINGS.cursor.asArrow,+ );const old = patchEditorSettings(baseDoc, {});old.legacyEditor = { ...old.legacyEditor, cursorAlwaysArrow: true };expect(getEditorSettings(old).cursor.asArrow).toHaveLength(9);diff --git a/src/lib/ai-edition/store/editorSettings.ts b/src/lib/ai-edition/store/editorSettings.tsindex fcb80a906..f8298e295 100644--- a/src/lib/ai-edition/store/editorSettings.ts+++ b/src/lib/ai-edition/store/editorSettings.ts@@ -229,7 +229,11 @@ export function getEditorSettings(doc: AxcutDocument | null | undefined): Editor),// Absent in every project saved before the setting existed: those keep the flat cursor.model3d: bool(legacy?.cursorModel3d, DEFAULT_EDITOR_SETTINGS.cursor.model3d),- asArrow: readCursorAsArrow(legacy?.cursorAsArrow, legacy?.cursorAlwaysArrow),+ asArrow: readCursorAsArrow(+ legacy?.cursorAsArrow,+ legacy?.cursorAlwaysArrow,+ defaults.cursor.asArrow,+ ),clickImpact: bool(legacy?.cursorClickImpact, DEFAULT_EDITOR_SETTINGS.cursor.clickImpact),autoHide: bool(legacy?.cursorAutoHide, DEFAULT_EDITOR_SETTINGS.cursorAutoHide),};diff --git a/src/lib/ai-edition/stylePresets.test.ts b/src/lib/ai-edition/stylePresets.test.tsindex f409b0723..0bbade597 100644--- a/src/lib/ai-edition/stylePresets.test.ts+++ b/src/lib/ai-edition/stylePresets.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from "vitest";import { CURSOR_KIND_IDS } from "../cursor/cursorThemes";+import { DEFAULT_PROJECT_APPEARANCE } from "../projectDefaults";import {parseStylePresetAppearance,parseStylePresetFile,@@ -176,13 +177,15 @@ describe("parseStylePresetAppearance", () => {expect(() => read({ asArrow: [1] })).toThrow(/cursor\.asArrow/);});- // Before the kinds, one switch drew every cursor as the arrow; before that, nothing did.+ // Before the kinds, one switch drew every cursor as the arrow. Off was its default, so a preset+ // with it off chose nothing and gets today's default: the arrow and the hand.it("reads a preset saved before the cursor kinds from its always-arrow switch", () => {const { asArrow: _asArrow, ...older } = appearance().cursor;const read = (cursor: Record<string, unknown>) =>parseStylePresetAppearance({ ...appearance(), cursor }).cursor.asArrow;- expect(read(older)).toEqual([]);- expect(read({ ...older, alwaysArrow: false })).toEqual([]);+ const byDefault = DEFAULT_PROJECT_APPEARANCE.cursor.asArrow;+ expect(read(older)).toEqual(byDefault);+ expect(read({ ...older, alwaysArrow: false })).toEqual(byDefault);expect(read({ ...older, alwaysArrow: true })).toEqual(CURSOR_KIND_IDS);expect(() => read({ ...older, alwaysArrow: "yes" })).toThrow(/cursor\.alwaysArrow/);});diff --git a/src/lib/ai-edition/stylePresets.ts b/src/lib/ai-edition/stylePresets.tsindex cc5070e05..2c9ea2a1f 100644--- a/src/lib/ai-edition/stylePresets.ts+++ b/src/lib/ai-edition/stylePresets.ts@@ -27,6 +27,7 @@ import {} from "../cursor/cursorThemes";import {clampToBound,+ DEFAULT_PROJECT_APPEARANCE,type FrameTheme,isFrameTheme,type RecordingFrame,@@ -205,19 +206,20 @@ function readFrame(source: Fields): { frame: RecordingFrame; frameTheme: FrameTh/*** The cursor kinds drawn as the arrow. A kind this build does not know (a newer build's) is* dropped, the way an unknown theme falls back to the default. A preset written before the kinds- * could be picked carries the one switch there was, or nothing: every cursor as recorded.+ * could be picked carries the one switch there was, or nothing: the project default then.*/function readAsArrow(cursor: Fields): CursorKind[] {const value = cursor.asArrow;+ const fallback = DEFAULT_PROJECT_APPEARANCE.cursor.asArrow;if (value === undefined) {const always =cursor.alwaysArrow === undefined ? false : readBoolean(cursor, "alwaysArrow", "cursor.");- return readCursorAsArrow(undefined, always);+ return readCursorAsArrow(undefined, always, fallback);}if (!Array.isArray(value) || value.some((kind) => typeof kind !== "string")) {throw new TypeError("Style preset cursor.asArrow must be a list of cursor kinds.");}- return readCursorAsArrow(value);+ return readCursorAsArrow(value, undefined, fallback);}const HEX_COLOR_RE = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;@@ -280,7 +282,7 @@ export function parseStylePresetWallpaper(value: unknown, key = "wallpaper"): st* otherwise sound (the editor does the same when it renders one). The others postdate the* first version-1 files, so a preset saved before one of them existed carries no choice about* it and gets the value that means "unchanged": `cursor.model3d` may be absent (the flat- * cursor), `cursor.asArrow` too (every cursor as recorded, see `readAsArrow`),+ * cursor), `cursor.asArrow` too (the project default, see `readAsArrow`),* `wallpaperMotion` too (a still wallpaper, which is exactly what "none" means),* `frame` as well (no frame, see `readFrame`), and `depthOfField` keeps the factory* value (on). A present but ill-typed value is still refused. Unknown extra keys are dropped.diff --git a/src/lib/cursor/cursorThemes.test.ts b/src/lib/cursor/cursorThemes.test.tsindex a342323ac..e712e8ad4 100644--- a/src/lib/cursor/cursorThemes.test.ts+++ b/src/lib/cursor/cursorThemes.test.ts@@ -1,6 +1,7 @@import { readFileSync } from "node:fs";import { join } from "node:path";import { describe, expect, it } from "vitest";+import { DEFAULT_PROJECT_APPEARANCE } from "../projectDefaults";import {CURSOR_KIND_IDS,CURSOR_KINDS,@@ -112,20 +113,31 @@ describe("cursor kinds", () => {});describe("readCursorAsArrow", () => {+ const fallback = ["busy"] as const;+it("keeps the known kinds, once each, in the order of CURSOR_KINDS", () => {- expect(readCursorAsArrow(["text", "sparkles", "pointer", "text", 7])).toEqual([- "pointer",- "text",- ]);- expect(readCursorAsArrow("text")).toEqual([]);+ expect(+ readCursorAsArrow(["text", "sparkles", "pointer", "text", 7], undefined, fallback),+ ).toEqual(["pointer", "text"]);+ expect(readCursorAsArrow([], undefined, fallback)).toEqual([]);+ expect(readCursorAsArrow("text", undefined, fallback)).toEqual(["busy"]);});- // The single switch the kinds replaced: on meant every one of them, off or absent none.+ // The single switch the kinds replaced: on meant every one of them. Off was its default, so it+ // says no more than an absent list does.it("reads the old always-arrow switch when there is no list", () => {- expect(readCursorAsArrow(undefined, true)).toEqual(CURSOR_KIND_IDS);- expect(readCursorAsArrow(undefined, false)).toEqual([]);- expect(readCursorAsArrow(undefined)).toEqual([]);- expect(readCursorAsArrow(["busy"], true)).toEqual(["busy"]);+ expect(readCursorAsArrow(undefined, true, fallback)).toEqual(CURSOR_KIND_IDS);+ expect(readCursorAsArrow(undefined, false, fallback)).toEqual(["busy"]);+ expect(readCursorAsArrow(undefined, undefined, fallback)).toEqual(["busy"]);+ expect(readCursorAsArrow(["text"], true, fallback)).toEqual(["text"]);+ });++ // Out of the box a project shows the arrow and the hand, and nothing else: a kind added to+ // CURSOR_KINDS has to join the default too, or new projects would start drawing it.+ it("defaults to every kind but the hand", () => {+ expect(DEFAULT_PROJECT_APPEARANCE.cursor.asArrow).toEqual(+ CURSOR_KIND_IDS.filter((kind) => kind !== "pointer"),+ );});});diff --git a/src/lib/cursor/cursorThemes.ts b/src/lib/cursor/cursorThemes.tsindex 52fd23bde..ada3ee416 100644--- a/src/lib/cursor/cursorThemes.ts+++ b/src/lib/cursor/cursorThemes.ts@@ -114,12 +114,17 @@ export const CURSOR_KIND_IDS = Object.keys(CURSOR_KINDS) as CursorKind[];/*** The kinds a project draws as the arrow, from what it stored: known ids only, once each, in- * `CURSOR_KINDS` order. `alwaysArrow` is the single switch that came before the kinds could be- * picked: on meant all of them.+ * `CURSOR_KINDS` order, and `fallback` (the project default) when it stored no list.+ * `alwaysArrow` is the single switch that came before the kinds could be picked: on meant all of+ * them, off was its default and says nothing more than an absent list.*/-export function readCursorAsArrow(asArrow: unknown, alwaysArrow?: unknown): CursorKind[] {- if (asArrow === undefined) return alwaysArrow === true ? [...CURSOR_KIND_IDS] : [];- return Array.isArray(asArrow) ? CURSOR_KIND_IDS.filter((kind) => asArrow.includes(kind)) : [];+export function readCursorAsArrow(+ asArrow: unknown,+ alwaysArrow: unknown,+ fallback: readonly CursorKind[],+): CursorKind[] {+ if (Array.isArray(asArrow)) return CURSOR_KIND_IDS.filter((kind) => asArrow.includes(kind));+ return alwaysArrow === true ? [...CURSOR_KIND_IDS] : [...fallback];}/**diff --git a/src/lib/projectDefaults.ts b/src/lib/projectDefaults.tsindex cbcb490b6..a016dba85 100644--- a/src/lib/projectDefaults.ts+++ b/src/lib/projectDefaults.ts@@ -244,8 +244,9 @@ export const DEFAULT_PROJECT_APPEARANCE: ProjectAppearanceDefaults = {// A light tap: 2.5 squashed the arrow to 40% and threw it to 140% in 260 ms on every click.clickBounce: 1,model3d: false,- // Every cursor as recorded.- asArrow: [],+ // The arrow and the hand, the two cursors a viewer follows; every other one is drawn as the+ // arrow until picked (`CURSOR_KINDS`). A test holds this to every kind but the hand.+ asArrow: ["text", "grab", "resize", "busy", "crosshair", "not-allowed", "help", "up-arrow"],clickImpact: false,autoHide: false,},diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex 39c6c99bd..b15d23cd1 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -1301,11 +1301,14 @@ describe("buildSceneDescription.settings mapping", () => {expect(cursor.asArrow).toEqual(["pointer", "text"]);});- // The single switch that came before the kinds: on drew every one of them as the arrow.+ // The single switch that came before the kinds: on drew every one of them as the arrow. With+ // neither, only the hand keeps its own sprite.it("reads the old always-arrow switch as every cursor kind", () => {const on = makeDoc({ legacyEditor: { cursorAlwaysArrow: true } });expect(buildSceneDescription(on).cursor.asArrow).toEqual(CURSOR_KIND_IDS);- expect(buildSceneDescription(makeDoc({})).cursor.asArrow).toEqual([]);+ expect(buildSceneDescription(makeDoc({})).cursor.asArrow).toEqual(+ CURSOR_KIND_IDS.filter((kind) => kind !== "pointer"),+ );});it("maps show / theme / shape / mirror through to layout+cursor", () => {