Skip to content

Commit

Permalink
Fix primitive size on load (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered authored Nov 3, 2024
1 parent 38847e1 commit 394df49
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/extensions/core/widgetInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export function convertToInput(
const { type } = getWidgetType(config)

// Add input and store widget config for creating on primitive node
const sz = node.size
const [oldWidth, oldHeight] = node.size
const inputIsOptional = !!widget.options?.inputIsOptional
const input = node.addInput(widget.name, type, {
widget: { name: widget.name, [GET_CONFIG]: () => config },
Expand All @@ -501,21 +501,27 @@ export function convertToInput(
}

// Restore original size but grow if needed
node.setSize([Math.max(sz[0], node.size[0]), Math.max(sz[1], node.size[1])])
node.setSize([
Math.max(oldWidth, node.size[0]),
Math.max(oldHeight, node.size[1])
])
return input
}

function convertToWidget(node, widget) {
showWidget(widget)
const sz = node.size
const [oldWidth, oldHeight] = node.size
node.removeInput(node.inputs.findIndex((i) => i.widget?.name === widget.name))

for (const widget of node.widgets) {
widget.last_y -= LiteGraph.NODE_SLOT_HEIGHT
}

// Restore original size but grow if needed
node.setSize([Math.max(sz[0], node.size[0]), Math.max(sz[1], node.size[1])])
node.setSize([
Math.max(oldWidth, node.size[0]),
Math.max(oldHeight, node.size[1])
])
}

function getWidgetType(config: InputSpec) {
Expand Down

0 comments on commit 394df49

Please sign in to comment.