fragment-tools 0.1.20 → 0.2.0
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/bin/index.js +2 -2
- package/package.json +5 -6
- package/src/cli/build.js +1 -1
- package/src/cli/run.js +1 -1
- package/src/cli/templates/three-fragment/index.js +6 -6
- package/src/cli/templates/three-orthographic/index.js +3 -3
- package/src/cli/templates/three-perspective/index.js +3 -3
- package/src/client/app/actions/resize.js +14 -0
- package/src/client/app/components/HintLoading.svelte +94 -0
- package/src/client/app/components/HintPaused.svelte +88 -0
- package/src/client/app/components/HintRecord.svelte +62 -0
- package/src/client/app/components/IconLocked.svelte +51 -0
- package/src/client/app/components/IconTriggers.svelte +48 -0
- package/src/client/app/components/Init.svelte +14 -27
- package/src/client/app/components/KeyBinding.svelte +3 -6
- package/src/client/app/helpers.js +4 -40
- package/src/client/app/hooks.js +41 -17
- package/src/client/app/inputs/MIDI.js +2 -1
- package/src/client/app/lib/canvas-recorder/CanvasRecorder.js +6 -1
- package/src/client/app/lib/gl/Renderer.js +1 -0
- package/src/client/app/lib/svelte-json-tree/ErrorNode.svelte +28 -0
- package/src/client/app/lib/svelte-json-tree/ErrorStack.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/Expandable.svelte +25 -0
- package/src/client/app/lib/svelte-json-tree/JSONArrayNode.svelte +38 -0
- package/src/client/app/lib/svelte-json-tree/JSONArrow.svelte +47 -0
- package/src/client/app/lib/svelte-json-tree/JSONFunctionNode.svelte +114 -0
- package/src/client/app/lib/svelte-json-tree/JSONIterableArrayNode.svelte +60 -0
- package/src/client/app/lib/svelte-json-tree/JSONIterableMapNode.svelte +87 -0
- package/src/client/app/lib/svelte-json-tree/JSONNested.svelte +94 -0
- package/src/client/app/lib/svelte-json-tree/JSONNode.svelte +91 -0
- package/src/client/app/lib/svelte-json-tree/JSONObjectNode.svelte +40 -0
- package/src/client/app/lib/svelte-json-tree/JSONStringNode.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/JSONValueNode.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/PreviewList.svelte +38 -0
- package/src/client/app/lib/svelte-json-tree/RegExpNode.svelte +42 -0
- package/src/client/app/lib/svelte-json-tree/Root.svelte +75 -0
- package/src/client/app/lib/svelte-json-tree/Summary.svelte +9 -0
- package/src/client/app/lib/svelte-json-tree/TypedArrayNode.svelte +56 -0
- package/src/client/app/lib/svelte-json-tree/index.js +1 -0
- package/src/client/app/lib/svelte-json-tree/utils.js +57 -0
- package/src/client/app/modules/Console/ConsoleLine.svelte +12 -11
- package/src/client/app/modules/Console.svelte +82 -17
- package/src/client/app/modules/Exports.svelte +48 -48
- package/src/client/app/modules/MidiPanel.svelte +12 -19
- package/src/client/app/modules/Monitor.svelte +147 -55
- package/src/client/app/modules/Params.svelte +127 -80
- package/src/client/app/renderers/2DRenderer.js +1 -0
- package/src/client/app/renderers/FragmentRenderer.js +1 -1
- package/src/client/app/renderers/P5GLRenderer.js +11 -5
- package/src/client/app/renderers/P5Renderer.js +7 -3
- package/src/client/app/renderers/THREERenderer.js +42 -79
- package/src/client/app/state/Sketch.svelte.js +538 -0
- package/src/client/app/state/errors.svelte.js +17 -0
- package/src/client/app/state/exports.svelte.js +152 -0
- package/src/client/app/state/layout.svelte.js +205 -0
- package/src/client/app/state/monitors.svelte.js +36 -0
- package/src/client/app/state/renderers.svelte.js +77 -0
- package/src/client/app/state/rendering.svelte.js +697 -0
- package/src/client/app/state/sketches.svelte.js +73 -0
- package/src/client/app/state/utils.svelte.js +65 -0
- package/src/client/app/ui/Build.svelte +53 -60
- package/src/client/app/ui/ErrorOverlay.svelte +2 -2
- package/src/client/app/ui/Field.svelte +63 -189
- package/src/client/app/ui/FieldGroup.svelte +4 -5
- package/src/client/app/ui/FieldSection.svelte +14 -9
- package/src/client/app/ui/FieldSpace.svelte +1 -1
- package/src/client/app/ui/FieldTrigger.svelte +86 -84
- package/src/client/app/ui/FieldTriggers.svelte +25 -24
- package/src/client/app/ui/FloatingParams.svelte +50 -12
- package/src/client/app/ui/Layout.svelte +24 -13
- package/src/client/app/ui/LayoutColumn.svelte +2 -2
- package/src/client/app/ui/LayoutComponent.svelte +86 -195
- package/src/client/app/ui/LayoutResizer.svelte +25 -37
- package/src/client/app/ui/LayoutRoot.svelte +3 -5
- package/src/client/app/ui/LayoutRow.svelte +2 -2
- package/src/client/app/ui/LayoutToolbar.svelte +17 -76
- package/src/client/app/ui/Module.svelte +31 -35
- package/src/client/app/ui/ModuleHeaderAction.svelte +23 -16
- package/src/client/app/ui/ModuleHeaderButton.svelte +3 -3
- package/src/client/app/ui/ModuleHeaderSelect.svelte +4 -12
- package/src/client/app/ui/ModuleRenderer.svelte +84 -22
- package/src/client/app/ui/ParamsOutput.svelte +61 -77
- package/src/client/app/ui/Preview.svelte +15 -4
- package/src/client/app/ui/SelectChevrons.svelte +1 -2
- package/src/client/app/ui/SketchRenderer.svelte +89 -701
- package/src/client/app/ui/SketchSelect.svelte +14 -49
- package/src/client/app/ui/fields/ButtonInput.svelte +14 -11
- package/src/client/app/ui/fields/CheckboxInput.svelte +5 -12
- package/src/client/app/ui/fields/ColorInput.svelte +46 -121
- package/src/client/app/ui/fields/FieldInputRow.svelte +5 -1
- package/src/client/app/ui/fields/ImageInput.svelte +14 -14
- package/src/client/app/ui/fields/Input.svelte +19 -25
- package/src/client/app/ui/fields/IntervalInput.svelte +22 -22
- package/src/client/app/ui/fields/NumberInput.svelte +32 -38
- package/src/client/app/ui/fields/ProgressInput.svelte +14 -13
- package/src/client/app/ui/fields/Select.svelte +34 -45
- package/src/client/app/ui/fields/TextInput.svelte +10 -6
- package/src/client/app/ui/fields/VectorInput.svelte +25 -30
- package/src/client/app/utils/canvas.utils.js +8 -8
- package/src/client/app/utils/color.utils.js +46 -13
- package/src/client/app/utils/fields.utils.js +1 -1
- package/src/client/app/utils/glsl.utils.js +1 -1
- package/src/client/app/utils/glslErrors.js +1 -1
- package/src/client/main.js +2 -2
|
@@ -1,207 +1,92 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
let ID = 0;
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
1
|
<script>
|
|
6
|
-
import { getContext,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
addChildren,
|
|
10
|
-
addSibling,
|
|
11
|
-
layout,
|
|
12
|
-
remove,
|
|
13
|
-
replaceChildren,
|
|
14
|
-
swapRoot,
|
|
15
|
-
updateModule,
|
|
16
|
-
} from '../stores/layout';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
3
|
+
import { layout } from '../state/layout.svelte';
|
|
17
4
|
import Toolbar from './LayoutToolbar.svelte';
|
|
18
5
|
import Resizer from './LayoutResizer.svelte';
|
|
19
|
-
import { getModuleID } from './Module.svelte';
|
|
20
6
|
import ModuleRenderer from './ModuleRenderer.svelte';
|
|
21
7
|
import Preview from './Preview.svelte';
|
|
8
|
+
import LayoutComponent from './LayoutComponent.svelte';
|
|
22
9
|
|
|
23
|
-
|
|
24
|
-
export let type = 'column';
|
|
25
|
-
export let tree = { children: [] };
|
|
26
|
-
|
|
27
|
-
let parent = hasContext('parent') ? getContext('parent') : null;
|
|
28
|
-
let depth = hasContext('depth') ? getContext('depth') + 1 : 0;
|
|
29
|
-
let module = writable({});
|
|
30
|
-
setContext('depth', depth);
|
|
31
|
-
setContext('module', module);
|
|
10
|
+
let { id = layout.getID(), size = 1, type = 'column', children } = $props();
|
|
32
11
|
|
|
33
|
-
let
|
|
34
|
-
let
|
|
35
|
-
let
|
|
12
|
+
let parent = getContext('parent');
|
|
13
|
+
let isColumn = $derived(type === 'column');
|
|
14
|
+
let isRow = $derived(!isColumn);
|
|
36
15
|
|
|
37
|
-
|
|
16
|
+
const component = layout.createComponent({
|
|
38
17
|
id,
|
|
39
|
-
parent = null,
|
|
40
|
-
root = false,
|
|
41
|
-
node = null,
|
|
42
|
-
depth,
|
|
43
|
-
size = 1,
|
|
44
|
-
minimized = false,
|
|
45
|
-
type,
|
|
46
|
-
children = [],
|
|
47
|
-
}) {
|
|
48
|
-
return {
|
|
49
|
-
id,
|
|
50
|
-
root,
|
|
51
|
-
node,
|
|
52
|
-
depth,
|
|
53
|
-
size,
|
|
54
|
-
minimized,
|
|
55
|
-
parent: parent ? parent.id : null,
|
|
56
|
-
type,
|
|
57
|
-
children,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let current = createComponent({
|
|
62
|
-
id: !isNaN(tree.id) ? tree.id : ID++,
|
|
63
|
-
root: isRoot,
|
|
64
|
-
depth,
|
|
65
18
|
size,
|
|
66
|
-
parent,
|
|
19
|
+
origin: parent,
|
|
67
20
|
type,
|
|
68
21
|
});
|
|
69
22
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
id: current.id,
|
|
77
|
-
children,
|
|
78
|
-
registerChild: (child) => {
|
|
79
|
-
$children = [...$children, child];
|
|
80
|
-
|
|
81
|
-
onDestroy(() => {
|
|
82
|
-
$children = $children.filter((c) => c !== child);
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
setContext('parent', context);
|
|
23
|
+
let current = $derived(layout.components.find((c) => c.id === id));
|
|
24
|
+
let childComponents = $derived(
|
|
25
|
+
current.children.map((c) => layout.getComponent(c)),
|
|
26
|
+
);
|
|
27
|
+
let minimized = $derived(current.minimized);
|
|
28
|
+
let isRoot = $derived(current.root);
|
|
88
29
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!__BUILD__) {
|
|
94
|
-
$layout.registerChild(current, () => $children);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
$: {
|
|
98
|
-
let property = ``,
|
|
99
|
-
value = ``;
|
|
100
|
-
|
|
101
|
-
const nodes = tree.children;
|
|
102
|
-
|
|
103
|
-
if (Array.isArray(nodes) && nodes.length > 1) {
|
|
104
|
-
if (isColumn) {
|
|
105
|
-
property = `grid-template-rows`;
|
|
106
|
-
value = nodes
|
|
107
|
-
.map((row, i) => {
|
|
108
|
-
let size = `${row.size}fr`;
|
|
109
|
-
|
|
110
|
-
return `minmax(25px, ${size}) 0px`;
|
|
111
|
-
})
|
|
112
|
-
.join(' ');
|
|
113
|
-
} else {
|
|
114
|
-
property = `grid-template-columns`;
|
|
115
|
-
value = nodes
|
|
116
|
-
.map((col, i) => {
|
|
117
|
-
let size = `${col.size}fr`;
|
|
118
|
-
|
|
119
|
-
return `minmax(25px, ${size}) 0px`;
|
|
120
|
-
})
|
|
121
|
-
.join(' ');
|
|
122
|
-
}
|
|
30
|
+
setContext('parent', component.id);
|
|
31
|
+
setContext('minimize', () => {
|
|
32
|
+
component.minimized = !component.minimized;
|
|
33
|
+
});
|
|
123
34
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
35
|
+
let property = $derived(
|
|
36
|
+
isColumn ? `grid-template-rows` : `grid-template-columns`,
|
|
37
|
+
);
|
|
38
|
+
let value = $derived.by(() => {
|
|
39
|
+
const totalSize = childComponents.reduce((t, n) => t + n.size, 0);
|
|
40
|
+
return childComponents
|
|
41
|
+
.map(({ size, minimized }) =>
|
|
42
|
+
minimized && isColumn && !layout.editing
|
|
43
|
+
? '25px 0px'
|
|
44
|
+
: `minmax(25px, ${(size / totalSize) * 100}%) 0px`,
|
|
45
|
+
)
|
|
46
|
+
.join(' ');
|
|
47
|
+
});
|
|
48
|
+
let style = $derived(
|
|
49
|
+
Array.isArray(childComponents) && childComponents.length > 0
|
|
50
|
+
? `${property}:${value}`
|
|
51
|
+
: '',
|
|
52
|
+
);
|
|
129
53
|
|
|
130
54
|
function addComponent(newType) {
|
|
131
|
-
const
|
|
55
|
+
const childCount = childComponents.length;
|
|
132
56
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
parent: isSibling ? parent : context,
|
|
136
|
-
depth: isSibling ? depth : depth + 1,
|
|
57
|
+
layout.createComponent({
|
|
58
|
+
origin: current.id,
|
|
137
59
|
type: newType,
|
|
138
|
-
children: [{ mID: getModuleID(), type: 'module' }],
|
|
139
60
|
});
|
|
140
61
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// switch type
|
|
151
|
-
current.children = [newSibling, newborn];
|
|
152
|
-
current.type = current.type === 'column' ? 'row' : 'column';
|
|
153
|
-
|
|
154
|
-
swapRoot(current);
|
|
155
|
-
} else {
|
|
156
|
-
addSibling(current, newborn);
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
if ($children.length === 1 && $children[0].type === 'module') {
|
|
160
|
-
replaceChildren(current, [
|
|
161
|
-
...$children.map((c, i) =>
|
|
162
|
-
createComponent({
|
|
163
|
-
id: ID++,
|
|
164
|
-
type: type === 'row' ? 'column' : 'row',
|
|
165
|
-
depth: depth + 1,
|
|
166
|
-
children: [c],
|
|
167
|
-
}),
|
|
168
|
-
),
|
|
169
|
-
newborn,
|
|
170
|
-
]);
|
|
171
|
-
|
|
172
|
-
module.set({});
|
|
173
|
-
} else {
|
|
174
|
-
addChildren(current, newborn);
|
|
175
|
-
}
|
|
62
|
+
// create a second child of new type to create divisions
|
|
63
|
+
// instead of a single child component which wouldn't make any visual change
|
|
64
|
+
if (childCount === 0 && newType !== current.type) {
|
|
65
|
+
layout.createComponent({
|
|
66
|
+
origin: current.id,
|
|
67
|
+
type: newType,
|
|
68
|
+
});
|
|
176
69
|
}
|
|
177
70
|
}
|
|
178
71
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function addRow() {
|
|
184
|
-
addComponent('row');
|
|
185
|
-
}
|
|
72
|
+
const addColumn = () => addComponent('column');
|
|
73
|
+
const addRow = () => addComponent('row');
|
|
186
74
|
|
|
187
75
|
function deleteCurrent() {
|
|
188
|
-
remove(current);
|
|
189
|
-
|
|
190
|
-
$children = current.children;
|
|
76
|
+
layout.remove(current);
|
|
191
77
|
}
|
|
192
78
|
|
|
193
|
-
function handleModuleChange(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
79
|
+
function handleModuleChange(moduleName) {
|
|
80
|
+
if (childComponents.length && childComponents[0].type === 'module') {
|
|
81
|
+
childComponents[0].name = moduleName; // keep state when replacingChildren
|
|
82
|
+
} else {
|
|
83
|
+
layout.createComponent({
|
|
84
|
+
type: 'module',
|
|
85
|
+
origin: current.id,
|
|
86
|
+
name: moduleName,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
200
89
|
}
|
|
201
|
-
|
|
202
|
-
let offsetWidth;
|
|
203
|
-
|
|
204
|
-
$: minimized = current.minimized;
|
|
205
90
|
</script>
|
|
206
91
|
|
|
207
92
|
<div
|
|
@@ -211,43 +96,45 @@
|
|
|
211
96
|
class:row={isRow}
|
|
212
97
|
class:minimized
|
|
213
98
|
bind:this={current.node}
|
|
214
|
-
|
|
99
|
+
data-component={component.id}
|
|
215
100
|
>
|
|
216
|
-
{#if isRoot &&
|
|
101
|
+
{#if isRoot && layout.previewing}
|
|
217
102
|
<Preview />
|
|
218
|
-
{:else if
|
|
219
|
-
{#each
|
|
103
|
+
{:else if childComponents.length > 0}
|
|
104
|
+
{#each childComponents as child (child.id)}
|
|
220
105
|
{#if child.type === 'column' || child.type === 'row'}
|
|
221
|
-
<
|
|
106
|
+
<LayoutComponent
|
|
107
|
+
id={child.id}
|
|
108
|
+
type={child.type}
|
|
109
|
+
size={child.size}
|
|
110
|
+
/>
|
|
222
111
|
{:else if child.type === 'module'}
|
|
223
112
|
<ModuleRenderer
|
|
113
|
+
id={child.id}
|
|
224
114
|
name={child.name}
|
|
225
|
-
|
|
226
|
-
|
|
115
|
+
headless={child.headless}
|
|
116
|
+
params={child.params}
|
|
227
117
|
/>
|
|
118
|
+
{:else}
|
|
119
|
+
<p>Cannot render child</p>
|
|
228
120
|
{/if}
|
|
229
121
|
{/each}
|
|
230
122
|
{:else}
|
|
231
|
-
|
|
123
|
+
{@render children()}
|
|
232
124
|
{/if}
|
|
233
|
-
{#if
|
|
125
|
+
{#if layout.editing && (isRoot || (childComponents.length === 1 && childComponents[0].type === 'module') || childComponents.length === 0)}
|
|
234
126
|
<Toolbar
|
|
235
127
|
{isRoot}
|
|
236
|
-
moduleName={
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
vertical={offsetWidth < 300}
|
|
128
|
+
moduleName={childComponents[0]?.name}
|
|
129
|
+
onchange={handleModuleChange}
|
|
130
|
+
onAddRow={addRow}
|
|
131
|
+
onAddColumn={addColumn}
|
|
132
|
+
onDelete={deleteCurrent}
|
|
242
133
|
/>
|
|
243
134
|
{/if}
|
|
244
135
|
</div>
|
|
245
136
|
{#if !isRoot}
|
|
246
|
-
<Resizer
|
|
247
|
-
direction={isColumn ? 'vertical' : 'horizontal'}
|
|
248
|
-
{current}
|
|
249
|
-
{parent}
|
|
250
|
-
/>
|
|
137
|
+
<Resizer direction={isColumn ? 'vertical' : 'horizontal'} {current} />
|
|
251
138
|
{/if}
|
|
252
139
|
|
|
253
140
|
<style>
|
|
@@ -264,6 +151,10 @@
|
|
|
264
151
|
grid-template-rows: minmax(25px, 1fr);
|
|
265
152
|
}
|
|
266
153
|
|
|
154
|
+
.column.minimized {
|
|
155
|
+
height: 25px;
|
|
156
|
+
}
|
|
157
|
+
|
|
267
158
|
.column:not(:last-child) {
|
|
268
159
|
border-right: 0.5px solid var(--color-lightblack);
|
|
269
160
|
}
|
|
@@ -8,45 +8,33 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
|
-
import { layout
|
|
11
|
+
import { layout } from '../state/layout.svelte.js';
|
|
12
12
|
import { clamp, map } from '../utils/math.utils.js';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
export let current;
|
|
16
|
-
export let parent = {};
|
|
14
|
+
let { direction = DIRECTIONS.HORIZONTAL, current } = $props();
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
let
|
|
22
|
-
let
|
|
16
|
+
let visible = $state(false);
|
|
17
|
+
let isDragging = $state(false);
|
|
18
|
+
let next = $state(null);
|
|
19
|
+
let currentRect, nextRect;
|
|
20
|
+
let currentSize, nextSize, totalSize;
|
|
23
21
|
|
|
24
22
|
function findNext() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const childNodes = [...parentNode.children];
|
|
28
|
-
|
|
29
|
-
const index = childNodes.findIndex((c) => c === current.node);
|
|
30
|
-
const nextNode = childNodes[index + 2];
|
|
31
|
-
|
|
32
|
-
next = $children.find((c) => c.node === nextNode);
|
|
23
|
+
const { parent } = current;
|
|
24
|
+
const parentNode = layout.getComponent(parent).node;
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
const childNodes = [...parentNode.children];
|
|
27
|
+
const currentNodeIndex = childNodes.findIndex(
|
|
28
|
+
(c) => c === current.node,
|
|
29
|
+
);
|
|
30
|
+
const nextNode = childNodes[currentNodeIndex + 2];
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, $tree);
|
|
43
|
-
}
|
|
32
|
+
next = layout.components.find((c) => c.node === nextNode);
|
|
33
|
+
nextSize = next.size;
|
|
34
|
+
currentSize = current.size;
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
let currentSize, nextSize, totalSize;
|
|
48
|
-
|
|
49
|
-
function handleMouseDown() {
|
|
37
|
+
function handleMouseDown(event) {
|
|
50
38
|
findNext();
|
|
51
39
|
|
|
52
40
|
if (!isDragging && next) {
|
|
@@ -62,6 +50,8 @@
|
|
|
62
50
|
nextRect = next.node.getBoundingClientRect();
|
|
63
51
|
|
|
64
52
|
visible = currentSize === nextSize;
|
|
53
|
+
|
|
54
|
+
handleMouseMove(event);
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
57
|
|
|
@@ -134,22 +124,20 @@
|
|
|
134
124
|
nextFlex = 0;
|
|
135
125
|
}
|
|
136
126
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
{ id: next.id, size: nextFlex },
|
|
140
|
-
]);
|
|
127
|
+
current.size = prevFlex;
|
|
128
|
+
next.size = nextFlex;
|
|
141
129
|
}
|
|
142
130
|
</script>
|
|
143
131
|
|
|
144
132
|
<div
|
|
145
133
|
class="resizer resizer--{direction}"
|
|
146
134
|
class:dragging={isDragging}
|
|
147
|
-
class:editing={
|
|
135
|
+
class:editing={layout.editing}
|
|
148
136
|
>
|
|
149
137
|
<div
|
|
150
138
|
class="resizer-hover"
|
|
151
139
|
class:visible
|
|
152
|
-
|
|
140
|
+
onmousedown={handleMouseDown}
|
|
153
141
|
></div>
|
|
154
142
|
</div>
|
|
155
143
|
<svelte:window on:mouseup={handleMouseUp} on:mousemove={handleMouseMove} />
|
|
@@ -168,7 +156,7 @@
|
|
|
168
156
|
|
|
169
157
|
.resizer-hover {
|
|
170
158
|
position: absolute;
|
|
171
|
-
z-index:
|
|
159
|
+
z-index: 200;
|
|
172
160
|
|
|
173
161
|
display: flex;
|
|
174
162
|
justify-content: center;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { tree } from '../stores/layout';
|
|
3
2
|
import LayoutComponent from './LayoutComponent.svelte';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
$: size = $tree.size;
|
|
4
|
+
let { children } = $props();
|
|
7
5
|
</script>
|
|
8
6
|
|
|
9
|
-
<LayoutComponent
|
|
10
|
-
|
|
7
|
+
<LayoutComponent>
|
|
8
|
+
{@render children?.()}
|
|
11
9
|
</LayoutComponent>
|
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
3
2
|
import IconCross from '../components/IconCross.svelte';
|
|
4
3
|
import ButtonInput from './fields/ButtonInput.svelte';
|
|
5
4
|
import Select from './fields/Select.svelte';
|
|
6
5
|
import { moduleNames } from './ModuleRenderer.svelte';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let splitRows = false;
|
|
18
|
-
|
|
19
|
-
function handleAddRow() {
|
|
20
|
-
dispatch('add-row');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function handleAddColumn() {
|
|
24
|
-
dispatch('add-column');
|
|
25
|
-
}
|
|
7
|
+
let {
|
|
8
|
+
moduleName,
|
|
9
|
+
isRoot,
|
|
10
|
+
vertical = false,
|
|
11
|
+
onAddColumn,
|
|
12
|
+
onAddRow,
|
|
13
|
+
onDelete,
|
|
14
|
+
onchange,
|
|
15
|
+
} = $props();
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
dispatch('delete');
|
|
29
|
-
}
|
|
17
|
+
const defaultValue = 'Select a module';
|
|
30
18
|
|
|
31
19
|
const options = [
|
|
32
20
|
{ value: undefined, label: defaultValue, disabled: true },
|
|
@@ -34,19 +22,14 @@
|
|
|
34
22
|
];
|
|
35
23
|
</script>
|
|
36
24
|
|
|
37
|
-
<div
|
|
38
|
-
class="toolbar"
|
|
39
|
-
class:root={isRoot}
|
|
40
|
-
class:split-columns={splitColumns}
|
|
41
|
-
class:split-rows={splitRows}
|
|
42
|
-
>
|
|
25
|
+
<div class="toolbar" class:root={isRoot}>
|
|
43
26
|
<div class="content" class:vertical>
|
|
44
27
|
{#if !isRoot}
|
|
45
28
|
<div class="module">
|
|
46
29
|
<Select
|
|
47
30
|
value={moduleName}
|
|
48
31
|
{options}
|
|
49
|
-
|
|
32
|
+
{onchange}
|
|
50
33
|
title="Switch module"
|
|
51
34
|
/>
|
|
52
35
|
</div>
|
|
@@ -57,9 +40,7 @@
|
|
|
57
40
|
label="Split in columns"
|
|
58
41
|
showLabel={false}
|
|
59
42
|
title="Split in columns"
|
|
60
|
-
|
|
61
|
-
on:mouseleave={() => (splitColumns = false)}
|
|
62
|
-
on:click={handleAddColumn}
|
|
43
|
+
onclick={onAddColumn}
|
|
63
44
|
>
|
|
64
45
|
<div class="icon-layout">
|
|
65
46
|
<div class="icon-box"></div>
|
|
@@ -70,9 +51,7 @@
|
|
|
70
51
|
label="Split in rows"
|
|
71
52
|
showLabel={false}
|
|
72
53
|
title="Split in rows"
|
|
73
|
-
|
|
74
|
-
on:mouseleave={() => (splitRows = false)}
|
|
75
|
-
on:click={handleAddRow}
|
|
54
|
+
onclick={onAddRow}
|
|
76
55
|
>
|
|
77
56
|
<div class="icon-layout row">
|
|
78
57
|
<div class="icon-box"></div>
|
|
@@ -84,7 +63,7 @@
|
|
|
84
63
|
<ButtonInput
|
|
85
64
|
label="Delete"
|
|
86
65
|
showLabel={false}
|
|
87
|
-
|
|
66
|
+
onclick={onDelete}
|
|
88
67
|
--color-text="white"
|
|
89
68
|
--background-color="var(--color-red)"
|
|
90
69
|
--box-shadow-color-active="var(--color-lightred)"
|
|
@@ -102,7 +81,7 @@
|
|
|
102
81
|
position: absolute;
|
|
103
82
|
top: 0;
|
|
104
83
|
left: 0;
|
|
105
|
-
|
|
84
|
+
z-index: 100;
|
|
106
85
|
|
|
107
86
|
display: grid;
|
|
108
87
|
justify-content: center;
|
|
@@ -116,47 +95,9 @@
|
|
|
116
95
|
background: rgba(0, 0, 0, 0.8);
|
|
117
96
|
}
|
|
118
97
|
|
|
119
|
-
.toolbar:after {
|
|
120
|
-
content: '';
|
|
121
|
-
|
|
122
|
-
position: absolute;
|
|
123
|
-
right: 0;
|
|
124
|
-
z-index: 100;
|
|
125
|
-
|
|
126
|
-
width: 6px;
|
|
127
|
-
height: 100%;
|
|
128
|
-
|
|
129
|
-
background-color: rgba(255, 255, 255, 0.2);
|
|
130
|
-
opacity: 0;
|
|
131
|
-
pointer-events: none;
|
|
132
|
-
transition: opacity 100ms ease;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.toolbar.split-columns:after {
|
|
136
|
-
opacity: 1;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.toolbar:before {
|
|
140
|
-
content: '';
|
|
141
|
-
|
|
142
|
-
position: absolute;
|
|
143
|
-
left: 0;
|
|
144
|
-
bottom: 0;
|
|
145
|
-
|
|
146
|
-
width: 100%;
|
|
147
|
-
height: 6px;
|
|
148
|
-
|
|
149
|
-
background-color: rgba(255, 255, 255, 0.2);
|
|
150
|
-
opacity: 0;
|
|
151
|
-
transition: opacity 100ms ease;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.toolbar.split-rows:before {
|
|
155
|
-
opacity: 1;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
98
|
.toolbar.root {
|
|
159
99
|
align-items: flex-start;
|
|
100
|
+
z-index: 200;
|
|
160
101
|
|
|
161
102
|
pointer-events: none;
|
|
162
103
|
}
|