Grease Pencil for Nodes Editor:
authorJoshua Leung <aligorith@gmail.com>
Wed, 11 Nov 2009 08:12:54 +0000 (08:12 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 11 Nov 2009 08:12:54 +0000 (08:12 +0000)
This commit restores Grease Pencil functionality for the Nodes Editor. Grease Pencil data is now stored at the NodeTree level, which means that annotations remain with the NodeTree they were made for.

Possible TODO's:
* In future, it may be worth investigating attaching Grease Pencil data to individual nodes, to allow annotations to stay attached to nodes as they are moved
* Include the settings for the 'active node' in a panel in the new NKEY region where the Grease Pencil buttons appear.

13 files changed:
source/blender/blenloader/intern/readfile.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/include/ED_gpencil.h
source/blender/editors/space_node/node_buttons.c [new file with mode: 0644]
source/blender/editors/space_node/node_draw.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/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesrna/intern/rna_nodetree.c

index 0082bfd546edd49b82308ade5dacc4f487c2e074..b6ec8376b12038e30856ced3dc5d6e28ac8ba406 100644 (file)
@@ -1983,6 +1983,8 @@ static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
        
        if(ntree->adt) lib_link_animdata(fd, &ntree->id, ntree->adt);
        
+       ntree->gpd= newlibadr_us(fd, id->lib, ntree->gpd);
+       
        for(node= ntree->nodes.first; node; node= node->next)
                node->id= newlibadr_us(fd, id->lib, node->id);
 }
index 9a0187dde0462dffafab7f76de70d028df76097f..6651c7745bbaf21feafa1164df4e6b01cf450181 100644 (file)
@@ -765,31 +765,4 @@ void draw_gpencil_3dview (bContext *C, short only3d)
        draw_gpencil_3dview_ext(scene, ar, only3d);
 }
 
-/* draw grease-pencil sketches to opengl render window assuming that matrices are already set correctly */
-// XXX porting note, ogl render will probably be a window with one 3d region
-void draw_gpencil_oglrender (bContext *C)
-{
-       ScrArea *sa= CTX_wm_area(C);
-       View3D *v3d= (View3D *)sa->spacedata.first;
-       ARegion *ar= CTX_wm_region(C);
-       Scene *scene= CTX_data_scene(C);
-       bGPdata *gpd;
-       
-       /* assume gpencil data comes from v3d */
-       if (v3d == NULL) return;
-       gpd= gpencil_data_get_active(C);
-       if (gpd == NULL) return;
-       
-       /* pass 1: draw 3d-strokes ------------ > */
-       gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, (GP_DRAWDATA_NOSTATUS|GP_DRAWDATA_ONLY3D));
-       
-       /* pass 2: draw 2d-strokes ------------ > */
-               /* adjust view matrices */
-       wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
-       glLoadIdentity();
-       
-               /* draw it! */
-       gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, GP_DRAWDATA_NOSTATUS);
-}
-
 /* ************************************************** */
index 1358ed80f7a57e12198d6daa69f411a2e058cb2d..c2b9a1a4bb96f7d5cac89478abf9b970a494fa4e 100644 (file)
@@ -45,6 +45,7 @@
 #include "DNA_curve_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
+#include "DNA_node_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
@@ -113,9 +114,18 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
                        
                        case SPACE_NODE: /* Nodes Editor */
                        {
-                               //SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
+                               SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
                                
                                /* return the GP data for the active node block/node */
+                               if (snode && snode->nodetree) {
+                                       /* for now, as long as there's an active node tree, default to using that in the Nodes Editor */
+                                       if (ptr) RNA_id_pointer_create(&snode->nodetree->id, ptr);
+                                       return &snode->nodetree->gpd;
+                               }
+                               else {
+                                       /* even when there is no node-tree, don't allow this to flow to scene */
+                                       return NULL;
+                               }
                        }
                                break;
                                
index 64e68fab508db8dc467b1d402a8d6c9aa9b7dbe9..4229c66353c7ecdfcd9674e492ce4409cca8eb96 100644 (file)
@@ -808,16 +808,17 @@ static tGPsdata *gp_session_initpaint (bContext *C)
 #endif
                }
                        break;
