Revision: 49672
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49672
Author:   campbellbarton
Date:     2012-08-07 18:45:24 +0000 (Tue, 07 Aug 2012)
Log Message:
-----------
minor edits to node view
- when single (non frame) node selected, dont zoom in, just pan.
- only reset the background when pressing home key

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_node/node_view.c

Modified: trunk/blender/source/blender/editors/space_node/node_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_view.c 2012-08-07 
18:41:47 UTC (rev 49671)
+++ trunk/blender/source/blender/editors/space_node/node_view.c 2012-08-07 
18:45:24 UTC (rev 49672)
@@ -36,6 +36,7 @@
 #include "BKE_context.h"
 #include "BKE_image.h"
 #include "BKE_screen.h"
+#include "BKE_node.h"
 
 #include "ED_node.h"  /* own include */
 #include "ED_screen.h"
@@ -65,9 +66,9 @@
        bNode *node;
        rctf cur_new;
        float oldwidth, oldheight, width, height;
-       int change = FALSE;
+       int tot = 0;
+       int has_frame = FALSE;
        
-       
        oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin;
        oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
 
@@ -77,42 +78,62 @@
                for (node = snode->edittree->nodes.first; node; node = 
node->next) {
                        if ((node->flag & node_flag) == node_flag) {
                                BLI_rctf_union(&cur_new, &node->totr);
-                               change = TRUE;
+                               tot++;
+
+                               if (node->type == NODE_FRAME) {
+                                       has_frame = TRUE;
+                               }
                        }
                }
        }
 
-       if (change) {
-               snode->xof = 0;
-               snode->yof = 0;
+       if (tot) {
                width = cur_new.xmax - cur_new.xmin;
                height = cur_new.ymax - cur_new.ymin;
 
-               if (width > height) {
-                       float newheight;
-                       newheight = oldheight * width / oldwidth;
-                       cur_new.ymin = cur_new.ymin - newheight / 4;
-                       cur_new.ymax = cur_new.ymax + newheight / 4;
+               /* for single non-frame nodes, don't zoom in, just pan view,
+                * but do allow zooming out, this allows for big nodes to be 
zoomed out */
+               if ((tot == 1) &&
+                   (has_frame == FALSE) &&
+                   ((oldwidth * oldheight) > (width * height)))
+               {
+                       /* center, don't zoom */
+                       BLI_rctf_resize(&cur_new, oldwidth, oldheight);
                }
                else {
-                       float newwidth;
-                       newwidth = oldwidth * height / oldheight;
-                       cur_new.xmin = cur_new.xmin - newwidth / 4;
-                       cur_new.xmax = cur_new.xmax + newwidth / 4;
+                       width = cur_new.xmax - cur_new.xmin;
+                       height = cur_new.ymax - cur_new.ymin;
+
+                       if (width > height) {
+                               float newheight;
+                               newheight = oldheight * width / oldwidth;
+                               cur_new.ymin = cur_new.ymin - newheight / 4;
+                               cur_new.ymax = cur_new.ymax + newheight / 4;
+                       }
+                       else {
+                               float newwidth;
+                               newwidth = oldwidth * height / oldheight;
+                               cur_new.xmin = cur_new.xmin - newwidth / 4;
+                               cur_new.xmax = cur_new.xmax + newwidth / 4;
+                       }
                }
 
                ar->v2d.tot = ar->v2d.cur = cur_new;
                UI_view2d_curRect_validate(&ar->v2d);
        }
 
-       return change;
+       return (tot != 0);
 }
 
 static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ARegion *ar = CTX_wm_region(C);
        SpaceNode *snode = CTX_wm_space_node(C);
-       
+
+       /* is this really needed? */
+       snode->xof = 0;
+       snode->yof = 0;
+
        if (space_node_view_flag(snode, ar, 0)) {
                ED_region_tag_redraw(ar);
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to