mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-26 01:34:07 +00:00
widgets can now be serialized if you set node.serialize_widgets = true
This commit is contained in:
@@ -27,7 +27,7 @@ function Subgraph()
|
||||
var that = this;
|
||||
this.size = [140,80];
|
||||
this.properties = { enabled: true };
|
||||
this.addInput("enabled","boolean");
|
||||
this.enabled = true;
|
||||
|
||||
//create inner graph
|
||||
this.subgraph = new LGraph();
|
||||
@@ -51,6 +51,11 @@ Subgraph.title = "Subgraph";
|
||||
Subgraph.desc = "Graph inside a node";
|
||||
Subgraph.title_color = "#334";
|
||||
|
||||
Subgraph.prototype.onGetInputs = function()
|
||||
{
|
||||
return [["enabled","boolean"]];
|
||||
}
|
||||
|
||||
Subgraph.prototype.onDrawTitle = function(ctx)
|
||||
{
|
||||
if(this.flags.collapsed)
|
||||
@@ -90,7 +95,8 @@ Subgraph.prototype.onAction = function( action, param )
|
||||
|
||||
Subgraph.prototype.onExecute = function()
|
||||
{
|
||||
if( !this.getInputOrProperty("enabled") )
|
||||
this.enabled = this.getInputOrProperty("enabled");
|
||||
if( !this.enabled )
|
||||
return;
|
||||
|
||||
//send inputs to subgraph global inputs
|
||||
@@ -115,6 +121,12 @@ Subgraph.prototype.onExecute = function()
|
||||
}
|
||||
}
|
||||
|
||||
Subgraph.prototype.sendEventToAllNodes = function( eventname, param, mode )
|
||||
{
|
||||
if(this.enabled)
|
||||
this.subgraph.sendEventToAllNodes( eventname, param, mode );
|
||||
}
|
||||
|
||||
//**** INPUTS ***********************************
|
||||
Subgraph.prototype.onSubgraphTrigger = function(event, param)
|
||||
{
|
||||
@@ -225,6 +237,7 @@ Subgraph.prototype.clone = function()
|
||||
return node;
|
||||
}
|
||||
|
||||
LiteGraph.Subgraph = Subgraph;
|
||||
LiteGraph.registerNodeType("graph/subgraph", Subgraph );
|
||||
|
||||
|
||||
@@ -630,7 +643,7 @@ LiteGraph.registerNodeType("basic/cast", Cast);
|
||||
function Console()
|
||||
{
|
||||
this.mode = LiteGraph.ON_EVENT;
|
||||
this.size = [60,20];
|
||||
this.size = [80,30];
|
||||
this.addProperty( "msg", "" );
|
||||
this.addInput("log", LiteGraph.EVENT);
|
||||
this.addInput("msg",0);
|
||||
@@ -665,6 +678,36 @@ Console.prototype.onGetInputs = function()
|
||||
LiteGraph.registerNodeType("basic/console", Console );
|
||||
|
||||
|
||||
//Show value inside the debug console
|
||||
function Alert()
|
||||
{
|
||||
this.mode = LiteGraph.ON_EVENT;
|
||||
this.addProperty( "msg", "" );
|
||||
this.addInput("", LiteGraph.EVENT);
|
||||
var that = this;
|
||||
this.widget = this.addWidget("text","Text","",function(v){
|
||||
that.properties.msg = v;
|
||||
});
|
||||
this.widgets_up = true;
|
||||
this.size = [200,30];
|
||||
}
|
||||
|
||||
Alert.title = "Alert";
|
||||
Alert.desc = "Show an alert window";
|
||||
Alert.color = "#510";
|
||||
|
||||
Alert.prototype.onConfigure = function(o)
|
||||
{
|
||||
this.widget.value = o.properties.msg;
|
||||
}
|
||||
|
||||
Alert.prototype.onAction = function(action, param)
|
||||
{
|
||||
var msg = this.properties.msg;
|
||||
setTimeout(function(){ alert(msg); },10 );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("basic/alert", Alert );
|
||||
|
||||
//Execites simple code
|
||||
function NodeScript()
|
||||
|
||||
@@ -107,6 +107,13 @@ function EventCounter()
|
||||
EventCounter.title = "Counter";
|
||||
EventCounter.desc = "Counts events";
|
||||
|
||||
EventCounter.prototype.getTitle = function()
|
||||
{
|
||||
if(this.flags.collapsed)
|
||||
return String(this.num);
|
||||
return this.title;
|
||||
}
|
||||
|
||||
EventCounter.prototype.onAction = function(action, param)
|
||||
{
|
||||
var v = this.num;
|
||||
|
||||
@@ -7,10 +7,12 @@ var LiteGraph = global.LiteGraph;
|
||||
function WidgetButton()
|
||||
{
|
||||
this.addOutput( "", LiteGraph.EVENT );
|
||||
this.addOutput( "", "boolean" );
|
||||
this.addProperty( "text","click me" );
|
||||
this.addProperty( "font_size", 30 );
|
||||
this.addProperty( "message", "" );
|
||||
this.size = [164,84];
|
||||
this.clicked = false;
|
||||
}
|
||||
|
||||
WidgetButton.title = "Button";
|
||||
@@ -45,17 +47,21 @@ var LiteGraph = global.LiteGraph;
|
||||
if(local_pos[0] > 1 && local_pos[1] > 1 && local_pos[0] < (this.size[0] - 2) && local_pos[1] < (this.size[1] - 2) )
|
||||
{
|
||||
this.clicked = true;
|
||||
this.trigger( "clicked", this.properties.message );
|
||||
this.triggerSlot( 0, this.properties.message );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
WidgetButton.prototype.onExecute = function()
|
||||
{
|
||||
this.setOutputData(1,this.clicked);
|
||||
}
|
||||
|
||||
WidgetButton.prototype.onMouseUp = function(e)
|
||||
{
|
||||
this.clicked = false;
|
||||
}
|
||||
|
||||
|
||||
LiteGraph.registerNodeType("widget/button", WidgetButton );
|
||||
|
||||
|
||||
@@ -128,7 +134,7 @@ var LiteGraph = global.LiteGraph;
|
||||
function WidgetNumber()
|
||||
{
|
||||
this.addOutput("",'number');
|
||||
this.size = [74,54];
|
||||
this.size = [80,60];
|
||||
this.properties = {min:-1000,max:1000,value:1,step:1};
|
||||
this.old_y = -1;
|
||||
this._remainder = 0;
|
||||
@@ -366,11 +372,12 @@ var LiteGraph = global.LiteGraph;
|
||||
text: "V"
|
||||
};
|
||||
var that = this;
|
||||
this.size = [80,60];
|
||||
this.size = [140,40];
|
||||
this.slider = this.addWidget("slider","V", this.properties.value, function(v){ that.properties.value = v; }, this.properties );
|
||||
this.widgets_up = true;
|
||||
}
|
||||
|
||||
WidgetSliderGUI.title = "Internal Slider";
|
||||
WidgetSliderGUI.title = "Inner Slider";
|
||||
|
||||
WidgetSliderGUI.prototype.onPropertyChanged = function(name,value)
|
||||
{
|
||||
@@ -604,6 +611,9 @@ var LiteGraph = global.LiteGraph;
|
||||
|
||||
WidgetPanel.prototype.onDrawForeground = function(ctx)
|
||||
{
|
||||
if(this.flags.collapsed)
|
||||
return;
|
||||
|
||||
if(this.lineargradient == null)
|
||||
this.createGradient(ctx);
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ if(global.glMatrix)
|
||||
function Math3DQuaternion()
|
||||
{
|
||||
this.addOutput("quat","quat");
|
||||
this.properties = { x:0, y:0, z:0, w: 1 };
|
||||
this.properties = { x:0, y:0, z:0, w: 1, normalize: false };
|
||||
this._value = quat.create();
|
||||
}
|
||||
|
||||
@@ -321,13 +321,19 @@ if(global.glMatrix)
|
||||
|
||||
Math3DQuaternion.prototype.onExecute = function()
|
||||
{
|
||||
this._value[0] = this.properties.x;
|
||||
this._value[1] = this.properties.y;
|
||||
this._value[2] = this.properties.z;
|
||||
this._value[3] = this.properties.w;
|
||||
this._value[0] = this.getInputOrProperty("x");
|
||||
this._value[1] = this.getInputOrProperty("y");
|
||||
this._value[2] = this.getInputOrProperty("z");
|
||||
this._value[3] = this.getInputOrProperty("w");
|
||||
if( this.properties.normalize )
|
||||
quat.normalize( this._value, this._value );
|
||||
this.setOutputData( 0, this._value );
|
||||
}
|
||||
|
||||
Math3DQuaternion.prototype.onGetInputs = function(){
|
||||
return [["x","number"],["y","number"],["z","number"],["w","number"]];
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math3d/quaternion", Math3DQuaternion );
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user