-#if 0 // XXX these other spaces will come over time...
+
                case SPACE_NODE:
                {
-                       SpaceNode *snode= curarea->spacedata.first;
+                       //SpaceNode *snode= curarea->spacedata.first;
                        
                        /* set current area */
                        p->sa= curarea;
                        p->ar= ar;
                        p->v2d= &ar->v2d;
                        
+#if 0 // XXX will this sort of antiquated stuff be restored?
                        /* check that gpencil data is allowed to be drawn */
                        if ((snode->flag & SNODE_DISPGP)==0) {
                                p->status= GP_STATUS_ERROR;
@@ -825,8 +826,10 @@ static tGPsdata *gp_session_initpaint (bContext *C)
                                        printf("Error: In active view, Grease Pencil not shown \n");
                                return;
                        }
+#endif
                }
                        break;
+#if 0 // XXX these other spaces will come over time...
                case SPACE_SEQ:
                {
                        SpaceSeq *sseq= curarea->spacedata.first;
@@ -983,12 +986,13 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode)
                                p->gpd->sbuffer_sflag |= GP_STROKE_3DSPACE;
                        }
                                break;
-#if 0 // XXX other spacetypes to be restored in due course
+                       
                        case SPACE_NODE:
                        {
                                p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
                        }
                                break;
+#if 0 // XXX other spacetypes to be restored in due course
                        case SPACE_SEQ:
                        {
                                SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first;
@@ -1298,12 +1302,15 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event)
        tGPsdata *p = NULL;
        wmWindow *win= CTX_wm_window(C);
        
-       //printf("GPencil - Starting Drawing \n");
+       if (G.f & G_DEBUG)
+               printf("GPencil - Starting Drawing \n");
        
        /* try to initialise context data needed while drawing */
        if (!gpencil_draw_init(C, op)) {
-               if (op->customdata) MEM_freeN(op->customdata);
-               printf("\tGP - no valid data \n");
+               if (op->customdata) 
+                       MEM_freeN(op->customdata);
+               if (G.f & G_DEBUG)
+                       printf("\tGP - no valid data \n");
                return OPERATOR_CANCELLED;
        }
        else
index 31c8e93c683303eb61278d19d33a83480d516291..ef5169465ab41487bd5e4f1aea264db4f0edfad1 100644 (file)
@@ -73,7 +73,6 @@ void draw_gpencil_2dimage(struct bContext *C, struct ImBuf *ibuf);
 void draw_gpencil_2dview(struct bContext *C, short onlyv2d);
 void draw_gpencil_3dview(struct bContext *C, short only3d);
 void draw_gpencil_3dview_ext(struct Scene *scene, struct ARegion *ar, short only3d);
-void draw_gpencil_oglrender(struct bContext *C);
 
 void gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
 
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
new file mode 100644 (file)
index 0000000..63361f2
--- /dev/null
@@ -0,0 +1,138 @@
+/**
+ * $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 *****
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
+#include "DNA_ID.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_node_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_rand.h"
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_idprop.h"
+#include "BKE_object.h"
+#include "BKE_global.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "ED_gpencil.h"
+#include "ED_screen.h"
+#include "ED_types.h"
+#include "ED_util.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "node_intern.h"       // own include
+
+
+/* ******************* node space & buttons ************** */
+#define B_NOP          1
+#define B_REDR         2
+
+#if 0 // XXX not used...
+static void do_node_region_buttons(bContext *C, void *arg, int event)
+{
+       //SpaceNode *snode= CTX_wm_space_node(C);
+       
+       switch(event) {
+       case B_REDR:
+               ED_area_tag_redraw(CTX_wm_area(C));
+               return; /* no notifier! */
+       }
+}
+#endif
+
+/* ******************* node buttons registration ************** */
+
+void node_buttons_register(ARegionType *art)
+{
+       PanelType *pt;
+       
+       // XXX active node
+       
+       pt= MEM_callocN(sizeof(PanelType), "spacetype node panel gpencil");
+       strcpy(pt->idname, "NODE_PT_gpencil");
+       strcpy(pt->label, "Grease Pencil");
+       pt->draw= gpencil_panel_standard;
+       BLI_addtail(&art->paneltypes, pt);
+}
+
+static int node_properties(bContext *C, wmOperator *op)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       ARegion *ar= node_has_buttons_region(sa);
+       
+       if(ar)
+               ED_region_toggle_hidden(C, ar);
+
+       return OPERATOR_FINISHED;
+}
+
+/* non-standard poll operator which doesn't care if there are any nodes */
+static int node_properties_poll(bContext *C)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       return (sa && (sa->spacetype == SPACE_NODE));
+}
+
+void NODE_OT_properties(wmOperatorType *ot)
+{
+       ot->name= "Properties";
+       ot->description= "Toggles the properties panel display.";
+       ot->idname= "NODE_OT_properties";
+       
+       ot->exec= node_properties;
+       ot->poll= node_properties_poll;
+       
+       /* flags */
+       ot->flag= 0;
+}
index 1ebb7e13193ab56399d86f7d4b93ba4b8f3a3d6a..4ac6fbebea1c7c5d25ad9531338d17c88fe19138 100644 (file)
 #include "BKE_text.h"
 #include "BKE_utildefines.h"
 
