|
27 | 27 |
|
28 | 28 | let graph: HTMLDivElement | undefined; |
29 | 29 |
|
30 | | - // Key value is node id + input/output index |
31 | | - // Imports/Export are stored at a key value of 0 |
32 | | -
|
33 | 30 | $: gridSpacing = calculateGridSpacing($nodeGraph.transform.scale); |
34 | 31 | $: gridDotRadius = 1 + Math.floor($nodeGraph.transform.scale - 0.5 + 0.001) / 2; |
35 | 32 |
|
|
115 | 112 | return iconMap[icon] || "NodeNodes"; |
116 | 113 | } |
117 | 114 |
|
118 | | - function toggleLayerDisplay(displayAsLayer: boolean, toggleId: bigint) { |
119 | | - let node = $nodeGraph.nodes.get(toggleId); |
120 | | - if (node) editor.handle.setToNodeOrLayer(node.id, displayAsLayer); |
121 | | - } |
122 | | -
|
123 | | - function canBeToggledBetweenNodeAndLayer(toggleDisplayAsLayerNodeId: bigint) { |
124 | | - return $nodeGraph.nodes.get(toggleDisplayAsLayerNodeId)?.canBeLayer || false; |
125 | | - } |
126 | | -
|
127 | 115 | function createNode(nodeType: string) { |
128 | 116 | if ($nodeGraph.contextMenuInformation === undefined) return; |
129 | 117 |
|
|
176 | 164 | return `M-2,-2 L${nodeWidth + 2},-2 L${nodeWidth + 2},${nodeHeight + 2} L-2,${nodeHeight + 2}z ${rectangles.join(" ")}`; |
177 | 165 | } |
178 | 166 |
|
179 | | - function dataTypeTooltip(value: FrontendGraphInput | FrontendGraphOutput): string { |
180 | | - return `Data Type: ${value.resolvedType}`; |
181 | | - } |
| 167 | + // function dataTypeTooltip(value: FrontendGraphInput | FrontendGraphOutput): string { |
| 168 | + // return `Data Type: ${value.resolvedType}`; |
| 169 | + // } |
182 | 170 |
|
183 | 171 | // function validTypesText(value: FrontendGraphInput): string { |
184 | 172 | // const validTypes = value.validTypes.length > 0 ? value.validTypes.map((x) => `• ${x}`).join("\n") : "None"; |
185 | 173 | // return `Valid Types:\n${validTypes}`; |
186 | 174 | // } |
187 | 175 |
|
188 | | - function outputConnectedToText(output: FrontendGraphOutput): string { |
189 | | - if (output.connectedTo.length === 0) return "Connected to nothing"; |
| 176 | + // function outputConnectedToText(output: FrontendGraphOutput): string { |
| 177 | + // if (output.connectedTo.length === 0) return "Connected to nothing"; |
190 | 178 |
|
191 | | - return `Connected to:\n${output.connectedTo.join("\n")}`; |
192 | | - } |
| 179 | + // return `Connected to:\n${output.connectedTo.join("\n")}`; |
| 180 | + // } |
193 | 181 |
|
194 | | - function inputConnectedToText(input: FrontendGraphInput): string { |
195 | | - return `Connected to:\n${input.connectedTo}`; |
196 | | - } |
| 182 | + // function inputConnectedToText(input: FrontendGraphInput): string { |
| 183 | + // return `Connected to:\n${input.connectedTo}`; |
| 184 | + // } |
197 | 185 |
|
198 | 186 | function zipWithUndefined(arr1: FrontendGraphInput[], arr2: FrontendGraphOutput[]) { |
199 | 187 | const maxLength = Math.max(arr1.length, arr2.length); |
|
224 | 212 | top: `${$nodeGraph.contextMenuInformation.contextMenuCoordinates.y * $nodeGraph.transform.scale + $nodeGraph.transform.y}px`, |
225 | 213 | }} |
226 | 214 | > |
227 | | - {#if typeof $nodeGraph.contextMenuInformation.contextMenuData === "string" && $nodeGraph.contextMenuInformation.contextMenuData === "CreateNode"} |
228 | | - <NodeCatalog on:selectNodeType={(e) => createNode(e.detail)} /> |
229 | | - {:else if $nodeGraph.contextMenuInformation.contextMenuData && "compatibleType" in $nodeGraph.contextMenuInformation.contextMenuData} |
230 | | - <NodeCatalog initialSearchTerm={$nodeGraph.contextMenuInformation.contextMenuData.compatibleType || ""} on:selectNodeType={(e) => createNode(e.detail)} /> |
231 | | - {:else} |
232 | | - {@const contextMenuData = $nodeGraph.contextMenuInformation.contextMenuData} |
| 215 | + {#if $nodeGraph.contextMenuInformation.contextMenuData.type == "CreateNode"} |
| 216 | + <NodeCatalog initialSearchTerm={$nodeGraph.contextMenuInformation.contextMenuData.data.compatibleType || ""} on:selectNodeType={(e) => createNode(e.detail)} /> |
| 217 | + {:else if $nodeGraph.contextMenuInformation.contextMenuData.type == "ModifyNode"} |
233 | 218 | <LayoutRow class="toggle-layer-or-node"> |
234 | 219 | <TextLabel>Display as</TextLabel> |
235 | 220 | <RadioInput |
236 | | - selectedIndex={contextMenuData.currentlyIsNode ? 0 : 1} |
| 221 | + selectedIndex={$nodeGraph.contextMenuInformation.contextMenuData.data.currentlyIsNode ? 0 : 1} |
237 | 222 | entries={[ |
238 | 223 | { |
239 | 224 | value: "node", |
240 | 225 | label: "Node", |
241 | | - action: () => toggleLayerDisplay(false, contextMenuData.nodeId), |
| 226 | + action: () => editor.handle.setToNodeOrLayer($nodeGraph.contextMenuInformation.contextMenuData.data.nodeId, false), |
242 | 227 | }, |
243 | 228 | { |
244 | 229 | value: "layer", |
245 | 230 | label: "Layer", |
246 | | - action: () => toggleLayerDisplay(true, contextMenuData.nodeId), |
| 231 | + action: () => editor.handle.setToNodeOrLayer($nodeGraph.contextMenuInformation.contextMenuData.data.nodeId, true), |
247 | 232 | }, |
248 | 233 | ]} |
249 | | - disabled={!canBeToggledBetweenNodeAndLayer(contextMenuData.nodeId)} |
| 234 | + disabled={!$nodeGraph.contextMenuInformation.contextMenuData.data.canBeLayer} |
250 | 235 | /> |
251 | 236 | </LayoutRow> |
252 | 237 | <Separator type="Section" direction="Vertical" /> |
|
264 | 249 | style={`left: ${$nodeGraph.error.position.x}px; |
265 | 250 | top: ${$nodeGraph.error.position.y}px;`} |
266 | 251 | transition:fade={FADE_TRANSITION} |
267 | | - title="" |
268 | 252 | data-node-error>{$nodeGraph.error.error}</span |
269 | 253 | > |
270 | 254 | <span |
271 | 255 | class="node-error hover" |
272 | 256 | style={`left: ${$nodeGraph.error.position.x}px; |
273 | 257 | top: ${$nodeGraph.error.position.y}px;`} |
274 | 258 | transition:fade={FADE_TRANSITION} |
275 | | - title="" |
276 | 259 | data-node-error>{$nodeGraph.error.error}</span |
277 | 260 | > |
278 | 261 | </div> |
|
338 | 321 | style:--offset-left={($nodeGraph.updateImportsExports.importPosition.x - 8) / 24} |
339 | 322 | style:--offset-top={($nodeGraph.updateImportsExports.importPosition.y - 8) / 24 + index} |
340 | 323 | > |
341 | | - <title>{`${dataTypeTooltip(frontendOutput)}\n\n${outputConnectedToText(frontendOutput)}`}</title> |
342 | 324 | {#if frontendOutput.connectedTo.length > 0} |
343 | 325 | <path d="M0,6.306A1.474,1.474,0,0,0,2.356,7.724L7.028,5.248c1.3-.687,1.3-1.809,0-2.5L2.356.276A1.474,1.474,0,0,0,0,1.694Z" fill="var(--data-color)" /> |
344 | 326 | {:else} |
|
382 | 364 | }} |
383 | 365 | /> |
384 | 366 | {#if index > 0} |
385 | | - <div class="reorder-drag-grip" title="Reorder this export" /> |
| 367 | + <div class="reorder-drag-grip" /> |
386 | 368 | {/if} |
387 | 369 | {/if} |
388 | 370 | </div> |
|
410 | 392 | style:--offset-left={($nodeGraph.updateImportsExports.exportPosition.x - 8) / 24} |
411 | 393 | style:--offset-top={($nodeGraph.updateImportsExports.exportPosition.y - 8) / 24 + index} |
412 | 394 | > |
413 | | - <title>{`${dataTypeTooltip(frontendInput)}\n\n${inputConnectedToText(frontendInput)}`}</title> |
414 | 395 | {#if frontendInput.connectedTo !== "nothing"} |
415 | 396 | <path d="M0,6.306A1.474,1.474,0,0,0,2.356,7.724L7.028,5.248c1.3-.687,1.3-1.809,0-2.5L2.356.276A1.474,1.474,0,0,0,0,1.694Z" fill="var(--data-color)" /> |
416 | 397 | {:else} |
|
428 | 409 | > |
429 | 410 | {#if (hoveringExportIndex === index || editingNameExportIndex === index) && $nodeGraph.updateImportsExports.addImportExport} |
430 | 411 | {#if index > 0} |
431 | | - <div class="reorder-drag-grip" title="Reorder this export" /> |
| 412 | + <div class="reorder-drag-grip" /> |
432 | 413 | {/if} |
433 | 414 | <IconButton |
434 | 415 | size={16} |
|
0 commit comments