Skip to content

Commit b6fb7de

Browse files
author
tamat
committed
fix in grapg\/output
1 parent 8c073dc commit b6fb7de

3 files changed

Lines changed: 45 additions & 33 deletions

File tree

build/litegraph.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
NO_TITLE: 1,
9090
TRANSPARENT_TITLE: 2,
9191
AUTOHIDE_TITLE: 3,
92+
VERTICAL_LAYOUT: "vertical", // arrange nodes vertically
9293

9394
proxy: null, //used to redirect calls
9495
node_images_path: "",
@@ -1260,7 +1261,7 @@
12601261
* Positions every node in a more readable manner
12611262
* @method arrange
12621263
*/
1263-
LGraph.prototype.arrange = function(margin) {
1264+
LGraph.prototype.arrange = function (margin, layout) {
12641265
margin = margin || 100;
12651266

12661267
var nodes = this.computeExecutionOrder(false, true);
@@ -1285,12 +1286,14 @@
12851286
var y = margin + LiteGraph.NODE_TITLE_HEIGHT;
12861287
for (var j = 0; j < column.length; ++j) {
12871288
var node = column[j];
1288-
node.pos[0] = x;
1289-
node.pos[1] = y;
1290-
if (node.size[0] > max_size) {
1291-
max_size = node.size[0];
1289+
node.pos[0] = (layout == LiteGraph.VERTICAL_LAYOUT) ? y : x;
1290+
node.pos[1] = (layout == LiteGraph.VERTICAL_LAYOUT) ? x : y;
1291+
max_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 1 : 0;
1292+
if (node.size[max_size_index] > max_size) {
1293+
max_size = node.size[max_size_index];
12921294
}
1293-
y += node.size[1] + margin + LiteGraph.NODE_TITLE_HEIGHT;
1295+
node_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 0 : 1;
1296+
y += node.size[node_size_index] + margin + LiteGraph.NODE_TITLE_HEIGHT;
12941297
}
12951298
x += max_size + margin;
12961299
}
@@ -14694,7 +14697,7 @@ if (typeof exports != "undefined") {
1469414697
this.addInput("", "");
1469514698

1469614699
this.name_in_graph = "";
14697-
this.properties = {};
14700+
this.properties = { name: "", type: "" };
1469814701
var that = this;
1469914702

1470014703
// Object.defineProperty(this.properties, "name", {
@@ -14771,18 +14774,20 @@ if (typeof exports != "undefined") {
1477114774
else if (name == "value") {
1477214775
}
1477314776
}
14774-
14775-
14777+
1477614778
GraphOutput.prototype.updateType = function () {
1477714779
var type = this.properties.type;
1477814780
if (this.type_widget)
1477914781
this.type_widget.value = type;
1478014782

1478114783
//update output
1478214784
if (this.inputs[0].type != type) {
14783-
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
14784-
this.disconnectInput(0);
14785-
this.inputs[0].type = type;
14785+
14786+
if ( type == "action" || type == "event")
14787+
type = LiteGraph.EVENT;
14788+
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
14789+
this.disconnectInput(0);
14790+
this.inputs[0].type = type;
1478614791
}
1478714792

1478814793
//update graph
@@ -14800,7 +14805,7 @@ if (typeof exports != "undefined") {
1480014805

1480114806
GraphOutput.prototype.onAction = function(action, param) {
1480214807
if (this.properties.type == LiteGraph.ACTION) {
14803-
this.graph.trigger(this.properties.name, param);
14808+
this.graph.trigger( this.properties.name, param );
1480414809
}
1480514810
};
1480614811

build/litegraph_mini.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
NO_TITLE: 1,
9090
TRANSPARENT_TITLE: 2,
9191
AUTOHIDE_TITLE: 3,
92+
VERTICAL_LAYOUT: "vertical", // arrange nodes vertically
9293

9394
proxy: null, //used to redirect calls
9495
node_images_path: "",
@@ -1260,7 +1261,7 @@
12601261
* Positions every node in a more readable manner
12611262
* @method arrange
12621263
*/
1263-
LGraph.prototype.arrange = function(margin) {
1264+
LGraph.prototype.arrange = function (margin, layout) {
12641265
margin = margin || 100;
12651266

12661267
var nodes = this.computeExecutionOrder(false, true);
@@ -1285,12 +1286,14 @@
12851286
var y = margin + LiteGraph.NODE_TITLE_HEIGHT;
12861287
for (var j = 0; j < column.length; ++j) {
12871288
var node = column[j];
1288-
node.pos[0] = x;
1289-
node.pos[1] = y;
1290-
if (node.size[0] > max_size) {
1291-
max_size = node.size[0];
1289+
node.pos[0] = (layout == LiteGraph.VERTICAL_LAYOUT) ? y : x;
1290+
node.pos[1] = (layout == LiteGraph.VERTICAL_LAYOUT) ? x : y;
1291+
max_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 1 : 0;
1292+
if (node.size[max_size_index] > max_size) {
1293+
max_size = node.size[max_size_index];
12921294
}
1293-
y += node.size[1] + margin + LiteGraph.NODE_TITLE_HEIGHT;
1295+
node_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 0 : 1;
1296+
y += node.size[node_size_index] + margin + LiteGraph.NODE_TITLE_HEIGHT;
12941297
}
12951298
x += max_size + margin;
12961299
}
@@ -14694,7 +14697,7 @@ if (typeof exports != "undefined") {
1469414697
this.addInput("", "");
1469514698

1469614699
this.name_in_graph = "";
14697-
this.properties = {};
14700+
this.properties = { name: "", type: "" };
1469814701
var that = this;
1469914702

1470014703
// Object.defineProperty(this.properties, "name", {
@@ -14771,18 +14774,20 @@ if (typeof exports != "undefined") {
1477114774
else if (name == "value") {
1477214775
}
1477314776
}
14774-
14775-
14777+
1477614778
GraphOutput.prototype.updateType = function () {
1477714779
var type = this.properties.type;
1477814780
if (this.type_widget)
1477914781
this.type_widget.value = type;
1478014782

1478114783
//update output
1478214784
if (this.inputs[0].type != type) {
14783-
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
14784-
this.disconnectInput(0);
14785-
this.inputs[0].type = type;
14785+
14786+
if ( type == "action" || type == "event")
14787+
type = LiteGraph.EVENT;
14788+
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
14789+
this.disconnectInput(0);
14790+
this.inputs[0].type = type;
1478614791
}
1478714792

1478814793
//update graph
@@ -14800,7 +14805,7 @@ if (typeof exports != "undefined") {
1480014805

1480114806
GraphOutput.prototype.onAction = function(action, param) {
1480214807
if (this.properties.type == LiteGraph.ACTION) {
14803-
this.graph.trigger(this.properties.name, param);
14808+
this.graph.trigger( this.properties.name, param );
1480414809
}
1480514810
};
1480614811

src/nodes/base.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@
562562
this.addInput("", "");
563563

564564
this.name_in_graph = "";
565-
this.properties = {};
565+
this.properties = { name: "", type: "" };
566566
var that = this;
567567

568568
// Object.defineProperty(this.properties, "name", {
@@ -639,18 +639,20 @@
639639
else if (name == "value") {
640640
}
641641
}
642-
643-
642+
644643
GraphOutput.prototype.updateType = function () {
645644
var type = this.properties.type;
646645
if (this.type_widget)
647646
this.type_widget.value = type;
648647

649648
//update output
650649
if (this.inputs[0].type != type) {
651-
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
652-
this.disconnectInput(0);
653-
this.inputs[0].type = type;
650+
651+
if ( type == "action" || type == "event")
652+
type = LiteGraph.EVENT;
653+
if (!LiteGraph.isValidConnection(this.inputs[0].type, type))
654+
this.disconnectInput(0);
655+
this.inputs[0].type = type;
654656
}
655657

656658
//update graph
@@ -668,7 +670,7 @@
668670

669671
GraphOutput.prototype.onAction = function(action, param) {
670672
if (this.properties.type == LiteGraph.ACTION) {
671-
this.graph.trigger(this.properties.name, param);
673+
this.graph.trigger( this.properties.name, param );
672674
}
673675
};
674676

0 commit comments

Comments
 (0)