-/* #include "BDR_gpencil.h" XXX */
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "ED_gpencil.h"
 #include "ED_screen.h"
 #include "ED_util.h"
 #include "ED_types.h"
@@ -1102,38 +1101,16 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
        }
        
        /* draw grease-pencil ('canvas' strokes) */
-       /*if ((snode->flag & SNODE_DISPGP) && (snode->nodetree))
-               draw_gpencil_2dview(sa, 1);*/
-       
-       /* restore viewport (not needed yet) */
-       /*mywinset(sa->win);*/
-
-       /* ortho at pixel level curarea */
-       /*myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);*/
-       
-       /* draw grease-pencil (screen strokes) */
-       /*if ((snode->flag & SNODE_DISPGP) && (snode->nodetree))
-               draw_gpencil_2dview(sa, 0);*/
-
-       //draw_area_emboss(sa);
-       
-       /* it is important to end a view in a transform compatible with buttons */
-       /*bwin_scalematrix(sa->win, snode->blockscale, snode->blockscale, snode->blockscale);
-       nodes_blockhandlers(sa);*/
-       
-       //curarea->win_swap= WIN_BACK_OK;
-       
-       /* in the end, this is a delayed previewrender test, to allow buttons to be first */
-       /*if(snode->flag & SNODE_DO_PREVIEW) {
-               addafterqueue(sa->win, RENDERPREVIEW, 1);
-               snode->flag &= ~SNODE_DO_PREVIEW;
-       }*/
-       
-       
+       if (/*(snode->flag & SNODE_DISPGP) &&*/ (snode->nodetree))
+               draw_gpencil_2dview((bContext*)C, 1);
        
        /* reset view matrix */
        UI_view2d_view_restore(C);
        
+       /* draw grease-pencil (screen strokes, and also paintbuffer) */
+       if (/*(snode->flag & SNODE_DISPGP) && */(snode->nodetree))
+               draw_gpencil_2dview((bContext*)C, 0);
+       
        /* scrollers */
        scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
        UI_view2d_scrollers_draw(C, v2d, scrollers);
index f55ecf1d0f49fe1cef2c8d613972a7d750eaff3a..2d4d70355685330bcfddec00da58ee004896618f 100644 (file)
@@ -44,6 +44,9 @@ struct wmWindowManager;
 #define NODE_EXTEND                            1
 #define NODE_EXCLUSIVE                 3
 
+/* space_node.c */
+ARegion *node_has_buttons_region(ScrArea *sa);
+
 /* node_header.c */
 void node_header_buttons(const bContext *C, ARegion *ar);
 void node_menus_register(struct ARegionType *art);
@@ -51,6 +54,10 @@ void node_menus_register(struct ARegionType *art);
 /* node_draw.c */
 void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d);
 
+/* node_buttons.c */
+void node_buttons_register(struct ARegionType *art);
+void NODE_OT_properties(struct wmOperatorType *ot);
+
 /* node_ops.c */
 void node_operatortypes(void);
 void node_keymap(wmKeyConfig *keyconf);
