From 2d7b4d1579d3bfeae1b0776013b3c75122fb3b5c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 22 Feb 2011 21:22:27 +0000 Subject: Empty groups are now displayed with some basic spacing in edit mode. Long socket lists don't outgrow the group box any more; the box height is adjusted to fit the length of the socket list instead. --- source/blender/editors/space_node/node_draw.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_node/node_draw.c') diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 77337f57765..a5f69a2dee2 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -390,6 +390,9 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) int counter; int dy; + rect->xmin = rect->xmax = gnode->locx; + rect->ymin = rect->ymax = gnode->locy; + /* center them, is a bit of abuse of locx and locy though */ for(node= ngroup->nodes.first; node; node= node->next) { node->locx+= gnode->locx; @@ -413,14 +416,9 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) } /* add some room for links to group sockets */ - rect->xmin -= 3*NODE_DY; - rect->xmax += 3*NODE_DY; - - if(counter==1) return; /* should be prevented? */ - - rect->xmin-= NODE_DY; + rect->xmin -= 4*NODE_DY; + rect->xmax += 4*NODE_DY; rect->ymin-= NODE_DY; - rect->xmax+= NODE_DY; rect->ymax+= NODE_DY; /* input sockets */ @@ -429,6 +427,13 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) gsock->locx = rect->xmin; sock->locx = rect->xmin - NODE_GROUP_FRAME; sock->locy = gsock->locy = dy; + + /* prevent long socket lists from growing out of the group box */ + if (dy-3*NODE_DYS < rect->ymin) + rect->ymin = dy-3*NODE_DYS; + if (dy+3*NODE_DYS > rect->ymax) + rect->ymax = dy+3*NODE_DYS; + dy -= 2*NODE_DY; } @@ -438,6 +443,13 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) gsock->locx = rect->xmax; sock->locx = rect->xmax + NODE_GROUP_FRAME; sock->locy = gsock->locy = dy - NODE_DYS; + + /* prevent long socket lists from growing out of the group box */ + if (dy-3*NODE_DYS < rect->ymin) + rect->ymin = dy-3*NODE_DYS; + if (dy+3*NODE_DYS > rect->ymax) + rect->ymax = dy+3*NODE_DYS; + dy -= 2*NODE_DY; } } -- cgit v1.2.3