Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 137 additions & 10 deletions src/components/video-editor/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import type {
AutoCaptionSettings,
CaptionCue,
CropRegion,
CursorClickEffectProfile,
CursorClickEffectStyle,
CursorStyle,
EditorEffectSection,
Expand Down Expand Up @@ -589,6 +590,8 @@ interface SettingsPanelProps {
onZoomClassicModeChange?: (enabled: boolean) => void;
cursorClickEffect?: CursorClickEffectStyle;
onCursorClickEffectChange?: (effect: CursorClickEffectStyle) => void;
rightClickEffect?: CursorClickEffectProfile;
onRightClickEffectChange?: (profile?: CursorClickEffectProfile) => void;
cursorClickEffectColor?: string;
onCursorClickEffectColorChange?: (color: string) => void;
cursorClickEffectScale?: number;
Expand Down Expand Up @@ -1037,6 +1040,8 @@ export function SettingsPanel({
onZoomClassicModeChange,
cursorClickEffect = DEFAULT_CURSOR_CLICK_EFFECT,
onCursorClickEffectChange,
rightClickEffect,
onRightClickEffectChange,
cursorClickEffectColor = DEFAULT_CURSOR_CLICK_EFFECT_COLOR,
onCursorClickEffectColorChange,
cursorClickEffectScale = DEFAULT_CURSOR_CLICK_EFFECT_SCALE,
Expand Down Expand Up @@ -1249,6 +1254,56 @@ export function SettingsPanel({
Partial<Record<string, string>>
>({});
const [showCursorClickEffectAdvanced, setShowCursorClickEffectAdvanced] = useState(false);
const [clickEffectTarget, setClickEffectTarget] = useState<"left" | "right">("left");
const activeClickEffect =
clickEffectTarget === "right"
? (rightClickEffect?.effect ?? cursorClickEffect)
: cursorClickEffect;
const activeClickEffectColor =
clickEffectTarget === "right"
? (rightClickEffect?.color ?? cursorClickEffectColor)
: cursorClickEffectColor;
const activeClickEffectScale =
clickEffectTarget === "right"
? (rightClickEffect?.scale ?? cursorClickEffectScale)
: cursorClickEffectScale;
const rightClickFollowsLeft = !rightClickEffect;
const updateActiveClickEffect = (effect: CursorClickEffectStyle) => {
if (clickEffectTarget === "left") {
onCursorClickEffectChange?.(effect);
return;
}

onRightClickEffectChange?.({
effect,
color: activeClickEffectColor,
scale: activeClickEffectScale,
});
};
const updateActiveClickEffectColor = (color: string) => {
if (clickEffectTarget === "left") {
onCursorClickEffectColorChange?.(color);
return;
}

onRightClickEffectChange?.({
effect: activeClickEffect,
color,
scale: activeClickEffectScale,
});
};
const updateActiveClickEffectScale = (scale: number) => {
if (clickEffectTarget === "left") {
onCursorClickEffectScaleChange?.(scale);
return;
}

onRightClickEffectChange?.({
effect: activeClickEffect,
color: activeClickEffectColor,
scale,
});
};
const cursorPreviewUrls = builtInCursorPreviewUrls;
const showDevMotionControls = import.meta.env.DEV;
const cursorStyleOptions = BUILTIN_CURSOR_STYLE_OPTIONS;
Expand Down Expand Up @@ -1579,6 +1634,7 @@ export function SettingsPanel({
onCursorSpringMassMultiplierChange?.(initialEditorPreferences.cursorSpringMassMultiplier);
onCursorClickEffectChange?.(initialEditorPreferences.cursorClickEffect);
onCursorClickEffectColorChange?.(initialEditorPreferences.cursorClickEffectColor);
onRightClickEffectChange?.(initialEditorPreferences.rightClickEffect);
onCursorClickEffectScaleChange?.(initialEditorPreferences.cursorClickEffectScale);
onCursorClickEffectOpacityChange?.(initialEditorPreferences.cursorClickEffectOpacity);
onCursorClickEffectDurationMsChange?.(initialEditorPreferences.cursorClickEffectDurationMs);
Expand Down Expand Up @@ -3311,14 +3367,85 @@ export function SettingsPanel({
formatValue={(v) => `${v.toFixed(2)}×`}
parseInput={(text) => parseFloat(text.replace(/×$/, ""))}
/>
<div className="grid gap-2">
<div className="text-[10px] text-muted-foreground">
{tSettings("effects.cursorClickEffects.target", "Click button")}
</div>
<ToggleGroup
type="single"
value={clickEffectTarget}
onValueChange={(value) => {
if (value === "left" || value === "right") {
setClickEffectTarget(value);
}
}}
className="grid grid-cols-2 gap-1 rounded-lg bg-foreground/[0.04] p-1"
aria-label={tSettings(
"effects.cursorClickEffects.target",
"Click button",
)}
>
<ToggleGroupItem
value="left"
className="h-7 rounded-md text-[10px] data-[state=on]:bg-background"
>
{tSettings("effects.cursorClickEffects.left", "Left click")}
</ToggleGroupItem>
<ToggleGroupItem
value="right"
className="h-7 rounded-md text-[10px] data-[state=on]:bg-background"
>
{tSettings(
"effects.cursorClickEffects.right",
"Right click",
)}
</ToggleGroupItem>
</ToggleGroup>
{clickEffectTarget === "right" ? (
<div className="flex items-center justify-between gap-3 rounded-lg border border-foreground/10 px-2.5 py-2">
<div className="grid gap-0.5">
<div className="text-[10px] text-foreground">
{tSettings(
"effects.cursorClickEffects.followLeft",
"Follow left click",
)}
</div>
<div className="text-[9px] text-muted-foreground">
{tSettings(
"effects.cursorClickEffects.followLeftDescription",
"Use the left-click effect until you customize this profile.",
)}
</div>
</div>
<Switch
checked={rightClickFollowsLeft}
onCheckedChange={(checked) => {
onRightClickEffectChange?.(
checked
? undefined
: {
effect: cursorClickEffect,
color: cursorClickEffectColor,
scale: cursorClickEffectScale,
},
);
}}
aria-label={tSettings(
"effects.cursorClickEffects.followLeft",
"Follow left click",
)}
/>
</div>
) : null}
</div>
<CursorClickEffectCards
title={tSettings(
"effects.cursorClickEffects.title",
"Click Effects",
)}
activeEffectId={cursorClickEffect}
effectColor={cursorClickEffectColor}
onApply={(effectId) => onCursorClickEffectChange?.(effectId)}
activeEffectId={activeClickEffect}
effectColor={activeClickEffectColor}
onApply={updateActiveClickEffect}
showAdvanced={showCursorClickEffectAdvanced}
onToggleAdvanced={() =>
setShowCursorClickEffectAdvanced((current) => !current)
Expand All @@ -3330,9 +3457,9 @@ export function SettingsPanel({
<input
ref={cursorClickEffectColorInputRef}
type="color"
value={cursorClickEffectColor}
value={activeClickEffectColor}
onChange={(event) =>
onCursorClickEffectColorChange?.(event.target.value)
updateActiveClickEffectColor(event.target.value)
}
className="sr-only"
/>
Expand All @@ -3346,14 +3473,14 @@ export function SettingsPanel({
<div className="flex flex-wrap gap-1.5">
{CLICK_EFFECT_COLOR_OPTIONS.map((color) => {
const isSelected =
cursorClickEffectColor.toLowerCase() ===
activeClickEffectColor.toLowerCase() ===
color.toLowerCase();
return (
<button
key={color}
type="button"
onClick={() =>
onCursorClickEffectColorChange?.(color)
updateActiveClickEffectColor(color)
}
className={cn(
"h-6 w-6 rounded-[8px] border transition-transform hover:scale-[1.04]",
Expand All @@ -3373,7 +3500,7 @@ export function SettingsPanel({
}
className="relative h-6 w-10 overflow-hidden rounded-[8px] border border-foreground/10 text-[8px] font-semibold uppercase tracking-[0.18em] text-foreground"
style={{
background: `linear-gradient(135deg, ${cursorClickEffectColor} 0%, ${cursorClickEffectColor} 58%, rgba(255,255,255,0.92) 58%, rgba(255,255,255,0.92) 100%)`,
background: `linear-gradient(135deg, ${activeClickEffectColor} 0%, ${activeClickEffectColor} 58%, rgba(255,255,255,0.92) 58%, rgba(255,255,255,0.92) 100%)`,
}}
aria-label="Custom effect color picker"
>
Expand All @@ -3388,12 +3515,12 @@ export function SettingsPanel({
"effects.cursorClickEffects.size",
"Effect Size",
)}
value={cursorClickEffectScale}
value={activeClickEffectScale}
defaultValue={DEFAULT_CURSOR_CLICK_EFFECT_SCALE}
min={0.5}
max={2}
step={0.05}
onChange={(v) => onCursorClickEffectScaleChange?.(v)}
onChange={updateActiveClickEffectScale}
formatValue={(v) => `${v.toFixed(2)}×`}
parseInput={(text) => parseFloat(text.replace(/×$/, ""))}
/>
Expand Down
17 changes: 13 additions & 4 deletions src/components/video-editor/VideoPlayback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
type AutoCaptionSettings,
type CaptionCue,
type ClipRegion,
type CursorClickEffectProfile,
type CursorClickEffectStyle,
type CursorStyle,
DEFAULT_CONNECTED_ZOOM_DURATION_MS,
Expand Down Expand Up @@ -115,13 +116,13 @@ import {
import { updateOverlayIndicator } from "./videoPlayback/overlayUtils";
import { supportsPreviewPlaybackRate } from "./videoPlayback/playbackRate";
import { PreviewVideoSource } from "./videoPlayback/previewVideoSource";
import { usePreviewVideoReady } from "./videoPlayback/usePreviewVideoReady";
import { getSceneEffectMetrics } from "./videoPlayback/sceneEffects";
import {
resolvePreviewMotionMode,
resolveSceneZoomTarget,
shouldComposePreviewFrame,
} from "./videoPlayback/sceneMotion";
import { usePreviewVideoReady } from "./videoPlayback/usePreviewVideoReady";
import {
getWebcamMediaTargetTimeSeconds,
isWebcamMediaSynchronized,
Expand Down Expand Up @@ -276,6 +277,7 @@ interface VideoPlaybackProps {
zoomMotionBlurTuning?: ZoomMotionBlurTuning;
cursorMotionBlur?: number;
cursorClickEffect?: CursorClickEffectStyle;
rightClickEffect?: CursorClickEffectProfile;
cursorClickEffectColor?: string;
cursorClickEffectScale?: number;
cursorClickEffectOpacity?: number;
Expand Down Expand Up @@ -361,6 +363,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
zoomMotionBlurTuning = DEFAULT_ZOOM_MOTION_BLUR_TUNING,
cursorMotionBlur = DEFAULT_CURSOR_MOTION_BLUR,
cursorClickEffect = DEFAULT_CURSOR_CLICK_EFFECT,
rightClickEffect,
cursorClickEffectColor = DEFAULT_CURSOR_CLICK_EFFECT_COLOR,
cursorClickEffectScale = DEFAULT_CURSOR_CLICK_EFFECT_SCALE,
cursorClickEffectOpacity = DEFAULT_CURSOR_CLICK_EFFECT_OPACITY,
Expand Down Expand Up @@ -502,6 +505,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
const cameraSpringMassMultiplierRef = useRef(cameraSpringMassMultiplier);
const cursorMotionBlurRef = useRef(cursorMotionBlur);
const cursorClickEffectRef = useRef(cursorClickEffect);
const rightClickEffectRef = useRef(rightClickEffect);
const cursorClickEffectColorRef = useRef(cursorClickEffectColor);
const cursorClickEffectScaleRef = useRef(cursorClickEffectScale);
const cursorClickEffectOpacityRef = useRef(cursorClickEffectOpacity);
Expand Down Expand Up @@ -530,9 +534,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
}, []);

const initializePixiRenderer = useCallback(
async (
container: HTMLDivElement,
): Promise<Application> => {
async (container: HTMLDivElement): Promise<Application> => {
const backendOrder: PixiPreviewBackend[] = ["webgl", "webgpu"];
const attempts: PixiRendererAttempt[] = [];

Expand Down Expand Up @@ -1499,6 +1501,10 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
cursorClickEffectRef.current = cursorClickEffect;
}, [cursorClickEffect]);

useEffect(() => {
rightClickEffectRef.current = rightClickEffect;
}, [rightClickEffect]);

useEffect(() => {
cursorClickEffectColorRef.current = cursorClickEffectColor;
}, [cursorClickEffectColor]);
Expand Down Expand Up @@ -1785,6 +1791,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
},
motionBlur: cursorMotionBlurRef.current,
clickEffect: cursorClickEffectRef.current,
rightClickEffect: rightClickEffectRef.current,
clickEffectColor: cursorClickEffectColorRef.current,
clickEffectScale: cursorClickEffectScaleRef.current,
clickEffectOpacity: cursorClickEffectOpacityRef.current,
Expand Down Expand Up @@ -2147,6 +2154,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
});
overlay.setMotionBlur(cursorMotionBlur);
overlay.setClickEffect(cursorClickEffect);
overlay.setRightClickEffect(rightClickEffect);
overlay.setClickEffectColor(cursorClickEffectColor);
overlay.setClickEffectScale(cursorClickEffectScale);
overlay.setClickEffectOpacity(cursorClickEffectOpacity);
Expand Down Expand Up @@ -2183,6 +2191,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
cursorSpringMassMultiplier,
cursorMotionBlur,
cursorClickEffect,
rightClickEffect,
cursorClickEffectColor,
cursorClickEffectScale,
cursorClickEffectOpacity,
Expand Down
3 changes: 3 additions & 0 deletions src/components/video-editor/editorPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type PersistedEditorControls = Pick<
| "cursorMotionBlur"
| "cursorClickEffect"
| "cursorClickEffectColor"
| "rightClickEffect"
| "cursorClickEffectScale"
| "cursorClickEffectOpacity"
| "cursorClickEffectDurationMs"
Expand Down Expand Up @@ -330,6 +331,7 @@ function normalizeEditorControls(
cursorClickEffect: sanitizedRaw.cursorClickEffect ?? fallback.cursorClickEffect,
cursorClickEffectColor:
sanitizedRaw.cursorClickEffectColor ?? fallback.cursorClickEffectColor,
rightClickEffect: sanitizedRaw.rightClickEffect ?? fallback.rightClickEffect,
cursorClickEffectScale:
sanitizedRaw.cursorClickEffectScale ?? fallback.cursorClickEffectScale,
cursorClickEffectOpacity:
Expand Down Expand Up @@ -395,6 +397,7 @@ function normalizeEditorControls(
cursorMotionBlur: normalized.cursorMotionBlur,
cursorClickEffect: normalized.cursorClickEffect,
cursorClickEffectColor: normalized.cursorClickEffectColor,
rightClickEffect: normalized.rightClickEffect,
cursorClickEffectScale: normalized.cursorClickEffectScale,
cursorClickEffectOpacity: normalized.cursorClickEffectOpacity,
cursorClickEffectDurationMs: normalized.cursorClickEffectDurationMs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function buildExportRenderOptions({
cursorMotionBlur: appearance.cursorMotionBlur,
cursorClickEffect: appearance.cursorClickEffect,
cursorClickEffectColor: appearance.cursorClickEffectColor,
rightClickEffect: appearance.rightClickEffect,
cursorClickEffectScale: appearance.cursorClickEffectScale,
cursorClickEffectOpacity: appearance.cursorClickEffectOpacity,
cursorClickEffectDurationMs: appearance.cursorClickEffectDurationMs,
Expand Down
1 change: 1 addition & 0 deletions src/components/video-editor/layout/EditorVideoPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export function EditorVideoPreview({
zoomMotionBlurTuning={appearance.zoomMotionBlurTuning}
cursorMotionBlur={appearance.cursorMotionBlur}
cursorClickEffect={appearance.cursorClickEffect}
rightClickEffect={appearance.rightClickEffect}
cursorClickEffectColor={appearance.cursorClickEffectColor}
cursorClickEffectScale={appearance.cursorClickEffectScale}
cursorClickEffectOpacity={appearance.cursorClickEffectOpacity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ export function useEditorSettingsPanelProps(input: Input): ComponentProps<typeof
onZoomClassicModeChange: appearance.setZoomClassicMode,
cursorClickEffect: appearance.cursorClickEffect,
cursorClickEffectColor: appearance.cursorClickEffectColor,
rightClickEffect: appearance.rightClickEffect,
onCursorClickEffectChange: appearance.setCursorClickEffect,
onCursorClickEffectColorChange: appearance.setCursorClickEffectColor,
onRightClickEffectChange: appearance.setRightClickEffect,
cursorClickEffectScale: appearance.cursorClickEffectScale,
onCursorClickEffectScaleChange: appearance.setCursorClickEffectScale,
cursorClickEffectOpacity: appearance.cursorClickEffectOpacity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function useEditorPreferencesPersistence({
cursorMotionBlur: appearance.cursorMotionBlur,
cursorClickEffect: appearance.cursorClickEffect,
cursorClickEffectColor: appearance.cursorClickEffectColor,
rightClickEffect: appearance.rightClickEffect,
cursorClickEffectScale: appearance.cursorClickEffectScale,
cursorClickEffectOpacity: appearance.cursorClickEffectOpacity,
cursorClickEffectDurationMs: appearance.cursorClickEffectDurationMs,
Expand Down Expand Up @@ -102,6 +103,7 @@ export function useEditorPreferencesPersistence({
appearance.cursorMotionBlur,
appearance.cursorClickEffect,
appearance.cursorClickEffectColor,
appearance.rightClickEffect,
appearance.cursorClickEffectScale,
appearance.cursorClickEffectOpacity,
appearance.cursorClickEffectDurationMs,
Expand Down
Loading