@@ -121,6 +128,6 @@ enum {
        B_MATPRV,
        B_NODE_LOADIMAGE,
        B_NODE_SETIMAGE,
-} eActHeader_ButEvents;
+} eNodeSpace_ButEvents;
 
 #endif /* ED_NODE_INTERN_H */
index 443b83a91bc2bbae173891be33c319617ba3b034..b78fc864a11fdfc5f9f39785496abfa5ff85e476 100644 (file)
@@ -49,6 +49,8 @@
 
 void node_operatortypes(void)
 {
+       WM_operatortype_append(NODE_OT_properties);
+       
        WM_operatortype_append(NODE_OT_select);
        WM_operatortype_append(NODE_OT_select_extend);
        WM_operatortype_append(NODE_OT_select_all);
@@ -69,9 +71,17 @@ void node_operatortypes(void)
 
 void node_keymap(struct wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "Node", SPACE_NODE, 0);
+       wmKeyMap *keymap;
        wmKeyMapItem *kmi;
        
+       /* Entire Editor only ----------------- */
+       keymap= WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0);
+       
+       WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0);
+       
+       /* Main Area only ----------------- */
+       keymap= WM_keymap_find(keyconf, "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);
index d8c6272dd7790021e147adf96ec5fac13eb762ed..17bb96f51631c018ba4ed585291d1f03fe5689d0 100644 (file)
 
 #include "node_intern.h"       // own include
 
+/* ******************** manage regions ********************* */
+
+ARegion *node_has_buttons_region(ScrArea *sa)
+{
+       ARegion *ar, *arnew;
+       
+       for(ar= sa->regionbase.first; ar; ar= ar->next)
+               if(ar->regiontype==RGN_TYPE_UI)
+                       return ar;
+       
+       /* add subdiv level; after header */
+       for(ar= sa->regionbase.first; ar; ar= ar->next)
+               if(ar->regiontype==RGN_TYPE_HEADER)
+                       break;
+       
+       /* is error! */
+       if(ar==NULL) return NULL;
+       
+       arnew= MEM_callocN(sizeof(ARegion), "buttons for node");
+       
+       BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+       arnew->regiontype= RGN_TYPE_UI;
+       arnew->alignment= RGN_ALIGN_RIGHT;
+       
+       arnew->flag = RGN_FLAG_HIDDEN;
+       
+       return arnew;
+}
+
 /* ******************** default callbacks for node space ***************** */
 
 static SpaceLink *node_new(const bContext *C)
@@ -82,16 +111,13 @@ static SpaceLink *node_new(const bContext *C)
        ar->regiontype= RGN_TYPE_HEADER;
        ar->alignment= RGN_ALIGN_BOTTOM;
        
-#if 0
-       /* channels */
-       ar= MEM_callocN(sizeof(ARegion), "nodetree area for node");
+       /* buttons/list view */
+       ar= MEM_callocN(sizeof(ARegion), "buttons for node");
        
        BLI_addtail(&snode->regionbase, ar);
-       ar->regiontype= RGN_TYPE_CHANNELS;
-       ar->alignment= RGN_ALIGN_LEFT;
-       
-       //ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
-#endif
+       ar->regiontype= RGN_TYPE_UI;
+       ar->alignment= RGN_ALIGN_RIGHT;
+       ar->flag = RGN_FLAG_HIDDEN;
        
        /* main area */
        ar= MEM_callocN(sizeof(ARegion), "main area for node");
@@ -128,9 +154,7 @@ static SpaceLink *node_new(const bContext *C)
 /* not spacelink itself */
 static void node_free(SpaceLink *sl)
 {      
-//     SpaceNode *snode= (SpaceNode*) sl;
        
-// XXX if(snode->gpd) free_gpencil_data(snode->gpd);
 }
 
 
@@ -210,41 +234,26 @@ static SpaceLink *node_duplicate(SpaceLink *sl)
        
        /* clear or remove stuff from old */
        snoden->nodetree= NULL;
-// XXX snoden->gpd= gpencil_data_duplicate(snode->gpd);
        
        return (SpaceLink *)snoden;
 }
 
