-
Notifications
You must be signed in to change notification settings - Fork 492
fix: Improve legacy widget compatibility in vueNodes mode #7766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,10 +203,13 @@ const processedWidgets = computed((): ProcessedWidget[] => { | |
| }) | ||
|
|
||
| const gridTemplateRows = computed((): string => { | ||
| const widgets = toValue(processedWidgets) | ||
| return widgets | ||
| .filter((w) => !w.simplified.options?.hidden) | ||
| .map((w) => (shouldExpand(w.type) ? 'auto' : 'min-content')) | ||
| if (!nodeData?.widgets) return '' | ||
| const processedNames = new Set(toValue(processedWidgets).map((w) => w.name)) | ||
| return nodeData.widgets | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic should be order dependent. You should be able to test it with a subgraph that contains multiple of the same type of node with the same widget promoted. |
||
| .filter((w) => processedNames.has(w.name) && !w.options?.hidden) | ||
| .map((w) => | ||
| shouldExpand(w.type) || w.hasLayoutSize ? 'auto' : 'min-content' | ||
| ) | ||
| .join(' ') | ||
| }) | ||
| </script> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ const props = defineProps<{ | |
| }>() | ||
|
|
||
| const canvasEl = ref() | ||
| const containerHeight = ref(20) | ||
|
|
||
| const canvas: LGraphCanvas = useCanvasStore().canvas as LGraphCanvas | ||
| let node: LGraphNode | undefined | ||
|
|
@@ -52,9 +53,19 @@ onBeforeUnmount(() => { | |
| function draw() { | ||
| if (!widgetInstance || !node) return | ||
| const width = canvasEl.value.parentElement.clientWidth | ||
| const height = widgetInstance.computeSize | ||
| ? widgetInstance.computeSize(width)[1] | ||
| : 20 | ||
| // Priority: computedHeight (from litegraph) > computeLayoutSize > computeSize | ||
| let height = 20 | ||
| if (widgetInstance.computedHeight) { | ||
| height = widgetInstance.computedHeight | ||
| } else if (widgetInstance.computeLayoutSize) { | ||
| height = widgetInstance.computeLayoutSize(node).minHeight | ||
| } else if (widgetInstance.computeSize) { | ||
| height = widgetInstance.computeSize(width)[1] | ||
| } | ||
| containerHeight.value = height | ||
| // Set node.canvasHeight for legacy widgets that use it (e.g., Impact Pack) | ||
| // @ts-expect-error canvasHeight is a custom property used by some extensions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you augment the type instead of adding a suppression? |
||
| node.canvasHeight = height | ||
| widgetInstance.y = 0 | ||
| canvasEl.value.height = (height + 2) * scaleFactor | ||
| canvasEl.value.width = width * scaleFactor | ||
|
|
@@ -87,7 +98,10 @@ function handleMove(e: PointerEvent) { | |
| } | ||
| </script> | ||
| <template> | ||
| <div class="relative mx-[-12px] min-w-0 basis-0"> | ||
| <div | ||
| class="relative mx-[-12px] min-w-0 basis-0" | ||
| :style="{ minHeight: `${containerHeight}px` }" | ||
| > | ||
| <canvas | ||
| ref="canvasEl" | ||
| class="absolute mt-[-13px] w-full cursor-crosshair" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this line ever actually make a difference?
This
callbackis exclusively used on the vue side when@update:modelValueis emitted, but WidgetLegacy never emits (or defines a model) because all the values are tracked on the litegraph side.