three things:
authorTon Roosendaal <ton@blender.org>
Thu, 8 Apr 2010 16:36:50 +0000 (16:36 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 8 Apr 2010 16:36:50 +0000 (16:36 +0000)
- ALT+Scrollwheel zooms backdrop in node editor
- Blender -d debug print will also print every event except mouse moves
  (needed to debug WM, some events are catched by OS)
- Changed order of keymaps... the default maps now are evaluated *after*
  the own custom maps, so you can make overrides or defaults.

source/blender/editors/screen/area.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/makesdna/DNA_space_types.h
source/blender/windowmanager/intern/wm_event_system.c

index 7c7f93e..cdfe179 100644 (file)
@@ -893,22 +893,22 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
        rect= sa->totrct;
        region_rect_recursive(sa, sa->regionbase.first, &rect, 0);
        
-       /* default area handlers */
-       ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag);
        /* checks spacedata, adds own handlers */
        if(sa->type->init)
                sa->type->init(wm, sa);
+       /* default area handlers */
+       ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag);
        
        /* region windows, default and own handlers */
        for(ar= sa->regionbase.first; ar; ar= ar->next) {
                region_subwindow(wm, win, ar);
                
                if(ar->swinid) {
-                       /* default region handlers */
-                       ed_default_handlers(wm, &ar->handlers, ar->type->keymapflag);
-
+                       /* own handlers */
                        if(ar->type->init)
                                ar->type->init(wm, ar);
+                       /* default region handlers */
+                       ed_default_handlers(wm, &ar->handlers, ar->type->keymapflag);
                }
                else {
                        /* prevent uiblocks to run */
index 5ba2c1c..5d3c00b 100644 (file)
@@ -1293,14 +1293,17 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                        glMatrixMode(GL_MODELVIEW);
                        glPushMatrix();
 
+                       /* keep this, saves us from a version patch */
+                       if(snode->zoom==0.0f) snode->zoom= 1.0f;
+                       
                        /* somehow the offset has to be calculated inverse */
                        
                        glaDefine2DArea(&ar->winrct);
                        /* ortho at pixel level curarea */
                        wmOrtho2(-0.375, ar->winx-0.375, -0.375, ar->winy-0.375);
                        
-                       x = (ar->winx-ibuf->x)/2 + snode->xof;
-                       y = (ar->winy-ibuf->y)/2 + snode->yof;
+                       x = (ar->winx-snode->zoom*ibuf->x)/2 + snode->xof;
+                       y = (ar->winy-snode->zoom*ibuf->y)/2 + snode->yof;
                        
                        if(!ibuf->rect) {
                                if(color_manage)
@@ -1310,8 +1313,11 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                                IMB_rect_from_float(ibuf);
                        }
 
-                       if(ibuf->rect)
+                       if(ibuf->rect) {
+                               glPixelZoom(snode->zoom, snode->zoom);
                                glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+                               glPixelZoom(1.0f, 1.0f);
+                       }
                        
                        glMatrixMode(GL_PROJECTION);
                        glPopMatrix();
index d211f8e..d6d1c8d 100644 (file)
@@ -775,6 +775,37 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
        ot->flag= OPTYPE_BLOCKING;
 }
 
+static int backimage_zoom(bContext *C, wmOperator *op)
+{
+       SpaceNode *snode= CTX_wm_space_node(C);
+       ARegion *ar= CTX_wm_region(C);
+       float fac= RNA_float_get(op->ptr, "factor");
+
+       snode->zoom *= fac;
+       ED_region_tag_redraw(ar);
+
+       return OPERATOR_FINISHED;
+}
+
+
+void NODE_OT_backimage_zoom(wmOperatorType *ot)
+{
+       
+       /* identifiers */
+       ot->name= "Background Image Zoom";
+       ot->idname= "NODE_OT_backimage_zoom";
+       
+       /* api callbacks */
+       ot->exec= backimage_zoom;
+       ot->poll= ED_operator_node_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_BLOCKING;
+
+       /* internal */
+       RNA_def_float(ot->srna, "factor", 1.2f, 0.0f, 10.0f, "Factor", "", 0.0f, 10.0f);
+}
+
 
 /* ********************** size widget operator ******************** */
 
index 11731b3..20c062a 100644 (file)
@@ -106,6 +106,7 @@ void NODE_OT_link_viewer(struct wmOperatorType *ot);
 void NODE_OT_read_fullsamplelayers(struct wmOperatorType *ot);
 void NODE_OT_read_renderlayers(struct wmOperatorType *ot);
 void NODE_OT_backimage_move(struct wmOperatorType *ot);
+void NODE_OT_backimage_zoom(struct wmOperatorType *ot);
 
 // XXXXXX
 
index 1e73ec0..1763525 100644 (file)
@@ -76,6 +76,7 @@ void node_operatortypes(void)
        WM_operatortype_append(NODE_OT_read_fullsamplelayers);
        
        WM_operatortype_append(NODE_OT_backimage_move);
+       WM_operatortype_append(NODE_OT_backimage_zoom);
 }
 
 void ED_operatormacros_node(void)
@@ -125,6 +126,11 @@ void node_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
        
        WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0);
+       kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", WHEELOUTMOUSE, KM_PRESS, KM_ALT, 0);
+               RNA_float_set(kmi->ptr, "factor", 0.83333f);
+       kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", WHEELINMOUSE, KM_PRESS, KM_ALT, 0);
+               RNA_float_set(kmi->ptr, "factor", 1.2f);
+       
        
        WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "replace", 1);
index 6cb22f3..1833318 100644 (file)
@@ -373,8 +373,9 @@ typedef struct SpaceNode {
        float aspect;
        void *curfont;
        
-       float xof, yof; /* offset for drawing the backdrop */
-       float mx, my;   /* mousepos for drawing socketless link */
+       float xof, yof;         /* offset for drawing the backdrop */
+       float zoom, padf;       /* zoom for backdrop */
+       float mx, my;           /* mousepos for drawing socketless link */
        
        struct bNodeTree *nodetree, *edittree;
        int treetype;                   /* treetype: as same nodetree->type */
index 08823e6..72e34ee 100644 (file)
@@ -1582,6 +1582,9 @@ void wm_event_do_handlers(bContext *C)
                while( (event= win->queue.first) ) {
                        int action = WM_HANDLER_CONTINUE;
 
+                       if((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE)
+                               printf("pass on evt %d val %d\n", event->type, event->val); 
+                       
                        wm_eventemulation(event);
 
                        CTX_wm_window_set(C, win);