-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(recording): add zoom marker shortcut while recording #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
muhammad-a-dev
wants to merge
29
commits into
webadderallorg:main
Choose a base branch
from
muhammad-a-dev:feat/recording-zoom-shortcut
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
70a05d5
feat(recording): add manual zoom markers helper and types
muhammad-a-dev 9366132
feat(recording): add fresh recording manual zoom hook
muhammad-a-dev b8b7881
feat(recording): add manual-zoom to CursorInteractionType
muhammad-a-dev d57bf14
feat(recording): add manual zoom pending refs to editor UI state
muhammad-a-dev 373fd82
feat(recording): restore editor UI state with manual zoom refs
muhammad-a-dev 58430d4
test
muhammad-a-dev 663cc59
feat(recording): restore project open actions with manual zoom pendin…
muhammad-a-dev 7d153be
feat(recording): restore project open actions with manual zoom pendin…
muhammad-a-dev 3d00b6f
feat(recording): capture manual zoom markers in cursor telemetry
muhammad-a-dev e6f6a97
feat(recording): restore cursor telemetry with manual zoom capture
muhammad-a-dev fcd5302
feat(recording): add manual-zoom to ipc CursorInteractionType
muhammad-a-dev 6afd0bc
feat(recording): add pending manual zoom refs to editor UI state
muhammad-a-dev a89ed22
feat(recording): set pending manual zoom path when importing media
muhammad-a-dev 852a50f
feat(recording): add CommandOrControl+Alt+Z zoom marker shortcut helper
muhammad-a-dev 1c254d7
chore: size probe (will replace)
muhammad-a-dev a394e60
feat(recording): register zoom shortcut from IPC recording state changes
muhammad-a-dev db691b6
feat(recording): add manual zoom region builder and fresh-recording hook
muhammad-a-dev 5b201ef
feat(recording): call manual zoom hook from timeline editing controller
muhammad-a-dev 10740e1
chore: remove size probe file
muhammad-a-dev 98611fa
feat(recording): queue manual zoom path when opening a fresh recording
muhammad-a-dev 643151f
feat(recording): thread manual zoom refs through project controller
muhammad-a-dev d968fee
feat(recording): wire manual zoom refs in VideoEditor
muhammad-a-dev 96d148f
feat(recording): reset manual zoom refs on project lifecycle events
muhammad-a-dev 3c01089
feat(recording): add manual-zoom to video editor CursorInteractionType
muhammad-a-dev 11cd958
feat(recording): extract CursorTelemetryPoint with manual-zoom type
muhammad-a-dev e983080
revert: remove split CursorTelemetryPoint file pending electron-env u…
muhammad-a-dev a0049c8
chore: size probe small first
muhammad-a-dev 8b7974b
chore: remove size probe file
muhammad-a-dev cbaae96
fix(recording): keep manual-zoom markers and allow close shortcut pre…
muhammad-a-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { app, globalShortcut } from "electron"; | ||
| import { captureManualZoomMarker } from "./ipc/cursor/telemetry"; | ||
|
|
||
| const RECORDING_ZOOM_SHORTCUT = "CommandOrControl+Alt+Z"; | ||
| const RECORDING_ZOOM_SHORTCUT_THROTTLE_MS = 500; | ||
|
|
||
| let recordingZoomShortcutRegistered = false; | ||
| let lastRecordingZoomShortcutAtMs = 0; | ||
| let beforeQuitHookInstalled = false; | ||
|
|
||
| function addRecordingZoomMarkerFromShortcut() { | ||
| const now = Date.now(); | ||
| if (now - lastRecordingZoomShortcutAtMs < RECORDING_ZOOM_SHORTCUT_THROTTLE_MS) { | ||
| return; | ||
| } | ||
|
|
||
| lastRecordingZoomShortcutAtMs = now; | ||
| if (captureManualZoomMarker()) { | ||
| console.log(`[recording-zoom] Added zoom marker via ${RECORDING_ZOOM_SHORTCUT}`); | ||
| } | ||
| } | ||
|
|
||
| function ensureBeforeQuitHook() { | ||
| if (beforeQuitHookInstalled) { | ||
| return; | ||
| } | ||
| beforeQuitHookInstalled = true; | ||
| app.on("before-quit", () => { | ||
| unregisterRecordingZoomShortcut(); | ||
| }); | ||
| } | ||
|
|
||
| export function registerRecordingZoomShortcut() { | ||
| ensureBeforeQuitHook(); | ||
| if (recordingZoomShortcutRegistered) { | ||
| return; | ||
| } | ||
|
|
||
| recordingZoomShortcutRegistered = globalShortcut.register( | ||
| RECORDING_ZOOM_SHORTCUT, | ||
| addRecordingZoomMarkerFromShortcut, | ||
| ); | ||
|
|
||
| if (!recordingZoomShortcutRegistered) { | ||
| console.warn( | ||
| `[recording-zoom] Failed to register ${RECORDING_ZOOM_SHORTCUT}; another app may already be using it.`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export function unregisterRecordingZoomShortcut() { | ||
| if (!recordingZoomShortcutRegistered) { | ||
| return; | ||
| } | ||
|
|
||
| globalShortcut.unregister(RECORDING_ZOOM_SHORTCUT); | ||
| recordingZoomShortcutRegistered = false; | ||
| lastRecordingZoomShortcutAtMs = 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/components/video-editor/hooks/useFreshRecordingManualZoom.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { | ||
| type Dispatch, | ||
| type MutableRefObject, | ||
| type SetStateAction, | ||
| useEffect, | ||
| } from "react"; | ||
| import { buildManualRecordingZoomRegions } from "../timeline/recordingZoomMarkers"; | ||
| import { | ||
| clampFocusToDepth, | ||
| DEFAULT_ZOOM_DEPTH, | ||
| type CursorTelemetryPoint, | ||
| type ZoomRegion, | ||
| } from "../types"; | ||
|
|
||
| interface UseFreshRecordingManualZoomParams { | ||
| videoPath: string | null; | ||
| loading: boolean; | ||
| duration: number; | ||
| normalizedCursorTelemetry: CursorTelemetryPoint[]; | ||
| zoomRegions: ZoomRegion[]; | ||
| setZoomRegions: Dispatch<SetStateAction<ZoomRegion[]>>; | ||
| nextZoomIdRef: MutableRefObject<number>; | ||
| autoSuggestedVideoPathRef: MutableRefObject<string | null>; | ||
| pendingFreshRecordingAutoZoomPathRef: MutableRefObject<string | null>; | ||
| pendingFreshRecordingManualZoomPathRef: MutableRefObject<string | null>; | ||
| manualRecordingZoomsAppliedVideoPathRef: MutableRefObject<string | null>; | ||
| } | ||
|
|
||
| export function useFreshRecordingManualZoom({ | ||
| videoPath, | ||
| loading, | ||
| duration, | ||
| normalizedCursorTelemetry, | ||
| zoomRegions, | ||
| setZoomRegions, | ||
| nextZoomIdRef, | ||
| autoSuggestedVideoPathRef, | ||
| pendingFreshRecordingAutoZoomPathRef, | ||
| pendingFreshRecordingManualZoomPathRef, | ||
| manualRecordingZoomsAppliedVideoPathRef, | ||
| }: UseFreshRecordingManualZoomParams) { | ||
| useEffect(() => { | ||
| if (!videoPath || loading || duration <= 0 || normalizedCursorTelemetry.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| if (pendingFreshRecordingManualZoomPathRef.current !== videoPath) { | ||
| return; | ||
| } | ||
|
|
||
| if (manualRecordingZoomsAppliedVideoPathRef.current === videoPath) { | ||
| return; | ||
| } | ||
|
|
||
| const totalMs = Math.round(duration * 1000); | ||
| const manualRegions = buildManualRecordingZoomRegions({ | ||
| cursorTelemetry: normalizedCursorTelemetry, | ||
| totalMs, | ||
| defaultDurationMs: Math.min(1000, totalMs), | ||
| reservedSpans: zoomRegions.map((region) => ({ | ||
| start: region.startMs, | ||
| end: region.endMs, | ||
| })), | ||
| }); | ||
|
|
||
| manualRecordingZoomsAppliedVideoPathRef.current = videoPath; | ||
| pendingFreshRecordingManualZoomPathRef.current = null; | ||
|
|
||
| if (manualRegions.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| setZoomRegions((previous) => [ | ||
| ...previous, | ||
| ...manualRegions.map((region) => ({ | ||
| id: `zoom-${nextZoomIdRef.current++}`, | ||
| startMs: region.start, | ||
| endMs: region.end, | ||
| depth: DEFAULT_ZOOM_DEPTH, | ||
| focus: clampFocusToDepth(region.focus, DEFAULT_ZOOM_DEPTH), | ||
| mode: "manual" as const, | ||
| })), | ||
| ]); | ||
| autoSuggestedVideoPathRef.current = videoPath; | ||
| pendingFreshRecordingAutoZoomPathRef.current = null; | ||
| }, [ | ||
| videoPath, | ||
| loading, | ||
| duration, | ||
| normalizedCursorTelemetry, | ||
| zoomRegions, | ||
| setZoomRegions, | ||
| nextZoomIdRef, | ||
| autoSuggestedVideoPathRef, | ||
| pendingFreshRecordingAutoZoomPathRef, | ||
| pendingFreshRecordingManualZoomPathRef, | ||
| manualRecordingZoomsAppliedVideoPathRef, | ||
| ]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.