Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2006-08-13 16:01:07 +0400
committerMatt Ebb <matt@mke3.net>2006-08-13 16:01:07 +0400
commit28f23d9b81ee194794b0ea088be076c24ceabbfb (patch)
treec7e810d929dd8a25bc12c146c2ace24d58786be3 /source
parent4718a22cd01d10ec9712323cf7050a11d0ae3ba2 (diff)
* Added Shift MMB in the node editor to pan the backdrop image display
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/src/drawnode.c8
-rw-r--r--source/blender/src/editnode.c70
3 files changed, 78 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 98ca418cdde..c885c709c0e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -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 */
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index cd443f049ed..f496b3f30ef 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -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);
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index 535f94ef585..55b93c47cda 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -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"
@@ -78,11 +79,13 @@
#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 */