From 7f64b743a7d082a0ff0327636f41b4f0c502226e Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Fri, 5 May 2023 00:49:34 -0500 Subject: [PATCH] Start of properties panel --- src/lib/components/BlockContainer.svelte | 87 ++++++------ src/lib/components/ComfyApp.svelte | 38 +++-- src/lib/components/ComfyProperties.svelte | 166 ++++++++++++++++++++++ src/lib/components/WidgetContainer.svelte | 35 +++-- src/lib/stores/layoutState.ts | 14 +- src/lib/widgets/ComboWidget.svelte | 4 +- src/scss/global.scss | 2 +- 7 files changed, 278 insertions(+), 68 deletions(-) create mode 100644 src/lib/components/ComfyProperties.svelte diff --git a/src/lib/components/BlockContainer.svelte b/src/lib/components/BlockContainer.svelte index 263ebfb..5667c15 100644 --- a/src/lib/components/BlockContainer.svelte +++ b/src/lib/components/BlockContainer.svelte @@ -16,14 +16,17 @@ export let zIndex: number = 0; export let classes: string[] = []; export let showHandles: boolean = false; + let attrsChanged: Writable | null = null; let children: IDragItem[] | null = null; const flipDurationMs = 100; $: if (container) { children = $layoutState.allItems[container.id].children; + attrsChanged = container.attrsChanged } else { children = null; + attrsChanged = null } function handleConsider(evt: any) { @@ -38,52 +41,48 @@ {#if container && children} -
1}> - - {#if container.attrs.showTitle} - - {/if} -
1} - use:dndzone="{{ - items: children, - flipDurationMs, - centreDraggedOnCursor: true, - morphDisabled: true, - dropFromOthersDisabled: zIndex === 0, - dragDisabled: zIndex === 0 || $layoutState.currentSelection.length > 2 || $uiState.uiEditMode === "disabled" - }}" - on:consider="{handleConsider}" - on:finalize="{handleFinalize}" - > - {#each children.filter(item => item.id !== SHADOW_PLACEHOLDER_ITEM_ID) as item(item.id)} -
- - {#if item[SHADOW_ITEM_MARKER_PROPERTY_NAME]} -
- {/if} + {#key $attrsChanged} +
1}> + + {#if container.attrs.showTitle} + + {/if} +
1} + use:dndzone="{{ + items: children, + flipDurationMs, + centreDraggedOnCursor: true, + morphDisabled: true, + dropFromOthersDisabled: zIndex === 0, + dragDisabled: zIndex === 0 || $layoutState.currentSelection.length > 2 || $uiState.uiEditMode === "disabled" + }}" + on:consider="{handleConsider}" + on:finalize="{handleFinalize}" + > + {#each children.filter(item => item.id !== SHADOW_PLACEHOLDER_ITEM_ID) as item(item.id)} +
+ + {#if item[SHADOW_ITEM_MARKER_PROPERTY_NAME]} +
+ {/if} +
+ {/each}
- {/each} + {#if showHandles} +
+ {/if} +
- {#if showHandles} -
- {/if} - -
+ {/key} {/if} diff --git a/src/lib/components/WidgetContainer.svelte b/src/lib/components/WidgetContainer.svelte index 1fd3b41..f37712e 100644 --- a/src/lib/components/WidgetContainer.svelte +++ b/src/lib/components/WidgetContainer.svelte @@ -5,11 +5,13 @@ import layoutState, { type ContainerLayout, type WidgetLayout, type IDragItem } from "$lib/stores/layoutState"; import { startDrag, stopDrag } from "$lib/utils" import BlockContainer from "./BlockContainer.svelte" + import { type Writable } from "svelte/store" export let dragItem: IDragItem | null = null; export let zIndex: number = 0; export let classes: string[] = []; let container: ContainerLayout | null = null; + let attrsChanged: Writable | null = null; let widget: WidgetLayout | null = null; let showHandles: boolean = false; @@ -17,13 +19,16 @@ dragItem = null; container = null; widget = null; + attrsChanged = null; } else if (dragItem.type === "container") { container = dragItem as ContainerLayout; + attrsChanged = container.attrsChanged; widget = null; } else if (dragItem.type === "widget") { widget = dragItem as WidgetLayout; + attrsChanged = widget.attrsChanged; container = null; } @@ -35,21 +40,31 @@ $: if ($queueState && widget && widget.node) { dragItem.isNodeExecuting = $queueState.runningNodeId === widget.node.id; } + + function getWidgetClass() { + const title = widget.node.type.replace("/", "-").replace(".", "-") + return `widget--${title}` + } {#if container} - + {#key $attrsChanged} + + {/key} {:else if widget && widget.node} -
1} - class:selected={$uiState.uiEditMode !== "disabled" && $layoutState.currentSelection.includes(widget.id)} - class:is-executing={$queueState.runningNodeId && $queueState.runningNodeId == widget.node.id} - > - -
- {#if showHandles} -
- {/if} + {#key $attrsChanged} +
1} + class:selected={$uiState.uiEditMode !== "disabled" && $layoutState.currentSelection.includes(widget.id)} + class:is-executing={$queueState.runningNodeId && $queueState.runningNodeId == widget.node.id} + > + +
+ {#if showHandles} +
+ {/if} + {/key} {/if}