2.5
authorTon Roosendaal <ton@blender.org>
Tue, 27 Jan 2009 17:12:40 +0000 (17:12 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 27 Jan 2009 17:12:40 +0000 (17:12 +0000)
Compositor now uses threaded jobs.

- updates happen per preview node! Check this file for
  fun: http://www.blender.org/bf/composite_image.blend
  (any compo node could get preview!)
- had to ensure the composite data gets fully copied before
  it executes thread, so editing is not frustrated.
- put back node buttons (missing init)
- added WM_jobs api call to check for running job,
  illustrated with red light icon in 'use nodes' button.
- added another callback to WM_jobs, to initialize.
  use this init to ensure you only do it when job really
  starts.
- added an extra notifier option for WM_jobs, to signal
  finished job (like redraw image view)
- fixed file read error, it copied the screen it read,
  instead of using it.
- commented out annoying prints for missing ops in imagewin

23 files changed:
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_node.h [new file with mode: 0644]
source/blender/editors/preview/previewrender.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/space_node.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_window.c

index 669ee11926b23087252de5fd3e0b4d19ac15d6da..bf2da8925069664964b794fe8e7c48975eaa4a4e 100644 (file)
@@ -106,6 +106,7 @@ typedef struct bNodeType {
 #define NODE_BREAK             2
 #define NODE_FINISHED  4
 #define NODE_FREEBUFS  8
+#define NODE_SKIPPED   16
 
 /* nodetype->nclass, for add-menu and themes */
 #define NODE_CLASS_INPUT               0
@@ -148,6 +149,11 @@ void                       ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
 void                   ntreeClearPreview(struct bNodeTree *ntree);
 
 void                   ntreeFreeCache(struct bNodeTree *ntree);
+                               
+                               /* calls allowing threaded composite */
+struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
+void                   ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
+void                   ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
 
 /* ************** GENERIC API, NODES *************** */
 
index e7ccb15d923d978c5c9a8f80d3a4016dbc04c12f..f6407e9416c13626b7757fab868bc63d50fc52d7 100644 (file)
@@ -1158,6 +1158,104 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
        return newtree;
 }
 
+/* *************** preview *********** */
+/* if node->preview, then we assume the rect to exist */
+
+static void node_free_preview(bNode *node)
+{
+       if(node->preview) {
+               if(node->preview->rect)
+                       MEM_freeN(node->preview->rect);
+               MEM_freeN(node->preview);
+               node->preview= NULL;
+       }       
+}
+
+static void node_init_preview(bNode *node, int xsize, int ysize)
+{
+       
+       if(node->preview==NULL) {
+               node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
+               //              printf("added preview %s\n", node->name);
+       }
+       
+       /* node previews can get added with variable size this way */
+       if(xsize==0 || ysize==0)
+               return;
+       
+       /* sanity checks & initialize */
+       if(node->preview->rect) {
+               if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
+                       MEM_freeN(node->preview->rect);
+                       node->preview->rect= NULL;
+               }
+       }
+       
+       if(node->preview->rect==NULL) {
+               node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
+               node->preview->xsize= xsize;
+               node->preview->ysize= ysize;
+       }
+}
+
+void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
+{
+       bNode *node;
+       
+       if(ntree==NULL)
+               return;
+       
+       for(node= ntree->nodes.first; node; node= node->next) {
+               if(node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
+                       node_init_preview(node, xsize, ysize);
+               if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
+                       ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
+       }               
+}
+
+static void nodeClearPreview(bNode *node)
+{
+       if(node->preview && node->preview->rect)
+               memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
+}
+
+/* use it to enforce clear */
+void ntreeClearPreview(bNodeTree *ntree)
+{
+       bNode *node;
+       
+       if(ntree==NULL)
+               return;
+       
+       for(node= ntree->nodes.first; node; node= node->next) {
+               if(node->typeinfo->flag & NODE_PREVIEW)
+                       nodeClearPreview(node);
+               if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
+                       ntreeClearPreview((bNodeTree *)node->id);
+       }               
+}
+
+/* hack warning! this function is only used for shader previews, and 
+since it gets called multiple times per pixel for Ztransp we only
+add the color once. Preview gets cleared before it starts render though */
+void nodeAddToPreview(bNode *node, float *col, int x, int y)
+{
+       bNodePreview *preview= node->preview;
+       if(preview) {
+               if(x>=0 && y>=0) {
+                       if(x<preview->xsize && y<preview->ysize) {
+                               float *tar= preview->rect+ 4*((preview->xsize*y) + x);
+                               //if(tar[0]==0.0f) {
+                               QUATCOPY(tar, col);
+                               //}
+                       }
+                       //else printf("prv out bound x y %d %d\n", x, y);
+               }
+               //else printf("prv out bound x y %d %d\n", x, y);
+       }
+}
+
+
 /* ************** Free stuff ********** */
 
 /* goes over entire tree */
@@ -1215,11 +1313,8 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
        BLI_freelistN(&node->inputs);
        BLI_freelistN(&node->outputs);
        
-       if(node->preview) {
-               if(node->preview->rect)
-                       MEM_freeN(node->preview->rect);
-               MEM_freeN(node->preview);
-       }
+       node_free_preview(node);
+
        if(node->typeinfo && node->typeinfo->freestoragefunc) {
                node->typeinfo->freestoragefunc(node);
        }
@@ -1652,14 +1747,8 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node)
 
                for(sock= node->outputs.first; sock; sock= sock->next) {
                        if(sock->ns.data) {
-                               free_compbuf(sock->ns.data);
-                               sock->ns.data= NULL;
-                               
-                               //if(node->preview && node->preview->rect) {
-                               //      MEM_freeN(node->preview->rect);
-                               //      node->preview->rect= NULL;
-                               //}
-                                       
+                               //free_compbuf(sock->ns.data);
+                               //sock->ns.data= NULL;
                        }
                }
                node->need_exec= 1;
@@ -1683,95 +1772,6 @@ void NodeTagIDChanged(bNodeTree *ntree, ID *id)
 }
 
 
-/* *************** preview *********** */
-
-/* if node->preview, then we assume the rect to exist */
-
-static void nodeInitPreview(bNode *node, int xsize, int ysize)
-{
-       
-       if(node->preview==NULL) {
-               node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
-//             printf("added preview %s\n", node->name);
-       }
-       
-       /* node previews can get added with variable size this way */
-       if(xsize==0 || ysize==0)
-               return;
-       
-       /* sanity checks & initialize */
-       if(node->preview->rect) {
-               if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
-                       MEM_freeN(node->preview->rect);
-                       node->preview->rect= NULL;
-               }
-       }
-       
-       if(node->preview->rect==NULL) {
-               node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
-               node->preview->xsize= xsize;
-               node->preview->ysize= ysize;
-       }
-}
-
-void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
-{
-       bNode *node;
-       
-       if(ntree==NULL)
-               return;
-       
-       for(node= ntree->nodes.first; node; node= node->next) {
-               if(node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
-                       nodeInitPreview(node, xsize, ysize);
-               if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
-                       ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
-       }               
-}
-
-static void nodeClearPreview(bNode *node)
-{
-       if(node->preview && node->preview->rect)
-               memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
-}
-
-/* use it to enforce clear */
-void ntreeClearPreview(bNodeTree *ntree)
-{
-       bNode *node;
-       
-       if(ntree==NULL)
-               return;
-       
-       for(node= ntree->nodes.first; node; node= node->next) {
-               if(node->typeinfo->flag & NODE_PREVIEW)
-                       nodeClearPreview(node);
-               if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
-                       ntreeClearPreview((bNodeTree *)node->id);
-       }               
-}
-
-/* hack warning! this function is only used for shader previews, and 
-   since it gets called multiple times per pixel for Ztransp we only
-   add the color once. Preview gets cleared before it starts render though */
-void nodeAddToPreview(bNode *node, float *col, int x, int y)
-{
-       bNodePreview *preview= node->preview;
-       if(preview) {
-               if(x>=0 && y>=0) {
-                       if(x<preview->xsize && y<preview->ysize) {
-                               float *tar= preview->rect+ 4*((preview->xsize*y) + x);
-                               //if(tar[0]==0.0f) {
-                                       QUATCOPY(tar, col);
-                               //}
-                       }
-                       //else printf("prv out bound x y %d %d\n", x, y);
-               }
-               //else printf("prv out bound x y %d %d\n", x, y);
-       }
-}
-
-
 
 /* ******************* executing ************* */
 
@@ -2205,7 +2205,7 @@ static void *exec_composite_node(void *node_v)
        bNodeStack *nsin[MAX_SOCKET];   /* arbitrary... watch this */
        bNodeStack *nsout[MAX_SOCKET];  /* arbitrary... watch this */
        bNode *node= node_v;
-       ThreadData *thd= (ThreadData *)node->new_node; /* abuse */
+       ThreadData *thd= (ThreadData *)node->threaddata;
        
        node_get_stack(node, thd->stack, nsin, nsout);
        
@@ -2300,7 +2300,7 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd)
                }
                else {
                        /* tag for getExecutableNode() */
-                       node->exec= NODE_READY|NODE_FINISHED;
+                       node->exec= NODE_READY|NODE_FINISHED|NODE_SKIPPED;
                        
                }
        }
@@ -2410,7 +2410,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
 
        /* sets need_exec tags in nodes */
        totnode= setExecutableNodes(ntree, &thdata);
-       
+
        BLI_init_threads(&threads, exec_composite_node, rd->threads);
        
        while(rendering) {
@@ -2418,7 +2418,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
                if(BLI_available_threads(&threads)) {
                        node= getExecutableNode(ntree);
                        if(node) {
-
+                               
                                if(ntree->timecursor)
                                        ntree->timecursor(ntree->tch, totnode);
                                if(ntree->stats_draw) {
@@ -2428,7 +2428,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
                                }
                                totnode--;
                                
-                               node->new_node = (bNode *)&thdata;
+                               node->threaddata = &thdata;
                                node->exec= NODE_PROCESSING;
                                BLI_insert_thread(&threads, node);
                        }
@@ -2461,12 +2461,115 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
                }
        }
        
-       
        BLI_end_threads(&threads);
        
        ntreeEndExecTree(ntree);
 }
 
+
+/* ********** copy composite tree entirely, to allow threaded exec ******************* */
+/* ***************** do NOT execute this in a thread!               ****************** */
+
+/* returns localized composite tree for execution in threads */
+/* local tree then owns all compbufs */
+bNodeTree *ntreeLocalize(bNodeTree *ntree)
+{
+       bNodeTree *ltree= ntreeCopyTree(ntree, 0);
+       bNode *node;
+       bNodeSocket *sock;
+       
+       /* move over the compbufs */
+       /* right after ntreeCopyTree() oldsock pointers are valid */
+       for(node= ntree->nodes.first; node; node= node->next) {
+               
+               /* store new_node pointer to original */
+               node->new_node->new_node= node;
+               /* ensure new user input gets handled ok */
+               node->need_exec= 0;
+               
+               for(sock= node->outputs.first; sock; sock= sock->next) {
+                       
+                       sock->new_sock->ns.data= sock->ns.data;
+                       sock->ns.data= NULL;
+                       sock->new_sock->new_sock= sock;
+               }
+       }
+       
+       return ltree;
+}
+
+static int node_exists(bNodeTree *ntree, bNode *testnode)
+{
+       bNode *node= ntree->nodes.first;
+       for(; node; node= node->next)
+               if(node==testnode)
+                       return 1;
+       return 0;
+}
+
+static int outsocket_exists(bNode *node, bNodeSocket *testsock)
+{
+       bNodeSocket *sock= node->outputs.first;
+       for(; sock; sock= sock->next)
+               if(sock==testsock)
+                       return 1;
+       return 0;
+}
+
+
+/* sync local composite with real tree */
+/* local composite is supposed to be running, be careful moving previews! */
+void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
+{
+       bNode *lnode;
+       
+       /* move over the compbufs and previews */
+       for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
+               if( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) {
+                       if(node_exists(ntree, lnode->new_node)) {
+                               
+                               if(lnode->preview && lnode->preview->rect) {
+                                       node_free_preview(lnode->new_node);
+                                       lnode->new_node->preview= lnode->preview;
+                                       lnode->preview= NULL;
+                               }
+                       }
+               }
+       }
+}
+
+/* merge local tree results back, and free local tree */
+/* we have to assume the editor already changed completely */
+void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
+{
+       bNode *lnode;
+       bNodeSocket *lsock;
+       
+       /* move over the compbufs and previews */
+       for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
+               if(node_exists(ntree, lnode->new_node)) {
+                       
+                       if(lnode->preview && lnode->preview->rect) {
+                               node_free_preview(lnode->new_node);
+                               lnode->new_node->preview= lnode->preview;
+                               lnode->preview= NULL;
+                       }
+                       
+                       for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) {
+                               if(outsocket_exists(lnode->new_node, lsock->new_sock)) {
+                                       lsock->new_sock->ns.data= lsock->ns.data;
+                                       lsock->ns.data= NULL;
+                                       lsock->new_sock= NULL;
+                               }
+                       }
+               }
+       }
+       ntreeFreeTree(localtree);
+       MEM_freeN(localtree);
+}
+
+/* *********************************************** */
+
 /* GPU material from shader nodes */
 
 static void gpu_from_node_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack *gs)
