-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathConfigSidebar.tsx
More file actions
3726 lines (3536 loc) · 107 KB
/
ConfigSidebar.tsx
File metadata and controls
3726 lines (3536 loc) · 107 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { NumberField } from "@kobalte/core";
import {
Collapsible,
Collapsible as KCollapsible,
} from "@kobalte/core/collapsible";
import {
RadioGroup as KRadioGroup,
RadioGroup,
} from "@kobalte/core/radio-group";
import { Select as KSelect } from "@kobalte/core/select";
import { Tabs as KTabs } from "@kobalte/core/tabs";
import { createElementBounds } from "@solid-primitives/bounds";
import { createEventListenerMap } from "@solid-primitives/event-listener";
import { createWritableMemo } from "@solid-primitives/memo";
import { convertFileSrc } from "@tauri-apps/api/core";
import { appDataDir, resolveResource } from "@tauri-apps/api/path";
import { BaseDirectory, writeFile } from "@tauri-apps/plugin-fs";
import { type as ostype } from "@tauri-apps/plugin-os";
import { cx } from "cva";
import {
batch,
createEffect,
createMemo,
createResource,
createRoot,
createSignal,
For,
Index,
on,
onMount,
Show,
Suspense,
type ValidComponent,
} from "solid-js";
import { createStore, produce } from "solid-js/store";
import { Dynamic } from "solid-js/web";
import toast from "solid-toast";
import colorBg from "~/assets/illustrations/color.webp";
import gradientBg from "~/assets/illustrations/gradient.webp";
import imageBg from "~/assets/illustrations/image.webp";
import transparentBg from "~/assets/illustrations/transparent.webp";
import { Toggle } from "~/components/Toggle";
import { generalSettingsStore } from "~/store";
import {
type BackgroundSource,
type CameraShape,
type ClipOffsets,
type CursorAnimationStyle,
type CursorType,
commands,
type SceneSegment,
type StereoMode,
type TimelineSegment,
type ZoomSegment,
} from "~/utils/tauri";
import IconLucideBoxSelect from "~icons/lucide/box-select";
import IconLucideGauge from "~icons/lucide/gauge";
import IconLucideGrid from "~icons/lucide/grid";
import IconLucideMonitor from "~icons/lucide/monitor";
import IconLucideMoon from "~icons/lucide/moon";
import IconLucidePalette from "~icons/lucide/palette";
import IconLucideRabbit from "~icons/lucide/rabbit";
import IconLucideSparkles from "~icons/lucide/sparkles";
import IconLucideTimer from "~icons/lucide/timer";
import IconLucideType from "~icons/lucide/type";
import IconLucideWind from "~icons/lucide/wind";
import { CaptionsTab } from "./CaptionsTab";
import { useEditorContext } from "./context";
import { evaluateMask, type MaskKind, type MaskSegment } from "./masks";
import {
DEFAULT_GRADIENT_FROM,
DEFAULT_GRADIENT_TO,
type RGBColor,
} from "./projectConfig";
import ShadowSettings from "./ShadowSettings";
import { TextInput } from "./TextInput";
import type { TextSegment } from "./text";
import {
ComingSoonTooltip,
EditorButton,
Field,
MenuItem,
MenuItemList,
PopperContent,
Slider,
Subfield,
topSlideAnimateClasses,
} from "./ui";
const BACKGROUND_SOURCES = {
wallpaper: "Wallpaper",
image: "Image",
color: "Color",
gradient: "Gradient",
} satisfies Record<BackgroundSource["type"], string>;
const BACKGROUND_ICONS = {
wallpaper: imageBg,
image: transparentBg,
color: colorBg,
gradient: gradientBg,
} satisfies Record<BackgroundSource["type"], string>;
const BACKGROUND_SOURCES_LIST = [
"wallpaper",
"image",
"color",
"gradient",
] satisfies Array<BackgroundSource["type"]>;
const BACKGROUND_COLORS = [
"#FF0000", // Red
"#FF4500", // Orange-Red
"#FF8C00", // Orange
"#FFD700", // Gold
"#FFFF00", // Yellow
"#ADFF2F", // Green-Yellow
"#32CD32", // Lime Green
"#008000", // Green
"#00CED1", // Dark Turquoise
"#4785FF", // Dodger Blue
"#0000FF", // Blue
"#4B0082", // Indigo
"#800080", // Purple
"#A9A9A9", // Dark Gray
"#FFFFFF", // White
"#000000", // Black
"#00000000", // Transparent
];
const BACKGROUND_GRADIENTS = [
{ from: [15, 52, 67], to: [52, 232, 158] }, // Dark Blue to Teal
{ from: [34, 193, 195], to: [253, 187, 45] }, // Turquoise to Golden Yellow
{ from: [29, 253, 251], to: [195, 29, 253] }, // Cyan to Purple
{ from: [69, 104, 220], to: [176, 106, 179] }, // Blue to Violet
{ from: [106, 130, 251], to: [252, 92, 125] }, // Soft Blue to Pinkish Red
{ from: [131, 58, 180], to: [253, 29, 29] }, // Purple to Red
{ from: [249, 212, 35], to: [255, 78, 80] }, // Yellow to Coral Red
{ from: [255, 94, 0], to: [255, 42, 104] }, // Orange to Reddish Pink
{ from: [255, 0, 150], to: [0, 204, 255] }, // Pink to Sky Blue
{ from: [0, 242, 96], to: [5, 117, 230] }, // Green to Blue
{ from: [238, 205, 163], to: [239, 98, 159] }, // Peach to Soft Pink
{ from: [44, 62, 80], to: [52, 152, 219] }, // Dark Gray Blue to Light Blue
{ from: [168, 239, 255], to: [238, 205, 163] }, // Light Blue to Peach
{ from: [74, 0, 224], to: [143, 0, 255] }, // Deep Blue to Bright Purple
{ from: [252, 74, 26], to: [247, 183, 51] }, // Deep Orange to Soft Yellow
{ from: [0, 255, 255], to: [255, 20, 147] }, // Cyan to Deep Pink
{ from: [255, 127, 0], to: [255, 255, 0] }, // Orange to Yellow
{ from: [255, 0, 255], to: [0, 255, 0] }, // Magenta to Green
] satisfies Array<{ from: RGBColor; to: RGBColor }>;
const WALLPAPER_NAMES = [
// macOS wallpapers
"macOS/tahoe-dusk-min",
"macOS/tahoe-dawn-min",
"macOS/tahoe-day-min",
"macOS/tahoe-night-min",
"macOS/tahoe-dark",
"macOS/tahoe-light",
"macOS/sequoia-dark",
"macOS/sequoia-light",
"macOS/sonoma-clouds",
"macOS/sonoma-dark",
"macOS/sonoma-evening",
"macOS/sonoma-fromabove",
"macOS/sonoma-horizon",
"macOS/sonoma-light",
"macOS/sonoma-river",
"macOS/ventura-dark",
"macOS/ventura-semi-dark",
"macOS/ventura",
// Blue wallpapers
"blue/1",
"blue/2",
"blue/3",
"blue/4",
"blue/5",
"blue/6",
// Purple wallpapers
"purple/1",
"purple/2",
"purple/3",
"purple/4",
"purple/5",
"purple/6",
// Dark wallpapers
"dark/1",
"dark/2",
"dark/3",
"dark/4",
"dark/5",
"dark/6",
// Orange wallpapers
"orange/1",
"orange/2",
"orange/3",
"orange/4",
"orange/5",
"orange/6",
"orange/7",
"orange/8",
"orange/9",
] as const;
const STEREO_MODES = [
{ name: "Stereo", value: "stereo" },
{ name: "Mono L", value: "monoL" },
{ name: "Mono R", value: "monoR" },
] satisfies Array<{ name: string; value: StereoMode }>;
const CAMERA_SHAPES = [
{
name: "Square",
value: "square",
},
{
name: "Source",
value: "source",
},
] satisfies Array<{ name: string; value: CameraShape }>;
const BACKGROUND_THEMES = {
macOS: "macOS",
dark: "Dark",
blue: "Blue",
purple: "Purple",
orange: "Orange",
};
type CursorPresetValues = {
tension: number;
mass: number;
friction: number;
};
const DEFAULT_CURSOR_MOTION_BLUR = 0.5;
const CURSOR_TYPE_OPTIONS = [
{
value: "auto" as CursorType,
label: "Auto",
description: "Uses the actual cursor from your recording.",
},
{
value: "circle" as CursorType,
label: "Circle",
description: "A touch-style circle cursor like mobile simulators.",
},
];
const CURSOR_ANIMATION_STYLE_OPTIONS = [
{
value: "slow",
label: "Slow",
description: "Relaxed easing with a gentle follow and higher inertia.",
preset: { tension: 65, mass: 1.8, friction: 16 },
},
{
value: "mellow",
label: "Mellow",
description: "Balanced smoothing for everyday tutorials and walkthroughs.",
preset: { tension: 120, mass: 1.1, friction: 18 },
},
{
value: "custom",
label: "Custom",
description: "Tune tension, friction, and mass manually for full control.",
},
] satisfies Array<{
value: CursorAnimationStyle;
label: string;
description: string;
preset?: CursorPresetValues;
}>;
const CURSOR_PRESET_TOLERANCE = {
tension: 1,
mass: 0.05,
friction: 0.2,
} as const;
const findCursorPreset = (
values: CursorPresetValues,
): CursorAnimationStyle | null => {
const preset = CURSOR_ANIMATION_STYLE_OPTIONS.find(
(option) =>
option.preset &&
Math.abs(option.preset.tension - values.tension) <=
CURSOR_PRESET_TOLERANCE.tension &&
Math.abs(option.preset.mass - values.mass) <=
CURSOR_PRESET_TOLERANCE.mass &&
Math.abs(option.preset.friction - values.friction) <=
CURSOR_PRESET_TOLERANCE.friction,
);
return preset?.value ?? null;
};
const TAB_IDS = {
background: "background",
camera: "camera",
transcript: "transcript",
audio: "audio",
cursor: "cursor",
hotkeys: "hotkeys",
} as const;
export function ConfigSidebar() {
const {
project,
setProject,
setEditorState,
projectActions,
editorInstance,
editorState,
meta,
} = useEditorContext();
const cursorIdleDelay = () =>
((project.cursor as { hideWhenIdleDelay?: number }).hideWhenIdleDelay ??
2) as number;
const clampIdleDelay = (value: number) =>
Math.round(Math.min(5, Math.max(0.5, value)) * 10) / 10;
type CursorPhysicsKey = "tension" | "mass" | "friction";
const setCursorPhysics = (key: CursorPhysicsKey, value: number) => {
const nextValues: CursorPresetValues = {
tension: key === "tension" ? value : project.cursor.tension,
mass: key === "mass" ? value : project.cursor.mass,
friction: key === "friction" ? value : project.cursor.friction,
};
const matched = findCursorPreset(nextValues);
const nextStyle = (matched ?? "custom") as CursorAnimationStyle;
batch(() => {
setProject("cursor", key, value);
if (project.cursor.animationStyle !== nextStyle) {
setProject("cursor", "animationStyle", nextStyle);
}
});
};
const applyCursorStylePreset = (style: CursorAnimationStyle) => {
const option = CURSOR_ANIMATION_STYLE_OPTIONS.find(
(item) => item.value === style,
);
batch(() => {
setProject("cursor", "animationStyle", style);
if (option?.preset) {
setProject("cursor", "tension", option.preset.tension);
setProject("cursor", "mass", option.preset.mass);
setProject("cursor", "friction", option.preset.friction);
}
});
};
const [state, setState] = createStore({
selectedTab: "background" as
| "background"
| "camera"
| "transcript"
| "audio"
| "cursor"
| "hotkeys"
| "captions",
});
let scrollRef!: HTMLDivElement;
return (
<KTabs
value={editorState.timeline.selection ? undefined : state.selectedTab}
class="flex flex-col min-h-0 shrink-0 flex-1 max-w-[26rem] overflow-hidden rounded-xl z-10 bg-gray-1 dark:bg-gray-2 border border-gray-3"
>
<KTabs.List class="flex overflow-hidden sticky top-0 z-[60] flex-row items-center h-16 text-lg border-b border-gray-3 shrink-0 bg-gray-1 dark:bg-gray-2">
<For
each={[
{ id: TAB_IDS.background, icon: IconCapImage },
{
id: TAB_IDS.camera,
icon: IconCapCamera,
disabled: editorInstance.recordings.segments.every(
(s) => s.camera === null,
),
},
{ id: TAB_IDS.audio, icon: IconCapAudioOn },
{
id: TAB_IDS.cursor,
icon: IconCapCursor,
disabled: !(
meta().type === "multiple" && (meta() as any).segments[0].cursor
),
},
{
id: "captions" as const,
icon: IconCapMessageBubble,
},
// { id: "hotkeys" as const, icon: IconCapHotkeys },
].filter(Boolean)}
>
{(item) => (
<KTabs.Trigger
value={item.id}
class={cx(
"flex relative z-10 flex-1 justify-center items-center px-4 py-2 transition-colors group disabled:opacity-50 focus:outline-none",
editorState.timeline.selection
? "text-gray-11"
: "text-gray-11 ui-selected:text-gray-12",
)}
onClick={() => {
// Clear any active selection first
if (editorState.timeline.selection) {
setEditorState("timeline", "selection", null);
}
setState("selectedTab", item.id);
scrollRef.scrollTo({
top: 0,
});
}}
disabled={item.disabled}
>
<div
class={cx(
"flex justify-center relative border-transparent border z-10 items-center rounded-md size-9 transition will-change-transform",
state.selectedTab !== item.id &&
"group-hover:border-gray-300 group-disabled:border-none",
)}
>
<Dynamic component={item.icon} />
</div>
</KTabs.Trigger>
)}
</For>
{/** Center the indicator with the icon */}
<Show when={!editorState.timeline.selection}>
<KTabs.Indicator class="absolute top-0 left-0 w-full h-full transition-transform duration-200 ease-in-out pointer-events-none will-change-transform">
<div class="absolute top-1/2 left-1/2 rounded-lg transform -translate-x-1/2 -translate-y-1/2 bg-gray-3 will-change-transform size-9" />
</KTabs.Indicator>
</Show>
</KTabs.List>
<div
ref={scrollRef}
style={{
"--margin-top-scroll": "5px",
}}
class="custom-scroll overflow-x-hidden overflow-y-scroll text-[0.875rem] flex-1 min-h-0"
classList={{
hidden: !!editorState.timeline.selection,
}}
>
<BackgroundConfig scrollRef={scrollRef} />
<CameraConfig scrollRef={scrollRef} />
<KTabs.Content
value="audio"
class="flex flex-col flex-1 gap-6 p-4 min-h-0"
>
<Field
name="Audio Controls"
icon={<IconLucideVolume2 class="size-4" />}
>
<Subfield name="Mute Audio">
<Toggle
checked={project.audio.mute}
onChange={(v) => setProject("audio", "mute", v)}
/>
</Subfield>
{editorInstance.recordings.segments[0].mic?.channels === 2 && (
<Subfield name="Microphone Stereo Mode">
<KSelect<{ name: string; value: StereoMode }>
options={STEREO_MODES}
optionValue="value"
optionTextValue="name"
value={STEREO_MODES.find(
(v) => v.value === project.audio.micStereoMode,
)}
onChange={(v) => {
if (v) setProject("audio", "micStereoMode", v.value);
}}
disallowEmptySelection
itemComponent={(props) => (
<MenuItem<typeof KSelect.Item>
as={KSelect.Item}
item={props.item}
>
<KSelect.ItemLabel class="flex-1">
{props.item.rawValue.name}
</KSelect.ItemLabel>
</MenuItem>
)}
>
<KSelect.Trigger class="flex flex-row gap-2 items-center px-2 w-full h-8 rounded-lg transition-colors bg-gray-3 disabled:text-gray-11">
<KSelect.Value<{
name: string;
value: StereoMode;
}> class="flex-1 text-sm text-left truncate text-[--gray-500] font-normal">
{(state) => <span>{state.selectedOption().name}</span>}
</KSelect.Value>
<KSelect.Icon<ValidComponent>
as={(props) => (
<IconCapChevronDown
{...props}
class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]"
/>
)}
/>
</KSelect.Trigger>
<KSelect.Portal>
<PopperContent<typeof KSelect.Content>
as={KSelect.Content}
class={cx(topSlideAnimateClasses, "z-50")}
>
<MenuItemList<typeof KSelect.Listbox>
class="overflow-y-auto max-h-32"
as={KSelect.Listbox}
/>
</PopperContent>
</KSelect.Portal>
</KSelect>
</Subfield>
)}
{/* <Subfield name="Mute Audio">
<Toggle
checked={project.audio.mute}
onChange={(v) => setProject("audio", "mute", v)}
/>
</Subfield> */}
{/* <ComingSoonTooltip>
<Subfield name="Improve Mic Quality">
<Toggle disabled />
</Subfield>
</ComingSoonTooltip> */}
</Field>
{meta().hasMicrophone && (
<Field
name="Microphone Volume"
icon={<IconCapMicrophone class="size-4" />}
>
<Slider
disabled={project.audio.mute}
value={[project.audio.micVolumeDb ?? 0]}
onChange={(v) => setProject("audio", "micVolumeDb", v[0])}
minValue={-30}
maxValue={10}
step={0.1}
formatTooltip={(v) =>
v <= -30 ? "Muted" : `${v > 0 ? "+" : ""}${v.toFixed(1)} dB`
}
/>
</Field>
)}
{meta().hasSystemAudio && (
<Field
name="System Audio Volume"
icon={<IconLucideMonitor class="size-4" />}
>
<Slider
disabled={project.audio.mute}
value={[project.audio.systemVolumeDb ?? 0]}
onChange={(v) => setProject("audio", "systemVolumeDb", v[0])}
minValue={-30}
maxValue={10}
step={0.1}
formatTooltip={(v) =>
v <= -30 ? "Muted" : `${v > 0 ? "+" : ""}${v.toFixed(1)} dB`
}
/>
</Field>
)}
</KTabs.Content>
<KTabs.Content
value="cursor"
class="flex flex-col flex-1 gap-6 p-4 min-h-0"
>
<Field
name="Cursor"
icon={<IconCapCursor />}
value={
<Toggle
checked={!project.cursor.hide}
onChange={(v) => {
setProject("cursor", "hide", !v);
}}
/>
}
/>
<Show when={!project.cursor.hide}>
<Field name="Cursor Type" icon={<IconCapCursor />}>
<RadioGroup
class="flex flex-col gap-2"
value={project.cursor.type}
onChange={(value) =>
setProject("cursor", "type", value as CursorType)
}
>
{CURSOR_TYPE_OPTIONS.map((option) => (
<RadioGroup.Item
value={option.value}
class="rounded-lg border border-gray-3 transition-colors ui-checked:border-blue-8 ui-checked:bg-blue-3/40"
>
<RadioGroup.ItemInput class="sr-only" />
<RadioGroup.ItemLabel class="flex cursor-pointer items-start gap-3 p-3">
<RadioGroup.ItemControl class="mt-1 size-4 rounded-full border border-gray-7 ui-checked:border-blue-9 ui-checked:bg-blue-9" />
<div class="flex flex-col text-left">
<span class="text-sm font-medium text-gray-12">
{option.label}
</span>
<span class="text-xs text-gray-11">
{option.description}
</span>
</div>
</RadioGroup.ItemLabel>
</RadioGroup.Item>
))}
</RadioGroup>
</Field>
<Field name="Size" icon={<IconCapEnlarge />}>
<Slider
value={[project.cursor.size]}
onChange={(v) => setProject("cursor", "size", v[0])}
minValue={20}
maxValue={300}
step={1}
/>
</Field>
<Field
name="Hide When Idle"
icon={<IconLucideTimer class="size-4" />}
value={
<Toggle
checked={project.cursor.hideWhenIdle}
onChange={(value) =>
setProject("cursor", "hideWhenIdle", value)
}
/>
}
/>
<Show when={project.cursor.hideWhenIdle}>
<Subfield name="Inactivity Delay" class="gap-4 items-center">
<div class="flex flex-1 gap-3 items-center">
<Slider
class="flex-1"
value={[cursorIdleDelay()]}
onChange={(v) => {
const rounded = clampIdleDelay(v[0]);
setProject("cursor", "hideWhenIdleDelay" as any, rounded);
}}
minValue={0.5}
maxValue={5}
step={0.1}
formatTooltip={(value) => `${value.toFixed(1)}s`}
/>
<span class="w-12 text-xs text-right text-gray-11">
{cursorIdleDelay().toFixed(1)}s
</span>
</div>
</Subfield>
</Show>
<Field
name="Cursor Movement Style"
icon={<IconLucideRabbit class="size-4" />}
>
<RadioGroup
class="flex flex-col gap-2"
value={project.cursor.animationStyle}
onChange={(value) =>
applyCursorStylePreset(value as CursorAnimationStyle)
}
>
{CURSOR_ANIMATION_STYLE_OPTIONS.map((option) => (
<RadioGroup.Item
value={option.value}
class="rounded-lg border border-gray-3 transition-colors ui-checked:border-blue-8 ui-checked:bg-blue-3/40"
>
<RadioGroup.ItemInput class="sr-only" />
<RadioGroup.ItemLabel class="flex cursor-pointer items-start gap-3 p-3">
<RadioGroup.ItemControl class="mt-1 size-4 rounded-full border border-gray-7 ui-checked:border-blue-9 ui-checked:bg-blue-9" />
<div class="flex flex-col text-left">
<span class="text-sm font-medium text-gray-12">
{option.label}
</span>
<span class="text-xs text-gray-11">
{option.description}
</span>
</div>
</RadioGroup.ItemLabel>
</RadioGroup.Item>
))}
</RadioGroup>
</Field>
<KCollapsible open={!project.cursor.raw}>
<Field
name="Smooth Movement"
icon={<IconHugeiconsEaseCurveControlPoints />}
value={
<Toggle
checked={!project.cursor.raw}
onChange={(value) => {
setProject("cursor", "raw", !value);
}}
/>
}
/>
<KCollapsible.Content class="overflow-hidden border-b opacity-0 transition-opacity border-gray-3 animate-collapsible-up ui-expanded:animate-collapsible-down ui-expanded:opacity-100">
{/* if Content has padding or margin the animation doesn't look as good */}
<div class="flex flex-col gap-4 pt-4 pb-6">
<Field name="Tension">
<Slider
value={[project.cursor.tension]}
onChange={(v) => setCursorPhysics("tension", v[0])}
minValue={1}
maxValue={500}
step={1}
/>
</Field>
<Field name="Friction">
<Slider
value={[project.cursor.friction]}
onChange={(v) => setCursorPhysics("friction", v[0])}
minValue={0}
maxValue={50}
step={0.1}
/>
</Field>
<Field name="Mass">
<Slider
value={[project.cursor.mass]}
onChange={(v) => setCursorPhysics("mass", v[0])}
minValue={0.1}
maxValue={10}
step={0.01}
/>
</Field>
</div>
</KCollapsible.Content>
</KCollapsible>
<Field
name="High Quality SVG Cursors"
icon={<IconLucideSparkles />}
value={
<Toggle
checked={(project.cursor as any).useSvg ?? true}
onChange={(value) => {
setProject("cursor", "useSvg" as any, value);
}}
/>
}
/>
</Show>
{/* <Field name="Animation Style" icon={<IconLucideRabbit />}>
<RadioGroup
defaultValue="regular"
value={project.cursor.animationStyle}
onChange={(value) => {
setProject(
"cursor",
"animationStyle",
value as CursorAnimationStyle
);
}}
class="flex flex-col gap-2"
disabled
>
{(
Object.entries(CURSOR_ANIMATION_STYLES) as [
CursorAnimationStyle,
string
][]
).map(([value, label]) => (
<RadioGroup.Item value={value} class="flex items-center">
<RadioGroup.ItemInput class="sr-only peer" />
<RadioGroup.ItemControl
class={cx(
"mr-2 w-4 h-4 rounded-full border border-gray-300",
"relative after:absolute after:inset-0 after:m-auto after:block after:w-2 after:h-2 after:rounded-full",
"after:transition-colors after:duration-200",
"peer-checked:border-blue-500 peer-checked:after:bg-blue-400",
"peer-focus-visible:ring-2 peer-focus-visible:ring-blue-400/50",
"peer-disabled:opacity-50"
)}
/>
<span
class={cx(
"text-gray-12",
"peer-checked:text-gray-900",
"peer-disabled:opacity-50"
)}
>
{label}
</span>
</RadioGroup.Item>
))}
</RadioGroup>
</Field> */}
</KTabs.Content>
<KTabs.Content value="hotkeys" class="flex flex-1 p-4 min-h-0">
<Field name="Hotkeys" icon={<IconCapHotkeys />}>
<ComingSoonTooltip>
<Subfield name="Show hotkeys">
<Toggle disabled />
</Subfield>
</ComingSoonTooltip>
</Field>
</KTabs.Content>
<KTabs.Content
value="captions"
class="flex flex-col flex-1 gap-6 p-4 min-h-0"
>
<CaptionsTab />
</KTabs.Content>
</div>
<div
style={{
"--margin-top-scroll": "5px",
}}
class="custom-scroll p-4 top-16 left-0 right-0 bottom-0 text-[0.875rem] space-y-4 bg-gray-1 dark:bg-gray-2 z-50"
classList={{
hidden: !editorState.timeline.selection,
"animate-in slide-in-from-bottom-2 fade-in":
!!editorState.timeline.selection,
}}
>
<Show when={editorState.timeline.selection}>
{(selection) => (
<Suspense>
<Show
when={(() => {
const textSelection = selection();
if (textSelection.type !== "text") return;
const segments = textSelection.indices
.map((index) => ({
index,
segment: project.timeline?.textSegments?.[index],
}))
.filter(
(item): item is { index: number; segment: TextSegment } =>
item.segment !== undefined,
);
if (segments.length === 0) {
setEditorState("timeline", "selection", null);
return;
}
return { selection: textSelection, segments };
})()}
>
{(value) => (
<div class="space-y-4">
<div class="flex flex-row justify-between items-center">
<div class="flex gap-2 items-center">
<EditorButton
onClick={() =>
setEditorState("timeline", "selection", null)
}
leftIcon={<IconLucideCheck />}
>
Done
</EditorButton>
<span class="text-sm text-gray-10">
{value().segments.length} text{" "}
{value().segments.length === 1
? "segment"
: "segments"}{" "}
selected
</span>
</div>
<EditorButton
variant="danger"
onClick={() =>
projectActions.deleteTextSegments(
value().segments.map((s) => s.index),
)
}
leftIcon={<IconCapTrash />}
>
Delete
</EditorButton>
</div>
<For each={value().segments}>
{(item) => (
<div class="p-4 rounded-lg border border-gray-200">
<TextSegmentConfig
segment={item.segment}
segmentIndex={item.index}
/>
</div>
)}
</For>
</div>
)}
</Show>
<Show
when={(() => {
const maskSelection = selection();
if (maskSelection.type !== "mask") return;
const segments = maskSelection.indices
.map((index) => ({
index,
segment: project.timeline?.maskSegments?.[index],
}))
.filter(
(item): item is { index: number; segment: MaskSegment } =>
item.segment !== undefined,
);
if (segments.length === 0) {
setEditorState("timeline", "selection", null);
return;
}
return { selection: maskSelection, segments };
})()}
>
{(value) => (
<div class="space-y-4">
<div class="flex flex-row justify-between items-center">
<div class="flex gap-2 items-center">
<EditorButton
onClick={() =>
setEditorState("timeline", "selection", null)
}
leftIcon={<IconLucideCheck />}
>
Done
</EditorButton>
<span class="text-sm text-gray-10">
{value().segments.length} mask{" "}
{value().segments.length === 1
? "segment"
: "segments"}{" "}
selected
</span>
</div>
<EditorButton
variant="danger"
onClick={() =>
projectActions.deleteMaskSegments(
value().segments.map((s) => s.index),
)
}
leftIcon={<IconCapTrash />}
>
Delete
</EditorButton>
</div>
<For each={value().segments}>
{(item) => (
<div class="p-4 rounded-lg border border-gray-200">
<MaskSegmentConfig
segment={item.segment}
segmentIndex={item.index}
/>
</div>
)}
</For>
</div>
)}
</Show>
<Show
when={(() => {
const zoomSelection = selection();
if (zoomSelection.type !== "zoom") return;
const segments = zoomSelection.indices
.map((index) => ({
index,
segment: project.timeline?.zoomSegments?.[index],
}))
.filter(
(item): item is { index: number; segment: ZoomSegment } =>
item.segment !== undefined,
);
if (segments.length === 0) {
setEditorState("timeline", "selection", null);
return;
}
return { selection: zoomSelection, segments };
})()}
>
{(value) => (
<div class="space-y-4">
<div class="flex flex-row justify-between items-center">
<div class="flex gap-2 items-center">
<EditorButton
onClick={() =>
setEditorState("timeline", "selection", null)
}
leftIcon={<IconLucideCheck />}
>
Done
</EditorButton>
<span class="text-sm text-gray-10">