@remotion/studio 4.0.475 → 4.0.477
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Canvas.js +40 -1
- package/dist/components/ColorPicker/ColorPickerPopup.d.ts +6 -0
- package/dist/components/ColorPicker/ColorPickerPopup.js +11 -6
- package/dist/components/ControlButton.d.ts +1 -0
- package/dist/components/ControlButton.js +7 -2
- package/dist/components/EditorGuides/Guide.js +122 -20
- package/dist/components/EditorRuler/Ruler.js +21 -15
- package/dist/components/EditorRuler/index.js +18 -10
- package/dist/components/GlobalKeybindings.js +12 -0
- package/dist/components/KeyboardShortcutsExplainer.js +24 -0
- package/dist/components/NewComposition/InputDragger.d.ts +6 -0
- package/dist/components/NewComposition/InputDragger.js +40 -14
- package/dist/components/NewComposition/RenameComposition.js +8 -1
- package/dist/components/NewComposition/RenameFolder.js +8 -1
- package/dist/components/NewComposition/RenameStaticFile.js +11 -1
- package/dist/components/Notifications/Notification.js +5 -4
- package/dist/components/Notifications/NotificationCenter.js +1 -1
- package/dist/components/ObserveDefaultPropsContext.js +6 -2
- package/dist/components/OutlineToggle.js +1 -1
- package/dist/components/PlayPause.js +22 -66
- package/dist/components/PreviewToolbar.js +15 -1
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +2 -1
- package/dist/components/SelectedOutlineElement.d.ts +17 -0
- package/dist/components/SelectedOutlineElement.js +938 -0
- package/dist/components/SelectedOutlineOverlay.d.ts +4 -174
- package/dist/components/SelectedOutlineOverlay.js +310 -1392
- package/dist/components/SelectedOutlineUvControls.js +1 -1
- package/dist/components/ShowGuidesProvider.js +4 -4
- package/dist/components/Timeline/SubscribeToNodePaths.d.ts +2 -1
- package/dist/components/Timeline/SubscribeToNodePaths.js +2 -1
- package/dist/components/Timeline/Timeline.js +3 -1
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +9 -10
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +15 -4
- package/dist/components/Timeline/TimelineKeyframeEasingLine.js +7 -11
- package/dist/components/Timeline/TimelineList.js +1 -1
- package/dist/components/Timeline/TimelineRotationField.js +17 -17
- package/dist/components/Timeline/TimelineScaleField.js +1 -1
- package/dist/components/Timeline/TimelineSelection.d.ts +27 -13
- package/dist/components/Timeline/TimelineSelection.js +47 -28
- package/dist/components/Timeline/TimelineSequence.js +169 -8
- package/dist/components/Timeline/TimelineSequenceFrame.d.ts +1 -0
- package/dist/components/Timeline/TimelineSequenceFrame.js +17 -6
- package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
- package/dist/components/Timeline/TimelineSequenceItem.js +294 -142
- package/dist/components/Timeline/TimelineSequenceName.d.ts +4 -2
- package/dist/components/Timeline/TimelineSequenceName.js +67 -2
- package/dist/components/Timeline/TimelineTransformOriginField.js +1 -1
- package/dist/components/Timeline/TimelineTranslateField.js +1 -1
- package/dist/components/Timeline/TimelineUvCoordinateField.js +1 -1
- package/dist/components/Timeline/delete-selected-timeline-item.js +4 -0
- package/dist/components/Timeline/disable-sequence-interactivity.d.ts +8 -0
- package/dist/components/Timeline/disable-sequence-interactivity.js +24 -0
- package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +1 -2
- package/dist/components/Timeline/get-sequence-context-menu-items.d.ts +20 -0
- package/dist/components/Timeline/get-sequence-context-menu-items.js +160 -0
- package/dist/components/Timeline/reset-selected-timeline-props.js +2 -2
- package/dist/components/Timeline/sequence-props-subscription-store.d.ts +2 -1
- package/dist/components/Timeline/sequence-props-subscription-store.js +11 -3
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +2 -0
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +16 -2
- package/dist/components/Timeline/timeline-rotation-utils.d.ts +1 -1
- package/dist/components/Timeline/timeline-rotation-utils.js +4 -2
- package/dist/components/Timeline/update-selected-easing.d.ts +4 -6
- package/dist/components/Timeline/use-sequence-props-subscription.d.ts +2 -1
- package/dist/components/Timeline/use-sequence-props-subscription.js +3 -1
- package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +37 -1
- package/dist/components/Timeline/use-timeline-keyframe-drag.js +290 -14
- package/dist/components/import-assets.d.ts +36 -8
- package/dist/components/import-assets.js +170 -10
- package/dist/components/selected-outline-drag.d.ts +117 -0
- package/dist/components/selected-outline-drag.js +427 -0
- package/dist/components/selected-outline-measurement.d.ts +67 -0
- package/dist/components/selected-outline-measurement.js +355 -0
- package/dist/components/selected-outline-types.d.ts +121 -0
- package/dist/components/selected-outline-types.js +15 -0
- package/dist/components/selected-outline-uv.d.ts +1 -0
- package/dist/components/selected-outline-uv.js +12 -0
- package/dist/esm/{chunk-qaqqvw4q.js → chunk-t8fjnw2d.js} +14059 -12029
- package/dist/esm/internals.mjs +14059 -12029
- package/dist/esm/previewEntry.mjs +14066 -12036
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/editor-guide-selection.d.ts +31 -0
- package/dist/helpers/editor-guide-selection.js +58 -0
- package/dist/helpers/editor-ruler.d.ts +3 -3
- package/dist/helpers/editor-ruler.js +16 -18
- package/dist/state/editor-guides.d.ts +2 -2
- package/dist/state/editor-guides.js +2 -2
- package/package.json +11 -11
|
@@ -33,1385 +33,60 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SelectedOutlineOverlay = exports.
|
|
36
|
+
exports.SelectedOutlineOverlay = exports.selectedOutlineDragThresholdPx = exports.getTransformedSvgViewportPoints = exports.getSequencesWithSelectableOutlines = exports.getSelectedSequenceKeys = exports.getSelectedOutlineRotationPivot = exports.getSelectedOutlineRotationDeltaDegrees = exports.getSelectedOutlineRotationCornerInfo = exports.getSelectedEffectFieldsBySequenceKey = exports.getOutlineSelectionInteraction = exports.isSelectedOutlineDragPastThreshold = exports.getSelectedOutlineScaleEdgeInfo = exports.getSelectedOutlineScaleDragValues = exports.getSelectedOutlineScaleDragStates = exports.getSelectedOutlineScaleDragChanges = exports.getSelectedOutlineRotationDragValues = exports.getSelectedOutlineRotationDragStates = exports.getSelectedOutlineRotationDragChanges = exports.getSelectedOutlineKeyboardNudgeDeltas = exports.getSelectedOutlineKeyboardNudgeDelta = exports.getSelectedOutlineDragValues = exports.getSelectedOutlineDragChanges = exports.compensateTranslateForTransformOrigin = exports.applySelectedOutlineDragAxisLock = void 0;
|
|
37
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const player_1 = require("@remotion/player");
|
|
38
39
|
const react_1 = __importStar(require("react"));
|
|
39
40
|
const remotion_1 = require("remotion");
|
|
40
41
|
const no_react_1 = require("remotion/no-react");
|
|
41
|
-
const calculate_timeline_1 = require("../helpers/calculate-timeline");
|
|
42
42
|
const client_id_1 = require("../helpers/client-id");
|
|
43
|
-
const
|
|
44
|
-
const format_file_location_1 = require("../helpers/format-file-location");
|
|
45
|
-
const get_box_quads_ponyfill_1 = require("../helpers/get-box-quads-ponyfill");
|
|
46
|
-
const open_in_editor_1 = require("../helpers/open-in-editor");
|
|
43
|
+
const use_keybinding_1 = require("../helpers/use-keybinding");
|
|
47
44
|
const editor_outlines_1 = require("../state/editor-outlines");
|
|
48
45
|
const scale_lock_1 = require("../state/scale-lock");
|
|
49
|
-
const ContextMenu_1 = require("./ContextMenu");
|
|
50
|
-
const effect_drag_and_drop_1 = require("./effect-drag-and-drop");
|
|
51
|
-
const ForceSpecificCursor_1 = require("./ForceSpecificCursor");
|
|
52
46
|
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
53
|
-
const
|
|
47
|
+
const selected_outline_drag_1 = require("./selected-outline-drag");
|
|
48
|
+
const selected_outline_measurement_1 = require("./selected-outline-measurement");
|
|
49
|
+
const selected_outline_types_1 = require("./selected-outline-types");
|
|
54
50
|
const selected_outline_uv_1 = require("./selected-outline-uv");
|
|
51
|
+
const SelectedOutlineElement_1 = require("./SelectedOutlineElement");
|
|
55
52
|
const SelectedOutlineUvControls_1 = require("./SelectedOutlineUvControls");
|
|
56
53
|
const call_add_keyframe_1 = require("./Timeline/call-add-keyframe");
|
|
57
|
-
const
|
|
54
|
+
const imperative_state_1 = require("./Timeline/imperative-state");
|
|
58
55
|
const save_sequence_prop_1 = require("./Timeline/save-sequence-prop");
|
|
59
|
-
const
|
|
60
|
-
const timeline_translate_utils_1 = require("./Timeline/timeline-translate-utils");
|
|
61
|
-
const TimelineScaleField_1 = require("./Timeline/TimelineScaleField");
|
|
56
|
+
const timeline_scroll_logic_1 = require("./Timeline/timeline-scroll-logic");
|
|
62
57
|
const TimelineSelection_1 = require("./Timeline/TimelineSelection");
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
const selected_outline_drag_2 = require("./selected-outline-drag");
|
|
59
|
+
Object.defineProperty(exports, "applySelectedOutlineDragAxisLock", { enumerable: true, get: function () { return selected_outline_drag_2.applySelectedOutlineDragAxisLock; } });
|
|
60
|
+
Object.defineProperty(exports, "compensateTranslateForTransformOrigin", { enumerable: true, get: function () { return selected_outline_drag_2.compensateTranslateForTransformOrigin; } });
|
|
61
|
+
Object.defineProperty(exports, "getSelectedOutlineDragChanges", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineDragChanges; } });
|
|
62
|
+
Object.defineProperty(exports, "getSelectedOutlineDragValues", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineDragValues; } });
|
|
63
|
+
Object.defineProperty(exports, "getSelectedOutlineKeyboardNudgeDelta", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineKeyboardNudgeDelta; } });
|
|
64
|
+
Object.defineProperty(exports, "getSelectedOutlineKeyboardNudgeDeltas", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineKeyboardNudgeDeltas; } });
|
|
65
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationDragChanges", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineRotationDragChanges; } });
|
|
66
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationDragStates", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineRotationDragStates; } });
|
|
67
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationDragValues", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineRotationDragValues; } });
|
|
68
|
+
Object.defineProperty(exports, "getSelectedOutlineScaleDragChanges", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineScaleDragChanges; } });
|
|
69
|
+
Object.defineProperty(exports, "getSelectedOutlineScaleDragStates", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineScaleDragStates; } });
|
|
70
|
+
Object.defineProperty(exports, "getSelectedOutlineScaleDragValues", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineScaleDragValues; } });
|
|
71
|
+
Object.defineProperty(exports, "getSelectedOutlineScaleEdgeInfo", { enumerable: true, get: function () { return selected_outline_drag_2.getSelectedOutlineScaleEdgeInfo; } });
|
|
72
|
+
Object.defineProperty(exports, "isSelectedOutlineDragPastThreshold", { enumerable: true, get: function () { return selected_outline_drag_2.isSelectedOutlineDragPastThreshold; } });
|
|
73
|
+
const selected_outline_measurement_2 = require("./selected-outline-measurement");
|
|
74
|
+
Object.defineProperty(exports, "getOutlineSelectionInteraction", { enumerable: true, get: function () { return selected_outline_measurement_2.getOutlineSelectionInteraction; } });
|
|
75
|
+
Object.defineProperty(exports, "getSelectedEffectFieldsBySequenceKey", { enumerable: true, get: function () { return selected_outline_measurement_2.getSelectedEffectFieldsBySequenceKey; } });
|
|
76
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationCornerInfo", { enumerable: true, get: function () { return selected_outline_measurement_2.getSelectedOutlineRotationCornerInfo; } });
|
|
77
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationDeltaDegrees", { enumerable: true, get: function () { return selected_outline_measurement_2.getSelectedOutlineRotationDeltaDegrees; } });
|
|
78
|
+
Object.defineProperty(exports, "getSelectedOutlineRotationPivot", { enumerable: true, get: function () { return selected_outline_measurement_2.getSelectedOutlineRotationPivot; } });
|
|
79
|
+
Object.defineProperty(exports, "getSelectedSequenceKeys", { enumerable: true, get: function () { return selected_outline_measurement_2.getSelectedSequenceKeys; } });
|
|
80
|
+
Object.defineProperty(exports, "getSequencesWithSelectableOutlines", { enumerable: true, get: function () { return selected_outline_measurement_2.getSequencesWithSelectableOutlines; } });
|
|
81
|
+
Object.defineProperty(exports, "getTransformedSvgViewportPoints", { enumerable: true, get: function () { return selected_outline_measurement_2.getTransformedSvgViewportPoints; } });
|
|
82
|
+
const selected_outline_types_2 = require("./selected-outline-types");
|
|
83
|
+
Object.defineProperty(exports, "selectedOutlineDragThresholdPx", { enumerable: true, get: function () { return selected_outline_types_2.selectedOutlineDragThresholdPx; } });
|
|
69
84
|
const outlineContainer = {
|
|
70
85
|
position: 'absolute',
|
|
71
86
|
inset: 0,
|
|
72
87
|
pointerEvents: 'none',
|
|
73
88
|
overflow: 'visible',
|
|
74
89
|
};
|
|
75
|
-
const emptyContextMenuValues = [];
|
|
76
|
-
const pointToString = (point) => `${point.x},${point.y}`;
|
|
77
|
-
const midpoint = (from, to) => {
|
|
78
|
-
return (0, selected_outline_geometry_1.mixPoint)(from, to, 0.5);
|
|
79
|
-
};
|
|
80
|
-
const getOutlineCenter = (points) => {
|
|
81
|
-
const [tl, tr, br, bl] = points;
|
|
82
|
-
return {
|
|
83
|
-
x: (tl.x + tr.x + br.x + bl.x) / 4,
|
|
84
|
-
y: (tl.y + tr.y + br.y + bl.y) / 4,
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
const dot = (left, right) => {
|
|
88
|
-
return left.x * right.x + left.y * right.y;
|
|
89
|
-
};
|
|
90
|
-
const vectorLength = (vector) => {
|
|
91
|
-
return Math.hypot(vector.x, vector.y);
|
|
92
|
-
};
|
|
93
|
-
const vectorBetween = (from, to) => {
|
|
94
|
-
return { x: to.x - from.x, y: to.y - from.y };
|
|
95
|
-
};
|
|
96
|
-
const getAngleDegrees = (from, to) => {
|
|
97
|
-
return Math.atan2(to.y - from.y, to.x - from.x) * (180 / Math.PI);
|
|
98
|
-
};
|
|
99
|
-
const getSelectedOutlineRotationDeltaDegrees = ({ from, to, }) => {
|
|
100
|
-
return ((((to - from) % 360) + 540) % 360) - 180;
|
|
101
|
-
};
|
|
102
|
-
exports.getSelectedOutlineRotationDeltaDegrees = getSelectedOutlineRotationDeltaDegrees;
|
|
103
|
-
const normalizeRotationCursorDegrees = (rotation) => {
|
|
104
|
-
const normalizedRotation = ((rotation % 360) + 360) % 360;
|
|
105
|
-
return Number(normalizedRotation.toFixed(3));
|
|
106
|
-
};
|
|
107
|
-
const getRotationCursor = (rotation) => {
|
|
108
|
-
const normalizedRotation = normalizeRotationCursorDegrees(rotation);
|
|
109
|
-
const transform = normalizedRotation === 0
|
|
110
|
-
? ''
|
|
111
|
-
: `<g transform="rotate(${normalizedRotation} 32 32)">`;
|
|
112
|
-
const transformEnd = normalizedRotation === 0 ? '' : '</g>';
|
|
113
|
-
const svg = `<svg width="24" height="24" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">${transform}<g transform="scale(0.876712329)" filter="url(#filter0_d_1_14)"><path d="M10.9111 17.7687C10.3413 18.3701 10.367 19.3195 10.9684 19.8893L20.7687 29.1738C21.3701 29.7436 22.3195 29.7179 22.8893 29.1165C23.459 28.5151 23.4334 27.5657 22.832 26.996L14.1206 18.7431L22.3735 10.0316C22.9432 9.43022 22.9176 8.48082 22.3162 7.91107C21.7148 7.34133 20.7654 7.36699 20.1956 7.96839L10.9111 17.7687ZM49.3923 58.3118C49.9509 58.9235 50.8996 58.9667 51.5114 58.4081L61.481 49.3055C62.0927 48.7469 62.1359 47.7981 61.5773 47.1863C61.0187 46.5745 60.0699 46.5314 59.4581 47.09L50.5963 55.1812L42.5051 46.3194C41.9465 45.7076 40.9977 45.6645 40.386 46.2231C39.7742 46.7817 39.7311 47.7304 40.2896 48.3422L49.3923 58.3118ZM12.6747 18.7431L13 19.8893C22.1283 19.6426 30.7584 21.4283 37.8564 26.6927C44.8518 31.8809 49.734 39.8538 49 56H50.5963H51.5114C52.2774 39.1461 47.6482 30.2198 39.6436 24.2831C31.7416 18.4224 22.3717 17.2467 13 17.5L12.6747 18.7431Z" fill="black"/><path d="M19.1064 6.93652C20.2459 5.73379 22.1448 5.68278 23.3477 6.82227C24.5505 7.96181 24.6022 9.86076 23.4629 11.0635L18.7373 16.0508C26.3487 16.4239 33.9128 18.1651 40.5371 23.0781C44.7339 26.1907 48.0794 30.1189 50.2568 35.4834C51.9666 39.6958 52.9327 44.7395 53.0742 50.8867L58.4463 45.9824C59.6697 44.8654 61.5673 44.9514 62.6846 46.1748C63.8018 47.3985 63.7155 49.296 62.4922 50.4131L52.5225 59.5156C51.337 60.5979 49.5196 60.5507 48.3916 59.4346L48.2842 59.3232L39.1816 49.3535C38.0648 48.1301 38.1507 46.2324 39.374 45.1152C40.5975 43.9979 42.4961 44.0841 43.6133 45.3076L47.4756 49.5381C47.1908 44.7613 46.2876 40.9448 44.9482 37.8291C43.0666 33.4521 40.2851 30.3614 36.9629 27.8975C31.8259 24.0875 25.8071 22.1663 19.2891 21.5732L23.8633 25.9072C25.0662 27.0468 25.1178 28.9457 23.9785 30.1484C22.8746 31.3135 21.0576 31.3982 19.8516 30.3662L19.7373 30.2627L9.93652 20.9785C8.73384 19.839 8.6828 17.9401 9.82227 16.7373L19.1064 6.93652Z" stroke="white" stroke-width="3"/></g>${transformEnd}<defs><filter id="filter0_d_1_14" x="0" y="0" width="72.4696" height="72.3004" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="3.75"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1_14"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1_14" result="shape"/></filter></defs></svg>`;
|
|
114
|
-
return `url("data:image/svg+xml,${encodeURIComponent(svg)}") 12 12, alias`;
|
|
115
|
-
};
|
|
116
|
-
const rotationCursorBaseDegrees = {
|
|
117
|
-
'top-left': 270,
|
|
118
|
-
'top-right': 0,
|
|
119
|
-
'bottom-right': 90,
|
|
120
|
-
'bottom-left': 180,
|
|
121
|
-
};
|
|
122
|
-
const getOutlineRotationDegrees = (points) => {
|
|
123
|
-
const [tl, tr] = points;
|
|
124
|
-
return getAngleDegrees(tl, tr);
|
|
125
|
-
};
|
|
126
|
-
const getRotationCursorDegrees = (points, corner) => normalizeRotationCursorDegrees(getOutlineRotationDegrees(points) + rotationCursorBaseDegrees[corner]);
|
|
127
|
-
const getSelectedOutlineRotationCornerInfo = (points, corner) => {
|
|
128
|
-
const [tl, tr, br, bl] = points;
|
|
129
|
-
const point = {
|
|
130
|
-
'top-left': tl,
|
|
131
|
-
'top-right': tr,
|
|
132
|
-
'bottom-right': br,
|
|
133
|
-
'bottom-left': bl,
|
|
134
|
-
}[corner];
|
|
135
|
-
const center = getOutlineCenter(points);
|
|
136
|
-
const cursorDegrees = getRotationCursorDegrees(points, corner);
|
|
137
|
-
return {
|
|
138
|
-
center,
|
|
139
|
-
cursor: getRotationCursor(cursorDegrees),
|
|
140
|
-
cursorDegrees,
|
|
141
|
-
point,
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
exports.getSelectedOutlineRotationCornerInfo = getSelectedOutlineRotationCornerInfo;
|
|
145
|
-
const rectToPoints = (elementRect, containerRect) => {
|
|
146
|
-
const left = elementRect.left - containerRect.left;
|
|
147
|
-
const top = elementRect.top - containerRect.top;
|
|
148
|
-
const right = elementRect.right - containerRect.left;
|
|
149
|
-
const bottom = elementRect.bottom - containerRect.top;
|
|
150
|
-
return [
|
|
151
|
-
{ x: left, y: top },
|
|
152
|
-
{ x: right, y: top },
|
|
153
|
-
{ x: right, y: bottom },
|
|
154
|
-
{ x: left, y: bottom },
|
|
155
|
-
];
|
|
156
|
-
};
|
|
157
|
-
const quadToPoints = (quad, containerRect) => {
|
|
158
|
-
// `getBoxQuads`/the ponyfill returns the quad in viewport coordinates.
|
|
159
|
-
// The overlay <svg> is unscaled (the canvas `scale()`/pan live on a sibling
|
|
160
|
-
// container, not the svg), so 1 user unit == 1 px and we only need to move
|
|
161
|
-
// the quad into the svg's local space by subtracting its viewport origin.
|
|
162
|
-
// We deliberately do not pass `relativeTo` to the ponyfill: when the target
|
|
163
|
-
// is not an ancestor of the element, the polyfill cannot resolve the
|
|
164
|
-
// coordinate space and leaves the quad in viewport coordinates.
|
|
165
|
-
return [
|
|
166
|
-
{ x: quad.p1.x - containerRect.left, y: quad.p1.y - containerRect.top },
|
|
167
|
-
{ x: quad.p2.x - containerRect.left, y: quad.p2.y - containerRect.top },
|
|
168
|
-
{ x: quad.p3.x - containerRect.left, y: quad.p3.y - containerRect.top },
|
|
169
|
-
{ x: quad.p4.x - containerRect.left, y: quad.p4.y - containerRect.top },
|
|
170
|
-
];
|
|
171
|
-
};
|
|
172
|
-
const getElementOutlinePoints = (element, containerRect) => {
|
|
173
|
-
const elementRect = element.getBoundingClientRect();
|
|
174
|
-
if (elementRect.width === 0 && elementRect.height === 0) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
const quads = (0, get_box_quads_ponyfill_1.getBoxQuadsPonyfill)(element, {
|
|
178
|
-
box: 'border',
|
|
179
|
-
});
|
|
180
|
-
const quad = quads === null || quads === void 0 ? void 0 : quads[0];
|
|
181
|
-
if (!quad) {
|
|
182
|
-
return rectToPoints(elementRect, containerRect);
|
|
183
|
-
}
|
|
184
|
-
return quadToPoints(quad, containerRect);
|
|
185
|
-
};
|
|
186
|
-
const getSelectedSequenceKeys = (selectedItems) => {
|
|
187
|
-
return new Set(selectedItems
|
|
188
|
-
.filter((item) => item.type === 'sequence')
|
|
189
|
-
.map((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo)));
|
|
190
|
-
};
|
|
191
|
-
exports.getSelectedSequenceKeys = getSelectedSequenceKeys;
|
|
192
|
-
const getSequenceKeysContainingSelection = (selectedItems) => {
|
|
193
|
-
return new Set(selectedItems.map((item) => (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo)));
|
|
194
|
-
};
|
|
195
|
-
const getOutlineSelectionInteraction = ({ shiftKey, metaKey, ctrlKey, }) => ({
|
|
196
|
-
shiftKey,
|
|
197
|
-
toggleKey: metaKey || ctrlKey,
|
|
198
|
-
});
|
|
199
|
-
exports.getOutlineSelectionInteraction = getOutlineSelectionInteraction;
|
|
200
|
-
const getSelectedEffectFieldsBySequenceKey = (selectedItems) => {
|
|
201
|
-
var _a, _b;
|
|
202
|
-
const selectedEffects = new Map();
|
|
203
|
-
for (const item of selectedItems) {
|
|
204
|
-
if (item.type !== 'sequence-effect' &&
|
|
205
|
-
item.type !== 'sequence-effect-prop') {
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
const sequenceKey = (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(item.nodePathInfo);
|
|
209
|
-
const effectsForSequence = (_a = selectedEffects.get(sequenceKey)) !== null && _a !== void 0 ? _a : new Map();
|
|
210
|
-
const selectedFields = (_b = effectsForSequence.get(item.i)) !== null && _b !== void 0 ? _b : {
|
|
211
|
-
allFields: false,
|
|
212
|
-
fieldKeys: new Set(),
|
|
213
|
-
};
|
|
214
|
-
if (item.type === 'sequence-effect') {
|
|
215
|
-
selectedFields.allFields = true;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
selectedFields.fieldKeys.add(item.key);
|
|
219
|
-
}
|
|
220
|
-
effectsForSequence.set(item.i, selectedFields);
|
|
221
|
-
selectedEffects.set(sequenceKey, effectsForSequence);
|
|
222
|
-
}
|
|
223
|
-
return selectedEffects;
|
|
224
|
-
};
|
|
225
|
-
exports.getSelectedEffectFieldsBySequenceKey = getSelectedEffectFieldsBySequenceKey;
|
|
226
|
-
const getSelectedTransformOriginInfo = (selectedItems) => {
|
|
227
|
-
if (selectedItems.length !== 1) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
const [selectedItem] = selectedItems;
|
|
231
|
-
if (selectedItem.type === 'sequence-prop' &&
|
|
232
|
-
selectedItem.key === transformOriginFieldKey) {
|
|
233
|
-
return {
|
|
234
|
-
sequenceKey: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(selectedItem.nodePathInfo),
|
|
235
|
-
displayFrame: null,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
if (selectedItem.type !== 'keyframe') {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
const field = (0, parse_keyframe_field_from_node_path_1.parseKeyframeFieldFromNodePath)(selectedItem.nodePathInfo.auxiliaryKeys);
|
|
242
|
-
if ((field === null || field === void 0 ? void 0 : field.type) !== 'sequence' ||
|
|
243
|
-
field.fieldKey !== transformOriginFieldKey) {
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
sequenceKey: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(selectedItem.nodePathInfo),
|
|
248
|
-
displayFrame: selectedItem.frame,
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
const getSequencesWithSelectableOutlines = ({ sequences, overrideIdsToNodePaths, }) => {
|
|
252
|
-
return (0, calculate_timeline_1.calculateTimeline)({
|
|
253
|
-
sequences: [...sequences],
|
|
254
|
-
overrideIdsToNodePaths,
|
|
255
|
-
})
|
|
256
|
-
.filter((track) => {
|
|
257
|
-
if (track.nodePathInfo === null) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
return (track.sequence.showInTimeline &&
|
|
261
|
-
track.nodePathInfo.auxiliaryKeys.length === 0);
|
|
262
|
-
})
|
|
263
|
-
.filter((track) => track.sequence.refForOutline !== null)
|
|
264
|
-
.sort((a, b) => a.depth - b.depth)
|
|
265
|
-
.map((track) => {
|
|
266
|
-
if (track.nodePathInfo === null) {
|
|
267
|
-
throw new Error('Expected selected outline to have a node path');
|
|
268
|
-
}
|
|
269
|
-
return {
|
|
270
|
-
depth: track.depth,
|
|
271
|
-
keyframeDisplayOffset: track.keyframeDisplayOffset,
|
|
272
|
-
key: (0, TimelineSelection_1.getTimelineSequenceSelectionKey)(track.nodePathInfo),
|
|
273
|
-
nodePathInfo: track.nodePathInfo,
|
|
274
|
-
sequence: track.sequence,
|
|
275
|
-
};
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
exports.getSequencesWithSelectableOutlines = getSequencesWithSelectableOutlines;
|
|
279
|
-
const measureOutlines = (container, targets) => {
|
|
280
|
-
const containerRect = container.getBoundingClientRect();
|
|
281
|
-
const outlines = [];
|
|
282
|
-
for (const target of targets) {
|
|
283
|
-
const element = target.ref.current;
|
|
284
|
-
if (element === null) {
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const points = getElementOutlinePoints(element, containerRect);
|
|
288
|
-
if (points === null) {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
outlines.push({
|
|
292
|
-
key: target.key,
|
|
293
|
-
dimensions: element instanceof HTMLElement
|
|
294
|
-
? {
|
|
295
|
-
width: element.offsetWidth,
|
|
296
|
-
height: element.offsetHeight,
|
|
297
|
-
}
|
|
298
|
-
: null,
|
|
299
|
-
points,
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
return outlines;
|
|
303
|
-
};
|
|
304
|
-
const outlinesAreEqual = (a, b) => {
|
|
305
|
-
var _a, _b, _c, _d;
|
|
306
|
-
if (a.length !== b.length) {
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
for (let i = 0; i < a.length; i++) {
|
|
310
|
-
if (a[i].key !== b[i].key) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
if (((_a = a[i].dimensions) === null || _a === void 0 ? void 0 : _a.width) !== ((_b = b[i].dimensions) === null || _b === void 0 ? void 0 : _b.width) ||
|
|
314
|
-
((_c = a[i].dimensions) === null || _c === void 0 ? void 0 : _c.height) !== ((_d = b[i].dimensions) === null || _d === void 0 ? void 0 : _d.height)) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
for (let j = 0; j < a[i].points.length; j++) {
|
|
318
|
-
if (Math.abs(a[i].points[j].x - b[i].points[j].x) > 0.01 ||
|
|
319
|
-
Math.abs(a[i].points[j].y - b[i].points[j].y) > 0.01) {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return true;
|
|
325
|
-
};
|
|
326
|
-
const getSelectedOutlineDragStates = ({ dragTargets, getDragOverrides, timelinePosition, }) => {
|
|
327
|
-
return dragTargets.map((target) => {
|
|
328
|
-
var _a;
|
|
329
|
-
const dragOverrideValue = ((_a = getDragOverrides(target.nodePath)) !== null && _a !== void 0 ? _a : {})[translateFieldKey];
|
|
330
|
-
const sourceFrame = timelinePosition - target.keyframeDisplayOffset;
|
|
331
|
-
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
332
|
-
propStatus: target.propStatus,
|
|
333
|
-
dragOverrideValue,
|
|
334
|
-
defaultValue: target.fieldDefault,
|
|
335
|
-
frame: sourceFrame,
|
|
336
|
-
shouldResortToDefaultValueIfUndefined: true,
|
|
337
|
-
});
|
|
338
|
-
const [startX, startY] = (0, timeline_translate_utils_1.parseTranslate)(String(effectiveValue !== null && effectiveValue !== void 0 ? effectiveValue : '0px 0px'));
|
|
339
|
-
return {
|
|
340
|
-
defaultValue: target.fieldDefault !== undefined
|
|
341
|
-
? JSON.stringify(target.fieldDefault)
|
|
342
|
-
: null,
|
|
343
|
-
key: remotion_1.Internals.makeSequencePropsSubscriptionKey(target.nodePath),
|
|
344
|
-
sourceFrame,
|
|
345
|
-
startX,
|
|
346
|
-
startY,
|
|
347
|
-
target,
|
|
348
|
-
};
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
const getSelectedOutlineDragValues = ({ dragStates, deltaX, deltaY, }) => {
|
|
352
|
-
return new Map(dragStates.map((dragState) => [
|
|
353
|
-
dragState.key,
|
|
354
|
-
(0, timeline_translate_utils_1.serializeTranslate)(dragState.startX + deltaX, dragState.startY + deltaY),
|
|
355
|
-
]));
|
|
356
|
-
};
|
|
357
|
-
exports.getSelectedOutlineDragValues = getSelectedOutlineDragValues;
|
|
358
|
-
const applySelectedOutlineDragAxisLock = ({ deltaX, deltaY, axisLocked, }) => {
|
|
359
|
-
if (!axisLocked) {
|
|
360
|
-
return { deltaX, deltaY };
|
|
361
|
-
}
|
|
362
|
-
if (Math.abs(deltaX) >= Math.abs(deltaY)) {
|
|
363
|
-
return { deltaX, deltaY: 0 };
|
|
364
|
-
}
|
|
365
|
-
return { deltaX: 0, deltaY };
|
|
366
|
-
};
|
|
367
|
-
exports.applySelectedOutlineDragAxisLock = applySelectedOutlineDragAxisLock;
|
|
368
|
-
const getSelectedOutlineDragChanges = ({ dragStates, lastValues, }) => {
|
|
369
|
-
const changes = [];
|
|
370
|
-
for (const dragState of dragStates) {
|
|
371
|
-
const value = lastValues.get(dragState.key);
|
|
372
|
-
if (value === undefined) {
|
|
373
|
-
continue;
|
|
374
|
-
}
|
|
375
|
-
if (dragState.target.propStatus.status === 'keyframed') {
|
|
376
|
-
const startValue = (0, timeline_translate_utils_1.serializeTranslate)(dragState.startX, dragState.startY);
|
|
377
|
-
if (value === startValue) {
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
changes.push({
|
|
381
|
-
type: 'keyframed',
|
|
382
|
-
fileName: dragState.target.nodePath.absolutePath,
|
|
383
|
-
nodePath: dragState.target.nodePath,
|
|
384
|
-
fieldKey: translateFieldKey,
|
|
385
|
-
sourceFrame: dragState.sourceFrame,
|
|
386
|
-
value,
|
|
387
|
-
schema: dragState.target.schema,
|
|
388
|
-
clientId: dragState.target.clientId,
|
|
389
|
-
});
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
const stringifiedValue = JSON.stringify(value);
|
|
393
|
-
const shouldSave = value !== dragState.target.propStatus.codeValue &&
|
|
394
|
-
!(dragState.defaultValue === stringifiedValue &&
|
|
395
|
-
dragState.target.propStatus.codeValue === undefined);
|
|
396
|
-
if (!shouldSave) {
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
changes.push({
|
|
400
|
-
type: 'static',
|
|
401
|
-
fileName: dragState.target.nodePath.absolutePath,
|
|
402
|
-
nodePath: dragState.target.nodePath,
|
|
403
|
-
fieldKey: translateFieldKey,
|
|
404
|
-
value,
|
|
405
|
-
defaultValue: dragState.defaultValue,
|
|
406
|
-
schema: dragState.target.schema,
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
return changes;
|
|
410
|
-
};
|
|
411
|
-
exports.getSelectedOutlineDragChanges = getSelectedOutlineDragChanges;
|
|
412
|
-
const getSelectedOutlineScaleEdgeInfo = (points, edge) => {
|
|
413
|
-
const [tl, tr, br, bl] = points;
|
|
414
|
-
const edgePoints = {
|
|
415
|
-
top: { start: tl, end: tr, oppositeStart: bl, oppositeEnd: br },
|
|
416
|
-
right: { start: tr, end: br, oppositeStart: tl, oppositeEnd: bl },
|
|
417
|
-
bottom: { start: bl, end: br, oppositeStart: tl, oppositeEnd: tr },
|
|
418
|
-
left: { start: tl, end: bl, oppositeStart: tr, oppositeEnd: br },
|
|
419
|
-
}[edge];
|
|
420
|
-
const edgeMidpoint = midpoint(edgePoints.start, edgePoints.end);
|
|
421
|
-
const oppositeMidpoint = midpoint(edgePoints.oppositeStart, edgePoints.oppositeEnd);
|
|
422
|
-
const outward = vectorBetween(oppositeMidpoint, edgeMidpoint);
|
|
423
|
-
const length = vectorLength(outward);
|
|
424
|
-
if (length < 0.001) {
|
|
425
|
-
return null;
|
|
426
|
-
}
|
|
427
|
-
return {
|
|
428
|
-
axis: edge === 'left' || edge === 'right' ? 'x' : 'y',
|
|
429
|
-
cursor: edge === 'left' || edge === 'right' ? 'ew-resize' : 'ns-resize',
|
|
430
|
-
end: edgePoints.end,
|
|
431
|
-
extent: length,
|
|
432
|
-
normal: { x: outward.x / length, y: outward.y / length },
|
|
433
|
-
start: edgePoints.start,
|
|
434
|
-
};
|
|
435
|
-
};
|
|
436
|
-
exports.getSelectedOutlineScaleEdgeInfo = getSelectedOutlineScaleEdgeInfo;
|
|
437
|
-
const getSelectedOutlineScaleDragStates = ({ dragTargets, getDragOverrides, }) => {
|
|
438
|
-
return dragTargets.map((target) => {
|
|
439
|
-
var _a;
|
|
440
|
-
const dragOverrideValue = ((_a = getDragOverrides(target.nodePath)) !== null && _a !== void 0 ? _a : {})[scaleFieldKey];
|
|
441
|
-
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
442
|
-
propStatus: target.propStatus,
|
|
443
|
-
dragOverrideValue,
|
|
444
|
-
defaultValue: target.fieldDefault,
|
|
445
|
-
shouldResortToDefaultValueIfUndefined: true,
|
|
446
|
-
});
|
|
447
|
-
const [startX, startY, startZ] = no_react_1.NoReactInternals.parseScaleValue(effectiveValue);
|
|
448
|
-
return {
|
|
449
|
-
defaultValue: target.fieldDefault !== undefined
|
|
450
|
-
? JSON.stringify(target.fieldDefault)
|
|
451
|
-
: null,
|
|
452
|
-
key: remotion_1.Internals.makeSequencePropsSubscriptionKey(target.nodePath),
|
|
453
|
-
startX,
|
|
454
|
-
startY,
|
|
455
|
-
startZ,
|
|
456
|
-
target,
|
|
457
|
-
};
|
|
458
|
-
});
|
|
459
|
-
};
|
|
460
|
-
exports.getSelectedOutlineScaleDragStates = getSelectedOutlineScaleDragStates;
|
|
461
|
-
const getSelectedOutlineScaleDragValues = ({ axis, dragStates, scaleFactor, }) => {
|
|
462
|
-
return new Map(dragStates.map((dragState) => {
|
|
463
|
-
var _a, _b;
|
|
464
|
-
const min = (_a = dragState.target.fieldSchema.min) !== null && _a !== void 0 ? _a : -Infinity;
|
|
465
|
-
const max = (_b = dragState.target.fieldSchema.max) !== null && _b !== void 0 ? _b : Infinity;
|
|
466
|
-
const baseX = dragState.startX;
|
|
467
|
-
const baseY = dragState.startY;
|
|
468
|
-
const newValue = (axis === 'x' ? baseX : baseY) * scaleFactor;
|
|
469
|
-
const [x, y] = dragState.target.linked
|
|
470
|
-
? (0, TimelineScaleField_1.getLinkedScale)({
|
|
471
|
-
axis,
|
|
472
|
-
newValue,
|
|
473
|
-
baseX,
|
|
474
|
-
baseY,
|
|
475
|
-
min,
|
|
476
|
-
max,
|
|
477
|
-
})
|
|
478
|
-
: axis === 'x'
|
|
479
|
-
? [(0, selected_outline_geometry_1.clamp)(newValue, min, max), baseY]
|
|
480
|
-
: [baseX, (0, selected_outline_geometry_1.clamp)(newValue, min, max)];
|
|
481
|
-
return [
|
|
482
|
-
dragState.key,
|
|
483
|
-
no_react_1.NoReactInternals.serializeScaleValue([x, y, dragState.startZ]),
|
|
484
|
-
];
|
|
485
|
-
}));
|
|
486
|
-
};
|
|
487
|
-
exports.getSelectedOutlineScaleDragValues = getSelectedOutlineScaleDragValues;
|
|
488
|
-
const getSelectedOutlineScaleDragChanges = ({ dragStates, lastValues, }) => {
|
|
489
|
-
return dragStates.flatMap((dragState) => {
|
|
490
|
-
const value = lastValues.get(dragState.key);
|
|
491
|
-
if (value === undefined) {
|
|
492
|
-
return [];
|
|
493
|
-
}
|
|
494
|
-
const stringifiedValue = JSON.stringify(value);
|
|
495
|
-
const shouldSave = stringifiedValue !==
|
|
496
|
-
JSON.stringify(dragState.target.propStatus.codeValue) &&
|
|
497
|
-
!(dragState.defaultValue === stringifiedValue &&
|
|
498
|
-
dragState.target.propStatus.codeValue === undefined);
|
|
499
|
-
if (!shouldSave) {
|
|
500
|
-
return [];
|
|
501
|
-
}
|
|
502
|
-
return [
|
|
503
|
-
{
|
|
504
|
-
fileName: dragState.target.nodePath.absolutePath,
|
|
505
|
-
nodePath: dragState.target.nodePath,
|
|
506
|
-
fieldKey: scaleFieldKey,
|
|
507
|
-
value,
|
|
508
|
-
defaultValue: dragState.defaultValue,
|
|
509
|
-
schema: dragState.target.schema,
|
|
510
|
-
},
|
|
511
|
-
];
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
exports.getSelectedOutlineScaleDragChanges = getSelectedOutlineScaleDragChanges;
|
|
515
|
-
const getSelectedOutlineRotationDragStates = ({ dragTargets, getDragOverrides, timelinePosition, }) => {
|
|
516
|
-
return dragTargets.map((target) => {
|
|
517
|
-
var _a;
|
|
518
|
-
const dragOverrideValue = ((_a = getDragOverrides(target.nodePath)) !== null && _a !== void 0 ? _a : {})[rotateFieldKey];
|
|
519
|
-
const sourceFrame = timelinePosition - target.keyframeDisplayOffset;
|
|
520
|
-
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
521
|
-
propStatus: target.propStatus,
|
|
522
|
-
dragOverrideValue,
|
|
523
|
-
defaultValue: target.fieldDefault,
|
|
524
|
-
frame: sourceFrame,
|
|
525
|
-
shouldResortToDefaultValueIfUndefined: true,
|
|
526
|
-
});
|
|
527
|
-
return {
|
|
528
|
-
defaultValue: target.fieldDefault !== undefined
|
|
529
|
-
? JSON.stringify(target.fieldDefault)
|
|
530
|
-
: null,
|
|
531
|
-
key: remotion_1.Internals.makeSequencePropsSubscriptionKey(target.nodePath),
|
|
532
|
-
sourceFrame,
|
|
533
|
-
startDegrees: (0, timeline_rotation_utils_1.parseCssRotationToDegrees)(String(effectiveValue !== null && effectiveValue !== void 0 ? effectiveValue : '0deg')),
|
|
534
|
-
target,
|
|
535
|
-
};
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
exports.getSelectedOutlineRotationDragStates = getSelectedOutlineRotationDragStates;
|
|
539
|
-
const getSelectedOutlineRotationDragValues = ({ dragStates, rotationDeltaDegrees, }) => {
|
|
540
|
-
return new Map(dragStates.map((dragState) => [
|
|
541
|
-
dragState.key,
|
|
542
|
-
(0, timeline_rotation_utils_1.serializeCssRotation)(dragState.startDegrees + rotationDeltaDegrees),
|
|
543
|
-
]));
|
|
544
|
-
};
|
|
545
|
-
exports.getSelectedOutlineRotationDragValues = getSelectedOutlineRotationDragValues;
|
|
546
|
-
const getSelectedOutlineRotationDragChanges = ({ dragStates, lastValues, }) => {
|
|
547
|
-
const changes = [];
|
|
548
|
-
for (const dragState of dragStates) {
|
|
549
|
-
const value = lastValues.get(dragState.key);
|
|
550
|
-
if (value === undefined) {
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
if (dragState.target.propStatus.status === 'keyframed') {
|
|
554
|
-
const startValue = (0, timeline_rotation_utils_1.serializeCssRotation)(dragState.startDegrees);
|
|
555
|
-
if (value === startValue) {
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
changes.push({
|
|
559
|
-
type: 'keyframed',
|
|
560
|
-
fileName: dragState.target.nodePath.absolutePath,
|
|
561
|
-
nodePath: dragState.target.nodePath,
|
|
562
|
-
fieldKey: rotateFieldKey,
|
|
563
|
-
sourceFrame: dragState.sourceFrame,
|
|
564
|
-
value,
|
|
565
|
-
schema: dragState.target.schema,
|
|
566
|
-
clientId: dragState.target.clientId,
|
|
567
|
-
});
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
const stringifiedValue = JSON.stringify(value);
|
|
571
|
-
const shouldSave = value !== dragState.target.propStatus.codeValue &&
|
|
572
|
-
!(dragState.defaultValue === stringifiedValue &&
|
|
573
|
-
dragState.target.propStatus.codeValue === undefined);
|
|
574
|
-
if (!shouldSave) {
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
changes.push({
|
|
578
|
-
type: 'static',
|
|
579
|
-
fileName: dragState.target.nodePath.absolutePath,
|
|
580
|
-
nodePath: dragState.target.nodePath,
|
|
581
|
-
fieldKey: rotateFieldKey,
|
|
582
|
-
value,
|
|
583
|
-
defaultValue: dragState.defaultValue,
|
|
584
|
-
schema: dragState.target.schema,
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
return changes;
|
|
588
|
-
};
|
|
589
|
-
exports.getSelectedOutlineRotationDragChanges = getSelectedOutlineRotationDragChanges;
|
|
590
|
-
const clearSelectedOutlineDragOverrides = ({ clearDragOverrides, dragStates, }) => {
|
|
591
|
-
for (const dragState of dragStates) {
|
|
592
|
-
clearDragOverrides(dragState.target.nodePath);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
const clearSelectedOutlineScaleDragOverrides = ({ clearDragOverrides, dragStates, }) => {
|
|
596
|
-
for (const dragState of dragStates) {
|
|
597
|
-
clearDragOverrides(dragState.target.nodePath);
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
const clearSelectedOutlineRotationDragOverrides = ({ clearDragOverrides, dragStates, }) => {
|
|
601
|
-
for (const dragState of dragStates) {
|
|
602
|
-
clearDragOverrides(dragState.target.nodePath);
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
const parseCssRotationToRadians = (value) => {
|
|
606
|
-
const match = value
|
|
607
|
-
.trim()
|
|
608
|
-
.match(/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);
|
|
609
|
-
if (!match) {
|
|
610
|
-
return null;
|
|
611
|
-
}
|
|
612
|
-
const number = Number(match[1]);
|
|
613
|
-
if (!Number.isFinite(number)) {
|
|
614
|
-
return null;
|
|
615
|
-
}
|
|
616
|
-
if (match[2] === 'rad') {
|
|
617
|
-
return number;
|
|
618
|
-
}
|
|
619
|
-
if (match[2] === 'turn') {
|
|
620
|
-
return number * Math.PI * 2;
|
|
621
|
-
}
|
|
622
|
-
if (match[2] === 'grad') {
|
|
623
|
-
return (number / 400) * Math.PI * 2;
|
|
624
|
-
}
|
|
625
|
-
return (number / 180) * Math.PI;
|
|
626
|
-
};
|
|
627
|
-
const compensateTranslateForTransformOrigin = ({ startTranslate, deltaOrigin, rotate, scale, }) => {
|
|
628
|
-
const cos = Math.cos(rotate);
|
|
629
|
-
const sin = Math.sin(rotate);
|
|
630
|
-
const matrixA = cos * scale[0];
|
|
631
|
-
const matrixB = sin * scale[0];
|
|
632
|
-
const matrixC = -sin * scale[1];
|
|
633
|
-
const matrixD = cos * scale[1];
|
|
634
|
-
const transformedDeltaX = matrixA * deltaOrigin[0] + matrixC * deltaOrigin[1];
|
|
635
|
-
const transformedDeltaY = matrixB * deltaOrigin[0] + matrixD * deltaOrigin[1];
|
|
636
|
-
const compensationX = deltaOrigin[0] - transformedDeltaX;
|
|
637
|
-
const compensationY = deltaOrigin[1] - transformedDeltaY;
|
|
638
|
-
return [startTranslate[0] - compensationX, startTranslate[1] - compensationY];
|
|
639
|
-
};
|
|
640
|
-
exports.compensateTranslateForTransformOrigin = compensateTranslateForTransformOrigin;
|
|
641
|
-
const uvsEqual = (left, right) => Math.abs(left[0] - right[0]) < 0.000001 &&
|
|
642
|
-
Math.abs(left[1] - right[1]) < 0.000001;
|
|
643
|
-
const SelectedOutlineTransformOriginHandle = ({ outline, onDraggingChange, target }) => {
|
|
644
|
-
var _a;
|
|
645
|
-
const { setDragOverrides, clearDragOverrides, setPropStatuses } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
646
|
-
const transformOriginDrag = (_a = target === null || target === void 0 ? void 0 : target.transformOriginDrag) !== null && _a !== void 0 ? _a : null;
|
|
647
|
-
const parsed = (0, react_1.useMemo)(() => transformOriginDrag === null
|
|
648
|
-
? null
|
|
649
|
-
: (0, transform_origin_utils_1.parseTransformOrigin)(transformOriginDrag.originValue), [transformOriginDrag]);
|
|
650
|
-
const uv = (0, react_1.useMemo)(() => {
|
|
651
|
-
if (parsed === null || outline.dimensions === null) {
|
|
652
|
-
return null;
|
|
653
|
-
}
|
|
654
|
-
return (0, transform_origin_utils_1.parsedTransformOriginToUv)({
|
|
655
|
-
parsed,
|
|
656
|
-
width: outline.dimensions.width,
|
|
657
|
-
height: outline.dimensions.height,
|
|
658
|
-
});
|
|
659
|
-
}, [outline.dimensions, parsed]);
|
|
660
|
-
const position = (0, react_1.useMemo)(() => (uv === null ? null : (0, selected_outline_uv_1.getUvHandlePosition)(outline.points, uv)), [outline.points, uv]);
|
|
661
|
-
const onPointerDown = react_1.default.useCallback((event) => {
|
|
662
|
-
if (event.button !== 0 ||
|
|
663
|
-
transformOriginDrag === null ||
|
|
664
|
-
parsed === null ||
|
|
665
|
-
uv === null ||
|
|
666
|
-
outline.dimensions === null) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
event.preventDefault();
|
|
670
|
-
event.stopPropagation();
|
|
671
|
-
const svg = event.currentTarget.ownerSVGElement;
|
|
672
|
-
if (svg === null) {
|
|
673
|
-
return;
|
|
674
|
-
}
|
|
675
|
-
const rotation = parseCssRotationToRadians(transformOriginDrag.rotateValue);
|
|
676
|
-
if (rotation === null) {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
const { dimensions } = outline;
|
|
680
|
-
if (dimensions === null) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
const [scaleX, scaleY] = no_react_1.NoReactInternals.parseScaleValue(transformOriginDrag.scaleValue);
|
|
684
|
-
const startTranslate = (0, timeline_translate_utils_1.parseTranslate)(transformOriginDrag.translateValue);
|
|
685
|
-
const svgRect = svg.getBoundingClientRect();
|
|
686
|
-
const defaultOrigin = transformOriginDrag.originDefault !== undefined
|
|
687
|
-
? JSON.stringify(transformOriginDrag.originDefault)
|
|
688
|
-
: null;
|
|
689
|
-
const defaultTranslate = transformOriginDrag.translateDefault !== undefined
|
|
690
|
-
? JSON.stringify(transformOriginDrag.translateDefault)
|
|
691
|
-
: null;
|
|
692
|
-
let last = null;
|
|
693
|
-
onDraggingChange(true);
|
|
694
|
-
(0, ForceSpecificCursor_1.forceSpecificCursor)('crosshair');
|
|
695
|
-
const updateFromPointerEvent = (pointerEvent) => {
|
|
696
|
-
const point = {
|
|
697
|
-
x: pointerEvent.clientX - svgRect.left,
|
|
698
|
-
y: pointerEvent.clientY - svgRect.top,
|
|
699
|
-
};
|
|
700
|
-
const nextUv = (0, selected_outline_uv_1.getUvCoordinateForPoint)(outline.points, point);
|
|
701
|
-
const deltaOrigin = [
|
|
702
|
-
(nextUv[0] - uv[0]) * dimensions.width,
|
|
703
|
-
(nextUv[1] - uv[1]) * dimensions.height,
|
|
704
|
-
];
|
|
705
|
-
const [nextTranslateX, nextTranslateY] = (0, exports.compensateTranslateForTransformOrigin)({
|
|
706
|
-
startTranslate,
|
|
707
|
-
deltaOrigin,
|
|
708
|
-
rotate: rotation,
|
|
709
|
-
scale: [scaleX, scaleY],
|
|
710
|
-
});
|
|
711
|
-
const origin = (0, transform_origin_utils_1.serializeTransformOrigin)({
|
|
712
|
-
uv: nextUv,
|
|
713
|
-
z: parsed.z,
|
|
714
|
-
});
|
|
715
|
-
const translate = (0, timeline_translate_utils_1.serializeTranslate)(nextTranslateX, nextTranslateY);
|
|
716
|
-
last = { uv: nextUv, origin, translate };
|
|
717
|
-
setDragOverrides(transformOriginDrag.nodePath, transformOriginFieldKey, transformOriginDrag.originPropStatus.status === 'keyframed'
|
|
718
|
-
? remotion_1.Internals.makeKeyframedDragOverride({
|
|
719
|
-
status: transformOriginDrag.originPropStatus,
|
|
720
|
-
frame: transformOriginDrag.sourceFrame,
|
|
721
|
-
value: origin,
|
|
722
|
-
})
|
|
723
|
-
: remotion_1.Internals.makeStaticDragOverride(origin));
|
|
724
|
-
setDragOverrides(transformOriginDrag.nodePath, translateFieldKey, transformOriginDrag.translatePropStatus.status === 'keyframed'
|
|
725
|
-
? remotion_1.Internals.makeKeyframedDragOverride({
|
|
726
|
-
status: transformOriginDrag.translatePropStatus,
|
|
727
|
-
frame: transformOriginDrag.sourceFrame,
|
|
728
|
-
value: translate,
|
|
729
|
-
})
|
|
730
|
-
: remotion_1.Internals.makeStaticDragOverride(translate));
|
|
731
|
-
};
|
|
732
|
-
updateFromPointerEvent(event);
|
|
733
|
-
const onPointerMove = (moveEvent) => {
|
|
734
|
-
moveEvent.preventDefault();
|
|
735
|
-
updateFromPointerEvent(moveEvent);
|
|
736
|
-
};
|
|
737
|
-
const onPointerUp = () => {
|
|
738
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
739
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
740
|
-
window.removeEventListener('pointercancel', onPointerUp);
|
|
741
|
-
(0, ForceSpecificCursor_1.stopForcingSpecificCursor)();
|
|
742
|
-
onDraggingChange(false);
|
|
743
|
-
if (last === null || uvsEqual(last.uv, uv)) {
|
|
744
|
-
clearDragOverrides(transformOriginDrag.nodePath);
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
const originChanged = last.origin !== transformOriginDrag.originValue;
|
|
748
|
-
const translateChanged = last.translate !== transformOriginDrag.translateValue;
|
|
749
|
-
if (!originChanged && !translateChanged) {
|
|
750
|
-
clearDragOverrides(transformOriginDrag.nodePath);
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
|
-
const shouldSaveAsKeyframes = transformOriginDrag.originPropStatus.status === 'keyframed' ||
|
|
754
|
-
transformOriginDrag.translatePropStatus.status === 'keyframed';
|
|
755
|
-
const promise = shouldSaveAsKeyframes
|
|
756
|
-
? (0, call_add_keyframe_1.callAddKeyframes)({
|
|
757
|
-
sequenceKeyframes: [
|
|
758
|
-
originChanged
|
|
759
|
-
? {
|
|
760
|
-
fileName: transformOriginDrag.nodePath.absolutePath,
|
|
761
|
-
nodePath: transformOriginDrag.nodePath,
|
|
762
|
-
fieldKey: transformOriginFieldKey,
|
|
763
|
-
sourceFrame: transformOriginDrag.sourceFrame,
|
|
764
|
-
value: last.origin,
|
|
765
|
-
schema: transformOriginDrag.schema,
|
|
766
|
-
}
|
|
767
|
-
: null,
|
|
768
|
-
translateChanged
|
|
769
|
-
? {
|
|
770
|
-
fileName: transformOriginDrag.nodePath.absolutePath,
|
|
771
|
-
nodePath: transformOriginDrag.nodePath,
|
|
772
|
-
fieldKey: translateFieldKey,
|
|
773
|
-
sourceFrame: transformOriginDrag.sourceFrame,
|
|
774
|
-
value: last.translate,
|
|
775
|
-
schema: transformOriginDrag.schema,
|
|
776
|
-
}
|
|
777
|
-
: null,
|
|
778
|
-
].filter(no_react_1.NoReactInternals.truthy),
|
|
779
|
-
effectKeyframes: [],
|
|
780
|
-
setPropStatuses,
|
|
781
|
-
clientId: transformOriginDrag.clientId,
|
|
782
|
-
})
|
|
783
|
-
: (0, save_sequence_prop_1.saveSequenceProps)({
|
|
784
|
-
changes: [
|
|
785
|
-
originChanged
|
|
786
|
-
? {
|
|
787
|
-
fileName: transformOriginDrag.nodePath.absolutePath,
|
|
788
|
-
nodePath: transformOriginDrag.nodePath,
|
|
789
|
-
fieldKey: transformOriginFieldKey,
|
|
790
|
-
value: last.origin,
|
|
791
|
-
defaultValue: defaultOrigin,
|
|
792
|
-
schema: transformOriginDrag.schema,
|
|
793
|
-
}
|
|
794
|
-
: null,
|
|
795
|
-
translateChanged
|
|
796
|
-
? {
|
|
797
|
-
fileName: transformOriginDrag.nodePath.absolutePath,
|
|
798
|
-
nodePath: transformOriginDrag.nodePath,
|
|
799
|
-
fieldKey: translateFieldKey,
|
|
800
|
-
value: last.translate,
|
|
801
|
-
defaultValue: defaultTranslate,
|
|
802
|
-
schema: transformOriginDrag.schema,
|
|
803
|
-
}
|
|
804
|
-
: null,
|
|
805
|
-
].filter(no_react_1.NoReactInternals.truthy),
|
|
806
|
-
setPropStatuses,
|
|
807
|
-
clientId: transformOriginDrag.clientId,
|
|
808
|
-
undoLabel: 'Move transform origin',
|
|
809
|
-
redoLabel: 'Move transform origin back',
|
|
810
|
-
});
|
|
811
|
-
promise
|
|
812
|
-
.catch((err) => {
|
|
813
|
-
(0, NotificationCenter_1.showNotification)(`Could not save transform origin: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
814
|
-
})
|
|
815
|
-
.finally(() => {
|
|
816
|
-
clearDragOverrides(transformOriginDrag.nodePath);
|
|
817
|
-
});
|
|
818
|
-
};
|
|
819
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
820
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
821
|
-
window.addEventListener('pointercancel', onPointerUp);
|
|
822
|
-
}, [
|
|
823
|
-
clearDragOverrides,
|
|
824
|
-
onDraggingChange,
|
|
825
|
-
outline,
|
|
826
|
-
parsed,
|
|
827
|
-
setDragOverrides,
|
|
828
|
-
setPropStatuses,
|
|
829
|
-
transformOriginDrag,
|
|
830
|
-
uv,
|
|
831
|
-
]);
|
|
832
|
-
if (transformOriginDrag === null ||
|
|
833
|
-
parsed === null ||
|
|
834
|
-
uv === null ||
|
|
835
|
-
position === null) {
|
|
836
|
-
return null;
|
|
837
|
-
}
|
|
838
|
-
return (jsx_runtime_1.jsxs("g", { pointerEvents: "all", cursor: "crosshair", onPointerDown: onPointerDown, "aria-hidden": "true", children: [
|
|
839
|
-
jsx_runtime_1.jsx("line", { x1: position.x - 8, y1: position.y, x2: position.x + 8, y2: position.y, stroke: "white", strokeWidth: 4, vectorEffect: "non-scaling-stroke" }), jsx_runtime_1.jsx("line", { x1: position.x, y1: position.y - 8, x2: position.x, y2: position.y + 8, stroke: "white", strokeWidth: 4, vectorEffect: "non-scaling-stroke" }), jsx_runtime_1.jsx("circle", { cx: position.x, cy: position.y, r: 4, fill: "white", stroke: colors_1.BLUE, strokeWidth: 2, vectorEffect: "non-scaling-stroke" }), jsx_runtime_1.jsx("line", { x1: position.x - 8, y1: position.y, x2: position.x + 8, y2: position.y, stroke: colors_1.BLUE, strokeWidth: 2, vectorEffect: "non-scaling-stroke" }), jsx_runtime_1.jsx("line", { x1: position.x, y1: position.y - 8, x2: position.x, y2: position.y + 8, stroke: colors_1.BLUE, strokeWidth: 2, vectorEffect: "non-scaling-stroke" })
|
|
840
|
-
] }));
|
|
841
|
-
};
|
|
842
|
-
const SelectedOutlinePolygon = ({ allDragTargets, contextMenuValues, dragging, hovered, onContextMenuOpen, outline, onDraggingChange, onHoverChange, onSelect, scale, target, }) => {
|
|
843
|
-
var _a, _b, _c, _d;
|
|
844
|
-
const { getDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
845
|
-
const { setPropStatuses, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
846
|
-
const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
847
|
-
const timelinePositionRef = (0, react_1.useRef)(timelinePosition);
|
|
848
|
-
timelinePositionRef.current = timelinePosition;
|
|
849
|
-
const polygonRef = (0, react_1.useRef)(null);
|
|
850
|
-
const points = (0, react_1.useMemo)(() => outline.points.map(pointToString).join(' '), [outline.points]);
|
|
851
|
-
const drag = (_a = target === null || target === void 0 ? void 0 : target.drag) !== null && _a !== void 0 ? _a : null;
|
|
852
|
-
const selected = (_b = target === null || target === void 0 ? void 0 : target.selected) !== null && _b !== void 0 ? _b : false;
|
|
853
|
-
const containsSelection = (_c = target === null || target === void 0 ? void 0 : target.containsSelection) !== null && _c !== void 0 ? _c : false;
|
|
854
|
-
const effectDrop = (_d = target === null || target === void 0 ? void 0 : target.effectDrop) !== null && _d !== void 0 ? _d : null;
|
|
855
|
-
const [effectDropHovered, setEffectDropHovered] = (0, react_1.useState)(false);
|
|
856
|
-
const visible = containsSelection || hovered;
|
|
857
|
-
const onPointerDown = react_1.default.useCallback((event) => {
|
|
858
|
-
if (event.button !== 0 || target === undefined) {
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
event.preventDefault();
|
|
862
|
-
event.stopPropagation();
|
|
863
|
-
const interaction = (0, exports.getOutlineSelectionInteraction)(event);
|
|
864
|
-
const shouldUpdateSelection = !selected || interaction.shiftKey || interaction.toggleKey;
|
|
865
|
-
if (shouldUpdateSelection) {
|
|
866
|
-
onSelect(target.selection, interaction);
|
|
867
|
-
}
|
|
868
|
-
if (drag === null || interaction.shiftKey || interaction.toggleKey) {
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
onDraggingChange(true);
|
|
872
|
-
const startPointerX = event.clientX;
|
|
873
|
-
const startPointerY = event.clientY;
|
|
874
|
-
const dragStates = getSelectedOutlineDragStates({
|
|
875
|
-
dragTargets: selected ? allDragTargets : [drag],
|
|
876
|
-
getDragOverrides,
|
|
877
|
-
timelinePosition: timelinePositionRef.current,
|
|
878
|
-
});
|
|
879
|
-
let lastValues = new Map();
|
|
880
|
-
let currentPointerX = startPointerX;
|
|
881
|
-
let currentPointerY = startPointerY;
|
|
882
|
-
let axisLocked = false;
|
|
883
|
-
const updateDragOverrides = () => {
|
|
884
|
-
const dragDelta = (0, exports.applySelectedOutlineDragAxisLock)({
|
|
885
|
-
deltaX: (currentPointerX - startPointerX) / scale,
|
|
886
|
-
deltaY: (currentPointerY - startPointerY) / scale,
|
|
887
|
-
axisLocked,
|
|
888
|
-
});
|
|
889
|
-
lastValues = (0, exports.getSelectedOutlineDragValues)({
|
|
890
|
-
dragStates,
|
|
891
|
-
deltaX: dragDelta.deltaX,
|
|
892
|
-
deltaY: dragDelta.deltaY,
|
|
893
|
-
});
|
|
894
|
-
for (const dragState of dragStates) {
|
|
895
|
-
const value = lastValues.get(dragState.key);
|
|
896
|
-
if (value === undefined) {
|
|
897
|
-
throw new Error('Expected drag value to be available');
|
|
898
|
-
}
|
|
899
|
-
if (dragState.target.propStatus.status === 'keyframed') {
|
|
900
|
-
setDragOverrides(dragState.target.nodePath, translateFieldKey, remotion_1.Internals.makeKeyframedDragOverride({
|
|
901
|
-
status: dragState.target.propStatus,
|
|
902
|
-
frame: dragState.sourceFrame,
|
|
903
|
-
value,
|
|
904
|
-
}));
|
|
905
|
-
}
|
|
906
|
-
else {
|
|
907
|
-
setDragOverrides(dragState.target.nodePath, translateFieldKey, remotion_1.Internals.makeStaticDragOverride(value));
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
};
|
|
911
|
-
const onPointerMove = (moveEvent) => {
|
|
912
|
-
moveEvent.preventDefault();
|
|
913
|
-
currentPointerX = moveEvent.clientX;
|
|
914
|
-
currentPointerY = moveEvent.clientY;
|
|
915
|
-
axisLocked = moveEvent.shiftKey;
|
|
916
|
-
updateDragOverrides();
|
|
917
|
-
};
|
|
918
|
-
const onKeyChange = (keyEvent) => {
|
|
919
|
-
if (keyEvent.key !== 'Shift') {
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
const nextAxisLocked = keyEvent.type === 'keydown';
|
|
923
|
-
if (nextAxisLocked === axisLocked) {
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
axisLocked = nextAxisLocked;
|
|
927
|
-
updateDragOverrides();
|
|
928
|
-
};
|
|
929
|
-
const onPointerUp = () => {
|
|
930
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
931
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
932
|
-
window.removeEventListener('pointercancel', onPointerUp);
|
|
933
|
-
window.removeEventListener('keydown', onKeyChange);
|
|
934
|
-
window.removeEventListener('keyup', onKeyChange);
|
|
935
|
-
onDraggingChange(false);
|
|
936
|
-
const changes = (0, exports.getSelectedOutlineDragChanges)({
|
|
937
|
-
dragStates,
|
|
938
|
-
lastValues,
|
|
939
|
-
});
|
|
940
|
-
if (changes.length === 0) {
|
|
941
|
-
clearSelectedOutlineDragOverrides({ clearDragOverrides, dragStates });
|
|
942
|
-
return;
|
|
943
|
-
}
|
|
944
|
-
const staticChanges = changes.filter((change) => change.type === 'static');
|
|
945
|
-
const keyframedChanges = changes.filter((change) => change.type === 'keyframed');
|
|
946
|
-
Promise.all([
|
|
947
|
-
staticChanges.length > 0
|
|
948
|
-
? (0, save_sequence_prop_1.saveSequenceProps)({
|
|
949
|
-
changes: staticChanges,
|
|
950
|
-
setPropStatuses,
|
|
951
|
-
clientId: drag.clientId,
|
|
952
|
-
undoLabel: changes.length > 1
|
|
953
|
-
? 'Move selected sequences'
|
|
954
|
-
: 'Move sequence',
|
|
955
|
-
redoLabel: changes.length > 1
|
|
956
|
-
? 'Move selected sequences back'
|
|
957
|
-
: 'Move sequence back',
|
|
958
|
-
})
|
|
959
|
-
: Promise.resolve(),
|
|
960
|
-
...keyframedChanges.map((change) => (0, call_add_keyframe_1.callAddSequenceKeyframe)({
|
|
961
|
-
fileName: change.fileName,
|
|
962
|
-
nodePath: change.nodePath,
|
|
963
|
-
fieldKey: change.fieldKey,
|
|
964
|
-
sourceFrame: change.sourceFrame,
|
|
965
|
-
value: change.value,
|
|
966
|
-
schema: change.schema,
|
|
967
|
-
setPropStatuses,
|
|
968
|
-
clientId: change.clientId,
|
|
969
|
-
})),
|
|
970
|
-
])
|
|
971
|
-
.catch((err) => {
|
|
972
|
-
(0, NotificationCenter_1.showNotification)(`Could not save sequence props: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
973
|
-
})
|
|
974
|
-
.finally(() => {
|
|
975
|
-
clearSelectedOutlineDragOverrides({ clearDragOverrides, dragStates });
|
|
976
|
-
});
|
|
977
|
-
};
|
|
978
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
979
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
980
|
-
window.addEventListener('pointercancel', onPointerUp);
|
|
981
|
-
window.addEventListener('keydown', onKeyChange);
|
|
982
|
-
window.addEventListener('keyup', onKeyChange);
|
|
983
|
-
}, [
|
|
984
|
-
allDragTargets,
|
|
985
|
-
clearDragOverrides,
|
|
986
|
-
drag,
|
|
987
|
-
getDragOverrides,
|
|
988
|
-
onDraggingChange,
|
|
989
|
-
onSelect,
|
|
990
|
-
scale,
|
|
991
|
-
selected,
|
|
992
|
-
setPropStatuses,
|
|
993
|
-
setDragOverrides,
|
|
994
|
-
target,
|
|
995
|
-
]);
|
|
996
|
-
const onEffectDragOver = react_1.default.useCallback((event) => {
|
|
997
|
-
if (effectDrop === null || !(0, effect_drag_and_drop_1.hasEffectDragType)(event.dataTransfer)) {
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
event.preventDefault();
|
|
1001
|
-
event.stopPropagation();
|
|
1002
|
-
event.dataTransfer.dropEffect = 'copy';
|
|
1003
|
-
setEffectDropHovered(true);
|
|
1004
|
-
}, [effectDrop]);
|
|
1005
|
-
const onEffectDragLeave = react_1.default.useCallback((event) => {
|
|
1006
|
-
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
setEffectDropHovered(false);
|
|
1010
|
-
}, []);
|
|
1011
|
-
const onEffectDrop = react_1.default.useCallback(async (event) => {
|
|
1012
|
-
if (effectDrop === null || !(0, effect_drag_and_drop_1.hasEffectDragType)(event.dataTransfer)) {
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
const dragData = (0, effect_drag_and_drop_1.getEffectDragData)(event.dataTransfer);
|
|
1016
|
-
if (!dragData) {
|
|
1017
|
-
if ((0, effect_drag_and_drop_1.hasExplicitEffectDragType)(event.dataTransfer)) {
|
|
1018
|
-
event.preventDefault();
|
|
1019
|
-
event.stopPropagation();
|
|
1020
|
-
setEffectDropHovered(false);
|
|
1021
|
-
(0, NotificationCenter_1.showNotification)('Could not read effect drag data', 3000);
|
|
1022
|
-
}
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
|
-
event.preventDefault();
|
|
1026
|
-
event.stopPropagation();
|
|
1027
|
-
setEffectDropHovered(false);
|
|
1028
|
-
await (0, effect_drag_and_drop_1.addEffectFromDragData)({
|
|
1029
|
-
dragData,
|
|
1030
|
-
fileName: effectDrop.fileName,
|
|
1031
|
-
nodePath: effectDrop.nodePath,
|
|
1032
|
-
clientId: effectDrop.clientId,
|
|
1033
|
-
});
|
|
1034
|
-
}, [effectDrop]);
|
|
1035
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
1036
|
-
jsx_runtime_1.jsx("polygon", { ref: polygonRef, points: points, fill: effectDropHovered ? 'rgba(0, 155, 255, 0.12)' : 'transparent', stroke: colors_1.BLUE, strokeOpacity: visible || effectDropHovered ? 1 : 0, strokeWidth: 2, vectorEffect: "non-scaling-stroke", pointerEvents: target === undefined ? undefined : 'all', onPointerEnter: () => {
|
|
1037
|
-
if (!dragging) {
|
|
1038
|
-
onHoverChange(outline.key);
|
|
1039
|
-
}
|
|
1040
|
-
}, onPointerLeave: () => {
|
|
1041
|
-
if (!dragging) {
|
|
1042
|
-
onHoverChange(null);
|
|
1043
|
-
}
|
|
1044
|
-
}, onPointerDown: onPointerDown, onDragOver: effectDrop === null ? undefined : onEffectDragOver, onDragLeave: effectDrop === null ? undefined : onEffectDragLeave, onDrop: effectDrop === null ? undefined : onEffectDrop }), jsx_runtime_1.jsx(ContextMenu_1.ContextMenuForTarget, { triggerRef: polygonRef, values: [...contextMenuValues], onOpen: onContextMenuOpen })
|
|
1045
|
-
] }));
|
|
1046
|
-
};
|
|
1047
|
-
const SelectedOutlineScaleEdgeLine = ({ allScaleDragTargets, contextMenuValues, dragging, edge, outline, onDraggingChange, onContextMenuOpen, onHoverChange, onSelect, target, }) => {
|
|
1048
|
-
var _a, _b;
|
|
1049
|
-
const { getDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
1050
|
-
const { setPropStatuses, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
1051
|
-
const scaleDrag = (_a = target === null || target === void 0 ? void 0 : target.scaleDrag) !== null && _a !== void 0 ? _a : null;
|
|
1052
|
-
const selected = (_b = target === null || target === void 0 ? void 0 : target.selected) !== null && _b !== void 0 ? _b : false;
|
|
1053
|
-
const lineRef = (0, react_1.useRef)(null);
|
|
1054
|
-
const edgeInfo = (0, react_1.useMemo)(() => (0, exports.getSelectedOutlineScaleEdgeInfo)(outline.points, edge), [edge, outline.points]);
|
|
1055
|
-
const onPointerDown = react_1.default.useCallback((event) => {
|
|
1056
|
-
if (event.button !== 0 || scaleDrag === null || edgeInfo === null) {
|
|
1057
|
-
return;
|
|
1058
|
-
}
|
|
1059
|
-
event.preventDefault();
|
|
1060
|
-
event.stopPropagation();
|
|
1061
|
-
const interaction = (0, exports.getOutlineSelectionInteraction)(event);
|
|
1062
|
-
const shouldUpdateSelection = !selected || interaction.shiftKey || interaction.toggleKey;
|
|
1063
|
-
if (shouldUpdateSelection && target !== undefined) {
|
|
1064
|
-
onSelect(target.selection, interaction);
|
|
1065
|
-
}
|
|
1066
|
-
if (interaction.shiftKey || interaction.toggleKey) {
|
|
1067
|
-
return;
|
|
1068
|
-
}
|
|
1069
|
-
onDraggingChange(true);
|
|
1070
|
-
const startPointer = { x: event.clientX, y: event.clientY };
|
|
1071
|
-
const dragStates = (0, exports.getSelectedOutlineScaleDragStates)({
|
|
1072
|
-
dragTargets: selected ? allScaleDragTargets : [scaleDrag],
|
|
1073
|
-
getDragOverrides,
|
|
1074
|
-
});
|
|
1075
|
-
let lastValues = new Map();
|
|
1076
|
-
const onPointerMove = (moveEvent) => {
|
|
1077
|
-
moveEvent.preventDefault();
|
|
1078
|
-
const delta = {
|
|
1079
|
-
x: moveEvent.clientX - startPointer.x,
|
|
1080
|
-
y: moveEvent.clientY - startPointer.y,
|
|
1081
|
-
};
|
|
1082
|
-
const projectedDelta = dot(delta, edgeInfo.normal);
|
|
1083
|
-
const scaleFactor = Math.max(0.001, 1 + projectedDelta / edgeInfo.extent);
|
|
1084
|
-
lastValues = (0, exports.getSelectedOutlineScaleDragValues)({
|
|
1085
|
-
dragStates,
|
|
1086
|
-
axis: edgeInfo.axis,
|
|
1087
|
-
scaleFactor,
|
|
1088
|
-
});
|
|
1089
|
-
for (const dragState of dragStates) {
|
|
1090
|
-
const value = lastValues.get(dragState.key);
|
|
1091
|
-
if (value === undefined) {
|
|
1092
|
-
throw new Error('Expected scale drag value to be available');
|
|
1093
|
-
}
|
|
1094
|
-
setDragOverrides(dragState.target.nodePath, scaleFieldKey, remotion_1.Internals.makeStaticDragOverride(value));
|
|
1095
|
-
}
|
|
1096
|
-
};
|
|
1097
|
-
const onPointerUp = () => {
|
|
1098
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
1099
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
1100
|
-
window.removeEventListener('pointercancel', onPointerUp);
|
|
1101
|
-
onDraggingChange(false);
|
|
1102
|
-
const changes = (0, exports.getSelectedOutlineScaleDragChanges)({
|
|
1103
|
-
dragStates,
|
|
1104
|
-
lastValues,
|
|
1105
|
-
});
|
|
1106
|
-
if (changes.length === 0) {
|
|
1107
|
-
clearSelectedOutlineScaleDragOverrides({
|
|
1108
|
-
clearDragOverrides,
|
|
1109
|
-
dragStates,
|
|
1110
|
-
});
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
(0, save_sequence_prop_1.saveSequenceProps)({
|
|
1114
|
-
changes,
|
|
1115
|
-
setPropStatuses,
|
|
1116
|
-
clientId: scaleDrag.clientId,
|
|
1117
|
-
undoLabel: changes.length > 1 ? 'Scale selected sequences' : 'Scale sequence',
|
|
1118
|
-
redoLabel: changes.length > 1
|
|
1119
|
-
? 'Scale selected sequences back'
|
|
1120
|
-
: 'Scale sequence back',
|
|
1121
|
-
})
|
|
1122
|
-
.catch((err) => {
|
|
1123
|
-
(0, NotificationCenter_1.showNotification)(`Could not save sequence props: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
1124
|
-
})
|
|
1125
|
-
.finally(() => {
|
|
1126
|
-
clearSelectedOutlineScaleDragOverrides({
|
|
1127
|
-
clearDragOverrides,
|
|
1128
|
-
dragStates,
|
|
1129
|
-
});
|
|
1130
|
-
});
|
|
1131
|
-
};
|
|
1132
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
1133
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
1134
|
-
window.addEventListener('pointercancel', onPointerUp);
|
|
1135
|
-
}, [
|
|
1136
|
-
allScaleDragTargets,
|
|
1137
|
-
clearDragOverrides,
|
|
1138
|
-
edgeInfo,
|
|
1139
|
-
getDragOverrides,
|
|
1140
|
-
onDraggingChange,
|
|
1141
|
-
onSelect,
|
|
1142
|
-
scaleDrag,
|
|
1143
|
-
selected,
|
|
1144
|
-
setPropStatuses,
|
|
1145
|
-
setDragOverrides,
|
|
1146
|
-
target,
|
|
1147
|
-
]);
|
|
1148
|
-
if (scaleDrag === null || edgeInfo === null) {
|
|
1149
|
-
return null;
|
|
1150
|
-
}
|
|
1151
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
1152
|
-
jsx_runtime_1.jsx("line", { ref: lineRef, x1: edgeInfo.start.x, y1: edgeInfo.start.y, x2: edgeInfo.end.x, y2: edgeInfo.end.y, stroke: "transparent", strokeWidth: 12, vectorEffect: "non-scaling-stroke", pointerEvents: "stroke", cursor: edgeInfo.cursor, onPointerEnter: () => {
|
|
1153
|
-
if (!dragging) {
|
|
1154
|
-
onHoverChange(outline.key);
|
|
1155
|
-
}
|
|
1156
|
-
}, onPointerLeave: () => {
|
|
1157
|
-
if (!dragging) {
|
|
1158
|
-
onHoverChange(null);
|
|
1159
|
-
}
|
|
1160
|
-
}, onPointerDown: onPointerDown }), jsx_runtime_1.jsx(ContextMenu_1.ContextMenuForTarget, { triggerRef: lineRef, values: [...contextMenuValues], onOpen: onContextMenuOpen })
|
|
1161
|
-
] }));
|
|
1162
|
-
};
|
|
1163
|
-
const svgPointToClientPoint = (point, rect) => {
|
|
1164
|
-
return {
|
|
1165
|
-
x: point.x + rect.left,
|
|
1166
|
-
y: point.y + rect.top,
|
|
1167
|
-
};
|
|
1168
|
-
};
|
|
1169
|
-
const SelectedOutlineRotationCornerHandle = ({ allRotationDragTargets, contextMenuValues, corner, dragging, outline, onDraggingChange, onContextMenuOpen, onHoverChange, onSelect, target, }) => {
|
|
1170
|
-
var _a, _b;
|
|
1171
|
-
const { getDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
1172
|
-
const { setPropStatuses, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
1173
|
-
const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
1174
|
-
const timelinePositionRef = (0, react_1.useRef)(timelinePosition);
|
|
1175
|
-
timelinePositionRef.current = timelinePosition;
|
|
1176
|
-
const rotationDrag = (_a = target === null || target === void 0 ? void 0 : target.rotationDrag) !== null && _a !== void 0 ? _a : null;
|
|
1177
|
-
const selected = (_b = target === null || target === void 0 ? void 0 : target.selected) !== null && _b !== void 0 ? _b : false;
|
|
1178
|
-
const circleRef = (0, react_1.useRef)(null);
|
|
1179
|
-
const cornerInfo = (0, react_1.useMemo)(() => (0, exports.getSelectedOutlineRotationCornerInfo)(outline.points, corner), [corner, outline.points]);
|
|
1180
|
-
const onPointerDown = react_1.default.useCallback((event) => {
|
|
1181
|
-
if (event.button !== 0 || rotationDrag === null) {
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
event.preventDefault();
|
|
1185
|
-
event.stopPropagation();
|
|
1186
|
-
const svg = event.currentTarget.ownerSVGElement;
|
|
1187
|
-
if (svg === null) {
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
1190
|
-
const interaction = (0, exports.getOutlineSelectionInteraction)(event);
|
|
1191
|
-
const shouldUpdateSelection = !selected || interaction.shiftKey || interaction.toggleKey;
|
|
1192
|
-
if (shouldUpdateSelection && target !== undefined) {
|
|
1193
|
-
onSelect(target.selection, interaction);
|
|
1194
|
-
}
|
|
1195
|
-
if (interaction.shiftKey || interaction.toggleKey) {
|
|
1196
|
-
return;
|
|
1197
|
-
}
|
|
1198
|
-
onDraggingChange(true);
|
|
1199
|
-
(0, ForceSpecificCursor_1.forceSpecificCursor)(cornerInfo.cursor);
|
|
1200
|
-
const svgRect = svg.getBoundingClientRect();
|
|
1201
|
-
const center = svgPointToClientPoint(cornerInfo.center, svgRect);
|
|
1202
|
-
const dragStates = (0, exports.getSelectedOutlineRotationDragStates)({
|
|
1203
|
-
dragTargets: selected ? allRotationDragTargets : [rotationDrag],
|
|
1204
|
-
getDragOverrides,
|
|
1205
|
-
timelinePosition: timelinePositionRef.current,
|
|
1206
|
-
});
|
|
1207
|
-
let previousAngle = getAngleDegrees(center, {
|
|
1208
|
-
x: event.clientX,
|
|
1209
|
-
y: event.clientY,
|
|
1210
|
-
});
|
|
1211
|
-
let accumulatedDelta = 0;
|
|
1212
|
-
let lastValues = new Map();
|
|
1213
|
-
const onPointerMove = (moveEvent) => {
|
|
1214
|
-
moveEvent.preventDefault();
|
|
1215
|
-
const nextAngle = getAngleDegrees(center, {
|
|
1216
|
-
x: moveEvent.clientX,
|
|
1217
|
-
y: moveEvent.clientY,
|
|
1218
|
-
});
|
|
1219
|
-
accumulatedDelta += (0, exports.getSelectedOutlineRotationDeltaDegrees)({
|
|
1220
|
-
from: previousAngle,
|
|
1221
|
-
to: nextAngle,
|
|
1222
|
-
});
|
|
1223
|
-
previousAngle = nextAngle;
|
|
1224
|
-
lastValues = (0, exports.getSelectedOutlineRotationDragValues)({
|
|
1225
|
-
dragStates,
|
|
1226
|
-
rotationDeltaDegrees: accumulatedDelta,
|
|
1227
|
-
});
|
|
1228
|
-
(0, ForceSpecificCursor_1.forceSpecificCursor)(getRotationCursor(cornerInfo.cursorDegrees + accumulatedDelta));
|
|
1229
|
-
for (const dragState of dragStates) {
|
|
1230
|
-
const value = lastValues.get(dragState.key);
|
|
1231
|
-
if (value === undefined) {
|
|
1232
|
-
throw new Error('Expected rotation drag value to be available');
|
|
1233
|
-
}
|
|
1234
|
-
if (dragState.target.propStatus.status === 'keyframed') {
|
|
1235
|
-
setDragOverrides(dragState.target.nodePath, rotateFieldKey, remotion_1.Internals.makeKeyframedDragOverride({
|
|
1236
|
-
status: dragState.target.propStatus,
|
|
1237
|
-
frame: dragState.sourceFrame,
|
|
1238
|
-
value,
|
|
1239
|
-
}));
|
|
1240
|
-
}
|
|
1241
|
-
else {
|
|
1242
|
-
setDragOverrides(dragState.target.nodePath, rotateFieldKey, remotion_1.Internals.makeStaticDragOverride(value));
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
const onPointerUp = () => {
|
|
1247
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
1248
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
1249
|
-
window.removeEventListener('pointercancel', onPointerUp);
|
|
1250
|
-
(0, ForceSpecificCursor_1.stopForcingSpecificCursor)();
|
|
1251
|
-
onDraggingChange(false);
|
|
1252
|
-
const changes = (0, exports.getSelectedOutlineRotationDragChanges)({
|
|
1253
|
-
dragStates,
|
|
1254
|
-
lastValues,
|
|
1255
|
-
});
|
|
1256
|
-
if (changes.length === 0) {
|
|
1257
|
-
clearSelectedOutlineRotationDragOverrides({
|
|
1258
|
-
clearDragOverrides,
|
|
1259
|
-
dragStates,
|
|
1260
|
-
});
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
const staticChanges = changes.filter((change) => change.type === 'static');
|
|
1264
|
-
const keyframedChanges = changes.filter((change) => change.type === 'keyframed');
|
|
1265
|
-
Promise.all([
|
|
1266
|
-
staticChanges.length > 0
|
|
1267
|
-
? (0, save_sequence_prop_1.saveSequenceProps)({
|
|
1268
|
-
changes: staticChanges,
|
|
1269
|
-
setPropStatuses,
|
|
1270
|
-
clientId: rotationDrag.clientId,
|
|
1271
|
-
undoLabel: changes.length > 1
|
|
1272
|
-
? 'Rotate selected sequences'
|
|
1273
|
-
: 'Rotate sequence',
|
|
1274
|
-
redoLabel: changes.length > 1
|
|
1275
|
-
? 'Rotate selected sequences back'
|
|
1276
|
-
: 'Rotate sequence back',
|
|
1277
|
-
})
|
|
1278
|
-
: Promise.resolve(),
|
|
1279
|
-
...keyframedChanges.map((change) => (0, call_add_keyframe_1.callAddSequenceKeyframe)({
|
|
1280
|
-
fileName: change.fileName,
|
|
1281
|
-
nodePath: change.nodePath,
|
|
1282
|
-
fieldKey: change.fieldKey,
|
|
1283
|
-
sourceFrame: change.sourceFrame,
|
|
1284
|
-
value: change.value,
|
|
1285
|
-
schema: change.schema,
|
|
1286
|
-
setPropStatuses,
|
|
1287
|
-
clientId: change.clientId,
|
|
1288
|
-
})),
|
|
1289
|
-
])
|
|
1290
|
-
.catch((err) => {
|
|
1291
|
-
(0, NotificationCenter_1.showNotification)(`Could not save sequence props: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
1292
|
-
})
|
|
1293
|
-
.finally(() => {
|
|
1294
|
-
clearSelectedOutlineRotationDragOverrides({
|
|
1295
|
-
clearDragOverrides,
|
|
1296
|
-
dragStates,
|
|
1297
|
-
});
|
|
1298
|
-
});
|
|
1299
|
-
};
|
|
1300
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
1301
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
1302
|
-
window.addEventListener('pointercancel', onPointerUp);
|
|
1303
|
-
}, [
|
|
1304
|
-
allRotationDragTargets,
|
|
1305
|
-
clearDragOverrides,
|
|
1306
|
-
cornerInfo,
|
|
1307
|
-
getDragOverrides,
|
|
1308
|
-
onDraggingChange,
|
|
1309
|
-
onSelect,
|
|
1310
|
-
rotationDrag,
|
|
1311
|
-
selected,
|
|
1312
|
-
setPropStatuses,
|
|
1313
|
-
setDragOverrides,
|
|
1314
|
-
target,
|
|
1315
|
-
]);
|
|
1316
|
-
if (rotationDrag === null) {
|
|
1317
|
-
return null;
|
|
1318
|
-
}
|
|
1319
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
1320
|
-
jsx_runtime_1.jsx("circle", { ref: circleRef, cx: cornerInfo.point.x, cy: cornerInfo.point.y, r: 12, fill: "transparent", stroke: "transparent", vectorEffect: "non-scaling-stroke", pointerEvents: "all", cursor: cornerInfo.cursor, onPointerEnter: () => {
|
|
1321
|
-
if (!dragging) {
|
|
1322
|
-
onHoverChange(outline.key);
|
|
1323
|
-
}
|
|
1324
|
-
}, onPointerLeave: () => {
|
|
1325
|
-
if (!dragging) {
|
|
1326
|
-
onHoverChange(null);
|
|
1327
|
-
}
|
|
1328
|
-
}, onPointerDown: onPointerDown }), jsx_runtime_1.jsx(ContextMenu_1.ContextMenuForTarget, { triggerRef: circleRef, values: [...contextMenuValues], onOpen: onContextMenuOpen })
|
|
1329
|
-
] }));
|
|
1330
|
-
};
|
|
1331
|
-
const SelectedOutlineElement = ({ allDragTargets, allRotationDragTargets, allScaleDragTargets, dragging, hovered, outline, onDraggingChange, onHoverChange, onSelect, scale, target, }) => {
|
|
1332
|
-
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
1333
|
-
const updateResolvedStackTrace = (0, react_1.useContext)(remotion_1.Internals.SequenceStackTracesUpdateContext);
|
|
1334
|
-
const onContextMenuOpen = react_1.default.useCallback(async () => {
|
|
1335
|
-
if (target === undefined || previewServerState.type !== 'connected') {
|
|
1336
|
-
return false;
|
|
1337
|
-
}
|
|
1338
|
-
if (!target.selected) {
|
|
1339
|
-
onSelect(target.selection, { shiftKey: false, toggleKey: false });
|
|
1340
|
-
}
|
|
1341
|
-
const stack = target.sequence.getStack();
|
|
1342
|
-
let originalLocation = null;
|
|
1343
|
-
if (stack) {
|
|
1344
|
-
try {
|
|
1345
|
-
originalLocation = await (0, get_stack_1.getOriginalLocationFromStack)(stack, 'sequence');
|
|
1346
|
-
}
|
|
1347
|
-
catch (err) {
|
|
1348
|
-
(0, NotificationCenter_1.showNotification)(err.message, 2000);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
if (stack) {
|
|
1352
|
-
updateResolvedStackTrace(stack, originalLocation);
|
|
1353
|
-
}
|
|
1354
|
-
const fileLocation = (0, format_file_location_1.formatFileLocation)({
|
|
1355
|
-
location: originalLocation,
|
|
1356
|
-
root: window.remotion_cwd,
|
|
1357
|
-
});
|
|
1358
|
-
const editorName = window.remotion_editorName;
|
|
1359
|
-
return [
|
|
1360
|
-
editorName
|
|
1361
|
-
? {
|
|
1362
|
-
type: 'item',
|
|
1363
|
-
id: 'show-outline-in-editor',
|
|
1364
|
-
keyHint: null,
|
|
1365
|
-
label: `Show in ${editorName}`,
|
|
1366
|
-
leftItem: null,
|
|
1367
|
-
disabled: !originalLocation,
|
|
1368
|
-
onClick: () => {
|
|
1369
|
-
if (!originalLocation) {
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
(0, open_in_editor_1.openOriginalPositionInEditor)(originalLocation).catch((err) => {
|
|
1373
|
-
(0, NotificationCenter_1.showNotification)(err.message, 2000);
|
|
1374
|
-
});
|
|
1375
|
-
},
|
|
1376
|
-
quickSwitcherLabel: null,
|
|
1377
|
-
subMenu: null,
|
|
1378
|
-
value: 'show-outline-in-editor',
|
|
1379
|
-
}
|
|
1380
|
-
: null,
|
|
1381
|
-
{
|
|
1382
|
-
type: 'item',
|
|
1383
|
-
id: 'copy-outline-file-location',
|
|
1384
|
-
keyHint: null,
|
|
1385
|
-
label: 'Copy file location',
|
|
1386
|
-
leftItem: null,
|
|
1387
|
-
disabled: !fileLocation,
|
|
1388
|
-
onClick: () => {
|
|
1389
|
-
if (!fileLocation) {
|
|
1390
|
-
return;
|
|
1391
|
-
}
|
|
1392
|
-
navigator.clipboard
|
|
1393
|
-
.writeText(fileLocation)
|
|
1394
|
-
.then(() => {
|
|
1395
|
-
(0, NotificationCenter_1.showNotification)('Copied file location to clipboard', 1000);
|
|
1396
|
-
})
|
|
1397
|
-
.catch((err) => {
|
|
1398
|
-
(0, NotificationCenter_1.showNotification)(`Could not copy to clipboard: ${err.message}`, 1000);
|
|
1399
|
-
});
|
|
1400
|
-
},
|
|
1401
|
-
quickSwitcherLabel: null,
|
|
1402
|
-
subMenu: null,
|
|
1403
|
-
value: 'copy-outline-file-location',
|
|
1404
|
-
},
|
|
1405
|
-
].filter(no_react_1.NoReactInternals.truthy);
|
|
1406
|
-
}, [onSelect, previewServerState.type, target, updateResolvedStackTrace]);
|
|
1407
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
1408
|
-
jsx_runtime_1.jsx(SelectedOutlinePolygon, { allDragTargets: allDragTargets, contextMenuValues: emptyContextMenuValues, dragging: dragging, hovered: hovered, outline: outline, onContextMenuOpen: onContextMenuOpen, onDraggingChange: onDraggingChange, onHoverChange: onHoverChange, onSelect: onSelect, scale: scale, target: target }), (target === null || target === void 0 ? void 0 : target.containsSelection) || hovered
|
|
1409
|
-
? ['top', 'right', 'bottom', 'left'].map((edge) => (jsx_runtime_1.jsx(SelectedOutlineScaleEdgeLine, { allScaleDragTargets: allScaleDragTargets, contextMenuValues: emptyContextMenuValues, dragging: dragging, edge: edge, outline: outline, onContextMenuOpen: onContextMenuOpen, onDraggingChange: onDraggingChange, onHoverChange: onHoverChange, onSelect: onSelect, target: target }, edge)))
|
|
1410
|
-
: null, (target === null || target === void 0 ? void 0 : target.containsSelection) || hovered
|
|
1411
|
-
? ['top-left', 'top-right', 'bottom-right', 'bottom-left'].map((corner) => (jsx_runtime_1.jsx(SelectedOutlineRotationCornerHandle, { allRotationDragTargets: allRotationDragTargets, contextMenuValues: emptyContextMenuValues, corner: corner, dragging: dragging, outline: outline, onContextMenuOpen: onContextMenuOpen, onDraggingChange: onDraggingChange, onHoverChange: onHoverChange, onSelect: onSelect, target: target }, corner)))
|
|
1412
|
-
: null, jsx_runtime_1.jsx(SelectedOutlineTransformOriginHandle, { outline: outline, onDraggingChange: onDraggingChange, target: target })
|
|
1413
|
-
] }));
|
|
1414
|
-
};
|
|
1415
90
|
const SelectedOutlineOverlay = ({ scale }) => {
|
|
1416
91
|
const { selectedItems, selectItem } = (0, TimelineSelection_1.useTimelineSelection)();
|
|
1417
92
|
const { sequences } = (0, react_1.useContext)(remotion_1.Internals.SequenceManager);
|
|
@@ -1419,13 +94,18 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1419
94
|
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
1420
95
|
const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
|
|
1421
96
|
const { getDragOverrides, getEffectDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeDragOverridesContext);
|
|
97
|
+
const { setPropStatuses, setDragOverrides, clearDragOverrides } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
1422
98
|
const { getScaleLockState } = (0, react_1.useContext)(scale_lock_1.ScaleLockContext);
|
|
1423
99
|
const { editorShowOutlines } = (0, react_1.useContext)(editor_outlines_1.EditorShowOutlinesContext);
|
|
100
|
+
const { frameBack, frameForward, getCurrentFrame, seek } = player_1.PlayerInternals.usePlayer();
|
|
101
|
+
const keybindings = (0, use_keybinding_1.useKeybinding)();
|
|
1424
102
|
const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
1425
103
|
const [outlines, setOutlines] = (0, react_1.useState)([]);
|
|
1426
104
|
const [hoveredOutlineKey, setHoveredOutlineKey] = (0, react_1.useState)(null);
|
|
1427
105
|
const [draggingOutline, setDraggingOutline] = (0, react_1.useState)(false);
|
|
1428
106
|
const overlayRef = (0, react_1.useRef)(null);
|
|
107
|
+
const keyboardNudgeSessionRef = (0, react_1.useRef)(null);
|
|
108
|
+
const saveKeyboardNudgeSessionRef = (0, react_1.useRef)(() => undefined);
|
|
1429
109
|
const onDraggingChange = react_1.default.useCallback((dragging) => {
|
|
1430
110
|
setDraggingOutline(dragging);
|
|
1431
111
|
if (dragging) {
|
|
@@ -1436,19 +116,19 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1436
116
|
if (!editorShowOutlines) {
|
|
1437
117
|
return [];
|
|
1438
118
|
}
|
|
1439
|
-
const selectedSequenceKeys = (0,
|
|
1440
|
-
const sequenceKeysContainingSelection = getSequenceKeysContainingSelection(selectedItems);
|
|
1441
|
-
const selectedEffectsBySequenceKey = (0,
|
|
1442
|
-
const selectedTransformOriginInfo = getSelectedTransformOriginInfo(selectedItems);
|
|
119
|
+
const selectedSequenceKeys = (0, selected_outline_measurement_1.getSelectedSequenceKeys)(selectedItems);
|
|
120
|
+
const sequenceKeysContainingSelection = (0, selected_outline_measurement_1.getSequenceKeysContainingSelection)(selectedItems);
|
|
121
|
+
const selectedEffectsBySequenceKey = (0, selected_outline_measurement_1.getSelectedEffectFieldsBySequenceKey)(selectedItems);
|
|
122
|
+
const selectedTransformOriginInfo = (0, selected_outline_measurement_1.getSelectedTransformOriginInfo)(selectedItems);
|
|
1443
123
|
const clientId = previewServerState.type === 'connected'
|
|
1444
124
|
? previewServerState.clientId
|
|
1445
125
|
: null;
|
|
1446
|
-
return (0,
|
|
126
|
+
return (0, selected_outline_measurement_1.getSequencesWithSelectableOutlines)({
|
|
1447
127
|
sequences,
|
|
1448
128
|
overrideIdsToNodePaths: overrideIdToNodePathMappings,
|
|
1449
129
|
}).map(({ key, keyframeDisplayOffset, nodePathInfo, sequence }) => {
|
|
1450
130
|
var _a;
|
|
1451
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
131
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1452
132
|
if (sequence.refForOutline === null) {
|
|
1453
133
|
throw new Error('Expected sequence to have a ref for outline');
|
|
1454
134
|
}
|
|
@@ -1456,15 +136,27 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1456
136
|
const containsSelection = sequenceKeysContainingSelection.has(key);
|
|
1457
137
|
const nodePath = nodePathInfo.sequenceSubscriptionKey;
|
|
1458
138
|
const { controls } = sequence;
|
|
1459
|
-
const fieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[translateFieldKey];
|
|
139
|
+
const fieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[selected_outline_types_1.translateFieldKey];
|
|
1460
140
|
const nodePropStatuses = remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath);
|
|
1461
|
-
const propStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[translateFieldKey];
|
|
1462
|
-
const scaleFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[scaleFieldKey];
|
|
1463
|
-
const scalePropStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[scaleFieldKey];
|
|
1464
|
-
const rotationFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[rotateFieldKey];
|
|
1465
|
-
const rotationPropStatus = (_a = remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath)) === null || _a === void 0 ? void 0 : _a[rotateFieldKey];
|
|
1466
|
-
const transformOriginFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[transformOriginFieldKey];
|
|
1467
|
-
const transformOriginPropStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[transformOriginFieldKey];
|
|
141
|
+
const propStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[selected_outline_types_1.translateFieldKey];
|
|
142
|
+
const scaleFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[selected_outline_types_1.scaleFieldKey];
|
|
143
|
+
const scalePropStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[selected_outline_types_1.scaleFieldKey];
|
|
144
|
+
const rotationFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[selected_outline_types_1.rotateFieldKey];
|
|
145
|
+
const rotationPropStatus = (_a = remotion_1.Internals.getPropStatusesCtx(propStatuses, nodePath)) === null || _a === void 0 ? void 0 : _a[selected_outline_types_1.rotateFieldKey];
|
|
146
|
+
const transformOriginFieldSchema = controls === null || controls === void 0 ? void 0 : controls.schema[selected_outline_types_1.transformOriginFieldKey];
|
|
147
|
+
const transformOriginPropStatus = nodePropStatuses === null || nodePropStatuses === void 0 ? void 0 : nodePropStatuses[selected_outline_types_1.transformOriginFieldKey];
|
|
148
|
+
const rotationSourceFrame = timelinePosition - keyframeDisplayOffset;
|
|
149
|
+
const transformOriginValueForRotation = (transformOriginFieldSchema === null || transformOriginFieldSchema === void 0 ? void 0 : transformOriginFieldSchema.type) === 'transform-origin' &&
|
|
150
|
+
((transformOriginPropStatus === null || transformOriginPropStatus === void 0 ? void 0 : transformOriginPropStatus.status) === 'static' ||
|
|
151
|
+
(transformOriginPropStatus === null || transformOriginPropStatus === void 0 ? void 0 : transformOriginPropStatus.status) === 'keyframed')
|
|
152
|
+
? String((_c = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
153
|
+
propStatus: transformOriginPropStatus,
|
|
154
|
+
dragOverrideValue: ((_b = getDragOverrides(nodePath)) !== null && _b !== void 0 ? _b : {})[selected_outline_types_1.transformOriginFieldKey],
|
|
155
|
+
defaultValue: transformOriginFieldSchema.default,
|
|
156
|
+
frame: rotationSourceFrame,
|
|
157
|
+
shouldResortToDefaultValueIfUndefined: true,
|
|
158
|
+
})) !== null && _c !== void 0 ? _c : transformOriginFieldSchema.default)
|
|
159
|
+
: '50% 50%';
|
|
1468
160
|
const canDragStatus = (propStatus === null || propStatus === void 0 ? void 0 : propStatus.status) === 'static' ||
|
|
1469
161
|
((propStatus === null || propStatus === void 0 ? void 0 : propStatus.status) === 'keyframed' &&
|
|
1470
162
|
propStatus.interpolationFunction === 'interpolate');
|
|
@@ -1475,10 +167,13 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1475
167
|
controls !== null &&
|
|
1476
168
|
(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.type) === 'translate' &&
|
|
1477
169
|
canDragStatus;
|
|
170
|
+
const canScaleDragStatus = (scalePropStatus === null || scalePropStatus === void 0 ? void 0 : scalePropStatus.status) === 'static' ||
|
|
171
|
+
((scalePropStatus === null || scalePropStatus === void 0 ? void 0 : scalePropStatus.status) === 'keyframed' &&
|
|
172
|
+
scalePropStatus.interpolationFunction === 'interpolate');
|
|
1478
173
|
const canScaleDrag = previewServerState.type === 'connected' &&
|
|
1479
174
|
controls !== null &&
|
|
1480
175
|
(scaleFieldSchema === null || scaleFieldSchema === void 0 ? void 0 : scaleFieldSchema.type) === 'scale' &&
|
|
1481
|
-
|
|
176
|
+
canScaleDragStatus;
|
|
1482
177
|
const canRotationDrag = previewServerState.type === 'connected' &&
|
|
1483
178
|
controls !== null &&
|
|
1484
179
|
(rotationFieldSchema === null || rotationFieldSchema === void 0 ? void 0 : rotationFieldSchema.type) === 'rotation-css' &&
|
|
@@ -1534,12 +229,13 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1534
229
|
clientId: previewServerState.clientId,
|
|
1535
230
|
fieldDefault: scaleFieldSchema.default,
|
|
1536
231
|
fieldSchema: scaleFieldSchema,
|
|
232
|
+
keyframeDisplayOffset,
|
|
1537
233
|
linked: getScaleLockState({
|
|
1538
234
|
nodePath,
|
|
1539
|
-
fieldKey: scaleFieldKey,
|
|
235
|
+
fieldKey: selected_outline_types_1.scaleFieldKey,
|
|
1540
236
|
defaultValue: (() => {
|
|
1541
237
|
var _a;
|
|
1542
|
-
const dragOverrideValue = ((_a = getDragOverrides(nodePath)) !== null && _a !== void 0 ? _a : {})[scaleFieldKey];
|
|
238
|
+
const dragOverrideValue = ((_a = getDragOverrides(nodePath)) !== null && _a !== void 0 ? _a : {})[selected_outline_types_1.scaleFieldKey];
|
|
1543
239
|
const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
1544
240
|
propStatus: scalePropStatus,
|
|
1545
241
|
dragOverrideValue,
|
|
@@ -1563,6 +259,7 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1563
259
|
keyframeDisplayOffset,
|
|
1564
260
|
nodePath,
|
|
1565
261
|
schema: controls.schema,
|
|
262
|
+
transformOriginValue: transformOriginValueForRotation,
|
|
1566
263
|
}
|
|
1567
264
|
: null,
|
|
1568
265
|
transformOriginDrag: canTransformOriginDrag
|
|
@@ -1572,48 +269,48 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1572
269
|
nodePath,
|
|
1573
270
|
originDefault: transformOriginFieldSchema.default,
|
|
1574
271
|
originPropStatus: transformOriginPropStatus,
|
|
1575
|
-
originValue: String((
|
|
272
|
+
originValue: String((_e = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
1576
273
|
propStatus: transformOriginPropStatus,
|
|
1577
|
-
dragOverrideValue: ((
|
|
274
|
+
dragOverrideValue: ((_d = getDragOverrides(nodePath)) !== null && _d !== void 0 ? _d : {})[selected_outline_types_1.transformOriginFieldKey],
|
|
1578
275
|
defaultValue: transformOriginFieldSchema.default,
|
|
1579
276
|
frame: transformOriginSourceFrame,
|
|
1580
277
|
shouldResortToDefaultValueIfUndefined: true,
|
|
1581
|
-
})) !== null &&
|
|
278
|
+
})) !== null && _e !== void 0 ? _e : transformOriginFieldSchema.default),
|
|
1582
279
|
rotateValue: String((rotationPropStatus === null || rotationPropStatus === void 0 ? void 0 : rotationPropStatus.status) === 'static' ||
|
|
1583
280
|
(rotationPropStatus === null || rotationPropStatus === void 0 ? void 0 : rotationPropStatus.status) === 'keyframed'
|
|
1584
|
-
? ((
|
|
281
|
+
? ((_g = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
1585
282
|
propStatus: rotationPropStatus,
|
|
1586
|
-
dragOverrideValue: ((
|
|
283
|
+
dragOverrideValue: ((_f = getDragOverrides(nodePath)) !== null && _f !== void 0 ? _f : {})[selected_outline_types_1.rotateFieldKey],
|
|
1587
284
|
defaultValue: (rotationFieldSchema === null || rotationFieldSchema === void 0 ? void 0 : rotationFieldSchema.type) === 'rotation-css'
|
|
1588
285
|
? rotationFieldSchema.default
|
|
1589
286
|
: '0deg',
|
|
1590
287
|
frame: transformOriginSourceFrame,
|
|
1591
288
|
shouldResortToDefaultValueIfUndefined: true,
|
|
1592
|
-
})) !== null &&
|
|
289
|
+
})) !== null && _g !== void 0 ? _g : '0deg')
|
|
1593
290
|
: '0deg'),
|
|
1594
291
|
scaleValue: (scalePropStatus === null || scalePropStatus === void 0 ? void 0 : scalePropStatus.status) === 'static' ||
|
|
1595
292
|
(scalePropStatus === null || scalePropStatus === void 0 ? void 0 : scalePropStatus.status) === 'keyframed'
|
|
1596
|
-
? String((
|
|
293
|
+
? String((_j = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
1597
294
|
propStatus: scalePropStatus,
|
|
1598
|
-
dragOverrideValue: ((
|
|
295
|
+
dragOverrideValue: ((_h = getDragOverrides(nodePath)) !== null && _h !== void 0 ? _h : {})[selected_outline_types_1.scaleFieldKey],
|
|
1599
296
|
defaultValue: (scaleFieldSchema === null || scaleFieldSchema === void 0 ? void 0 : scaleFieldSchema.type) === 'scale'
|
|
1600
297
|
? scaleFieldSchema.default
|
|
1601
298
|
: 1,
|
|
1602
299
|
frame: transformOriginSourceFrame,
|
|
1603
300
|
shouldResortToDefaultValueIfUndefined: true,
|
|
1604
|
-
})) !== null &&
|
|
301
|
+
})) !== null && _j !== void 0 ? _j : 1)
|
|
1605
302
|
: '1',
|
|
1606
303
|
schema: controls.schema,
|
|
1607
304
|
sourceFrame: transformOriginSourceFrame,
|
|
1608
305
|
translateDefault: fieldSchema.default,
|
|
1609
306
|
translatePropStatus: propStatus,
|
|
1610
|
-
translateValue: String((
|
|
307
|
+
translateValue: String((_l = remotion_1.Internals.getEffectiveVisualModeValue({
|
|
1611
308
|
propStatus,
|
|
1612
|
-
dragOverrideValue: ((
|
|
309
|
+
dragOverrideValue: ((_k = getDragOverrides(nodePath)) !== null && _k !== void 0 ? _k : {})[selected_outline_types_1.translateFieldKey],
|
|
1613
310
|
defaultValue: fieldSchema.default,
|
|
1614
311
|
frame: transformOriginSourceFrame,
|
|
1615
312
|
shouldResortToDefaultValueIfUndefined: true,
|
|
1616
|
-
})) !== null &&
|
|
313
|
+
})) !== null && _l !== void 0 ? _l : fieldSchema.default),
|
|
1617
314
|
}
|
|
1618
315
|
: null,
|
|
1619
316
|
uvHandles: containsSelection
|
|
@@ -1661,6 +358,227 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1661
358
|
? [target.rotationDrag]
|
|
1662
359
|
: []);
|
|
1663
360
|
}, [outlineTargets]);
|
|
361
|
+
const saveKeyboardNudgeSession = (0, react_1.useCallback)(() => {
|
|
362
|
+
const session = keyboardNudgeSessionRef.current;
|
|
363
|
+
if (session === null) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
keyboardNudgeSessionRef.current = null;
|
|
367
|
+
const changes = (0, selected_outline_drag_1.getSelectedOutlineDragChanges)({
|
|
368
|
+
dragStates: session.dragStates,
|
|
369
|
+
lastValues: session.lastValues,
|
|
370
|
+
});
|
|
371
|
+
if (changes.length === 0) {
|
|
372
|
+
(0, selected_outline_drag_1.clearSelectedOutlineDragOverrides)({
|
|
373
|
+
clearDragOverrides,
|
|
374
|
+
dragStates: session.dragStates,
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const staticChanges = changes.filter((change) => change.type === 'static');
|
|
379
|
+
const keyframedChanges = changes.filter((change) => change.type === 'keyframed');
|
|
380
|
+
Promise.all([
|
|
381
|
+
staticChanges.length > 0
|
|
382
|
+
? (0, save_sequence_prop_1.saveSequenceProps)({
|
|
383
|
+
changes: staticChanges,
|
|
384
|
+
setPropStatuses,
|
|
385
|
+
clientId: session.clientId,
|
|
386
|
+
undoLabel: changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
|
|
387
|
+
redoLabel: changes.length > 1
|
|
388
|
+
? 'Move selected sequences back'
|
|
389
|
+
: 'Move sequence back',
|
|
390
|
+
})
|
|
391
|
+
: Promise.resolve(),
|
|
392
|
+
...keyframedChanges.map((change) => (0, call_add_keyframe_1.callAddSequenceKeyframe)({
|
|
393
|
+
fileName: change.fileName,
|
|
394
|
+
nodePath: change.nodePath,
|
|
395
|
+
fieldKey: change.fieldKey,
|
|
396
|
+
sourceFrame: change.sourceFrame,
|
|
397
|
+
value: change.value,
|
|
398
|
+
schema: change.schema,
|
|
399
|
+
setPropStatuses,
|
|
400
|
+
clientId: change.clientId,
|
|
401
|
+
})),
|
|
402
|
+
])
|
|
403
|
+
.catch((err) => {
|
|
404
|
+
(0, NotificationCenter_1.showNotification)(`Could not save sequence props: ${err instanceof Error ? err.message : String(err)}`, 4000);
|
|
405
|
+
})
|
|
406
|
+
.finally(() => {
|
|
407
|
+
(0, selected_outline_drag_1.clearSelectedOutlineDragOverrides)({
|
|
408
|
+
clearDragOverrides,
|
|
409
|
+
dragStates: session.dragStates,
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}, [clearDragOverrides, setPropStatuses]);
|
|
413
|
+
(0, react_1.useEffect)(() => {
|
|
414
|
+
saveKeyboardNudgeSessionRef.current = saveKeyboardNudgeSession;
|
|
415
|
+
}, [saveKeyboardNudgeSession]);
|
|
416
|
+
(0, react_1.useEffect)(() => {
|
|
417
|
+
return () => {
|
|
418
|
+
saveKeyboardNudgeSessionRef.current();
|
|
419
|
+
};
|
|
420
|
+
}, []);
|
|
421
|
+
const seekWithArrowKey = (0, react_1.useCallback)((event, direction) => {
|
|
422
|
+
if (direction === 'up' || direction === 'down') {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
if (direction === 'left') {
|
|
427
|
+
if (event.altKey) {
|
|
428
|
+
seek(0);
|
|
429
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
430
|
+
direction: 'fit-left',
|
|
431
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
|
|
432
|
+
frame: 0,
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
else if (event.shiftKey) {
|
|
436
|
+
frameBack((0, imperative_state_1.getCurrentFps)());
|
|
437
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
438
|
+
direction: 'fit-left',
|
|
439
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
|
|
440
|
+
frame: Math.max(0, getCurrentFrame() - (0, imperative_state_1.getCurrentFps)()),
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
frameBack(1);
|
|
445
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
446
|
+
direction: 'fit-left',
|
|
447
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
|
|
448
|
+
frame: Math.max(0, getCurrentFrame() - 1),
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (event.altKey) {
|
|
454
|
+
seek((0, imperative_state_1.getCurrentDuration)() - 1);
|
|
455
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
456
|
+
direction: 'fit-right',
|
|
457
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)() - 1,
|
|
458
|
+
frame: (0, imperative_state_1.getCurrentDuration)() - 1,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
else if (event.shiftKey) {
|
|
462
|
+
frameForward((0, imperative_state_1.getCurrentFps)());
|
|
463
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
464
|
+
direction: 'fit-right',
|
|
465
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
|
|
466
|
+
frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, getCurrentFrame() + (0, imperative_state_1.getCurrentFps)()),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
frameForward(1);
|
|
471
|
+
(0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
|
|
472
|
+
direction: 'fit-right',
|
|
473
|
+
durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
|
|
474
|
+
frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, getCurrentFrame() + 1),
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}, [frameBack, frameForward, getCurrentFrame, seek]);
|
|
478
|
+
const onArrowKeyDown = (0, react_1.useCallback)((event) => {
|
|
479
|
+
var _a;
|
|
480
|
+
const direction = (0, selected_outline_drag_1.getSelectedOutlineKeyboardNudgeDirection)(event.key);
|
|
481
|
+
if (direction === null) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (selectedItems.length === 0 || allDragTargets.length === 0) {
|
|
485
|
+
seekWithArrowKey(event, direction);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (event.altKey) {
|
|
489
|
+
seekWithArrowKey(event, direction);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
const activeSession = (_a = keyboardNudgeSessionRef.current) !== null && _a !== void 0 ? _a : (() => {
|
|
494
|
+
const [firstDragTarget] = allDragTargets;
|
|
495
|
+
if (firstDragTarget === undefined) {
|
|
496
|
+
throw new Error('Expected a drag target');
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
clientId: firstDragTarget.clientId,
|
|
500
|
+
deltaX: 0,
|
|
501
|
+
deltaY: 0,
|
|
502
|
+
dragStates: (0, selected_outline_drag_1.getSelectedOutlineDragStates)({
|
|
503
|
+
dragTargets: allDragTargets,
|
|
504
|
+
getDragOverrides,
|
|
505
|
+
timelinePosition,
|
|
506
|
+
}),
|
|
507
|
+
lastValues: new Map(),
|
|
508
|
+
};
|
|
509
|
+
})();
|
|
510
|
+
keyboardNudgeSessionRef.current = activeSession;
|
|
511
|
+
const nextDeltas = (0, selected_outline_drag_1.getSelectedOutlineKeyboardNudgeDeltas)({
|
|
512
|
+
deltaX: activeSession.deltaX,
|
|
513
|
+
deltaY: activeSession.deltaY,
|
|
514
|
+
direction,
|
|
515
|
+
shiftKey: event.shiftKey,
|
|
516
|
+
});
|
|
517
|
+
activeSession.deltaX = nextDeltas.deltaX;
|
|
518
|
+
activeSession.deltaY = nextDeltas.deltaY;
|
|
519
|
+
const lastValues = (0, selected_outline_drag_1.getSelectedOutlineDragValues)({
|
|
520
|
+
dragStates: activeSession.dragStates,
|
|
521
|
+
deltaX: activeSession.deltaX,
|
|
522
|
+
deltaY: activeSession.deltaY,
|
|
523
|
+
});
|
|
524
|
+
activeSession.lastValues = lastValues;
|
|
525
|
+
for (const dragState of activeSession.dragStates) {
|
|
526
|
+
const value = lastValues.get(dragState.key);
|
|
527
|
+
if (value === undefined) {
|
|
528
|
+
throw new Error('Expected drag value to be available');
|
|
529
|
+
}
|
|
530
|
+
if (dragState.target.propStatus.status === 'keyframed') {
|
|
531
|
+
setDragOverrides(dragState.target.nodePath, selected_outline_types_1.translateFieldKey, remotion_1.Internals.makeKeyframedDragOverride({
|
|
532
|
+
status: dragState.target.propStatus,
|
|
533
|
+
frame: dragState.sourceFrame,
|
|
534
|
+
value,
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
setDragOverrides(dragState.target.nodePath, selected_outline_types_1.translateFieldKey, remotion_1.Internals.makeStaticDragOverride(value));
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}, [
|
|
542
|
+
allDragTargets,
|
|
543
|
+
getDragOverrides,
|
|
544
|
+
seekWithArrowKey,
|
|
545
|
+
selectedItems.length,
|
|
546
|
+
setDragOverrides,
|
|
547
|
+
timelinePosition,
|
|
548
|
+
]);
|
|
549
|
+
const onArrowKeyUp = (0, react_1.useCallback)((event) => {
|
|
550
|
+
const direction = (0, selected_outline_drag_1.getSelectedOutlineKeyboardNudgeDirection)(event.key);
|
|
551
|
+
if (direction === null || keyboardNudgeSessionRef.current === null) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
event.preventDefault();
|
|
555
|
+
saveKeyboardNudgeSession();
|
|
556
|
+
}, [saveKeyboardNudgeSession]);
|
|
557
|
+
(0, react_1.useEffect)(() => {
|
|
558
|
+
const keyDownBindings = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].map((key) => keybindings.registerKeybinding({
|
|
559
|
+
event: 'keydown',
|
|
560
|
+
key,
|
|
561
|
+
callback: onArrowKeyDown,
|
|
562
|
+
commandCtrlKey: false,
|
|
563
|
+
preventDefault: false,
|
|
564
|
+
triggerIfInputFieldFocused: false,
|
|
565
|
+
keepRegisteredWhenNotHighestContext: false,
|
|
566
|
+
}));
|
|
567
|
+
const keyUpBindings = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].map((key) => keybindings.registerKeybinding({
|
|
568
|
+
event: 'keyup',
|
|
569
|
+
key,
|
|
570
|
+
callback: onArrowKeyUp,
|
|
571
|
+
commandCtrlKey: false,
|
|
572
|
+
preventDefault: false,
|
|
573
|
+
triggerIfInputFieldFocused: false,
|
|
574
|
+
keepRegisteredWhenNotHighestContext: false,
|
|
575
|
+
}));
|
|
576
|
+
return () => {
|
|
577
|
+
for (const binding of [...keyDownBindings, ...keyUpBindings]) {
|
|
578
|
+
binding.unregister();
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}, [keybindings, onArrowKeyDown, onArrowKeyUp, saveKeyboardNudgeSession]);
|
|
1664
582
|
(0, react_1.useEffect)(() => {
|
|
1665
583
|
if (outlineTargets.length === 0) {
|
|
1666
584
|
setOutlines((prevOutlines) => prevOutlines.length === 0 ? prevOutlines : []);
|
|
@@ -1669,8 +587,8 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1669
587
|
let animationFrame = null;
|
|
1670
588
|
const updateOutlines = () => {
|
|
1671
589
|
if (overlayRef.current) {
|
|
1672
|
-
const nextOutlines = measureOutlines(overlayRef.current, outlineTargets);
|
|
1673
|
-
setOutlines((prevOutlines) => outlinesAreEqual(prevOutlines, nextOutlines)
|
|
590
|
+
const nextOutlines = (0, selected_outline_measurement_1.measureOutlines)(overlayRef.current, outlineTargets);
|
|
591
|
+
setOutlines((prevOutlines) => (0, selected_outline_measurement_1.outlinesAreEqual)(prevOutlines, nextOutlines)
|
|
1674
592
|
? prevOutlines
|
|
1675
593
|
: nextOutlines);
|
|
1676
594
|
}
|
|
@@ -1686,6 +604,6 @@ const SelectedOutlineOverlay = ({ scale }) => {
|
|
|
1686
604
|
if (outlineTargets.length === 0) {
|
|
1687
605
|
return null;
|
|
1688
606
|
}
|
|
1689
|
-
return (jsx_runtime_1.jsxs("svg", { ref: overlayRef, style: outlineContainer, width: "100%", height: "100%", "aria-hidden": "true", children: [outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineElement, { allDragTargets: allDragTargets, allRotationDragTargets: allRotationDragTargets, allScaleDragTargets: allScaleDragTargets, dragging: draggingOutline, hovered: hoveredOutlineKey === outline.key, outline: outline, onDraggingChange: onDraggingChange, onHoverChange: setHoveredOutlineKey, onSelect: selectItem, scale: scale, target: targetsByKey.get(outline.key) }, outline.key))), outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineUvControls_1.SelectedOutlineUvHandleConnectionLayer, { outline: outline, target: targetsByKey.get(outline.key) }, `${outline.key}-uv-connection-lines`))), outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineUvControls_1.SelectedOutlineUvHandleCircleLayer, { onDraggingChange: onDraggingChange, outline: outline, target: targetsByKey.get(outline.key) }, `${outline.key}-uv-handles`)))] }));
|
|
607
|
+
return (jsx_runtime_1.jsxs("svg", { ref: overlayRef, style: outlineContainer, width: "100%", height: "100%", "aria-hidden": "true", children: [outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineElement_1.SelectedOutlineElement, { allDragTargets: allDragTargets, allRotationDragTargets: allRotationDragTargets, allScaleDragTargets: allScaleDragTargets, dragging: draggingOutline, hovered: hoveredOutlineKey === outline.key, outline: outline, onDraggingChange: onDraggingChange, onHoverChange: setHoveredOutlineKey, onSelect: selectItem, scale: scale, target: targetsByKey.get(outline.key) }, outline.key))), outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineUvControls_1.SelectedOutlineUvHandleConnectionLayer, { outline: outline, target: targetsByKey.get(outline.key) }, `${outline.key}-uv-connection-lines`))), outlines.map((outline) => (jsx_runtime_1.jsx(SelectedOutlineUvControls_1.SelectedOutlineUvHandleCircleLayer, { onDraggingChange: onDraggingChange, outline: outline, target: targetsByKey.get(outline.key) }, `${outline.key}-uv-handles`)))] }));
|
|
1690
608
|
};
|
|
1691
609
|
exports.SelectedOutlineOverlay = SelectedOutlineOverlay;
|