index 1ff658aa864f2176e8d3630512762c05e51ee51f..bd266b08e870ff64f8674accd8e2321421dce0c5 100644 (file)
@@ -4152,6 +4152,22 @@ static void lib_link_screen(FileData *fd, Main *main)
 
                                                ssound->sound= newlibadr_us(fd, sc->id.lib, ssound->sound);
                                        }
+                                       else if(sl->spacetype==SPACE_NODE) {
+                                               SpaceNode *snode= (SpaceNode *)sl;
+                                               
+                                               snode->id= newlibadr(fd, sc->id.lib, snode->id);
+                                               
+                                               /* internal data, a bit patchy */
+                                               if(snode->id) {
+                                                       if(GS(snode->id->name)==ID_MA)
+                                                               snode->nodetree= ((Material *)snode->id)->nodetree;
+                                                       else if(GS(snode->id->name)==ID_SCE)
+                                                               snode->nodetree= ((Scene *)snode->id)->nodetree;
+                                                       else if(GS(snode->id->name)==ID_TE)
+                                                               snode->nodetree= ((Tex *)snode->id)->nodetree;
+                                               }
+                                               
+                                       }
                                }
                                sa= sa->next;
                        }
@@ -4345,8 +4361,19 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                else if(sl->spacetype==SPACE_NODE) {
                                        SpaceNode *snode= (SpaceNode *)sl;
                                        
-                                       snode->nodetree= snode->edittree= NULL;
-                                       snode->flag |= SNODE_DO_PREVIEW;
+                                       snode->id= restore_pointer_by_name(newmain, snode->id, 1);
+                                       snode->edittree= NULL;
+                                       
+                                       if(snode->id==NULL)
+                                               snode->nodetree= NULL;
+                                       else {
+                                               if(GS(snode->id->name)==ID_MA)
+                                                       snode->nodetree= ((Material *)snode->id)->nodetree;
+                                               else if(GS(snode->id->name)==ID_SCE)
+                                                       snode->nodetree= ((Scene *)snode->id)->nodetree;
+                                               else if(GS(snode->id->name)==ID_TE)
+                                                       snode->nodetree= ((Tex *)snode->id)->nodetree;
+                                       }
                                }
                        }
                        sa= sa->next;
@@ -4544,7 +4571,6 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        link_gpencil(fd, snode->gpd);
                                }
                                snode->nodetree= snode->edittree= NULL;
-                               snode->flag |= SNODE_DO_PREVIEW;
                        }
                        else if(sl->spacetype==SPACE_SEQ) {
                                SpaceSeq *sseq= (SpaceSeq *)sl;
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
new file mode 100644 (file)
index 0000000..0cd5551
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef ED_NODE_H
+#define ED_NODE_H
+
+/* drawnode.c */
+void ED_init_node_butfuncs(void);
+
+#endif /* ED_NODE_H */
+
index 7fbac0a77c207be952437d2fc25b68a36659c8d2..407674163a6b9c4dbc60bcd6d653f5ed35f4699f 100644 (file)
@@ -1060,13 +1060,6 @@ static void shader_preview_free(void *customdata)
        MEM_freeN(sp);
 }
 
-static void shader_preview_update(void *customdata)
-{
-//     ShaderPreview *sp= customdata;
-       
-}
-
-
 void ED_preview_shader_job(const bContext *C, void *owner, ID *id, int sizex, int sizey)
 {
        wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner);
@@ -1082,8 +1075,8 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, int sizex, in
        
        /* setup job */
        WM_jobs_customdata(steve, sp, shader_preview_free);
-       WM_jobs_timer(steve, 0.1, NC_MATERIAL);
-       WM_jobs_callbacks(steve, shader_preview_startjob, shader_preview_update);
+       WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
+       WM_jobs_callbacks(steve, shader_preview_startjob, NULL, NULL);
        
        WM_jobs_start(steve);
 }
index caf8eacdddbb0354766acf764760641bbca85358..de39eb0fd27b1b34b8080c7a4a96457057b2bc00 100644 (file)
@@ -1306,11 +1306,11 @@ void image_header_buttons(const bContext *C, ARegion *ar)
                /* record & play */
                uiBlockBeginAlign(block);
                if(ima->type==IMA_TYPE_COMPOSITE) {
-                       uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
+//XXX                  uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
                        xco+= XIC;
                }
                if((ima->type==IMA_TYPE_COMPOSITE) || ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
-                       uiDefIconButO(block, BUT, "IMAGE_OT_play_composite", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco, yco, XIC, YIC, NULL); // PLAY
+//XXX                  uiDefIconButO(block, BUT, "IMAGE_OT_play_composite", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco, yco, XIC, YIC, NULL); // PLAY
                        xco+= XIC;
                }
                uiBlockEndAlign(block);
