Skip to content

Commit d35267e

Browse files
Litegraph updates.
Update from upstream repo. Auto select value in prompt. Increase maximum number of nodes to 10k.
1 parent 6781b18 commit d35267e

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

web/lib/litegraph.core.js

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
EVENT_LINK_COLOR: "#A86",
4949
CONNECTING_LINK_COLOR: "#AFA",
5050

51-
MAX_NUMBER_OF_NODES: 1000, //avoid infinite loops
51+
MAX_NUMBER_OF_NODES: 10000, //avoid infinite loops
5252
DEFAULT_POSITION: [100, 100], //default node position
5353
VALID_SHAPES: ["default", "box", "round", "card"], //,"circle"
5454

@@ -3788,16 +3788,42 @@
37883788

37893789
/**
37903790
* returns the bounding of the object, used for rendering purposes
3791-
* bounding is: [topleft_cornerx, topleft_cornery, width, height]
37923791
* @method getBounding
3793-
* @return {Float32Array[4]} the total size
3792+
* @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage
3793+
* @param compute_outer {boolean?} [optional] set to true to include the shadow and connection points in the bounding calculation
3794+
* @return {Float32Array[4]} the bounding box in format of [topleft_cornerx, topleft_cornery, width, height]
37943795
*/
3795-
LGraphNode.prototype.getBounding = function(out) {
3796+
LGraphNode.prototype.getBounding = function(out, compute_outer) {
37963797
out = out || new Float32Array(4);
3797-
out[0] = this.pos[0] - 4;
3798-
out[1] = this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT;
3799-
out[2] = this.flags.collapsed ? (this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) : this.size[0] + 4;
3800-
out[3] = this.flags.collapsed ? LiteGraph.NODE_TITLE_HEIGHT : this.size[1] + LiteGraph.NODE_TITLE_HEIGHT;
3798+
const nodePos = this.pos;
3799+
const isCollapsed = this.flags.collapsed;
3800+
const nodeSize = this.size;
3801+
3802+
let left_offset = 0;
3803+
// 1 offset due to how nodes are rendered
3804+
let right_offset = 1 ;
3805+
let top_offset = 0;
3806+
let bottom_offset = 0;
3807+
3808+
if (compute_outer) {
3809+
// 4 offset for collapsed node connection points
3810+
left_offset = 4;
3811+
// 6 offset for right shadow and collapsed node connection points
3812+
right_offset = 6 + left_offset;
3813+
// 4 offset for collapsed nodes top connection points
3814+
top_offset = 4;
3815+
// 5 offset for bottom shadow and collapsed node connection points
3816+
bottom_offset = 5 + top_offset;
3817+
}
3818+
3819+
out[0] = nodePos[0] - left_offset;
3820+
out[1] = nodePos[1] - LiteGraph.NODE_TITLE_HEIGHT - top_offset;
3821+
out[2] = isCollapsed ?
3822+
(this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) + right_offset :
3823+
nodeSize[0] + right_offset;
3824+
out[3] = isCollapsed ?
3825+
LiteGraph.NODE_TITLE_HEIGHT + bottom_offset :
3826+
nodeSize[1] + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset;
38013827

38023828
if (this.onBounding) {
38033829
this.onBounding(out);
@@ -7674,7 +7700,7 @@ LGraphNode.prototype.executeAction = function(action)
76747700
continue;
76757701
}
76767702

7677-
if (!overlapBounding(this.visible_area, n.getBounding(temp))) {
7703+
if (!overlapBounding(this.visible_area, n.getBounding(temp, true))) {
76787704
continue;
76797705
} //out of the visible area
76807706

@@ -11336,6 +11362,7 @@ LGraphNode.prototype.executeAction = function(action)
1133611362
name_element.innerText = title;
1133711363
var value_element = dialog.querySelector(".value");
1133811364
value_element.value = value;
11365+
value_element.select();
1133911366

1134011367
var input = value_element;
1134111368
input.addEventListener("keydown", function(e) {

0 commit comments

Comments
 (0)