Fix fit group to nodes with reroute and collapsed nodes

This commit is contained in:
Jairo Correa 2023-10-16 16:00:01 -03:00
parent e8c02219ee
commit 682c84ccf3
1 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,18 @@ function addNodesToGroup(group, nodes=[]) {
nx2 = node.pos[0] + node.size[0]
ny2 = node.pos[1] + node.size[1]
if (node.type != "Reroute") {
ny1 -= LiteGraph.NODE_TITLE_HEIGHT;
}
if (node.flags?.collapsed) {
ny2 = ny1 + LiteGraph.NODE_TITLE_HEIGHT;
if (node?._collapsed_width) {
nx2 = nx1 + Math.round(node._collapsed_width);
}
}
if (x1 == -1 || nx1 < x1) {
x1 = nx1;
}
@ -42,7 +54,7 @@ function addNodesToGroup(group, nodes=[]) {
var padding = 10;
y1 = y1 - Math.round(group.font_size * 2.7);
y1 = y1 - Math.round(group.font_size * 1.4);
group.pos = [x1 - padding, y1 - padding];
group.size = [x2 - x1 + padding * 2, y2 - y1 + padding * 2];