index b21c9aaab2a910e9102fe38de030eef98a8a25d5..5ac79ea46e68590c198055bfa1ecf5b0fa125f61 100644 (file)
@@ -215,6 +215,8 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
                case NC_SCENE:
                        switch(wmn->data) {
                                case ND_MODE:
+                               case ND_RENDER_RESULT:
+                               case ND_COMPO_RESULT:
                                        ED_area_tag_refresh(sa);
                                        ED_area_tag_redraw(sa);
                                        break;
index dd9487c211372085ea436775a1cd1b4853424f8b..97c4086e71ad97b2b2f7d3171ade9ad7fcc67626 100644 (file)
 #include "CMP_node.h"
 #include "SHD_node.h"
 
-/* #include "BDR_gpencil.h" XXX */
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
-/*
-#include "BIF_drawgpencil.h"
-#include "BIF_interface.h"
-#include "BIF_interface_icons.h"
-#include "BIF_language.h"
-#include "BIF_mywindow.h"
-#include "BIF_previewrender.h"
-#include "BIF_resources.h"
-#include "BIF_screen.h"
-#include "BIF_space.h"
-*/
-
-/* XXX
-#include "BSE_drawipo.h"
-#include "BSE_node.h"
-#include "BSE_view.h"
-*/
-
 
 #include "BMF_Api.h"
 
 #include "MEM_guardedalloc.h"
 
+#include "ED_node.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_types.h"
 #include "RE_pipeline.h"
 #include "IMB_imbuf_types.h"
 
-/*#include "blendef.h"
-#include "butspace.h"*/
-/*#include "interface.h"*/     /* urm...  for rasterpos_safe, roundbox */
-/*#include "mydevice.h"*/
-
 #include "node_intern.h"
 
 extern void autocomplete_uv(char *str, void *arg_v);
@@ -234,7 +210,7 @@ static int node_buts_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *
        if(block) {
                bNodeSocket *sock= node->outputs.first;         /* first socket stores value */
                
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", 
+               uiDefButF(block, NUM, B_NODE_EXEC, "", 
                                  (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin, 20, 
                                  sock->ns.vec, sock->ns.min, sock->ns.max, 10, 2, "");
                
@@ -250,10 +226,10 @@ static int node_buts_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *bu
                        /* enforce square box drawing */
                        uiBlockSetEmboss(block, UI_EMBOSSP);
                        
-                       uiDefButF(block, HSVCUBE, B_NODE_EXEC+node->nr, "", 
+                       uiDefButF(block, HSVCUBE, B_NODE_EXEC, "", 
                                          (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin, 12, 
                                          sock->ns.vec, 0.0f, 1.0f, 3, 0, "");
-                       uiDefButF(block, HSVCUBE, B_NODE_EXEC+node->nr, "", 
+                       uiDefButF(block, HSVCUBE, B_NODE_EXEC, "", 
                                          (short)butr->xmin, (short)butr->ymin+15, butr->xmax-butr->xmin, butr->ymax-butr->ymin -15 -15, 
                                          sock->ns.vec, 0.0f, 1.0f, 2, 0, "");
                        uiDefButF(block, COL, B_NOP, "",                
@@ -275,13 +251,13 @@ static int node_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf
                
                /* blend type */
                uiBlockBeginAlign(block);
-               bt=uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken %x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue %x12",
+               bt=uiDefButS(block, MENU, B_NODE_EXEC, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken %x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue %x12",
                                         (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin -(a_but?20:0), 20, 
                                         &node->custom1, 0, 0, 0, 0, "");
                uiButSetFunc(bt, node_but_title_cb, node, bt);
                /* Alpha option, composite */
                if(a_but)
-                       uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "A",
+                       uiDefButS(block, TOG, B_NODE_EXEC, "A",
                                  (short)butr->xmax-20, (short)butr->ymin, 20, 20, 
                                  &node->custom2, 0, 0, 0, 0, "Include Alpha of 2nd input in this operation");
        }
@@ -295,7 +271,7 @@ static int node_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *b
                short dx= (short)((butr->xmax-butr->xmin)/2);
                butr->ymin += 26;
 
-               // XXX curvemap_buttons(block, node->storage, 's', B_NODE_EXEC+node->nr, B_REDR, butr);
+               // XXX curvemap_buttons(block, node->storage, 's', B_NODE_EXEC, B_REDR, butr);
                
                if(cumap) {
                        cumap->flag |= CUMA_DRAW_CFRA;
@@ -304,10 +280,10 @@ static int node_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *b
                }
 
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Sta:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Sta:",
                                  (short)butr->xmin, (short)butr->ymin-22, dx, 19, 
                                  &node->custom1, 1.0, 20000.0, 0, 0, "Start frame");
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "End:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "End:",
                                  (short)butr->xmin+dx, (short)butr->ymin-22, dx, 19, 
                                  &node->custom2, 1.0, 20000.0, 0, 0, "End frame");
        }
@@ -319,7 +295,7 @@ static int node_buts_valtorgb(uiBlock *block, bNodeTree *ntree, bNode *node, rct
 {
        if(block) {
                if(node->storage) {
-                       ; // XXX draw_colorband_buts_small(block, node->storage, butr, B_NODE_EXEC+node->nr);
+                       ; // XXX draw_colorband_buts_small(block, node->storage, butr, B_NODE_EXEC);
                }
        }
        return 40;
@@ -328,7 +304,7 @@ static int node_buts_valtorgb(uiBlock *block, bNodeTree *ntree, bNode *node, rct
 static int node_buts_curvevec(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 {
        if(block) {
-               ; // XXX curvemap_buttons(block, node->storage, 'v', B_NODE_EXEC+node->nr, B_REDR, butr);
+               ; // XXX curvemap_buttons(block, node->storage, 'v', B_NODE_EXEC, B_REDR, butr);
        }       
        return (int)(node->width-NODE_DY);
 }
@@ -350,7 +326,7 @@ static int node_buts_curvecol(uiBlock *block, bNodeTree *ntree, bNode *node, rct
                else 
                        cumap->flag &= ~CUMA_DRAW_SAMPLE;
 
-               // XXX curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC+node->nr, B_REDR, butr);
+               // XXX curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC, B_REDR, butr);
        }       
        return (int)(node->width-NODE_DY);
 }
@@ -360,7 +336,7 @@ static int node_buts_normal(uiBlock *block, bNodeTree *ntree, bNode *node, rctf
        if(block) {
                bNodeSocket *sock= node->outputs.first;         /* first socket stores normal */
                
-               uiDefButF(block, BUT_NORMAL, B_NODE_EXEC+node->nr, "", 
+               uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", 
                                  (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin, butr->ymax-butr->ymin, 
                                  sock->ns.vec, 0.0f, 1.0f, 0, 0, "");
                
@@ -447,7 +423,7 @@ static int node_buts_texture(uiBlock *block, bNodeTree *ntree, bNode *node, rctf
                uiBlockBeginAlign(block);
                IDnames_to_pupstring(&strp, NULL, "", &(G.main->tex), NULL, NULL);
                node->menunr= 0;
-               bt= uiDefButS(block, MENU, B_NODE_EXEC+node->nr, strp, 
+               bt= uiDefButS(block, MENU, B_NODE_EXEC, strp, 
                                butr->xmin, butr->ymin+(multi?30:0), 20, 19, 
                                          &node->menunr, 0, 0, 0, 0, "Browse texture");
                uiButSetFunc(bt, node_browse_tex_cb, ntree, node);
@@ -639,13 +615,13 @@ static int node_shader_buts_material(uiBlock *block, bNodeTree *ntree, bNode *no
                        if(butr->ymax-butr->ymin > 21.0f) {
                                /* node options */
                                uiBlockSetCol(block, TH_AUTO);
-                               uiDefButBitS(block, TOG, SH_NODE_MAT_DIFF, B_NODE_EXEC+node->nr, "Diff",
+                               uiDefButBitS(block, TOG, SH_NODE_MAT_DIFF, B_NODE_EXEC, "Diff",
                                                         butr->xmin, butr->ymin, dx, 19, 
                                                         &node->custom1, 0, 0, 0, 0, "Material Node outputs Diffuse");
-                               uiDefButBitS(block, TOG, SH_NODE_MAT_SPEC, B_NODE_EXEC+node->nr, "Spec",
+                               uiDefButBitS(block, TOG, SH_NODE_MAT_SPEC, B_NODE_EXEC, "Spec",
                                                         butr->xmin+dx, butr->ymin, dx, 19, 
                                                         &node->custom1, 0, 0, 0, 0, "Material Node outputs Specular");
-                               uiDefButBitS(block, TOG, SH_NODE_MAT_NEG, B_NODE_EXEC+node->nr, "Neg Normal",
+                               uiDefButBitS(block, TOG, SH_NODE_MAT_NEG, B_NODE_EXEC, "Neg Normal",
                                                         butr->xmax-dx, butr->ymin, dx, 19,
                                                         &node->custom1, 0, 0, 0, 0, "Material Node uses inverted Normal");
                        }
@@ -665,26 +641,26 @@ static int node_shader_buts_mapping(uiBlock *block, bNodeTree *ntree, bNode *nod
                uiBlockSetFunc(block, node_texmap_cb, texmap, NULL);    /* all buttons get this */
                
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+dx, dy, 2*dx, 19, texmap->loc, -1000.0f, 1000.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->loc+1, -1000.0f, 1000.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->loc+2, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->loc, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->loc+1, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->loc+2, -1000.0f, 1000.0f, 10, 2, "");
                dy-= 19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+dx, dy, 2*dx, 19, texmap->rot, -1000.0f, 1000.0f, 1000, 1, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->rot+1, -1000.0f, 1000.0f, 1000, 1, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->rot+2, -1000.0f, 1000.0f, 1000, 1, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->rot, -1000.0f, 1000.0f, 1000, 1, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->rot+1, -1000.0f, 1000.0f, 1000, 1, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->rot+2, -1000.0f, 1000.0f, 1000, 1, "");
                dy-= 19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+dx, dy, 2*dx, 19, texmap->size, -1000.0f, 1000.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->size+1, -1000.0f, 1000.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->size+2, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->size, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->size+1, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->size+2, -1000.0f, 1000.0f, 10, 2, "");
                dy-= 25;
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+dx, dy, 2*dx, 19, texmap->min, -10.0f, 10.0f, 100, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->min+1, -10.0f, 10.0f, 100, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->min+2, -10.0f, 10.0f, 100, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->min, -10.0f, 10.0f, 100, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->min+1, -10.0f, 10.0f, 100, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->min+2, -10.0f, 10.0f, 100, 2, "");
                dy-= 19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+dx, dy, 2*dx, 19, texmap->max, -10.0f, 10.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->max+1, -10.0f, 10.0f, 10, 2, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->max+2, -10.0f, 10.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->max, -10.0f, 10.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->max+1, -10.0f, 10.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->max+2, -10.0f, 10.0f, 10, 2, "");
                uiBlockEndAlign(block);
                
                /* labels/options */
@@ -696,9 +672,9 @@ static int node_shader_buts_mapping(uiBlock *block, bNodeTree *ntree, bNode *nod
                dy-= 19;
                uiDefBut(block, LABEL, B_NOP, "Size", butr->xmin, dy, dx, 19, NULL, 0.0f, 0.0f, 0, 0, "");
                dy-= 25;
-               uiDefButBitI(block, TOG, TEXMAP_CLIP_MIN, B_NODE_EXEC+node->nr, "Min", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+               uiDefButBitI(block, TOG, TEXMAP_CLIP_MIN, B_NODE_EXEC, "Min", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
                dy-= 19;
-               uiDefButBitI(block, TOG, TEXMAP_CLIP_MAX, B_NODE_EXEC+node->nr, "Max", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+               uiDefButBitI(block, TOG, TEXMAP_CLIP_MAX, B_NODE_EXEC, "Max", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
                
        }       
        return 5*19 + 6;
@@ -723,13 +699,13 @@ static int node_shader_buts_geometry(uiBlock *block, bNodeTree *ntree, bNode *no
 
                // XXX if(!verify_valid_uv_name(ngeo->uvname))
                // XXX  uiBlockSetCol(block, TH_REDALERT);
-               but= uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "UV:", butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
+               but= uiDefBut(block, TEX, B_NODE_EXEC, "UV:", butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
                // uiButSetCompleteFunc(but, autocomplete_uv, NULL);
                uiBlockSetCol(block, TH_AUTO);
 
                if(!verify_valid_vcol_name(ngeo->colname))
                        uiBlockSetCol(block, TH_REDALERT);
-               but= uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "Col:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->colname, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
+               but= uiDefBut(block, TEX, B_NODE_EXEC, "Col:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->colname, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
                uiButSetCompleteFunc(but, autocomplete_vcol, NULL);
                uiBlockSetCol(block, TH_AUTO);
        }
@@ -852,7 +828,7 @@ static void node_browse_image_cb(bContext *C, void *ntree_v, void *node_v)
 
                NodeTagChanged(ntree, node); 
                BKE_image_signal((Image *)node->id, node->storage, IMA_SIGNAL_USER_NEW_IMAGE);
-               // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC+node->nr); XXX
+               // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC); XXX
        }
        node->menunr= 0;
 }
@@ -966,20 +942,20 @@ static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *nod
                                width= (xmax-xmin)/2;
                                
                                dy-= 19;
-                               uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "Frs:",
+                               uiDefButI(block, NUM, B_NODE_EXEC, "Frs:",
                                                  xmin, dy, width, 19, 
                                                  &iuser->frames, 1.0, MAXFRAMEF, 0, 0, "Amount of images used in animation");
-                               uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "SFra:",
+                               uiDefButI(block, NUM, B_NODE_EXEC, "SFra:",
                                                  xmin+width, dy, width, 19, 
                                                  &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Start frame of animation");
                                dy-= 19;
-                               uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "Offs:",
+                               uiDefButI(block, NUM, B_NODE_EXEC, "Offs:",
                                                  xmin, dy, width, 19, 
                                                  &iuser->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the frame to use in the animation");
-                               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Cycl",
+                               uiDefButS(block, TOG, B_NODE_EXEC, "Cycl",
                                                  xmin+width, dy, width-20, 19, 
                                                  &iuser->cycl, 0.0, 0.0, 0, 0, "Make animation go cyclic");
-                               uiDefIconButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NODE_EXEC+node->nr, ICON_AUTO,
+                               uiDefIconButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NODE_EXEC, ICON_AUTO,
                                                  xmax-20, dy, 20, 19, 
                                                  &iuser->flag, 0.0, 0.0, 0, 0, "Always refresh Image on frame changes");
                        }
@@ -989,7 +965,7 @@ static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *nod
                                        width= (xmax-xmin);
                                        dy-= 19;
                                        strp= layer_menu(ima->rr);
-                                       bt= uiDefButS(block, MENU, B_NODE_EXEC+node->nr, strp,
+                                       bt= uiDefButS(block, MENU, B_NODE_EXEC, strp,
                                                          xmin, dy, width, 19, 
                                                          &iuser->layer, 0.0, 10000.0, 0, 0, "Layer");
                                        uiButSetFunc(bt, image_layer_cb, ima->rr, node->storage);
@@ -1006,7 +982,7 @@ static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *nod
                /* for each draw we test for anim refresh event */
                if(iuser->flag & IMA_ANIM_REFRESHED) {
                        iuser->flag &= ~IMA_ANIM_REFRESHED;
-                       // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC+node->nr); XXX
+                       // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC); XXX
                }
                
                if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE) )
@@ -1111,11 +1087,11 @@ static int node_composit_buts_renderlayers(uiBlock *block, bNodeTree *ntree, bNo
                /* browse button layer */
                strp= scene_layer_menu(node->id?(Scene *)node->id:scene);
                if(node->id)
-                       bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC+node->nr, ICON_SCENE_DEHLT, strp, 
+                       bt= uiDefIconTextButS(block, MENU, B_NODE_EXEC, ICON_SCENE_DEHLT, strp, 
                                  butr->xmin+20, butr->ymin, (butr->xmax-butr->xmin)-40, 19, 
                                  &node->custom1, 0, 0, 0, 0, "Choose Render Layer");
                else
-                       bt= uiDefButS(block, MENU, B_NODE_EXEC+node->nr, strp, 
+                       bt= uiDefButS(block, MENU, B_NODE_EXEC, strp, 
                                  butr->xmin+20, butr->ymin, (butr->xmax-butr->xmin)-40, 19, 
                                  &node->custom1, 0, 0, 0, 0, "Choose Render Layer");
                uiButSetFunc(bt, set_render_layers_title, node, NULL);
@@ -1123,7 +1099,7 @@ static int node_composit_buts_renderlayers(uiBlock *block, bNodeTree *ntree, bNo
                
                /* re-render */
                /* uses custom2, not the best implementation of the world... but we need it to work now :) */
-               bt= uiDefIconButS(block, TOG, B_NODE_EXEC+node->nr, ICON_SCENE, 
+               bt= uiDefIconButS(block, TOG, B_NODE_EXEC, ICON_SCENE, 
                                  butr->xmax-20, butr->ymin, 20, 19, 
                                  &node->custom2, 0, 0, 0, 0, "Re-render this Layer");
                
@@ -1171,15 +1147,15 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
                
                uiBlockBeginAlign(block);
                sprintf(str, "Filter Type%%t|Flat %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|Fast Gauss%%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_FAST_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH);
-               uiDefButS(block, MENU, B_NODE_EXEC+node->nr,str,
+               uiDefButS(block, MENU, B_NODE_EXEC,str,
                                  butr->xmin, dy, dx*2, 19, 
                                  &nbd->filtertype, 0, 0, 0, 0, "Set sampling filter for blur");
                dy-=19;
                if (nbd->filtertype != R_FILTER_FAST_GAUSS) { 
-                       uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Bokeh",
+                       uiDefButC(block, TOG, B_NODE_EXEC, "Bokeh",
                                        butr->xmin, dy, dx, 19, 
                                        &nbd->bokeh, 0, 0, 0, 0, "Uses circular filter, warning it's slow!");
-                       uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Gamma",
+                       uiDefButC(block, TOG, B_NODE_EXEC, "Gamma",
                                        butr->xmin+dx, dy, dx, 19, 
                                        &nbd->gamma, 0, 0, 0, 0, "Applies filter on gamma corrected values");
                } else {
@@ -1194,20 +1170,20 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
 
                dy-=19;
                if(nbd->relative) {
-                       bt= uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "X:",
+                       bt= uiDefButF(block, NUM, B_NODE_EXEC, "X:",
                                                 butr->xmin, dy, dx, 19, 
                                                 &nbd->percentx, 0.0f, 1.0f, 0, 0, "");
                        uiButSetFunc(bt, node_blur_update_sizex_cb, node, NULL);
-                       bt= uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Y:",
+                       bt= uiDefButF(block, NUM, B_NODE_EXEC, "Y:",
                                                 butr->xmin+dx, dy, dx, 19, 
                                                 &nbd->percenty, 0.0f, 1.0f, 0, 0, "");
                        uiButSetFunc(bt, node_blur_update_sizey_cb, node, NULL);
                }
                else {
-                       uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "X:",
+                       uiDefButS(block, NUM, B_NODE_EXEC, "X:",
                                                 butr->xmin, dy, dx, 19, 
                                                 &nbd->sizex, 0, 256, 0, 0, "");
-                       uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Y:",
+                       uiDefButS(block, NUM, B_NODE_EXEC, "Y:",
                                                 butr->xmin+dx, dy, dx, 19, 
                                                 &nbd->sizey, 0, 256, 0, 0, "");
                }
@@ -1225,10 +1201,10 @@ static int node_composit_buts_dblur(uiBlock *block, bNodeTree *ntree, bNode *nod
                short halfdx= (short)dx/2;
 
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Iterations:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Iterations:",
                                butr->xmin, dy, dx, 19,
                                &ndbd->iter, 1, 32, 10, 0, "Amount of iterations");
-               uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Wrap",
+               uiDefButC(block, TOG, B_NODE_EXEC, "Wrap",
                                butr->xmin, dy-= 19, dx, 19, 
                                &ndbd->wrap, 0, 0, 0, 0, "Wrap blur");
                uiBlockEndAlign(block);
@@ -1238,10 +1214,10 @@ static int node_composit_buts_dblur(uiBlock *block, bNodeTree *ntree, bNode *nod
                uiDefBut(block, LABEL, B_NOP, "Center", butr->xmin, dy-= 19, dx, 19, NULL, 0.0f, 0.0f, 0, 0, "");
 
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "X:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "X:",
                                butr->xmin, dy-= 19, halfdx, 19,
                                &ndbd->center_x, 0.0f, 1.0f, 10, 0, "X center in percents");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Y:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Y:",
                                butr->xmin+halfdx, dy, halfdx, 19,
                                &ndbd->center_y, 0.0f, 1.0f, 10, 0, "Y center in percents");
                uiBlockEndAlign(block);
@@ -1249,23 +1225,23 @@ static int node_composit_buts_dblur(uiBlock *block, bNodeTree *ntree, bNode *nod
                dy-= 9;
 
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Distance:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Distance:",
                                butr->xmin, dy-= 19, dx, 19,
                                &ndbd->distance, -1.0f, 1.0f, 10, 0, "Amount of which the image moves");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Angle:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Angle:",
                                butr->xmin, dy-= 19, dx, 19,
                                &ndbd->angle, 0.0f, 360.0f, 1000, 0, "Angle in which the image will be moved");
                uiBlockEndAlign(block);
 
                dy-= 9;
 
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Spin:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Spin:",
                                butr->xmin, dy-= 19, dx, 19,
                                &ndbd->spin, -360.0f, 360.0f, 1000, 0, "Angle that is used to spin the image");
 
                dy-= 9;
 
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Zoom:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Zoom:",
                                butr->xmin, dy-= 19, dx, 19,
                                &ndbd->zoom, 0.0f, 100.0f, 100, 0, "Amount of which the image is zoomed");
 
@@ -1281,15 +1257,15 @@ static int node_composit_buts_bilateralblur(uiBlock *block, bNodeTree *ntree, bN
                short dx= (butr->xmax-butr->xmin);
                
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Iterations:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Iterations:",
                                 butr->xmin, dy, dx, 19, 
                                 &nbbd->iter, 1, 128, 0, 0, "Amount of iterations");
                dy-=19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Color Sigma:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Color Sigma:",
                                  butr->xmin, dy, dx, 19, 
                                  &nbbd->sigma_color,0.01, 3, 10, 0, "Sigma value used to modify color");
                dy-=19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Space Sigma:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Space Sigma:",
                                  butr->xmin, dy, dx, 19, 
                                  &nbbd->sigma_space ,0.01, 30, 10, 0, "Sigma value used to modify space");
                
@@ -1307,43 +1283,43 @@ static int node_composit_buts_defocus(uiBlock *block, bNodeTree *ntree, bNode *n
                char* mstr1 = "Bokeh Type%t|Octagon %x8|Heptagon %x7|Hexagon %x6|Pentagon %x5|Square %x4|Triangle %x3|Disk %x0";
 
                uiDefBut(block, LABEL, B_NOP, "Bokeh Type", butr->xmin, dy, dx, 19, NULL, 0, 0, 0, 0, "");
-               uiDefButC(block, MENU, B_NODE_EXEC+node->nr, mstr1,
+               uiDefButC(block, MENU, B_NODE_EXEC, mstr1,
                          butr->xmin, dy-19, dx, 19,
                          &nqd->bktype, 0, 0, 0, 0, "Bokeh type");
                if (nqd->bktype) { /* for some reason rotating a disk doesn't seem to work... ;) */
-                       uiDefButC(block, NUM, B_NODE_EXEC+node->nr, "Rotate:",
+                       uiDefButC(block, NUM, B_NODE_EXEC, "Rotate:",
                                  butr->xmin, dy-38, dx, 19,
                                  &nqd->rotation, 0, 90, 0, 0, "Bokeh shape rotation offset in degrees");
                }
-               uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Gamma Correct",
+               uiDefButC(block, TOG, B_NODE_EXEC, "Gamma Correct",
                          butr->xmin, dy-57, dx, 19,
                          &nqd->gamco, 0, 0, 0, 0, "Enable gamma correction before and after main process");
                if (nqd->no_zbuf==0) {
                        // only needed for zbuffer input
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "fStop:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "fStop:",
                                  butr->xmin, dy-76, dx, 19,
                                  &nqd->fstop, 0.5, 128, 10, 0, "Amount of focal blur, 128=infinity=perfect focus, half the value doubles the blur radius");
                }
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Maxblur:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Maxblur:",
                          butr->xmin, dy-95, dx, 19,
                          &nqd->maxblur, 0, 10000, 1000, 0, "blur limit, maximum CoC radius, 0=no limit");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "BThreshold:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "BThreshold:",
                          butr->xmin, dy-114, dx, 19,
                          &nqd->bthresh, 0, 100, 100, 0, "CoC radius threshold, prevents background bleed on in-focus midground, 0=off");
-               uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Preview",
+               uiDefButC(block, TOG, B_NODE_EXEC, "Preview",
                          butr->xmin, dy-142, dx, 19,
                          &nqd->preview, 0, 0, 0, 0, "Enable sampling mode, useful for preview when using low samplecounts");
                if (nqd->preview) {
                        /* only visible when sampling mode enabled */
-                       uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Samples:",
+                       uiDefButS(block, NUM, B_NODE_EXEC, "Samples:",
                                  butr->xmin, dy-161, dx, 19,
                                  &nqd->samples, 16, 256, 0, 0, "Number of samples (16=grainy, higher=less noise)");
                }
-               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "No zbuffer",
+               uiDefButS(block, TOG, B_NODE_EXEC, "No zbuffer",
                          butr->xmin, dy-190, dx, 19,
                          &nqd->no_zbuf, 0, 0, 0, 0, "Enable when using an image as input instead of actual zbuffer (auto enabled if node not image based, eg. time node)");
                if (nqd->no_zbuf) {
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Zscale:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Zscale:",
                            butr->xmin, dy-209, dx, 19,
                            &nqd->scale, 0, 1000, 100, 0, "Scales the Z input when not using a zbuffer, controls maximum blur designated by the color white or input value 1");
                }
@@ -1360,56 +1336,56 @@ static int node_composit_buts_glare(uiBlock *block, bNodeTree *ntree, bNode *nod
                short dy = butr->ymin + 152, dx = butr->xmax - butr->xmin; 
                char* mn1 = "Type%t|Ghosts%x3|Streaks%x2|Fog Glow%x1|Simple Star%x0";
                char* mn2 = "Quality/Speed%t|High/Slow%x0|Medium/Medium%x1|Low/Fast%x2";
-               uiDefButC(block, MENU, B_NODE_EXEC+node->nr, mn1,
+               uiDefButC(block, MENU, B_NODE_EXEC, mn1,
                          butr->xmin, dy, dx, 19,
                          &ndg->type, 0, 0, 0, 0, "Glow/Flare/Bloom type");
-               uiDefButC(block, MENU, B_NODE_EXEC+node->nr, mn2,
+               uiDefButC(block, MENU, B_NODE_EXEC, mn2,
                          butr->xmin, dy-19, dx, 19,
                          &ndg->quality, 0, 0, 0, 0,
                          "Quality speed trade off, if not set to high quality, effect will be applied to low-res copy of source image");
                if (ndg->type != 1) {
-                       uiDefButC(block, NUM, B_NODE_EXEC+node->nr, "Iterations:",
+                       uiDefButC(block, NUM, B_NODE_EXEC, "Iterations:",
                                  butr->xmin, dy-38, dx, 19,
                                  &ndg->iter, 2, 5, 1, 0,
                                  "higher values will generate longer/more streaks/ghosts");
                        if (ndg->type != 0)
-                               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "ColMod:",
+                               uiDefButF(block, NUM, B_NODE_EXEC, "ColMod:",
                                          butr->xmin, dy-57, dx, 19,
                                          &ndg->colmod, 0, 1, 10, 0,
                                          "Amount of Color Modulation, modulates colors of streaks and ghosts for a spectral dispersion effect");
                }
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Mix:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Mix:",
                          butr->xmin, dy-76, dx, 19,
                          &ndg->mix, -1, 1, 10, 0,
                          "Mix balance, -1 is original image only, 0 is exact 50/50 mix, 1 is processed image only");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Threshold:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Threshold:",
                          butr->xmin, dy-95, dx, 19,
                          &ndg->threshold, 0, 1000, 10, 0,
                          "Brightness threshold, the glarefilter will be applied only to pixels brighter than this value");
                if ((ndg->type == 2) || (ndg->type == 0))
                {
                        if (ndg->type == 2) {
-                               uiDefButC(block, NUM, B_NODE_EXEC+node->nr, "streaks:",
+                               uiDefButC(block, NUM, B_NODE_EXEC, "streaks:",
                                          butr->xmin, dy-114, dx, 19,
                                          &ndg->angle, 2, 16, 1000, 0,
                                          "Total number of streaks");
-                               uiDefButC(block, NUM, B_NODE_EXEC+node->nr, "AngOfs:",
+                               uiDefButC(block, NUM, B_NODE_EXEC, "AngOfs:",
                                          butr->xmin, dy-133, dx, 19,
                                          &ndg->angle_ofs, 0, 180, 1000, 0,
                                          "Streak angle rotation offset in degrees");
                        }
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Fade:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Fade:",
                                  butr->xmin, dy-152, dx, 19,
                                  &ndg->fade, 0.75, 1, 5, 0,
                                  "Streak fade out factor");
                }
                if (ndg->type == 0)
-                       uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Rot45",
+                       uiDefButC(block, TOG, B_NODE_EXEC, "Rot45",
                                  butr->xmin, dy-114, dx, 19,
                                  &ndg->angle, 0, 0, 0, 0,
                                  "simple star filter, add 45 degree rotation offset");
                if ((ndg->type == 1) || (ndg->type > 3))        // PBGH and fog glow
-                       uiDefButC(block, NUM, B_NODE_EXEC+node->nr, "Size:",
+                       uiDefButC(block, NUM, B_NODE_EXEC, "Size:",
                                  butr->xmin, dy-114, dx, 19,
                                  &ndg->size, 6, 9, 1000, 0,
                                  "glow/glare size (not actual size, relative to initial size of bright area of pixels)");
@@ -1426,35 +1402,35 @@ static int node_composit_buts_tonemap(uiBlock *block, bNodeTree *ntree, bNode *n
                char* mn = "Type%t|R/D Photoreceptor%x1|Rh Simple%x0";
                
                uiBlockBeginAlign(block);
-               uiDefButI(block, MENU, B_NODE_EXEC+node->nr, mn,
+               uiDefButI(block, MENU, B_NODE_EXEC, mn,
                          butr->xmin, dy, dx, 19,
                          &ntm->type, 0, 0, 0, 0,
                          "Tone mapping type");
                if (ntm->type == 0) {
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Key:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Key:",
                                  butr->xmin, dy-19, dx, 19,
                                  &ntm->key, 0, 1, 5, 0,
                                  "The value the average luminance is mapped to");
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Offset:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Offset:",
                                  butr->xmin, dy-38, dx, 19,
                                  &ntm->offset, 0.001, 10, 5, 0,
                                  "Tonemap offset, normally always 1, but can be used as an extra control to alter the brightness curve");
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Gamma:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Gamma:",
                                  butr->xmin, dy-57, dx, 19,
                                  &ntm->gamma, 0.001, 3, 5, 0,
                                  "Gamma factor, if not used, set to 1");
                }
                else {
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Intensity:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Intensity:",
                                  butr->xmin, dy-19, dx, 19,
                                  &ntm->f, -8, 8, 10, 0, "if less than zero, darkens image, otherwise makes it brighter");
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Contrast:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Contrast:",
                                  butr->xmin, dy-38, dx, 19,
                                  &ntm->m, 0, 1, 5, 0, "Set to 0 to use estimate from input image");
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Adaptation:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "Adaptation:",
                                  butr->xmin, dy-57, dx, 19,
                                  &ntm->a, 0, 1, 5, 0, "if 0, global, if 1, based on pixel intensity");
-                       uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "ColCorrect:",
+                       uiDefButF(block, NUM, B_NODE_EXEC, "ColCorrect:",
                                  butr->xmin, dy-76, dx, 19,
                                  &ntm->c, 0, 1, 5, 0, "color correction, if 0, same for all channels, if 1, each independent");
                }
@@ -1470,16 +1446,16 @@ static int node_composit_buts_lensdist(uiBlock *block, bNodeTree *ntree, bNode *
                NodeLensDist *nld = node->storage;
                short dy = butr->ymin + 19, dx = butr->xmax - butr->xmin; 
                uiBlockBeginAlign(block);
-               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Projector",
+               uiDefButS(block, TOG, B_NODE_EXEC, "Projector",
                          butr->xmin, dy, dx, 19,
                          &nld->proj, 0, 0, 0, 0,
                          "Enable/disable projector mode, effect is applied in horizontal direction only");
                if (!nld->proj) {
-                       uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Jitter",
+                       uiDefButS(block, TOG, B_NODE_EXEC, "Jitter",
                                  butr->xmin, dy-19, dx/2, 19,
                                  &nld->jit, 0, 0, 0, 0,
                                  "Enable/disable jittering, faster, but also noisier");
-                       uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Fit",
+                       uiDefButS(block, TOG, B_NODE_EXEC, "Fit",
                                  butr->xmin+dx/2, dy-19, dx/2, 19,
                                  &nld->fit, 0, 0, 0, 0,
                                  "For positive distortion factor only, scale image such that black areas are not visible");
@@ -1498,19 +1474,19 @@ static int node_composit_buts_vecblur(uiBlock *block, bNodeTree *ntree, bNode *n
                short dx= (butr->xmax-butr->xmin);
                
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Samples:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Samples:",
                                 butr->xmin, dy+76, dx, 19, 
                                 &nbd->samples, 1, 256, 0, 0, "Amount of samples");
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "MinSpeed:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "MinSpeed:",
                                  butr->xmin, dy+57, dx, 19, 
                                  &nbd->minspeed, 0, 1024, 0, 0, "Minimum speed for a pixel to be blurred, used to separate background from foreground");
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "MaxSpeed:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "MaxSpeed:",
                                  butr->xmin, dy+38, dx, 19, 
                                  &nbd->maxspeed, 0, 1024, 0, 0, "If not zero, maximum speed in pixels");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "BlurFac:",
+               uiDefButF(block, NUM, B_NODE_EXEC, "BlurFac:",
                                  butr->xmin, dy+19, dx, 19, 
                                  &nbd->fac, 0.0f, 2.0f, 10, 2, "Scaling factor for motion vectors, actually 'shutter speed' in frames");
-               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Curved",
+               uiDefButS(block, TOG, B_NODE_EXEC, "Curved",
                                  butr->xmin, dy, dx, 19, 
                                  &nbd->curved, 0.0f, 2.0f, 10, 2, "Interpolate between frames in a bezier curve, rather than linearly");
                uiBlockEndAlign(block);
@@ -1524,7 +1500,7 @@ static int node_composit_buts_filter(uiBlock *block, bNodeTree *ntree, bNode *no
                uiBut *bt;
                
                /* blend type */
-               bt=uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Soften %x0|Sharpen %x1|Laplace %x2|Sobel %x3|Prewitt %x4|Kirsch %x5|Shadow %x6",
+               bt=uiDefButS(block, MENU, B_NODE_EXEC, "Soften %x0|Sharpen %x1|Laplace %x2|Sobel %x3|Prewitt %x4|Kirsch %x5|Shadow %x6",
                                         butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                         &node->custom1, 0, 0, 0, 0, "");
                uiButSetFunc(bt, node_but_title_cb, node, bt);
@@ -1538,7 +1514,7 @@ static int node_composit_buts_flip(uiBlock *block, bNodeTree *ntree, bNode *node
                uiBut *bt;
                
                /* flip x\y */
-               bt=uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Flip X %x0|Flip Y %x1|Flip X & Y %x2",
+               bt=uiDefButS(block, MENU, B_NODE_EXEC, "Flip X %x0|Flip Y %x1|Flip X & Y %x2",
                                         butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                         &node->custom1, 0, 0, 0, 0, "");
                uiButSetFunc(bt, node_but_title_cb, node, bt);
@@ -1558,29 +1534,29 @@ static int node_composit_buts_crop(uiBlock *block, bNodeTree *ntree, bNode *node
                uiBlockBeginAlign(block);
 
                /* crop image size toggle */
-               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Crop Image Size",
+               uiDefButS(block, TOG, B_NODE_EXEC, "Crop Image Size",
                                  butr->xmin, dy, dx*2, elementheight, 
                                  &node->custom1, 0, 0, 0, 0, "Crop the size of the input image.");
 
                dy-=elementheight;
 
                /* x1 */
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "X1:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "X1:",
                                         butr->xmin, dy, dx, elementheight,
                                         &ntxy->x1, xymin, xymax, 0, 0, "");
                /* y1 */
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Y1:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Y1:",
                                         butr->xmin+dx, dy, dx, elementheight,
                                         &ntxy->y1, xymin, xymax, 0, 0, "");
 
                dy-=elementheight;
 
                /* x2 */
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "X2:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "X2:",
                                         butr->xmin, dy, dx, elementheight,
                                         &ntxy->x2, xymin, xymax, 0, 0, "");
                /* y2 */
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Y2:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Y2:",
                                         butr->xmin+dx, dy, dx, elementheight,
                                         &ntxy->y2, xymin, xymax, 0, 0, "");
 
@@ -1594,14 +1570,14 @@ static int node_composit_buts_splitviewer(uiBlock *block, bNodeTree *ntree, bNod
        if(block) {     
                uiBlockBeginAlign(block);
                
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "X",
+               uiDefButS(block, ROW, B_NODE_EXEC, "X",
                                  butr->xmin, butr->ymin+19, (butr->xmax-butr->xmin)/2, 20, 
                                  &node->custom2, 0.0, 0.0, 0, 0, "");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Y",
+               uiDefButS(block, ROW, B_NODE_EXEC, "Y",
                                  butr->xmin+(butr->xmax-butr->xmin)/2, butr->ymin+19, (butr->xmax-butr->xmin)/2, 20, 
                                  &node->custom2, 0.0, 1.0, 0, 0, "");
                                  
-               uiDefButS(block, NUMSLI, B_NODE_EXEC+node->nr, "Split %: ",
+               uiDefButS(block, NUMSLI, B_NODE_EXEC, "Split %: ",
                                butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, &node->custom1, 0, 100, 10, 0, "");
        }
        return 40;
@@ -1616,16 +1592,16 @@ static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode
                short dx= (short)(butr->xmax-butr->xmin)/2;
                
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Offs:", xstart, dy, 2*dx, 19, texmap->loc, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "Offs:", xstart, dy, 2*dx, 19, texmap->loc, -1000.0f, 1000.0f, 10, 2, "");
                dy-= 19;
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Size:", xstart, dy, 2*dx, 19, texmap->size, -1000.0f, 1000.0f, 10, 3, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "Size:", xstart, dy, 2*dx, 19, texmap->size, -1000.0f, 1000.0f, 10, 3, "");
                dy-= 23;
                uiBlockBeginAlign(block);
-               uiDefButBitI(block, TOG, TEXMAP_CLIP_MIN, B_NODE_EXEC+node->nr, "Min", xstart, dy, dx, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", xstart+dx, dy, dx, 19, texmap->min, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButBitI(block, TOG, TEXMAP_CLIP_MIN, B_NODE_EXEC, "Min", xstart, dy, dx, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", xstart+dx, dy, dx, 19, texmap->min, -1000.0f, 1000.0f, 10, 2, "");
                dy-= 19;
-               uiDefButBitI(block, TOG, TEXMAP_CLIP_MAX, B_NODE_EXEC+node->nr, "Max", xstart, dy, dx, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "", xstart+dx, dy, dx, 19, texmap->max, -1000.0f, 1000.0f, 10, 2, "");
+               uiDefButBitI(block, TOG, TEXMAP_CLIP_MAX, B_NODE_EXEC, "Max", xstart, dy, dx, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+               uiDefButF(block, NUM, B_NODE_EXEC, "", xstart+dx, dy, dx, 19, texmap->max, -1000.0f, 1000.0f, 10, 2, "");
        }
        return 80;
 }
@@ -1636,11 +1612,11 @@ static int node_composit_buts_alphaover(uiBlock *block, bNodeTree *ntree, bNode
                NodeTwoFloats *ntf= node->storage;
                
                /* alpha type */
-               uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "ConvertPremul",
+               uiDefButS(block, TOG, B_NODE_EXEC, "ConvertPremul",
                                  butr->xmin, butr->ymin+19, butr->xmax-butr->xmin, 19, 
                                  &node->custom1, 0, 0, 0, 0, "");
                /* mix factor */
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Premul: ",
+               uiDefButF(block, NUM, B_NODE_EXEC, "Premul: ",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19, 
                                  &ntf->x, 0.0f, 1.0f, 100, 0, "");
        }
@@ -1653,13 +1629,13 @@ static int node_composit_buts_hue_sat(uiBlock *block, bNodeTree *ntree, bNode *n
                NodeHueSat *nhs= node->storage;
                
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Hue: ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Hue: ",
                                  butr->xmin, butr->ymin+40.0f, butr->xmax-butr->xmin, 20, 
                                  &nhs->hue, 0.0f, 1.0f, 100, 0, "");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Sat: ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Sat: ",
                                  butr->xmin, butr->ymin+20.0f, butr->xmax-butr->xmin, 20, 
                                  &nhs->sat, 0.0f, 2.0f, 100, 0, "");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Val: ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Val: ",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                  &nhs->val, 0.0f, 2.0f, 100, 0, "");
        }
@@ -1669,7 +1645,7 @@ static int node_composit_buts_hue_sat(uiBlock *block, bNodeTree *ntree, bNode *n
 static int node_composit_buts_dilateerode(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 {
        if(block) {
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Distance:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Distance:",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                  &node->custom2, -100, 100, 0, 0, "Distance to grow/shrink (number of iterations)");
        }
@@ -1685,35 +1661,35 @@ static int node_composit_buts_diff_matte(uiBlock *block, bNodeTree *ntree, bNode
                
                uiBlockBeginAlign(block);
                /*color space selectors*/
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"RGB",
+               uiDefButS(block, ROW,B_NODE_EXEC,"RGB",
                                                        butr->xmin,butr->ymin+60,sx,20,
                                                        &node->custom1,1,1, 0, 0, "RGB Color Space");
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"HSV",
+               uiDefButS(block, ROW,B_NODE_EXEC,"HSV",
                                                        butr->xmin+sx,butr->ymin+60,sx,20,
                                                        &node->custom1,1,2, 0, 0, "HSV Color Space");
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"YUV",
+               uiDefButS(block, ROW,B_NODE_EXEC,"YUV",
                                                        butr->xmin+2*sx,butr->ymin+60,sx,20,
                                                        &node->custom1,1,3, 0, 0, "YUV Color Space");
-                                       uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"YCC",
+                                       uiDefButS(block, ROW,B_NODE_EXEC,"YCC",
                                                        butr->xmin+3*sx,butr->ymin+60,sx,20,
                                                        &node->custom1,1,4, 0, 0, "YCbCr Color Space");
                /*channel tolorences*/
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, " ",
+               uiDefButF(block, NUM, B_NODE_EXEC, " ",
                                                        butr->xmin, butr->ymin+40, dx, 20,
                                                        &c->t1, 0.0f, 1.0f, 100, 0, "Channel 1 Tolerance");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, " ",
+               uiDefButF(block, NUM, B_NODE_EXEC, " ",
                                                        butr->xmin+dx, butr->ymin+40, dx, 20,
                                                        &c->t2, 0.0f, 1.0f, 100, 0, "Channel 2 Tolorence");
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, " ",
+               uiDefButF(block, NUM, B_NODE_EXEC, " ",
                                                        butr->xmin+2*dx, butr->ymin+40, dx, 20,
                                                        &c->t3, 0.0f, 1.0f, 100, 0, "Channel 3 Tolorence");
                /*falloff parameters*/
                /*
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Falloff Size ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Falloff Size ",
                        butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20,
                        &c->fsize, 0.0f, 1.0f, 100, 0, "");
                */
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Falloff: ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Falloff: ",
                        butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20,
                        &c->fstrength, 0.0f, 1.0f, 100, 0, "");
        }
@@ -1727,16 +1703,16 @@ static int node_composit_buts_color_spill(uiBlock *block, bNodeTree *ntree, bNod
 
                NodeChroma *c=node->storage;
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "Enhance: ", 
+               uiDefButF(block, NUM, B_NODE_EXEC, "Enhance: ", 
                                butr->xmin, butr->ymin+20.0, butr->xmax-butr->xmin, 20,
                                &c->t1, 0.0f, 0.5f, 100, 2, "Adjusts how much selected channel is affected by color spill algorithm");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "R",
+               uiDefButS(block, ROW, B_NODE_EXEC, "R",
                                butr->xmin,butr->ymin,dx,20,
                                &node->custom1,1,1, 0, 0, "Red Spill Suppression");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "G",
+               uiDefButS(block, ROW, B_NODE_EXEC, "G",
                                butr->xmin+dx,butr->ymin,dx,20,
                                &node->custom1,1,2, 0, 0, "Green Spill Suppression");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "B",
+               uiDefButS(block, ROW, B_NODE_EXEC, "B",
                                butr->xmin+2*dx,butr->ymin,dx,20,
                                &node->custom1, 1, 3, 0, 0, "Blue Spill Suppression");
                uiBlockEndAlign(block);
@@ -1751,21 +1727,21 @@ static int node_composit_buts_chroma_matte(uiBlock *block, bNodeTree *ntree, bNo
                NodeChroma *c= node->storage;
                uiBlockBeginAlign(block);
 
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Acceptance ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Acceptance ",
                        butr->xmin, butr->ymin+60, butr->xmax-butr->xmin, 20,
                        &c->t1, 1.0f, 80.0f, 100, 0, "Tolerance for colors to be considered a keying color");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Cutoff ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Cutoff ",
                        butr->xmin, butr->ymin+40, butr->xmax-butr->xmin, 20,
                        &c->t2, 0.0f, 30.0f, 100, 0, "Colors below this will be considered as exact matches for keying color");
 
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Lift ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Lift ",
                        butr->xmin, butr->ymin+20, dx, 20,
                        &c->fsize, 0.0f, 1.0f, 100, 0, "Alpha Lift");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Gain ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Gain ",
                        butr->xmin+dx, butr->ymin+20, dx, 20,
                        &c->fstrength, 0.0f, 1.0f, 100, 0, "Alpha Gain");
 
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Shadow Adjust ",
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Shadow Adjust ",
                        butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
                        &c->t3, 0.0f, 1.0f, 100, 0, "Adjusts the brightness of any shadows captured");
 
@@ -1785,13 +1761,13 @@ static int node_composit_buts_channel_matte(uiBlock *block, bNodeTree *ntree, bN
        
                /*color space selectors*/
                uiBlockBeginAlign(block);
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"RGB",
+               uiDefButS(block, ROW,B_NODE_EXEC,"RGB",
                        butr->xmin,butr->ymin+60,sx,20,&node->custom1,1,1, 0, 0, "RGB Color Space");
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"HSV",
+               uiDefButS(block, ROW,B_NODE_EXEC,"HSV",
                        butr->xmin+sx,butr->ymin+60,sx,20,&node->custom1,1,2, 0, 0, "HSV Color Space");
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"YUV",
+               uiDefButS(block, ROW,B_NODE_EXEC,"YUV",
                        butr->xmin+2*sx,butr->ymin+60,sx,20,&node->custom1,1,3, 0, 0, "YUV Color Space");
-               uiDefButS(block, ROW,B_NODE_EXEC+node->nr,"YCC",
+               uiDefButS(block, ROW,B_NODE_EXEC,"YCC",
                        butr->xmin+3*sx,butr->ymin+60,sx,20,&node->custom1,1,4, 0, 0, "YCbCr Color Space");
        
                if (node->custom1==1) {
@@ -1808,18 +1784,18 @@ static int node_composit_buts_channel_matte(uiBlock *block, bNodeTree *ntree, bN
                }
        
                /*channel selector */
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, c1,
+               uiDefButS(block, ROW, B_NODE_EXEC, c1,
                        butr->xmin,butr->ymin+40,cx,20,&node->custom2,1, 1, 0, 0, "Channel 1");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, c2,
+               uiDefButS(block, ROW, B_NODE_EXEC, c2,
                        butr->xmin+cx,butr->ymin+40,cx,20,&node->custom2,1, 2, 0, 0, "Channel 2");
-               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, c3,
+               uiDefButS(block, ROW, B_NODE_EXEC, c3,
                        butr->xmin+cx+cx,butr->ymin+40,cx,20,&node->custom2, 1, 3, 0, 0, "Channel 3");
        
                /*tolerance sliders */
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "High ", 
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "High ", 
                        butr->xmin, butr->ymin+20.0, butr->xmax-butr->xmin, 20,
                        &c->t1, 0.0f, 1.0f, 100, 0, "Values higher than this setting are 100% opaque");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Low ", 
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Low ", 
                        butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
                        &c->t2, 0.0f, 1.0f, 100, 0, "Values lower than this setting are 100% keyed");
                uiBlockEndAlign(block);
@@ -1838,10 +1814,10 @@ static int node_composit_buts_luma_matte(uiBlock *block, bNodeTree *ntree, bNode
                NodeChroma *c=node->storage;
        
                /*tolerance sliders */
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "High ", 
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "High ", 
                        butr->xmin, butr->ymin+20.0, butr->xmax-butr->xmin, 20,
                        &c->t1, 0.0f, 1.0f, 100, 0, "Values higher than this setting are 100% opaque");
-               uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Low ", 
+               uiDefButF(block, NUMSLI, B_NODE_EXEC, "Low ", 
                        butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
                        &c->t2, 0.0f, 1.0f, 100, 0, "Values lower than this setting are 100% keyed");
                uiBlockEndAlign(block);
@@ -1857,7 +1833,7 @@ static int node_composit_buts_luma_matte(uiBlock *block, bNodeTree *ntree, bNode
 static int node_composit_buts_map_uv(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 {
        if(block) {
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Alpha:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "Alpha:",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                  &node->custom1, 0, 100, 0, 0, "Conversion percentage of UV differences to Alpha");
        }
@@ -1867,7 +1843,7 @@ static int node_composit_buts_map_uv(uiBlock *block, bNodeTree *ntree, bNode *no
 static int node_composit_buts_id_mask(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 {
        if(block) {
-               uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "ID:",
+               uiDefButS(block, NUM, B_NODE_EXEC, "ID:",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                  &node->custom1, 0, 10000, 0, 0, "Pass Index number to convert to Alpha");
        }
@@ -1941,10 +1917,10 @@ static int node_composit_buts_file_output(uiBlock *block, bNodeTree *ntree, bNod
                }
                
                /* start frame, end frame */
-               uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "SFra: ", 
+               uiDefButI(block, NUM, B_NODE_EXEC, "SFra: ", 
                                  x, y, w/2, 20, 
                                  &nif->sfra, 1, MAXFRAMEF, 10, 0, "");
-               uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "EFra: ", 
+               uiDefButI(block, NUM, B_NODE_EXEC, "EFra: ", 
                                  x+w/2, y, w/2, 20, 
                                  &nif->efra, 1, MAXFRAMEF, 10, 0, "");
                
@@ -1973,7 +1949,7 @@ static void node_scale_cb(bContext *C, void *node_v, void *unused_v)
 static int node_composit_buts_scale(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 {
        if(block) {
-               uiBut *bt= uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Relative %x0|Absolute %x1|Scene Size % %x2|",
+               uiBut *bt= uiDefButS(block, MENU, B_NODE_EXEC, "Relative %x0|Absolute %x1|Scene Size % %x2|",
                                  butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                  &node->custom1, 0, 0, 0, 0, "Scale new image to absolute pixel size, size relative to the incoming image, or using the 'percent' size of the scene");
                uiButSetFunc(bt, node_scale_cb, node, NULL);
@@ -1985,10 +1961,10 @@ static int node_composit_buts_invert(uiBlock *block, bNodeTree *ntree, bNode *no
 {
        if(block) {
                uiBlockBeginAlign(block);
-               uiDefButBitS(block, TOG, CMP_CHAN_RGB, B_NODE_EXEC+node->nr, "RGB",
+               uiDefButBitS(block, TOG, CMP_CHAN_RGB, B_NODE_EXEC, "RGB",
                                         butr->xmin, butr->ymin, (butr->xmax-butr->xmin)/2, 20, 
                                         &node->custom1, 0, 0, 0, 0, "");
-               uiDefButBitS(block, TOG, CMP_CHAN_A, B_NODE_EXEC+node->nr, "A",
+               uiDefButBitS(block, TOG, CMP_CHAN_A, B_NODE_EXEC, "A",
                                         butr->xmin+(butr->xmax-butr->xmin)/2, butr->ymin, (butr->xmax-butr->xmin)/2, 20, 
                                         &node->custom1, 0, 0, 0, 0, "");
                uiBlockEndAlign(block);
@@ -2002,7 +1978,7 @@ static int node_composit_buts_premulkey(uiBlock *block, bNodeTree *ntree, bNode
                uiBut *bt;
                
                /* blend type */
-               bt=uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Key to Premul %x0|Premul to Key %x1",
+               bt=uiDefButS(block, MENU, B_NODE_EXEC, "Key to Premul %x0|Premul to Key %x1",
                                         butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, 
                                         &node->custom1, 0, 0, 0, 0, "Conversion between premultiplied alpha and key alpha");
        }
@@ -2154,13 +2130,13 @@ static int node_texture_buts_bricks(uiBlock *block, bNodeTree *ntree, bNode *nod
                
                /* Offset */
                uiDefButF(
-                       block, NUM, B_NODE_EXEC+node->nr, "Offset",
+                       block, NUM, B_NODE_EXEC, "Offset",
                        butr->xmin, butr->ymin+20, w-ofw, 20,
                        &node->custom3,
                        0, 1, 0.25, 2,
                        "Offset amount" );
                uiDefButS(
-                       block, NUM, B_NODE_EXEC+node->nr, "",
+                       block, NUM, B_NODE_EXEC, "",
                        butr->xmin+w-ofw, butr->ymin+20, ofw, 20,
                        &node->custom1,
                        2, 99, 0, 0,
@@ -2168,13 +2144,13 @@ static int node_texture_buts_bricks(uiBlock *block, bNodeTree *ntree, bNode *nod
                
                /* Squash */
                uiDefButF(
-                       block, NUM, B_NODE_EXEC+node->nr, "Squash",
+                       block, NUM, B_NODE_EXEC, "Squash",
                        butr->xmin, butr->ymin+0, w-ofw, 20,
                        &node->custom4,
                        0, 99, 0.25, 2,
                        "Stretch amount" );
                uiDefButS(
-                       block, NUM, B_NODE_EXEC+node->nr, "",
+                       block, NUM, B_NODE_EXEC, "",
                        butr->xmin+w-ofw, butr->ymin+0, ofw, 20,
                        &node->custom2,
                        2, 99, 0, 0,
@@ -2211,10 +2187,10 @@ static int node_texture_buts_proc(uiBlock *block, bNodeTree *ntree, bNode *node,
                case TEX_BLEND:
                        if( block ) {
                                uiBlockBeginAlign( block );
-                               uiDefButS( block, MENU, B_NODE_EXEC+node->nr,
+                               uiDefButS( block, MENU, B_NODE_EXEC,
                                        "Linear %x0|Quad %x1|Ease %x2|Diag %x3|Sphere %x4|Halo %x5|Radial %x6",
                                        x, y+20, w, 20, &tex->stype, 0, 1, 0, 0, "Blend Type" );
-                               uiDefButBitS(block, TOG, TEX_FLIPBLEND, B_NODE_EXEC+node->nr, "Flip XY", x, y, w, 20,
+                               uiDefButBitS(block, TOG, TEX_FLIPBLEND, B_NODE_EXEC, "Flip XY", x, y, w, 20,
                                        &tex->flag, 0, 0, 0, 0, "Flips the direction of the progression 90 degrees");
                                uiBlockEndAlign( block );
                        }
@@ -2225,16 +2201,16 @@ static int node_texture_buts_proc(uiBlock *block, bNodeTree *ntree, bNode *node,
                        if( block ) {
                                uiBlockBeginAlign(block);
                        
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Soft",       0*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SOFT, 0, 0, "Uses soft marble"); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Sharp",      1*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARP, 0, 0, "Uses more clearly defined marble"); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Sharper",    2*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARPER, 0, 0, "Uses very clearly defined marble"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Soft",       0*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SOFT, 0, 0, "Uses soft marble"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Sharp",      1*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARP, 0, 0, "Uses more clearly defined marble"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Sharper",    2*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARPER, 0, 0, "Uses very clearly defined marble"); 
                                
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Soft noise", 0*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Hard noise", 1*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Soft noise", 0*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Hard noise", 1*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
                                
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Sin",        0*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands."); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Saw",        1*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands"); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Tri",        2*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Sin",        0*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands."); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Saw",        1*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Tri",        2*w/3+x,  0+y, w/3, 18, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands"); 
             
                                uiBlockEndAlign(block);
                        }
@@ -2248,12 +2224,12 @@ static int node_texture_buts_proc(uiBlock *block, bNodeTree *ntree, bNode *node,
                                uiDefButS(block, ROW, B_TEXPRV,             "Bands",     x,  40+y, w/2, 18, &tex->stype, 2.0, (float)TEX_BANDNOISE, 0, 0, "Uses standard noise"); 
                                uiDefButS(block, ROW, B_TEXPRV,             "Rings", w/2+x,  40+y, w/2, 18, &tex->stype, 2.0, (float)TEX_RINGNOISE, 0, 0, "Lets Noise return RGB value"); 
                                
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Sin", 0*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SIN, 0, 0, "Uses a sine wave to produce bands."); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Saw", 1*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SAW, 0, 0, "Uses a saw wave to produce bands"); 
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Tri", 2*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_TRI, 0, 0, "Uses a triangle wave to produce bands");
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Sin", 0*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SIN, 0, 0, "Uses a sine wave to produce bands."); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Saw", 1*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SAW, 0, 0, "Uses a saw wave to produce bands"); 
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Tri", 2*w/3+x,  20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_TRI, 0, 0, "Uses a triangle wave to produce bands");
                                
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Soft noise", 0*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
-                               uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Hard noise", 1*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Soft noise", 0*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
+                               uiDefButS(block, ROW, B_NODE_EXEC, "Hard noise", 1*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
                                uiBlockEndAlign(block);
                        }
                        return 80; 
@@ -2402,7 +2378,7 @@ static void node_texture_set_butfunc(bNodeType *ntype)
 
 /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
 
-void init_node_butfuncs(void)
+void ED_init_node_butfuncs(void)
 {
        bNodeType *ntype;
        
index 11f760bb882bc493f735d13a70b0789984f8c7d8..30b4bf86b68713fcb4ea6872bea951bbc9835463 100644 (file)
@@ -612,11 +612,34 @@ static void do_node_internal_buttons(bContext *C, void *node_v, int event)
        SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
        
        if(event==B_NODE_EXEC) {
-               if(snode->treetype==NTREE_SHADER)
+               if(snode->treetype==NTREE_SHADER) {
                        WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, snode->id);
+               }
+               else if(snode->treetype==NTREE_COMPOSIT) {
+                       bNode *node= node_v;
+                       
+                       NodeTagChanged(snode->edittree, node);
+                       /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */
+                               
+                       /* not the best implementation of the world... but we need it to work now :) */
+                       if(node->type==CMP_NODE_R_LAYERS && node->custom2) {
+                               /* add event for this window (after render curarea can be changed) */
+                               //addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
+                               
+                               //composite_node_render(snode, node);
+                               //snode_handle_recalc(snode);
+                               
+                               /* add another event, a render can go fullscreen and open new window */
+                               //addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
+                       }
+                       else {
+                               node= snode_get_editgroup(snode);
+                               if(node)
+                                       NodeTagIDChanged(snode->nodetree, node->id);
+                       }
+                       WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C));
+               }                       
                
-       //      else if(snode->treetype==NTREE_COMPOSIT)
-       //              composit_node_event(snode, val);
        //      else if(snode->treetype==NTREE_TEXTURE)
        //              texture_node_event(snode, val);
        }
index aa4d139e32fb84d26c8ecb9d43da6993a5027c48..b4c0fcbd1a5891ffe721fafb6ad73338ec3712e8 100644 (file)
 // XXX XXX XXX
 static void BIF_undo_push(char *s) {}
 
+/* ***************** composite job manager ********************** */
+
+typedef struct CompoJob {
+       Scene *scene;
+       bNodeTree *ntree;
+       bNodeTree *localtree;
+       short *stop;
+       short *do_update;
+} CompoJob;
+
+/* called by compo, only to check job 'stop' value */
+static int compo_breakjob(void *cjv)
+{
+       CompoJob *cj= cjv;
+       
+       return *(cj->stop);
+}
+
+/* called by compo, wmJob sends notifier */
+static void compo_redrawjob(void *cjv, char *str)
+{
+       CompoJob *cj= cjv;
+       
+       *(cj->do_update)= 1;
+}
+
+static void compo_freejob(void *cjv)
+{
+       CompoJob *cj= cjv;
+
+       if(cj->localtree) {
+               ntreeLocalMerge(cj->localtree, cj->ntree);
+       }
+       MEM_freeN(cj);
+}
+
+/* only now we copy the nodetree, so adding many jobs while
+   sliding buttons doesn't frustrate */
+static void compo_initjob(void *cjv)
+{
+       CompoJob *cj= cjv;
+
+       cj->localtree= ntreeLocalize(cj->ntree);
+}
+
+/* called before redraw notifiers, it moves finished previews over */
+static void compo_updatejob(void *cjv)
+{
+       CompoJob *cj= cjv;
+       
+       ntreeLocalSync(cj->localtree, cj->ntree);
+}
+
+
+/* only this runs inside thread */
+static void compo_startjob(void *cjv, short *stop, short *do_update)
+{
+       CompoJob *cj= cjv;
+       bNodeTree *ntree= cj->localtree;
+       
+       if(cj->scene->use_nodes==0)
+               return;
+       
+       cj->stop= stop;
+       cj->do_update= do_update;
+       
+       ntree->test_break= compo_breakjob;
+       ntree->tbh= cj;
+       ntree->stats_draw= compo_redrawjob;
+       ntree->sdh= cj;
+       
+       // XXX BIF_store_spare();
+       
+       ntreeCompositExecTree(ntree, &cj->scene->r, 1); /* 1 is do_previews */
+       
+       ntree->test_break= NULL;
+       ntree->stats_draw= NULL;
+
+}
+
+void snode_composite_job(const bContext *C, ScrArea *sa)
+{
+       SpaceNode *snode= sa->spacedata.first;
+       wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa);
+       CompoJob *cj= MEM_callocN(sizeof(CompoJob), "compo job");
+       
+       /* customdata for preview thread */
+       cj->scene= CTX_data_scene(C);
+       cj->ntree= snode->nodetree;
+       
+       /* setup job */
+       WM_jobs_customdata(steve, cj, compo_freejob);
+       WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE|ND_COMPO_RESULT);
+       WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob);
+       
+       WM_jobs_start(steve);
+       
+}
+
+/* ***************************************** */
+
 #if 0
 
 // XXX snode_handle_recalc will go away */
 static void snode_handle_recalc(SpaceNode *snode)
 {
-       if(snode->treetype==NTREE_COMPOSIT) {
-               if(G.scene->use_nodes) {
-                       snode->nodetree->timecursor= set_timecursor;
-                       G.afbreek= 0;
-                       snode->nodetree->test_break= blender_test_break;
-                       
-                       // XXX BIF_store_spare();
-                       
-                       ntreeCompositExecTree(snode->nodetree, &G.scene->r, 1); /* 1 is do_previews */
-                       
-                       snode->nodetree->timecursor= NULL;
-                       snode->nodetree->test_break= NULL;
-                       // XXX waitcursor(0);
-                       
-                       // allqueue(REDRAWIMAGE, 1);
-                       if(G.scene->r.scemode & R_DOCOMP) {
-                               // XXX BIF_redraw_render_rect();        /* seems to screwup display? */
-                               // mywinset(curarea->win);
-                       }
-               }
-
-               // allqueue(REDRAWNODE, 1);
-       }
-       else if(snode->treetype==NTREE_TEXTURE) {
+       if(snode->treetype==NTREE_TEXTURE) {
                ntreeTexUpdatePreviews(snode->nodetree);
                // XXX BIF_preview_changed(ID_TE);
        }
@@ -233,7 +311,7 @@ static void set_node_imagepath(char *str)   /* called from fileselect */
 
 #endif /* 0 */
 
-static bNode *snode_get_editgroup(SpaceNode *snode)
+bNode *snode_get_editgroup(SpaceNode *snode)
 {
        bNode *gnode;
        
index d239ebea4720b39f9eed1daf48f703a17d19eb3f..8655a7aeac9ebd8708942e71b0a48d1d0fe8bdd9 100644 (file)
@@ -773,8 +773,11 @@ void node_header_buttons(const bContext *C, ARegion *ar)
                }
        }
        else if(snode->treetype==NTREE_COMPOSIT) {
-               uiDefButS(block, TOG, B_NODE_USESCENE, "Use Nodes", xco+5,yco,90,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing");
-               xco+= 90;
+               int icon;
+               
+               if(WM_jobs_test(CTX_wm_manager(C), sa)) icon= ICON_REC; else icon= ICON_BLANK1;
+               uiDefIconTextButS(block, TOG, B_NODE_USESCENE, icon, "Use Nodes", xco+5,yco,100,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing");
+               xco+= 100;
                uiDefButBitI(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,yco,100,19, &scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite");
                xco+= 100;
                uiDefButBitS(block, TOG, SNODE_BACKDRAW, REDRAWNODE, "Backdrop", xco+5,yco,90,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop");
index 0259016b605d65209838f66ae82e1244995dcb91..fb48e4012ada0cabad1da6044309dc20f5e5e466 100644 (file)
@@ -78,6 +78,8 @@ void node_deselectall(SpaceNode *snode, int swap);
 void node_shader_default(Material *ma);
 void node_composit_default(Scene *sce);
 void node_texture_default(Tex *tx);
+void snode_composite_job(const struct bContext *C, ScrArea *sa);
+bNode *snode_get_editgroup(SpaceNode *snode);
 
 // XXXXXX
 
index 851c546507d60de6d1fea271efdefcc03413cb5d..09a5d12bd3485ffc5f251bf567fe7dea7e33f38c 100644 (file)
@@ -62,8 +62,12 @@ void node_keymap(struct wmWindowManager *wm)
 {
        ListBase *keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0);
        
+       /* mouse select in nodes used to be both keys, it's UI elements... */
+       RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
        RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
+       RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
        RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
+       
        WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", ACTIONMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NODE_OT_fit_all", HOMEKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NODE_OT_border_select", BKEY, KM_PRESS, 0, 0);
index f50a3640385c4eb9c09f032c07da2fbbeef0c29b..659069e321d815f9919ae01cc7994d21371798b6 100644 (file)
@@ -141,7 +141,14 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
        /* preview renders */
        switch(wmn->category) {
                case NC_SCENE:
+                       if(wmn->data==ND_NODES)
+                               ED_area_tag_refresh(sa);
+                       break;
+               case NC_WM:
+                       if(wmn->data==ND_FILEREAD)
+                               ED_area_tag_refresh(sa);
                        break;
+                               
                case NC_MATERIAL:
                        /* future: add ID check? */
                        if(wmn->data==ND_SHADING)
@@ -155,11 +162,13 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
        /* default now: refresh node is starting preview */
        SpaceNode *snode= sa->spacedata.first;
        
-       if(snode->treetype==NTREE_SHADER) {
-               if(snode->nodetree) {
-                       
+       if(snode->nodetree) {
+               if(snode->treetype==NTREE_SHADER) {
                        ED_preview_shader_job(C, sa, snode->id, 100, 100);
                }
+               else if(snode->treetype==NTREE_COMPOSIT) {
+                       snode_composite_job(C, sa);
+               }
        }
 }
 
@@ -250,7 +259,8 @@ static void node_header_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_restore(C);
 }
 
-static void node_main_area_listener(ARegion *ar, wmNotifier *wmn)
+/* used for header + main area */
+static void node_region_listener(ARegion *ar, wmNotifier *wmn)
 {
        /* context changes */
        switch(wmn->category) {
@@ -304,7 +314,7 @@ void ED_spacetype_node(void)
        art->regionid = RGN_TYPE_WINDOW;
        art->init= node_main_area_init;
        art->draw= node_main_area_draw;
-       art->listener= node_main_area_listener;
+       art->listener= node_region_listener;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
 
        BLI_addhead(&st->regiontypes, art);
@@ -314,7 +324,7 @@ void ED_spacetype_node(void)
        art->regionid = RGN_TYPE_HEADER;
        art->minsizey= HEADERY;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
-       
+       art->listener= node_region_listener;
        art->init= node_header_area_init;
        art->draw= node_header_area_draw;
        
index 852842465c2e7c1814bb8a428c540d5b28510c47..b10de02dbb49caa95c41079d0f0328eda76fa0bd 100644 (file)
@@ -125,6 +125,7 @@ typedef struct bNode {
        float custom3, custom4;
        
        short need_exec, exec;  /* need_exec is set as UI execution event, exec is flag during exec */
+       void *threaddata;               /* optional extra storage for use in thread (read only then!) */
        
        rctf totr;                              /* entire boundbox */
        rctf butr;                              /* optional buttons area */
index dffea96ce416d3f2631612c61896d4f72c828484..e45be7972ef0eab19d8710edff4e47268c9be245 100644 (file)
@@ -357,7 +357,6 @@ typedef struct SpaceNode {
 } SpaceNode;
 
 /* snode->flag */
-#define SNODE_DO_PREVIEW       1
 #define SNODE_BACKDRAW         2
 #define SNODE_DISPGP           4
 
index c46263183a95328908ba83897fdee59676a3dcb4..8eb12543b8668a0671bfe3539fdb84b5e5ddcd2a 100644 (file)
@@ -187,13 +187,17 @@ int                       WM_framebuffer_to_index(unsigned int col);
 
 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner);
 
+int                    WM_jobs_test(struct wmWindowManager *wm, void *owner);
+
 void           WM_jobs_customdata(struct wmJob *, void *customdata, void (*free)(void *));
-void           WM_jobs_timer(struct wmJob *, double timestep, unsigned int note);
+void           WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
 void           WM_jobs_callbacks(struct wmJob *, 
                                                          void (*startjob)(void *, short *, short *),
+                                                         void (*initjob)(void *),
                                                          void (*update)(void *));
 
 void           WM_jobs_start(struct wmJob *);
+void           WM_jobs_stop_all(struct wmWindowManager *wm);
 
 #endif /* WM_API_H */
 
index f0747e6dad0c7a73695cd66621c2664f2cb0df74..3b7def2923632112222fc84c7fcceb35cdad02f9 100644 (file)
@@ -140,18 +140,22 @@ typedef struct wmNotifier {
 
 /* category */
 #define NOTE_CATEGORY          0xFF000000
-#define        NC_WINDOW                       (1<<24)
-#define        NC_SCREEN                       (2<<24)
-#define        NC_SCENE                        (3<<24)
-#define        NC_OBJECT                       (4<<24)
-#define        NC_MATERIAL                     (5<<24)
-#define        NC_TEXTURE                      (6<<24)
-#define        NC_LAMP                         (7<<24)
-#define        NC_GROUP                        (8<<24)
+#define        NC_WM                           (1<<24)
+#define        NC_WINDOW                       (2<<24)
+#define        NC_SCREEN                       (3<<24)
+#define        NC_SCENE                        (4<<24)
+#define        NC_OBJECT                       (5<<24)
+#define        NC_MATERIAL                     (6<<24)
+#define        NC_TEXTURE                      (7<<24)
+#define        NC_LAMP                         (8<<24)
+#define        NC_GROUP                        (9<<24)
 
 /* data type, 256 entries is enough, it can overlap */
 #define NOTE_DATA                      0x00FF0000
 
+       /* windowmanager */
+#define ND_FILEREAD                    (1<<16)
+
        /* Scene */
 #define        ND_MARKERS                      (2<<16)
 #define        ND_FRAME                        (3<<16)
@@ -161,6 +165,8 @@ typedef struct wmNotifier {
 #define ND_OB_ACTIVE           (7<<16)
 #define ND_OB_SELECT           (8<<16)
 #define ND_MODE                                (9<<16)
+#define ND_RENDER_RESULT       (10<<16)
+#define ND_COMPO_RESULT                (11<<16)
 
        /* Object */
 #define        ND_TRANSFORM            (16<<16)
index d264b09601281030e6c7550169db8db1d0fd3448..3aa177b10186679dce9bf874c6592f3aae6c1936 100644 (file)
@@ -128,11 +128,13 @@ void wm_add_default(bContext *C)
 {
        wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
        wmWindow *win;
+       bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */
        
        CTX_wm_manager_set(C, wm);
-       
        win= wm_window_new(C);
-       win->screen= CTX_wm_screen(C); /* XXX from window? */
+       win->screen= screen;
+       if(screen)
+               BLI_strncpy(win->screenname, screen->id.name+2, 21);
        wm->winactive= win;
        wm_window_make_drawable(C, win); 
 }
index 4bd3cf3f39f302ef5e3a6b49a66d202ed3f75b94..744113f3d3aa8a46af799a0e9dcf2f3bb04c8878 100644 (file)
@@ -394,6 +394,9 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
        /* first wrap up running stuff */
        /* code copied from wm_init_exit.c */
        for(wm= wmlist->first; wm; wm= wm->id.next) {
+               
+               WM_jobs_stop_all(wm);
+               
                for(win= wm->windows.first; win; win= win->next) {
                
                        CTX_wm_window_set(C, win);      /* needed by operator close callbacks */
@@ -443,12 +446,14 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
                        /* match oldwm to new dbase, only old files */
                        
                        for(wm= oldwmlist->first; wm; wm= wm->id.next) {
+                               /* ensure making new keymaps and set space types */
+                               wm->initialized= 0;
+                               
                                for(win= wm->windows.first; win; win= win->next) {
-                                       win->screen= (bScreen *)find_id("SR", win->screenname);
-
-                                       if(win->screen==NULL)
-                                               win->screen= ED_screen_duplicate(win, CTX_wm_screen(C)); /* active screen */
-                                                       
+                                       /* all windows get active screen from file */
+                                       win->screen= CTX_wm_screen(C);
+                                       BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
+                                       
                                        if(win->screen->winid==0)
                                                win->screen->winid= win->winid;
                                }
@@ -462,6 +467,10 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
                        /* this code could move to setup_appdata */
                        oldwm= oldwmlist->first;
                        wm= G.main->wm.first;
+
+                       /* ensure making new keymaps and set space types */
+                       wm->initialized= 0;
+                       
                        /* only first wm in list has ghostwins */
                        for(win= wm->windows.first; win; win= win->next) {
                                for(oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
@@ -518,6 +527,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
                BKE_reset_undo();
                BKE_write_undo(C, "original");  /* save current state */
 
+               WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
 //             refresh_interface_font();
        }
 //     else if(retval==1)
index 01e4cd10b3d94cb1c71a3e5bab7407740140a127..f702154735e2c9e440c2748433b69c2adc1d7b09 100644 (file)
@@ -82,6 +82,7 @@
 #include "wm_files.h"
 #include "wm_window.h"
 
+#include "ED_node.h"
 #include "ED_previewrender.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
@@ -114,10 +115,11 @@ void WM_init(bContext *C)
        set_free_windowmanager_cb(wm_close_and_free);   /* library.c */
        set_blender_test_break_cb(wm_window_testbreak); /* blender.c */
        
-       ED_spacetypes_init();   /* editors/area/spacetype.c */
+       ED_spacetypes_init();   /* editors/space_api/spacetype.c */
+       
+       ED_file_init();                 /* for fsmenu */
+       ED_init_node_butfuncs();        
        
-       ED_file_init(); /* for fsmenu */
-
        /* get the default database, plus a wm */
        WM_read_homefile(C, 0);
        
@@ -175,6 +177,9 @@ void WM_exit(bContext *C)
        /* modal handlers are on window level freed, others too? */
        /* note; same code copied in wm_files.c */
        if(C && CTX_wm_manager(C)) {
+               
+               WM_jobs_stop_all(CTX_wm_manager(C));
+               
                for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
                        
                        CTX_wm_window_set(C, win);      /* needed by operator close callbacks */
index 422cc42e10b7e5f1b8ce0197f3ad87860b30d5c8..40a72034d2613fc7c7cc9a4f7724c0809c134516 100644 (file)
@@ -36,6 +36,7 @@
 #include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_idprop.h"
+#include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
@@ -87,18 +88,22 @@ struct wmJob {
        
        /* should store entire own context, for start, update, free */
        void *customdata;
+       /* to prevent cpu overhead, use this one which only gets called when job really starts, not in thread */
+       void (*initjob)(void *);
+       /* this runs inside thread, and does full job */
        void (*startjob)(void *, short *stop, short *do_update);
+       /* update gets called if thread defines so, and max once per timerstep */
+       /* it runs outside thread, blocking blender, no drawing! */
+       void (*update)(void *);
+       /* free entire customdata, doesn't run in thread */
        void (*free)(void *);
        
        /* running jobs each have own timer */
        double timestep;
        wmTimer *wt;
        /* the notifier event timers should send */
-       unsigned int note;
+       unsigned int note, endnote;
        
-       /* update gets called if thread defines so, and max once per timerstep */
-       /* no drawing, send notifiers! */
-       void (*update)(void *);
        
 /* internal */
        void *owner;
@@ -135,6 +140,18 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner)
        return steve;
 }
 
+/* returns true if job runs, for UI (progress) indicators */
+int WM_jobs_test(wmWindowManager *wm, void *owner)
+{
+       wmJob *steve;
+       
+       for(steve= wm->jobs.first; steve; steve= steve->next)
+               if(steve->owner==owner)
+                       if(steve->running)
+                               return 1;
+       return 0;
+}
+
 void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *))
 {
        /* pending job? just free */
@@ -150,17 +167,20 @@ void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *))
        }
 }
 
-void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note)
+void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note, unsigned int endnote)
 {
        steve->timestep = timestep;
        steve->note = note;
+       steve->endnote = endnote;
 }
 
 void WM_jobs_callbacks(wmJob *steve, 
                                           void (*startjob)(void *, short *, short *),
+                                          void (*initjob)(void *),
                                           void (*update)(void  *))
 {
        steve->startjob= startjob;
+       steve->initjob= initjob;
        steve->update= update;
 }
 
@@ -191,9 +211,14 @@ void WM_jobs_start(wmJob *steve)
                        steve->customdata= NULL;
                        steve->running= 1;
                        
-                       BLI_init_threads(&steve->threads, do_job_thread, 1);
+                       if(steve->initjob)
+                               steve->initjob(steve->run_customdata);
+                       
+                       BLI_init_threads(&steve->threads, do_job_thread, 1);
                        BLI_insert_thread(&steve->threads, steve);
 
+                       // printf("job started\n");
+                       
                        /* restarted job has timer already */
                        if(steve->wt==NULL)
                                steve->wt= WM_event_add_window_timer(steve->win, TIMERJOBS, steve->timestep);
@@ -202,6 +227,28 @@ void WM_jobs_start(wmJob *steve)
        }
 }
 
+void WM_jobs_stop_all(wmWindowManager *wm)
+{
+       wmJob *steve= wm->jobs.first;
+       
+       for(; steve; steve= steve->next) {
+               if(steve->running) {
+                       /* signal job to end */
+                       steve->stop= 1;
+                       BLI_end_threads(&steve->threads);
+               }
+               
+               if(steve->wt)
+                       WM_event_remove_window_timer(steve->win, steve->wt);
+               if(steve->customdata)
+                       steve->free(steve->customdata);
+               if(steve->run_customdata)
+                       steve->run_free(steve->run_customdata);
+       }       
+       
+       BLI_freelistN(&wm->jobs);
+}
+
 /* hardcoded to event TIMERJOBS */
 static int wm_jobs_timer(bContext *C, wmOperator *op, wmEvent *evt)
 {
@@ -214,9 +261,10 @@ static int wm_jobs_timer(bContext *C, wmOperator *op, wmEvent *evt)
                        /* running threads */
                        if(steve->threads.first) {
                                
-                               if(steve->do_update) {
+                               /* always call note and update when ready */
+                               if(steve->do_update || steve->ready) {
                                        if(steve->update)
-                                               steve->update(steve->customdata);
+                                               steve->update(steve->run_customdata);
                                        if(steve->note)
                                                WM_event_add_notifier(C, steve->note, NULL);
                                        steve->do_update= 0;
@@ -228,9 +276,15 @@ static int wm_jobs_timer(bContext *C, wmOperator *op, wmEvent *evt)
                                        steve->run_customdata= NULL;
                                        steve->run_free= NULL;
                                        
+                                       //      if(steve->stop) printf("job stopped\n");
+                                       //      else printf("job finished\n");
+
                                        steve->running= 0;
                                        BLI_end_threads(&steve->threads);
                                        
+                                       if(steve->endnote)
+                                               WM_event_add_notifier(C, steve->endnote, NULL);
+                                       
                                        /* new job added for steve? */
                                        if(steve->customdata) {
                                                WM_jobs_start(steve);
index fc49deb8154c035ef087d1d45fcf73da1f1c95f0..eebf89982c17ef200bfca1832fc914a96801e1d4 100644 (file)
@@ -153,6 +153,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
        win->sizey= winorig->sizey;
        
        win->screen= ED_screen_duplicate(win, winorig->screen);
+       BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
        win->screen->do_refresh= 1;
        win->screen->do_draw= 1;