* Added Shift MMB in the node editor to pan the backdrop image display
authorMatt Ebb <matt@mke3.net>
Sun, 13 Aug 2006 12:01:07 +0000 (12:01 +0000)
committerMatt Ebb <matt@mke3.net>
Sun, 13 Aug 2006 12:01:07 +0000 (12:01 +0000)
source/blender/makesdna/DNA_space_types.h
source/blender/src/drawnode.c
source/blender/src/editnode.c

index 98ca418cddea5d046d189f47d5a10478975f9da8..c885c709c0e772cd5cbc5119b11973a7242a8f18 100644 (file)
@@ -316,6 +316,8 @@ typedef struct SpaceNode {
        float aspect;
        void *curfont;
        
+       float xof, yof; /* offset for drawing the backdrop */
+       
        struct bNodeTree *nodetree, *edittree;
        int treetype, pad;                      /* treetype: as same nodetree->type */
        
index cd443f049eda94fede12f1a1fe0139c3c089f8d1..f496b3f30ef982f6fe1613eb7868c852a81774f5 100644 (file)
@@ -1205,6 +1205,7 @@ static void draw_nodespace_grid(SpaceNode *snode)
 static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode)
 {
        Image *ima;
+       int x, y; 
        
        draw_nodespace_grid(snode);
        
@@ -1217,10 +1218,13 @@ static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode)
                        /* ortho at pixel level curarea */
                        myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
 
+                       x = (sa->winx-ima->ibuf->x)/2 + snode->xof;
+                       y = (sa->winx-ima->ibuf->y)/2 + snode->yof;
+
                        if(ima->ibuf->rect)
-                               glaDrawPixelsSafe((sa->winx-ima->ibuf->x)/2, (sa->winy-ima->ibuf->y)/2, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ima->ibuf->rect);
+                               glaDrawPixelsSafe(x, y, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ima->ibuf->rect);
                        else
-                               glaDrawPixelsSafe((sa->winx-ima->ibuf->x)/2, (sa->winy-ima->ibuf->y)/2, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_FLOAT, ima->ibuf->rect_float);
+                               glaDrawPixelsSafe(x, y, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_FLOAT, ima->ibuf->rect_float);
                        
                        /* sort this out, this should not be needed */
                        myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax);
index 535f94ef58503f0e4425c89ff67fdc2addff5834..55b93c47cdab0c391e518d7b1b71bba26208f4c1 100644 (file)
@@ -54,6 +54,7 @@
 #include "BKE_scene.h"
 #include "BKE_utildefines.h"
 
+#include "BIF_cursors.h"
 #include "BIF_editview.h"
 #include "BIF_gl.h"
 #include "BIF_graphics.h"
 #include "BDR_editobject.h"
 
 #include "RE_pipeline.h"
+#include "IMB_imbuf_types.h"
 
 #include "blendef.h"
 #include "butspace.h"
 #include "PIL_time.h"
 #include "mydevice.h"
+#include "winlay.h"
 
 
 /* currently called from BIF_preview_changed */
@@ -697,6 +700,9 @@ void snode_home(ScrArea *sa, SpaceNode *snode)
                }
        }
        snode->v2d.tot= snode->v2d.cur;
+       
+       snode->xof = snode->yof = 0.0;
+       
        test_view2d(G.v2d, sa->winx, sa->winy);
        
 }
@@ -727,6 +733,65 @@ void snode_zoom_in(ScrArea *sa)
        test_view2d(G.v2d, sa->winx, sa->winy);
 }
 
+static void snode_bg_viewmove(SpaceNode *snode)
+{
+       ScrArea *sa;
+       short mval[2], mvalo[2];
+       short rectx, recty, xmin, xmax, ymin, ymax, pad;
+       Window *win;
+       int oldcursor;
+       Image *ima;
+       
+       ima= (Image *)find_id("IM", "Viewer Node");
+       
+       sa = snode->area;
+       
+       if(ima && ima->ibuf) {
+               rectx = ima->ibuf->x;
+               recty = ima->ibuf->y;
+       } else {
+               rectx = recty = 1;
+       }
+       
+       pad = 10;
+       xmin = -(sa->winx/2) - rectx/2 + pad;
+       xmax = sa->winx/2 + rectx/2 - pad;
+       ymin = -(sa->winy/2) - recty/2 + pad;
+       ymax = sa->winy/2 + recty/2 - pad;
+       
+       getmouseco_sc(mvalo);
+       
+       /* store the old cursor to temporarily change it */
+       oldcursor=get_cursor();
+       win=winlay_get_active_window();
+       
+       SetBlenderCursor(BC_NSEW_SCROLLCURSOR);
+       
+       while(get_mbut()&(L_MOUSE|M_MOUSE)) {
+               
+               getmouseco_sc(mval);
+               
+               if(mvalo[0]!=mval[0] || mvalo[1]!=mval[1]) {
+                       
+                       snode->xof -= (mvalo[0]-mval[0]);
+                       snode->yof -= (mvalo[1]-mval[1]);
+                       
+                       /* prevent dragging image outside of the window and losing it! */
+                       CLAMP(snode->xof, xmin, xmax);
+                       CLAMP(snode->yof, ymin, ymax);
+                       
+                       mvalo[0]= mval[0];
+                       mvalo[1]= mval[1];
+                       
+                       scrarea_do_windraw(curarea);
+                       screen_swapbuffers();
+               }
+               else BIF_wait_for_statechange();
+       }
+       
+       window_set_cursor(win, oldcursor);
+}
+
 /* checks mouse position, and returns found node/socket */
 /* type is SOCK_IN and/or SOCK_OUT */
 static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, int in_out)
@@ -1838,6 +1903,11 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
 
                        break;
                case MIDDLEMOUSE:
+                       if (G.qual==LR_SHIFTKEY) {
+                               snode_bg_viewmove(snode);
+                       } else {
+                               view2dmove(event);
+                       }
                case WHEELUPMOUSE:
                case WHEELDOWNMOUSE:
                        view2dmove(event);      /* in drawipo.c */