diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-07 22:45:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-07 22:45:24 +0400 |
commit | 4005b88b30cfb842bc2738d3ba03d80a78a0612c (patch) | |
tree | 061c255e1ab042043b40eed8fbfe65ddcf39a25e /source/blender | |
parent | c985a40abb80a7e62170d7f2e736377cca4623e8 (diff) |
minor edits to node view
- when single (non frame) node selected, dont zoom in, just pan.
- only reset the background when pressing home key
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_node/node_view.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 66e08fe0ffe..7ad283b9869 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -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,8 +66,8 @@ static int space_node_view_flag(SpaceNode *snode, ARegion *ar, const int node_fl 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 @@ static int space_node_view_flag(SpaceNode *snode, ARegion *ar, const int node_fl 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); |