-#if 0
-static void node_channel_area_init(wmWindowManager *wm, ARegion *ar)
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void node_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
+       wmKeyMap *keymap;
+
+       ED_region_panels_init(wm, ar);
+       
+       keymap= WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
-static void node_channel_area_draw(const bContext *C, ARegion *ar)
+static void node_buttons_area_draw(const bContext *C, ARegion *ar)
 {
-       View2D *v2d= &ar->v2d;
-       View2DScrollers *scrollers;
-       float col[3];
-       
-       /* clear and setup matrix */
-       UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       UI_view2d_view_ortho(C, v2d);
-       
-       /* data... */
-       
-       /* reset view matrix */
-       UI_view2d_view_restore(C);
-       
-       /* scrollers */
-       scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
-       UI_view2d_scrollers_draw(C, v2d, scrollers);
-       UI_view2d_scrollers_free(scrollers);
+       ED_region_panels(C, ar, 1, NULL, -1);
 }
-#endif
 
 /* Initialise main area, setting handlers. */
 static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
@@ -253,7 +262,10 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
-       /* own keymap */
+       /* own keymaps */
+       keymap= WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
        keymap= WM_keymap_find(wm->defaultconf, "Node", SPACE_NODE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
@@ -343,7 +355,7 @@ void ED_spacetype_node(void)
        art->init= node_main_area_init;
        art->draw= node_main_area_draw;
        art->listener= node_region_listener;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_GPENCIL;
 
        BLI_addhead(&st->regiontypes, art);
        
@@ -360,19 +372,17 @@ void ED_spacetype_node(void)
 
        node_menus_register(art);
        
-#if 0
-       /* regions: channels */
+       /* regions: listview/buttons */
        art= MEM_callocN(sizeof(ARegionType), "spacetype node region");
-       art->regionid = RGN_TYPE_CHANNELS;
-       art->minsizex= 100;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
-       
-       art->init= node_channel_area_init;
-       art->draw= node_channel_area_draw;
-       
+       art->regionid = RGN_TYPE_UI;
+       art->minsizex= 180; // XXX
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
+       art->listener= node_region_listener;
+       art->init= node_buttons_area_init;
+       art->draw= node_buttons_area_draw;
        BLI_addhead(&st->regiontypes, art);
-#endif
        
+       node_buttons_register(art);
        
        BKE_spacetype_register(st);
 }
index ee0830e85daa74cba1e6190aa8428fbebf6d4a01..8aa63518e96b196c576251a57bc8124ec4a0a034 100644 (file)
@@ -2176,7 +2176,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
                glDisable(GL_DEPTH_TEST);
        }
        
-       /* draw grease-pencil stuff */
+       /* draw grease-pencil stuff (3d-space strokes) */
        //if (v3d->flag2 & V3D_DISPGP)
                draw_gpencil_3dview((bContext *)C, 1);
        
index 9d80f7f720e39a68359cbd48b8bea7efd9159868..ab7277ee840575dcc5c396934ace6f97aa25526a 100644 (file)
@@ -40,6 +40,7 @@ struct bNodeLink;
 struct bNodeType;
 struct bNodeGroup;
 struct AnimData;
+struct bGPdata;
 struct uiBlock;
 
 #define NODE_MAXSTR 32
@@ -168,6 +169,8 @@ typedef struct bNodeTree {
        ID id;
        struct AnimData *adt;           /* animation data (must be immediately after id for utilities to use it) */ 
        
+       struct bGPdata *gpd;            /* grease pencil data */
+       
        ListBase nodes, links;
        
        bNodeStack *stack;                              /* stack is only while executing, no read/write in file */
index 8d8ed565d1c2606e78f00c613535a917bc04f6b6..2aef756bc8e82d2d1c2d8e32ba7bc35a24d8c7df 100644 (file)
@@ -2051,12 +2051,21 @@ static void rna_def_nodetree(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "bNodeTree");
        RNA_def_struct_ui_icon(srna, ICON_NODETREE);
        
+       /* AnimData */
        rna_def_animdata_common(srna);
-
+       
+       /* Nodes Collection */
        prop = RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
        RNA_def_property_struct_type(prop, "Node");
        RNA_def_property_ui_text(prop, "Nodes", "");
+       
+       /* Grease Pencil */
+       prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "gpd");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_struct_type(prop, "GreasePencil");
+       RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
 }
 
 static void define_specific_node(BlenderRNA *brna, int id, void (*func)(StructRNA*))