[Bf-blender-cvs] [d61f8a5] master: Fix T40094 Faulty resizing behavior of frame node.

Lukas Tönne noreply at git.blender.org
Fri May 9 09:00:15 CEST 2014


Commit: d61f8a5a22b7658582470cd15ba5f3713e9c3570
Author: Lukas Tönne
Date:   Fri May 9 08:51:37 2014 +0200
https://developer.blender.org/rBd61f8a5a22b7658582470cd15ba5f3713e9c3570

Fix T40094 Faulty resizing behavior of frame node.

Frame nodes still have the "hidden" flag like all other nodes, but this
has to be ignored during resizing. width/height range for the frame
nodes must be unlimited for this to work correctly.

===================================================================

M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_edit.c

===================================================================

diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 78333de..8ef1d0b 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -335,7 +335,7 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
 {
 	const float margin = 1.5f * U.widget_unit;
 	NodeFrame *data = (NodeFrame *)node->storage;
-	int bbinit;
+	bool bbinit;
 	bNode *tnode;
 	rctf rect, noderect;
 	float xmax, ymax;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index f9b5b09..fc0c82f 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -874,37 +874,38 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
 			dy = (my - nsw->mystart) / UI_DPI_FAC;
 			
 			if (node) {
-				if (node->flag & NODE_HIDDEN) {
-					float widthmin = 0.0f;
-					float widthmax = 100.0f;
-					if (nsw->directions & NODE_RESIZE_RIGHT) {
-						node->miniwidth = nsw->oldminiwidth + dx;
-						CLAMP(node->miniwidth, widthmin, widthmax);
-					}
-					if (nsw->directions & NODE_RESIZE_LEFT) {
-						float locmax = nsw->oldlocx + nsw->oldminiwidth;
-						
-						node->locx = nsw->oldlocx + dx;
-						CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
-						node->miniwidth = locmax - node->locx;
-					}
+				/* width can use node->width or node->miniwidth (hidden nodes) */
+				float *pwidth;
+				float oldwidth, widthmin, widthmax;
+				/* ignore hidden flag for frame nodes */
+				bool use_hidden = (node->type != NODE_FRAME);
+				if (use_hidden && node->flag & NODE_HIDDEN) {
+					pwidth = &node->miniwidth;
+					oldwidth = nsw->oldminiwidth;
+					widthmin = 0.0f;
+					widthmax = 100.0f;
 				}
 				else {
-					float widthmin = node->typeinfo->minwidth;
-					float widthmax = node->typeinfo->maxwidth;
+					pwidth = &node->width;
+					oldwidth = nsw->oldwidth;
+					widthmin = node->typeinfo->minwidth;
+					widthmax = node->typeinfo->maxwidth;
+				}
+				
+				{
 					if (nsw->directions & NODE_RESIZE_RIGHT) {
-						node->width = nsw->oldwidth + dx;
-						CLAMP(node->width, widthmin, widthmax);
+						*pwidth = oldwidth + dx;
+						CLAMP(*pwidth, widthmin, widthmax);
 					}
 					if (nsw->directions & NODE_RESIZE_LEFT) {
-						float locmax = nsw->oldlocx + nsw->oldwidth;
+						float locmax = nsw->oldlocx + oldwidth;
 						
 						node->locx = nsw->oldlocx + dx;
 						CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
-						node->width = locmax - node->locx;
+						*pwidth = locmax - node->locx;
 					}
 				}
-			
+				
 				/* height works the other way round ... */
 				{
 					float heightmin = UI_DPI_FAC * node->typeinfo->minheight;




More information about the Bf-blender-cvs mailing list