Skip to content

Commit

Permalink
Merge pull request #2 from flyingshutter/fizzle296
Browse files Browse the repository at this point in the history
Fizzle296
  • Loading branch information
FizzleDorf authored Mar 31, 2023
2 parents 27bae07 + 12ba214 commit 5dcbade
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
37 changes: 20 additions & 17 deletions web/extensions/core/widgetInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,7 @@ app.registerExtension({
this.outputs[0].name = type;
this.outputs[0].widget = widget;

//make sure the seedControl is added to the correct Primitive node labelled "seed"
if (widget.name === "seed") {
const seed = this.#createWidget(widget.config, theirNode, widget.name);
const seedControl = addSeedControlWidget(this, seed, "randomize");
//this.widgets[0].link = [seedControl];//tried using all different links, not just link
this.title = "seed";
}
else
this.#createWidget(widget.config, theirNode, widget.name);
this.#createWidget(widget.config, theirNode, widget.name);
}

#createWidget(inputData, node, widgetName) {
Expand All @@ -286,12 +278,27 @@ app.registerExtension({

let widget;

if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget;
// ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>"
// common example is "INT:seed"
// so let's check for those first
let combinedWidgetType = type + ":" + widgetName;
if (combinedWidgetType in ComfyWidgets) {
// widget = (ComfyWidgets[combinedWidgetType](this, "value", inputData, app) || {}).widget;
widget = (ComfyWidgets[combinedWidgetType](this, widgetName, inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, widgetName /*"value"*/, null, () => { }, {});
// we did not find a subtype, so proceed with "<type>" only
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, widgetName /*"value"*/, null, () => { }, {});
}

// addSeedControlWidget(node, seed.widget, "randomize");

if (widget.type === "number") {
addSeedControlWidget(this, widget, "fixed seed");
}
}


if (node?.widgets && widget) {

Expand All @@ -301,10 +308,6 @@ app.registerExtension({
}
}

if (widget.type === "combo") {
addSeedControlWidget(this, widget, "randomize");
}

// When our value changes, update other widgets to reflect our changes
// e.g. so LoadImage shows correct image
const callback = widget.callback;
Expand Down
7 changes: 4 additions & 3 deletions web/scripts/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ function getNumberDefaults(inputData, defaultStep) {
}

export function addSeedControlWidget(node, targetWidget, defaultValue = "randomize", values) {
const seedControl = node.addWidget("combo", "seed control after generating", "randomize", function (v) { }, {
values: ["fixed seed", "increment", "decrement", "randomize"]
const seedControl = node.addWidget("combo", "seed control after generating", defaultValue, function (v) { }, {
values: ["fixed seed", "increment", "decrement", "randomize"],
serialize: false, // Don't include this in prompt.
})
seedControl.afterQueued = () => {

Expand Down Expand Up @@ -59,7 +60,7 @@ function seedWidget(node, inputName, inputData) {
const seedControl = addSeedControlWidget(node, seed.widget, "randomize");

seed.widget.linkedWidgets = [seedControl];
return { widget: seed, seedControl };
return seed;
}

const MultilineSymbol = Symbol();
Expand Down

0 comments on commit 5dcbade

Please sign in to comment.