Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

Merge remote-tracking branch 'upstream/main' into codex/allow-png-background-upload

Sunwood-ai-labsd3b51e84f2c1
diff --cc electron/ipc/handlers.ts
index e067f5964,431cda1fc..19178be4f
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@@ -594,6 -718,48 +718,50 @@@ export function registerIpcHandlers
}
});
+ ipcMain.handle("request-screen-access", async () => {
+ if (process.platform !== "darwin") {
+ return { success: true, granted: true, status: "granted" };
+ }
+
+ try {
+ const status = systemPreferences.getMediaAccessStatus("screen");
+ if (status === "granted") {
+ return { success: true, granted: true, status };
+ }
+
+ // Screen recording has no askForMediaAccess equivalent — the TCC prompt
+ // is triggered by desktopCapturer.getSources(). Fire it and return so
+ // the renderer can re-check status after the user responds.
+ if (status === "not-determined") {
- desktopCapturer.getSources({ types: ["screen"] }).catch(() => {});
++ desktopCapturer.getSources({ types: ["screen"] }).catch(() => {
++ // Ignore prompt trigger failures; the renderer will re-check status.
++ });
+ return { success: true, granted: false, status: "not-determined" };
+ }
+
+ return { success: true, granted: false, status };
+ } catch (error) {
+ console.error("Failed to request screen access:", error);
+ return { success: false, granted: false, status: "unknown", error: String(error) };
+ }
+ });
+
+ // macOS Accessibility prompt for global click capture. First call shows the
+ // system dialog; the user has to toggle the app in System Settings (no
+ // programmatic grant exists for Accessibility).
+ ipcMain.handle("request-accessibility-access", () => {
+ if (process.platform !== "darwin") {
+ return { success: true, granted: true };
+ }
+ try {
+ const granted = systemPreferences.isTrustedAccessibilityClient(true);
+ return { success: true, granted };
+ } catch (error) {
+ console.error("Failed to request accessibility access:", error);
+ return { success: false, granted: false, error: String(error) };
+ }
+ });
+
ipcMain.handle("open-source-selector", () => {
const sourceSelectorWin = getSourceSelectorWindow();
if (sourceSelectorWin) {
diff --cc electron/main.ts
index ad0a33fc0,4e443a94e..3fe859954
--- a/electron/main.ts
+++ b/electron/main.ts
@@@ -382,6 -483,15 +483,17 @@@ app.whenReady().then(async () =>
if (micStatus !== "granted") {
await systemPreferences.askForMediaAccess("microphone");
}
+
+ // Screen recording has no askForMediaAccess equivalent — the TCC prompt is
+ // triggered by the first desktopCapturer.getSources() call. Firing it here
+ // at startup settles the permission state early and prevents repeated prompts
+ // driven by later getSources() calls (fixes repeated permission dialog).
+ const screenStatus = systemPreferences.getMediaAccessStatus("screen");
+ if (screenStatus === "not-determined") {
- desktopCapturer.getSources({ types: ["screen"] }).catch(() => {});
++ desktopCapturer.getSources({ types: ["screen"] }).catch(() => {
++ // Ignore prompt trigger failures; later capture attempts report status.
++ });
+ }
}
// Listen for HUD overlay quit event (macOS only)
diff --cc src/components/video-editor/SettingsPanel.tsx
index 5ac597969,9ef66b14d..21bb36064
--- a/src/components/video-editor/SettingsPanel.tsx
+++ b/src/components/video-editor/SettingsPanel.tsx
@@@ -628,529 -835,914 +834,914 @@@ export function SettingsPanel(
);
})}
</div>
- {selectedZoomFocusMode === "auto" && (
- <p className="text-[10px] text-slate-500 mt-1.5">
- {t("zoom.focusMode.autoDescription")}
- </p>
- )}
- </div>
- )}
- {zoomEnabled && (
- <Button
- onClick={handleDeleteClick}
- variant="destructive"
- size="sm"
- className="mt-2 w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
- >
- <Trash2 className="w-3 h-3" />
- {t("zoom.deleteZoom")}
- </Button>
- )}
- </div>
-
- {trimEnabled && (
- <div className="mb-4">
- <Button
- onClick={handleTrimDeleteClick}
- variant="destructive"
- size="sm"
- className="w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
- >
- <Trash2 className="w-3 h-3" />
- {t("trim.deleteRegion")}
- </Button>
- </div>
- )}
-
- <div className="mb-4">
- <div className="flex items-center justify-between mb-3">
- <span className="text-sm font-medium text-slate-200">{t("speed.playbackSpeed")}</span>
- {selectedSpeedId && selectedSpeedValue && (
- <span className="text-[10px] uppercase tracking-wider font-medium text-[#d97706] bg-[#d97706]/10 px-2 py-0.5 rounded-full">
- {SPEED_OPTIONS.find((o) => o.speed === selectedSpeedValue)?.label ??
- `${selectedSpeedValue}×`}
- </span>
- )}
- </div>
- <div className="grid grid-cols-5 gap-1.5">
- {SPEED_OPTIONS.map((option) => {
- const isActive = selectedSpeedValue === option.speed;
- return (
- <Button
- key={option.speed}
- type="button"
- disabled={!selectedSpeedId}
- onClick={() => onSpeedChange?.(option.speed)}
- className={cn(
- "h-auto w-full rounded-lg border px-1 py-2 text-center shadow-sm transition-all",
- "duration-200 ease-out",
- selectedSpeedId
- ? "opacity-100 cursor-pointer"
- : "opacity-40 cursor-not-allowed",
- isActive
- ? "border-[#d97706] bg-[#d97706] text-white shadow-[#d97706]/20"
- : "border-white/5 bg-white/5 text-slate-400 hover:bg-white/10 hover:border-white/10 hover:text-slate-200",
- )}
- >
- <span className="text-xs font-semibold">{option.label}</span>
- </Button>
- );
- })}
- </div>
- <div className="mt-3">
- <div className="flex items-center justify-between">
- <span
- className={cn("text-[11px]", selectedSpeedId ? "text-slate-500" : "text-slate-600")}
- >
- {t("speed.customPlaybackSpeed")}
- </span>
- {selectedSpeedId ? (
- <CustomSpeedInput
- value={selectedSpeedValue ?? 1}
- onChange={(val) => onSpeedChange?.(val)}
- onError={() => toast.error(t("speed.maxSpeedError"))}
- />
- ) : (
- <div className="flex items-center gap-1 opacity-40">
- <div className="w-12 bg-white/5 border border-white/10 rounded-md px-1 py-0.5 text-[11px] font-semibold text-slate-600 text-center">
- --
+ {zoomEnabled && (
+ <div>
+ <SliderPrimitive.Root
+ min={MIN_ZOOM_SCALE}
+ max={MAX_ZOOM_SCALE}
+ step={0.01}
+ value={[
+ selectedZoomCustomScale ??
+ (selectedZoomDepth != null
+ ? ZOOM_DEPTH_SCALES[selectedZoomDepth]
+ : MIN_ZOOM_SCALE),
+ ]}
+ onValueChange={(values) => onZoomCustomScaleChange?.(values[0])}
+ onValueCommit={() => onZoomCustomScaleCommit?.()}
+ disabled={!zoomEnabled}
+ className="relative flex w-full touch-none select-none items-center py-1"
+ >
+ <SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full border border-white/10 bg-white/5">
+ <SliderPrimitive.Range
+ className={cn(
+ "absolute h-full transition-colors duration-150",
+ selectedZoomCustomScale != null ? "bg-[#34B27B]" : "bg-white/20",
+ )}
+ />
+ </SliderPrimitive.Track>
+ <SliderPrimitive.Thumb
+ className={cn(
+ "block h-3.5 w-3.5 rounded-full border-2 shadow transition-all duration-150",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#34B27B]/50",
+ "disabled:pointer-events-none disabled:opacity-50 cursor-grab active:cursor-grabbing",
+ selectedZoomCustomScale != null
+ ? "border-[#34B27B] bg-[#34B27B] shadow-[0_0_6px_rgba(52,178,123,0.4)]"
+ : "border-white/20 bg-[#2a2a30] hover:border-white/40",
+ )}
+ />
+ </SliderPrimitive.Root>
+ <div className="flex justify-between text-[10px] text-slate-600 mt-1">
+ <span>{MIN_ZOOM_SCALE.toFixed(1)}×</span>
+ <span>{MAX_ZOOM_SCALE.toFixed(1)}×</span>
</div>
- <span className="text-[11px] font-semibold text-slate-600">×</span>
</div>
)}
- </div>
- </div>
- {!selectedSpeedId && (
- <p className="text-[10px] text-slate-500 mt-2 text-center">{t("speed.selectRegion")}</p>
- )}
- {selectedSpeedId && (
- <Button
- onClick={() => selectedSpeedId && onSpeedDelete?.(selectedSpeedId)}
- variant="destructive"
- size="sm"
- className="mt-2 w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
- >
- <Trash2 className="w-3 h-3" />
- {t("speed.deleteRegion")}
- </Button>
- )}
- </div>
-
- <Accordion
- type="multiple"
- defaultValue={hasWebcam ? ["layout", "effects", "background"] : ["effects", "background"]}
- className="space-y-1"
- >
- {hasWebcam && (
- <AccordionItem
- value="layout"
- className="border-white/5 rounded-xl bg-white/[0.02] px-3"
- >
- <AccordionTrigger className="py-2.5 hover:no-underline">
- <div className="flex items-center gap-2">
- <Sparkles className="w-4 h-4 text-[#34B27B]" />
- <span className="text-xs font-medium">{t("layout.title")}</span>
- </div>
- </AccordionTrigger>
- <AccordionContent className="pb-3">
- <div className="p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="text-[10px] font-medium text-slate-300 mb-1.5">
- {t("layout.preset")}
- </div>
- <Select
- value={webcamLayoutPreset}
- onValueChange={(value: WebcamLayoutPreset) =>
- onWebcamLayoutPresetChange?.(value)
- }
- >
- <SelectTrigger className="h-8 bg-black/20 border-white/10 text-xs">
- <SelectValue placeholder={t("layout.selectPreset")} />
- </SelectTrigger>
- <SelectContent>
- {WEBCAM_LAYOUT_PRESETS.filter((preset) => {
- if (preset.value === "picture-in-picture") return true;
- if (preset.value === "vertical-stack") return isPortraitCanvas;
- return !isPortraitCanvas;
- }).map((preset) => (
- <SelectItem key={preset.value} value={preset.value} className="text-xs">
- {preset.value === "picture-in-picture"
- ? t("layout.pictureInPicture")
- : preset.value === "vertical-stack"
- ? t("layout.verticalStack")
- : t("layout.dualFrame")}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </div>
- {webcamLayoutPreset === "picture-in-picture" && (
- <div className="mt-2 p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="text-[10px] font-medium text-slate-300 mb-1.5">
- {t("layout.webcamShape")}
- </div>
- <div className="grid grid-cols-4 gap-1.5">
- {(
- [
- { value: "rectangle", label: "Rect" },
- { value: "circle", label: "Circle" },
- { value: "square", label: "Square" },
- { value: "rounded", label: "Rounded" },
- ] as Array<{ value: WebcamMaskShape; label: string }>
- ).map((shape) => (
- <button
- key={shape.value}
+ {zoomEnabled && hasCursorTelemetry && (
+ <div className="flex items-center justify-between gap-3">
+ <span className="text-[11px] font-medium text-slate-400">
+ {t("zoom.focusMode.title")}
+ </span>
+ <div className="grid w-32 grid-cols-2 gap-0.5 rounded-lg border border-white/[0.06] bg-white/[0.035] p-0.5">
+ {(["manual", "auto"] as const).map((mode) => {
+ const isActive = selectedZoomFocusMode === mode;
+ return (
+ <Button
+ key={mode}
type="button"
- onClick={() => onWebcamMaskShapeChange?.(shape.value)}
+ onClick={() => onZoomFocusModeChange?.(mode)}
className={cn(
- "h-10 rounded-lg border flex flex-col items-center justify-center gap-0.5 transition-all",
- webcamMaskShape === shape.value
- ? "bg-[#34B27B] border-[#34B27B] text-white"
- : "bg-white/5 border-white/10 hover:bg-white/10 hover:border-white/20 text-slate-400",
+ "h-6 w-full rounded-md border px-1 text-center transition-all duration-150 ease-out cursor-pointer",
+ isActive
+ ? "border-[#34B27B]/50 bg-[#34B27B] text-white"
+ : "border-transparent bg-transparent text-slate-400 hover:bg-white/[0.06] hover:text-slate-200",
)}
>
- <svg
- width="16"
- height="16"
- viewBox="0 0 16 16"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- {shape.value === "rectangle" && (
- <rect
- x="1"
- y="3"
- width="14"
- height="10"
- rx="2"
- stroke="currentColor"
- strokeWidth="1.5"
- />
- )}
- {shape.value === "circle" && (
- <circle
- cx="8"
- cy="8"
- r="6.5"
- stroke="currentColor"
- strokeWidth="1.5"
- />
- )}
- {shape.value === "square" && (
- <rect
- x="2"
- y="2"
- width="12"
- height="12"
- rx="1"
- stroke="currentColor"
- strokeWidth="1.5"
- />
- )}
- {shape.value === "rounded" && (
- <rect
- x="1"
- y="3"
- width="14"
- height="10"
- rx="5"
- stroke="currentColor"
- strokeWidth="1.5"
- />
- )}
- </svg>
- <span className="text-[8px] leading-none">{shape.label}</span>
- </button>
- ))}
- </div>
+ <span className="text-[10px] font-semibold capitalize">
+ {t(`zoom.focusMode.${mode}`)}
+ </span>
+ </Button>
+ );
+ })}
</div>
- )}
- {webcamLayoutPreset === "picture-in-picture" && (
- <div className="p-2 rounded-lg bg-white/5 border border-white/5 mt-2">
- <div className="flex items-center justify-between mb-1.5">
- <div className="text-[10px] font-medium text-slate-300">
- {t("layout.webcamSize")}
- </div>
- <div className="text-[10px] font-medium text-slate-400">
- {webcamSizePreset}%
+ </div>
+ )}
+ {zoomEnabled &&
+ selectedZoomFocusMode !== "auto" &&
+ selectedZoomFocus &&
+ onZoomFocusCoordinateChange &&
+ (() => {
+ const effectiveZoomScale =
+ selectedZoomCustomScale ??
+ (selectedZoomDepth != null
+ ? ZOOM_DEPTH_SCALES[selectedZoomDepth]
+ : MIN_ZOOM_SCALE);
+ const bounds = getFocusBoundsForScale(effectiveZoomScale);
+ const xRange = bounds.maxX - bounds.minX;
+ const yRange = bounds.maxY - bounds.minY;
+ const focusToPercentX = (cx: number) =>
+ xRange <= 0
+ ? 50
+ : Math.max(0, Math.min(100, ((cx - bounds.minX) / xRange) * 100));
+ const focusToPercentY = (cy: number) =>
+ yRange <= 0
+ ? 50
+ : Math.max(0, Math.min(100, ((cy - bounds.minY) / yRange) * 100));
+ const percentToFocusX = (p: number) =>
+ xRange <= 0 ? bounds.minX : bounds.minX + (p / 100) * xRange;
+ const percentToFocusY = (p: number) =>
+ yRange <= 0 ? bounds.minY : bounds.minY + (p / 100) * yRange;
+ return (
+ <div>
+ <span className="text-[11px] font-medium text-slate-400 mb-1.5 block">
+ {t("zoom.position.title")}
+ </span>
+ <div className="grid grid-cols-2 gap-2">
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-medium text-slate-400 uppercase tracking-wider">
+ {t("zoom.position.x")}
+ </label>
+ <ZoomFocusCoordInput
+ ariaLabel={t("zoom.position.x")}
+ percent={focusToPercentX(selectedZoomFocus.cx)}
+ onChange={(p) =>
+ onZoomFocusCoordinateChange({
+ cx: percentToFocusX(p),
+ cy: selectedZoomFocus.cy,
+ })
+ }
+ onCommit={onZoomFocusCoordinateCommit}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-medium text-slate-400 uppercase tracking-wider">
+ {t("zoom.position.y")}
+ </label>
+ <ZoomFocusCoordInput
+ ariaLabel={t("zoom.position.y")}
+ percent={focusToPercentY(selectedZoomFocus.cy)}
+ onChange={(p) =>
+ onZoomFocusCoordinateChange({
+ cx: selectedZoomFocus.cx,
+ cy: percentToFocusY(p),
+ })
+ }
+ onCommit={onZoomFocusCoordinateCommit}
+ />
+ </div>
</div>
</div>
- <Slider
- value={[webcamSizePreset]}
- onValueChange={(values) => onWebcamSizePresetChange?.(values[0])}
- onValueCommit={() => onWebcamSizePresetCommit?.()}
- min={10}
- max={50}
- step={1}
- className="w-full"
- />
- </div>
- )}
- </AccordionContent>
- </AccordionItem>
- )}
-
- <AccordionItem value="effects" className="border-white/5 rounded-xl bg-white/[0.02] px-3">
- <AccordionTrigger className="py-2.5 hover:no-underline">
- <div className="flex items-center gap-2">
- <Sparkles className="w-4 h-4 text-[#34B27B]" />
- <span className="text-xs font-medium">{t("effects.title")}</span>
- </div>
- </AccordionTrigger>
- <AccordionContent className="pb-3">
- <div className="grid grid-cols-2 gap-2 mb-3">
- <div className="flex items-center justify-between p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="text-[10px] font-medium text-slate-300">
- {t("effects.blurBg")}
+ );
+ })()}
+ {zoomEnabled && (
+ <div>
+ <span className="text-[11px] font-medium text-slate-400 mb-1.5 block">
+ {t("zoom.threeD.title")}
+ </span>
+ <div className="grid grid-cols-3 gap-1.5">
+ {ROTATION_3D_PRESET_ORDER.map((preset) => {
+ const isActive = selectedZoomRotationPreset === preset;
+ return (
+ <Button
+ key={preset}
+ type="button"
+ onClick={() => onZoomRotationPresetChange?.(isActive ? null : preset)}
+ className={cn(
+ "h-8 w-full rounded-lg border px-1 text-center transition-all duration-150 ease-out cursor-pointer",
+ isActive
+ ? "border-[#34B27B]/60 bg-[#34B27B] text-white"
+ : "border-white/[0.06] bg-white/[0.035] text-slate-400 hover:bg-white/[0.075] hover:border-white/15 hover:text-slate-200",
+ )}
+ >
+ <span className="text-xs font-semibold capitalize">
+ {t(`zoom.threeD.preset.${preset}`)}
+ </span>
+ </Button>
+ );
+ })}
</div>
- <Switch
- checked={showBlur}
- onCheckedChange={onBlurChange}
- className="data-[state=checked]:bg-[#34B27B] scale-90"
- />
</div>
- </div>
+ )}
- <div className="grid grid-cols-2 gap-2">
- <div className="p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="flex items-center justify-between mb-1">
- <div className="text-[10px] font-medium text-slate-300">
- {t("effects.motionBlur")}
- </div>
- <span className="text-[10px] text-slate-500 font-mono">
- {motionBlurAmount === 0 ? t("effects.off") : motionBlurAmount.toFixed(2)}
- </span>
- </div>
- <Slider
- value={[motionBlurAmount]}
- onValueChange={(values) => onMotionBlurChange?.(values[0])}
- onValueCommit={() => onMotionBlurCommit?.()}
- min={0}
- max={1}
- step={0.01}
- className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
- />
- </div>
- <div className="p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="flex items-center justify-between mb-1">
- <div className="text-[10px] font-medium text-slate-300">
- {t("effects.shadow")}
- </div>
- <span className="text-[10px] text-slate-500 font-mono">
- {Math.round(shadowIntensity * 100)}%
- </span>
- </div>
- <Slider
- value={[shadowIntensity]}
- onValueChange={(values) => onShadowChange?.(values[0])}
- onValueCommit={() => onShadowCommit?.()}
- min={0}
- max={1}
- step={0.01}
- className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
- />
- </div>
- <div className="p-2 rounded-lg bg-white/5 border border-white/5">
- <div className="flex items-center justify-between mb-1">
- <div className="text-[10px] font-medium text-slate-300">
- {t("effects.roundness")}
- </div>
- <span className="text-[10px] text-slate-500 font-mono">{borderRadius}px</span>
- </div>
- <Slider
- value={[borderRadius]}
- onValueChange={(values) => onBorderRadiusChange?.(values[0])}
- onValueCommit={() => onBorderRadiusCommit?.()}
- min={0}
- max={16}
- step={0.5}
- className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
- />
- </div>
- <div
- className={`p-2 rounded-lg bg-white/5 border border-white/5 ${webcamLayoutPreset === "vertical-stack" ? "opacity-40 pointer-events-none" : ""}`}
+ {zoomEnabled && (
+ <Button
+ onClick={handleDeleteClick}
+ variant="destructive"
+ size="sm"
+ className="mt-1 w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
>
- <div className="flex items-center justify-between mb-1">
- <div className="text-[10px] font-medium text-slate-300">
- {t("effects.padding")}
- </div>
- <span className="text-[10px] text-slate-500 font-mono">
- {webcamLayoutPreset === "vertical-stack" ? "—" : `${padding}%`}
- </span>
- </div>
- <Slider
- value={[webcamLayoutPreset === "vertical-stack" ? 0 : padding]}
- onValueChange={(values) => onPaddingChange?.(values[0])}
- onValueCommit={() => onPaddingCommit?.()}
- min={0}
- max={100}
- step={1}
- disabled={webcamLayoutPreset === "vertical-stack"}
- className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
- />
- </div>
- </div>
+ <Trash2 className="w-3 h-3" />
+ {t("zoom.deleteZoom")}
+ </Button>
+ )}
+ </div>
+ )}
+ {trimEnabled && (
+ <div className="mb-4">
<Button
- onClick={handleCropToggle}
- variant="outline"
- className="w-full mt-2 gap-1.5 bg-white/5 text-slate-200 border-white/10 hover:bg-white/10 hover:border-white/20 hover:text-white text-[10px] h-8 transition-all"
+ onClick={handleTrimDeleteClick}
+ variant="destructive"
+ size="sm"
+ className="w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
>
- <Crop className="w-3 h-3" />
- {t("crop.cropVideo")}
+ <Trash2 className="w-3 h-3" />
+ {t("trim.deleteRegion")}
</Button>
- </AccordionContent>
- </AccordionItem>
+ </div>
+ )}
- <AccordionItem
- value="background"
- className="border-white/5 rounded-xl bg-white/[0.02] px-3"
- >
- <AccordionTrigger className="py-2.5 hover:no-underline">
- <div className="flex items-center gap-2">
- <Palette className="w-4 h-4 text-[#34B27B]" />
- <span className="text-xs font-medium">{t("background.title")}</span>
+ {selectedSpeedId && (
+ <div className="editor-panel-section mb-3 space-y-3 px-1">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-semibold uppercase tracking-[0.16em] text-slate-500">
+ {t("speed.playbackSpeed")}
+ </span>
+ {selectedSpeedId && selectedSpeedValue && (
+ <span className="rounded-full border border-[#d97706]/25 bg-[#d97706]/10 px-2 py-0.5 text-[11px] font-semibold tabular-nums text-[#d97706]">
+ {SPEED_OPTIONS.find((o) => o.speed === selectedSpeedValue)?.label ??
+ `${selectedSpeedValue}×`}
+ </span>
+ )}
</div>
- </AccordionTrigger>
- <AccordionContent className="pb-3">
- <Tabs defaultValue="image" className="w-full">
- <TabsList className="mb-2 bg-white/5 border border-white/5 p-0.5 w-full grid grid-cols-3 h-7 rounded-lg">
- <TabsTrigger
- value="image"
- className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
- >
- {t("background.image")}
- </TabsTrigger>
- <TabsTrigger
- value="color"
- className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
- >
- {t("background.color")}
- </TabsTrigger>
- <TabsTrigger
- value="gradient"
- className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
- >
- {t("background.gradient")}
- </TabsTrigger>
- </TabsList>
-
- <div className="overflow-y-auto custom-scrollbar">
- <TabsContent value="image" className="mt-0 space-y-2">
- <input
- type="file"
- ref={fileInputRef}
- onChange={handleImageUpload}
- accept={BACKGROUND_IMAGE_ACCEPT}
- className="hidden"
- />
+ <div className="grid grid-cols-5 gap-1">
+ {SPEED_OPTIONS.map((option) => {
+ const isActive = selectedSpeedValue === option.speed;
+ return (
<Button
- onClick={() => fileInputRef.current?.click()}
- variant="outline"
- className="w-full gap-2 bg-white/5 text-slate-200 border-white/10 hover:bg-[#34B27B] hover:text-white hover:border-[#34B27B] transition-all h-7 text-[10px]"
+ key={option.speed}
+ type="button"
+ disabled={!selectedSpeedId}
+ onClick={() => onSpeedChange?.(option.speed)}
+ className={cn(
+ "h-8 w-full rounded-lg border px-1 text-center transition-all duration-150 ease-out",
+ selectedSpeedId
+ ? "opacity-100 cursor-pointer"
+ : "opacity-40 cursor-not-allowed",
+ isActive
+ ? "border-[#d97706]/70 bg-[#d97706] text-white shadow-[0_8px_20px_rgba(217,119,6,0.16)]"
+ : "border-white/[0.06] bg-white/[0.035] text-slate-400 hover:bg-white/[0.075] hover:border-white/15 hover:text-slate-200",
+ )}
>
- <Upload className="w-3 h-3" />
- {t("background.uploadCustom")}
+ <span className="text-[11px] font-semibold">{option.label}</span>
</Button>
+ );
+ })}
+ </div>
+ <div className="flex items-center justify-between rounded-lg border border-white/[0.06] bg-white/[0.03] px-2 py-1.5">
+ <span
+ className={cn(
+ "text-[11px]",
+ selectedSpeedId ? "text-slate-500" : "text-slate-600",
+ )}
+ >
+ {t("speed.customPlaybackSpeed")}
+ </span>
+ {selectedSpeedId ? (
+ <CustomSpeedInput
+ value={selectedSpeedValue ?? 1}
+ onChange={(val) => onSpeedChange?.(val)}
+ onError={() => toast.error(t("speed.maxSpeedError"))}
+ />
+ ) : (
+ <div className="flex items-center gap-1 opacity-40">
+ <div className="w-12 bg-white/5 border border-white/10 rounded-md px-1 py-0.5 text-[11px] font-semibold text-slate-600 text-center">
+ --
+ </div>
+ <span className="text-[11px] font-semibold text-slate-600">×</span>
+ </div>
+ )}
+ </div>
+ {selectedSpeedId && (
+ <Button
+ onClick={() => selectedSpeedId && onSpeedDelete?.(selectedSpeedId)}
+ variant="destructive"
+ size="sm"
+ className="w-full gap-2 bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 hover:border-red-500/30 transition-all h-8 text-xs"
+ >
+ <Trash2 className="w-3 h-3" />
+ {t("speed.deleteRegion")}
+ </Button>
+ )}
+ </div>
+ )}
- <div className="grid grid-cols-7 gap-1.5">
- {customImages.map((imageUrl, idx) => {
- const isSelected = selected === imageUrl;
- return (
+ {!hasTimelineSelection && (
+ <Accordion type="multiple" value={[activePanelMode]} className="space-y-2">
+ {hasWebcam && activePanelMode === "layout" && (
+ <AccordionItem value="layout" className="editor-panel-section px-3">
+ <AccordionTrigger className="py-2.5 hover:no-underline">
+ <div className="flex items-center gap-2">
+ <Sparkles className="w-4 h-4 text-[#34B27B]" />
+ <span className="text-xs font-medium">{t("layout.title")}</span>
+ </div>
+ </AccordionTrigger>
+ <AccordionContent className="pb-3">
+ <div className="p-2 rounded-lg editor-control-surface">
+ <div className="text-[10px] font-medium text-slate-300 mb-1.5">
+ {t("layout.preset")}
+ </div>
+ <Select
+ value={webcamLayoutPreset}
+ onValueChange={(value: WebcamLayoutPreset) =>
+ onWebcamLayoutPresetChange?.(value)
+ }
+ >
+ <SelectTrigger className="h-8 bg-black/20 border-white/10 text-xs">
+ <SelectValue placeholder={t("layout.selectPreset")} />
+ </SelectTrigger>
+ <SelectContent>
+ {WEBCAM_LAYOUT_PRESETS.filter((preset) => {
+ if (preset.value === "picture-in-picture") return true;
+ if (preset.value === "no-webcam") return true;
+ if (preset.value === "vertical-stack") return isPortraitCanvas;
+ return !isPortraitCanvas;
+ }).map((preset) => (
+ <SelectItem key={preset.value} value={preset.value} className="text-xs">
+ {preset.value === "picture-in-picture"
+ ? t("layout.pictureInPicture")
+ : preset.value === "vertical-stack"
+ ? t("layout.verticalStack")
+ : preset.value === "no-webcam"
+ ? t("layout.noWebcam")
+ : t("layout.dualFrame")}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ {webcamLayoutPreset === "picture-in-picture" && (
+ <div className="mt-2 p-2 rounded-lg editor-control-surface">
+ <div className="text-[10px] font-medium text-slate-300 mb-1.5">
+ {t("layout.webcamShape")}
+ </div>
+ <div className="grid grid-cols-4 gap-1.5">
+ {(
+ [
+ { value: "rectangle", label: "Rect" },
+ { value: "circle", label: "Circle" },
+ { value: "square", label: "Square" },
+ { value: "rounded", label: "Rounded" },
+ ] as Array<{ value: WebcamMaskShape; label: string }>
+ ).map((shape) => (
+ <button
+ key={shape.value}
+ type="button"
+ onClick={() => onWebcamMaskShapeChange?.(shape.value)}
+ className={cn(
+ "h-10 rounded-lg border flex flex-col items-center justify-center gap-0.5 transition-all",
+ webcamMaskShape === shape.value
+ ? "bg-[#34B27B] border-[#34B27B] text-white"
+ : "bg-white/5 border-white/10 hover:bg-white/10 hover:border-white/20 text-slate-400",
+ )}
+ >
+ <svg
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ {shape.value === "rectangle" && (
+ <rect
+ x="1"
+ y="3"
+ width="14"
+ height="10"
+ rx="2"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ />
+ )}
+ {shape.value === "circle" && (
+ <circle
+ cx="8"
+ cy="8"
+ r="6.5"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ />
+ )}
+ {shape.value === "square" && (
+ <rect
+ x="2"
+ y="2"
+ width="12"
+ height="12"
+ rx="1"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ />
+ )}
+ {shape.value === "rounded" && (
+ <rect
+ x="1"
+ y="3"
+ width="14"
+ height="10"
+ rx="5"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ />
+ )}
+ </svg>
+ <span className="text-[8px] leading-none">{shape.label}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+ )}
+ {webcamLayoutPreset === "picture-in-picture" && (
+ <div className="p-2 rounded-lg editor-control-surface mt-2">
+ <div className="flex items-center justify-between mb-1.5">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("layout.webcamSize")}
+ </div>
+ <div className="text-[10px] font-medium text-slate-400">
+ {webcamSizePreset}%
+ </div>
+ </div>
+ <Slider
+ value={[webcamSizePreset]}
+ onValueChange={(values) => onWebcamSizePresetChange?.(values[0])}
+ onValueCommit={() => onWebcamSizePresetCommit?.()}
+ min={10}
+ max={50}
+ step={1}
+ className="w-full"
+ />
+ </div>
+ )}
+ </AccordionContent>
+ </AccordionItem>
+ )}
+
+ {(activePanelMode === "effects" || activePanelMode === "cursor") && (
+ <AccordionItem value={activePanelMode} className="editor-panel-section px-3">
+ <AccordionTrigger className="py-2.5 hover:no-underline">
+ <div className="flex items-center gap-2">
+ {activePanelMode === "cursor" ? (
+ <MousePointerClick className="w-4 h-4 text-[#34B27B]" />
+ ) : (
+ <SlidersHorizontal className="w-4 h-4 text-[#34B27B]" />
+ )}
+ <span className="text-xs font-medium">
+ {activePanelMode === "cursor"
+ ? t("effects.cursorHighlight.title")
+ : t("effects.title")}
+ </span>
+ </div>
+ </AccordionTrigger>
+ <AccordionContent className="pb-3">
+ {activePanelMode === "effects" && (
+ <>
+ <div className="grid grid-cols-2 gap-2 mb-3">
+ <div className="flex items-center justify-between p-2 rounded-lg editor-control-surface">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.blurBg")}
+ </div>
+ <Switch
+ checked={showBlur}
+ onCheckedChange={onBlurChange}
+ className="data-[state=checked]:bg-[#34B27B] scale-90"
+ />
+ </div>
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div className="p-2 rounded-lg editor-control-surface">
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.motionBlur")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {motionBlurAmount === 0
+ ? t("effects.off")
+ : motionBlurAmount.toFixed(2)}
+ </span>
+ </div>
+ <Slider
+ value={[motionBlurAmount]}
+ onValueChange={(values) => onMotionBlurChange?.(values[0])}
+ onValueCommit={() => onMotionBlurCommit?.()}
+ min={0}
+ max={1}
+ step={0.01}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
+ <div className="p-2 rounded-lg editor-control-surface">
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.shadow")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {Math.round(shadowIntensity * 100)}%
+ </span>
+ </div>
+ <Slider
+ value={[shadowIntensity]}
+ onValueChange={(values) => onShadowChange?.(values[0])}
+ onValueCommit={() => onShadowCommit?.()}
+ min={0}
+ max={1}
+ step={0.01}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
+ <div className="p-2 rounded-lg editor-control-surface">
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.roundness")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {borderRadius}px
+ </span>
+ </div>
+ <Slider
+ value={[borderRadius]}
+ onValueChange={(values) => onBorderRadiusChange?.(values[0])}
+ onValueCommit={() => onBorderRadiusCommit?.()}
+ min={0}
+ max={16}
+ step={0.5}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
<div
- key={`custom-${idx}`}
- className={cn(
- "aspect-square w-9 h-9 rounded-md border-2 overflow-hidden cursor-pointer transition-all duration-200 relative group shadow-sm",
- isSelected
- ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
- : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
- )}
- style={{
- backgroundImage: `url(${imageUrl})`,
- backgroundSize: "cover",
- backgroundPosition: "center",
- }}
- onClick={() => onWallpaperChange(imageUrl)}
- role="button"
+ className={`p-2 rounded-lg editor-control-surface ${webcamLayoutPreset === "vertical-stack" ? "opacity-40 pointer-events-none" : ""}`}
>
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.padding")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {webcamLayoutPreset === "vertical-stack" ? "—" : `${padding}%`}
+ </span>
+ </div>
+ <Slider
+ value={[webcamLayoutPreset === "vertical-stack" ? 0 : padding]}
+ onValueChange={(values) => onPaddingChange?.(values[0])}
+ onValueCommit={() => onPaddingCommit?.()}
+ min={0}
+ max={100}
+ step={1}
+ disabled={webcamLayoutPreset === "vertical-stack"}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
+ </div>
+ </>
+ )}
+
+ {activePanelMode === "cursor" && cursorHighlight && onCursorHighlightChange && (
+ <div className="p-2 rounded-lg editor-control-surface mt-2 space-y-2">
+ <div className="flex items-center justify-between">
+ <div className="text-[10px] font-medium text-slate-300">
+ {t("effects.cursorHighlight.title")}
+ </div>
+ <button
+ type="button"
+ onClick={() =>
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ enabled: !cursorHighlight.enabled,
+ })
+ }
+ className={`text-[10px] px-2 py-0.5 rounded border transition-colors ${
+ cursorHighlight.enabled
+ ? "bg-[#34B27B]/20 border-[#34B27B]/50 text-[#34B27B]"
+ : "bg-white/5 border-white/10 text-slate-400"
+ }`}
+ >
+ {cursorHighlight.enabled ? t("effects.on") : t("effects.off")}
+ </button>
+ </div>
+ <div
+ className={`grid grid-cols-2 gap-1 ${cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"}`}
+ >
+ {(["dot", "ring"] as const).map((style) => (
<button
- onClick={(e) => handleRemoveCustomImage(imageUrl, e)}
- className="absolute top-0.5 right-0.5 w-3 h-3 bg-red-500/90 hover:bg-red-500 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
+ key={style}
+ type="button"
+ onClick={() => onCursorHighlightChange({ ...cursorHighlight, style })}
+ className={`text-[10px] px-2 py-1 rounded border capitalize transition-colors ${
+ cursorHighlight.style === style
+ ? "bg-[#34B27B]/20 border-[#34B27B]/50 text-[#34B27B]"
+ : "bg-white/5 border-white/10 text-slate-300 hover:border-white/20"
+ }`}
>
- <X className="w-2 h-2 text-white" />
+ {t(`effects.cursorHighlight.${style}`)}
</button>
+ ))}
+ </div>
+ <div
+ className={
+ cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"
+ }
+ >
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] text-slate-400">
+ {t("effects.cursorHighlight.size")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {cursorHighlight.sizePx}px
+ </span>
</div>
- );
- })}
-
- {WALLPAPER_PATHS.map((canonicalPath, i) => {
- const previewUrl = wallpaperPreviewUrls[i] ?? canonicalPath;
- const isSelected = selected === canonicalPath;
- return (
+ <Slider
+ value={[cursorHighlight.sizePx]}
+ onValueChange={(values) =>
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ sizePx: values[0],
+ })
+ }
+ min={10}
+ max={36}
+ step={1}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
+ {cursorHighlightSupportsClicks && (
<div
- key={canonicalPath}
- className={cn(
- "aspect-square w-9 h-9 rounded-md border-2 overflow-hidden cursor-pointer transition-all duration-200 shadow-sm",
- isSelected
- ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
- : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
- )}
- style={{
- backgroundImage: `url(${previewUrl})`,
- backgroundSize: "cover",
- backgroundPosition: "center",
- }}
- onClick={() => onWallpaperChange(canonicalPath)}
- role="button"
+ className={`flex items-center justify-between ${cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"}`}
+ >
+ <div className="text-[10px] text-slate-400">
+ {t("effects.cursorHighlight.onlyOnClicks")}
+ </div>
+ <button
+ type="button"
+ onClick={async () => {
+ const turningOn = !cursorHighlight.onlyOnClicks;
+ if (turningOn) {
+ try {
+ const result =
+ await window.electronAPI?.requestAccessibilityAccess?.();
+ if (!result?.granted) {
+ toast.message(
+ t("effects.cursorHighlight.accessibilityPermissionTitle"),
+ {
+ description: t(
+ "effects.cursorHighlight.accessibilityPermissionDescription",
+ ),
+ },
+ );
+ return;
+ }
+ } catch (err) {
+ console.warn("Accessibility request failed:", err);
+ }
+ }
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ onlyOnClicks: turningOn,
+ });
+ }}
+ className={`text-[10px] px-2 py-0.5 rounded border transition-colors ${
+ cursorHighlight.onlyOnClicks
+ ? "bg-[#34B27B]/20 border-[#34B27B]/50 text-[#34B27B]"
+ : "bg-white/5 border-white/10 text-slate-400"
+ }`}
+ >
+ {cursorHighlight.onlyOnClicks ? t("effects.on") : t("effects.off")}
+ </button>
+ </div>
+ )}
+ <div
+ className={
+ cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"
+ }
+ >
+ <div className="text-[10px] text-slate-400 mb-1">
+ {t("effects.cursorHighlight.color")}
+ </div>
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ className="w-full h-8 justify-start gap-2 bg-white/5 border-white/10 hover:bg-white/10 px-2"
+ >
+ <div
+ className="w-4 h-4 rounded-full border border-white/20"
+ style={{ backgroundColor: cursorHighlight.color }}
+ />
+ <span className="text-[10px] text-slate-300 truncate flex-1 text-left font-mono">
+ {cursorHighlight.color}
+ </span>
+ <ChevronDown className="h-3 w-3 opacity-50" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent
+ side="top"
+ className="w-[260px] p-3 bg-[#1a1a1c] border border-white/10 rounded-xl shadow-xl"
+ >
+ <ColorPicker
+ selectedColor={cursorHighlight.color}
+ colorPalette={colorPalette}
+ translations={{
+ colorWheel: t("background.colorWheel"),
+ colorPalette: t("background.colorPalette"),
+ }}
+ onUpdateColor={(color) =>
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ color,
+ })
+ }
+ />
+ </PopoverContent>
+ </Popover>
+ </div>
+ <div
+ className={
+ cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"
+ }
+ >
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] text-slate-400">
+ {t("effects.cursorHighlight.offsetX")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {(cursorHighlight.offsetXNorm * 100).toFixed(1)}%
+ </span>
+ </div>
+ <Slider
+ value={[cursorHighlight.offsetXNorm]}
+ onValueChange={(values) =>
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ offsetXNorm: values[0],
+ })
+ }
+ min={-0.25}
+ max={0.25}
+ step={0.005}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
+ />
+ </div>
+ <div
+ className={
+ cursorHighlight.enabled ? "" : "opacity-40 pointer-events-none"
+ }
+ >
+ <div className="flex items-center justify-between mb-1">
+ <div className="text-[10px] text-slate-400">
+ {t("effects.cursorHighlight.offsetY")}
+ </div>
+ <span className="text-[10px] text-slate-500 font-mono">
+ {(cursorHighlight.offsetYNorm * 100).toFixed(1)}%
+ </span>
+ </div>
+ <Slider
+ value={[cursorHighlight.offsetYNorm]}
+ onValueChange={(values) =>
+ onCursorHighlightChange({
+ ...cursorHighlight,
+ offsetYNorm: values[0],
+ })
+ }
+ min={-0.25}
+ max={0.25}
+ step={0.005}
+ className="w-full [&_[role=slider]]:bg-[#34B27B] [&_[role=slider]]:border-[#34B27B] [&_[role=slider]]:h-3 [&_[role=slider]]:w-3"
/>
- );
- })}
+ </div>
+ </div>
+ )}
+ </AccordionContent>
+ </AccordionItem>
+ )}
+
+ {activePanelMode === "background" && (
+ <AccordionItem value="background" className="editor-panel-section px-3">
+ <AccordionTrigger className="py-2.5 hover:no-underline">
+ <div className="flex items-center gap-2">
+ <Palette className="w-4 h-4 text-[#34B27B]" />
+ <span className="text-xs font-medium">{t("background.title")}</span>
</div>
- </TabsContent>
+ </AccordionTrigger>
+ <AccordionContent className="pb-3">
+ <Tabs defaultValue="image" className="w-full">
+ <TabsList className="mb-2 bg-white/5 border border-white/5 p-0.5 w-full grid grid-cols-3 h-7 rounded-lg">
+ <TabsTrigger
+ value="image"
+ className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
+ >
+ {t("background.image")}
+ </TabsTrigger>
+ <TabsTrigger
+ value="color"
+ className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
+ >
+ {t("background.color")}
+ </TabsTrigger>
+ <TabsTrigger
+ value="gradient"
+ className="data-[state=active]:bg-[#34B27B] data-[state=active]:text-white text-slate-400 text-[10px] py-1 rounded-md transition-all"
+ >
+ {t("background.gradient")}
+ </TabsTrigger>
+ </TabsList>
- <TabsContent value="color" className="mt-0">
- <ColorPicker
- selectedColor={selectedColor}
- colorPalette={colorPalette}
- translations={{
- colorWheel: t("background.colorWheel"),
- colorPalette: t("background.colorPalette"),
- }}
- onUpdateColor={(color) => {
- setSelectedColor(color);
- onWallpaperChange(color);
- }}
- />
- </TabsContent>
+ <div className="overflow-y-auto custom-scrollbar">
+ <TabsContent value="image" className="mt-0 space-y-2">
+ <input
+ type="file"
+ ref={fileInputRef}
+ onChange={handleImageUpload}
- accept=".jpg,.jpeg,image/jpeg"
++ accept={BACKGROUND_IMAGE_ACCEPT}
+ className="hidden"
+ />
+ <Button
+ onClick={() => fileInputRef.current?.click()}
+ variant="outline"
+ className="w-full gap-2 bg-white/5 text-slate-200 border-white/10 hover:bg-[#34B27B] hover:text-white hover:border-[#34B27B] transition-all h-7 text-[10px]"
+ >
+ <Upload className="w-3 h-3" />
+ {t("background.uploadCustom")}
+ </Button>
- <TabsContent value="gradient" className="mt-0">
- <div className="grid grid-cols-7 gap-1.5">
- {GRADIENTS.map((g, idx) => (
- <div
- key={g}
- className={cn(
- "aspect-square w-9 h-9 rounded-md border-2 overflow-hidden cursor-pointer transition-all duration-200 shadow-sm",
- gradient === g
- ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
- : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
- )}
- style={{ background: g }}
- aria-label={t("background.gradientLabel", {
- index: idx + 1,
- })}
- onClick={() => {
- setGradient(g);
- onWallpaperChange(g);
- }}
- role="button"
- />
- ))}
- </div>
- </TabsContent>
- </div>
- </Tabs>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
+ <div className="grid grid-cols-6 gap-2">
+ {customImages.map((imageUrl, idx) => {
+ const isSelected = selected === imageUrl;
+ return (
+ <div
+ key={`custom-${idx}`}
+ className={cn(
+ "aspect-square w-8 h-8 rounded-lg border overflow-hidden cursor-pointer transition-all duration-150 relative group shadow-sm",
+ isSelected
+ ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
+ : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
+ )}
+ style={{
+ backgroundImage: `url(${imageUrl})`,
+ backgroundSize: "cover",
+ backgroundPosition: "center",
+ }}
+ onClick={() => onWallpaperChange(imageUrl)}
+ role="button"
+ >
+ <button
+ onClick={(e) => handleRemoveCustomImage(imageUrl, e)}
+ className="absolute top-0.5 right-0.5 w-3 h-3 bg-red-500/90 hover:bg-red-500 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
+ >
+ <X className="w-2 h-2 text-white" />
+ </button>
+ </div>
+ );
+ })}
+
+ {WALLPAPER_PATHS.map((canonicalPath, i) => {
+ const previewUrl = wallpaperPreviewUrls[i] ?? canonicalPath;
+ const isSelected = selected === canonicalPath;
+ return (
+ <div
+ key={canonicalPath}
+ className={cn(
+ "aspect-square w-8 h-8 rounded-lg border overflow-hidden cursor-pointer transition-all duration-150 shadow-sm",
+ isSelected
+ ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
+ : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
+ )}
+ style={{
+ backgroundImage: `url(${previewUrl})`,
+ backgroundSize: "cover",
+ backgroundPosition: "center",
+ }}
+ onClick={() => onWallpaperChange(canonicalPath)}
+ role="button"
+ />
+ );
+ })}
+ </div>
+ </TabsContent>
+
+ <TabsContent value="color" className="mt-0">
+ <ColorPicker
+ selectedColor={selectedColor}
+ colorPalette={colorPalette}
+ translations={{
+ colorWheel: t("background.colorWheel"),
+ colorPalette: t("background.colorPalette"),
+ }}
+ onUpdateColor={(color) => {
+ setSelectedColor(color);
+ onWallpaperChange(color);
+ }}
+ />
+ </TabsContent>
+
+ <TabsContent value="gradient" className="mt-0">
+ <div className="grid grid-cols-6 gap-2">
+ {GRADIENTS.map((g, idx) => (
+ <div
+ key={g}
+ className={cn(
+ "aspect-square w-8 h-8 rounded-lg border overflow-hidden cursor-pointer transition-all duration-150 shadow-sm",
+ gradient === g
+ ? "border-[#34B27B] ring-1 ring-[#34B27B]/30"
+ : "border-white/10 hover:border-[#34B27B]/40 opacity-80 hover:opacity-100 bg-white/5",
+ )}
+ style={{ background: g }}
+ aria-label={t("background.gradientLabel", {
+ index: idx + 1,
+ })}
+ onClick={() => {
+ setGradient(g);
+ onWallpaperChange(g);
+ }}
+ role="button"
+ />
+ ))}
+ </div>
+ </TabsContent>
+ </div>
+ </Tabs>
+ </AccordionContent>
+ </AccordionItem>
+ )}
+ </Accordion>
+ )}
+ </div>
</div>
{showCropModal && cropRegion && onCropChange && (
diff --cc src/i18n/locales/ja-JP/settings.json
index cde1f1db5,1ccc3815f..4c4b7c63b
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@@ -100,9 -101,9 +101,9 @@@
},
"imageUpload": {
"invalidFileType": "無効なファイル形式",
- "jpgOnly": "JPG、JPEG、または PNG 画像ファイルをアップロードしてください。",
- "uploadSuccess": "カスタム画像が正常にアップロードされました!",
- "failedToUpload": "画像のアップロードに失敗しました",
- "jpgOnly": "JPG または JPEG 画像ファイルを選択してください。",
++ "jpgOnly": "JPG、PNG、GIF、またはWebP画像ファイルを選択してください。",
+ "uploadSuccess": "カスタム画像を読み込みました。",
+ "failedToUpload": "画像の読み込みに失敗しました",
"errorReading": "ファイルの読み取り中にエラーが発生しました。"
},
"annotation": {