diff options
author | Miika Hamalainen <blender@miikah.org> | 2012-07-04 21:15:05 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2012-07-04 21:15:05 +0400 |
commit | 9324503b84a06f76af072131da947547c84698ed (patch) | |
tree | b9336118dcf8df9e9ca4888d9ee3ac9fec2c2798 /source/blender/editors/space_node | |
parent | 234c338655fc49efef0b7ffe0ef6736e8630411a (diff) | |
parent | 958cf139f6587df631944f6ec0fcb4111c7e58fa (diff) |
Merge with trunk r48602
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 51 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_templates.c | 152 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 325 |
5 files changed, 308 insertions, 253 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 69f2867535a..daab0ce0f5f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1194,7 +1194,7 @@ static void node_common_set_butfunc(bNodeType *ntype) /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */ -static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imaptr, PointerRNA *iuserptr) +static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, PointerRNA *imaptr, PointerRNA *iuserptr) { uiLayout *col; int source; @@ -1213,25 +1213,24 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap Scene *scene = CTX_data_scene(C); ImageUser *iuser = iuserptr->data; char numstr[32]; - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL); BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); uiItemL(layout, numstr, ICON_NONE); } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { col = uiLayoutColumn(layout, TRUE); - uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_cyclic", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); } col = uiLayoutColumn(layout, FALSE); if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) - uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); - + uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); } static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1311,7 +1310,10 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + /* note: image user properties used directly here, unlike compositor image node, + * which redefines them in the node struct RNA to get proper updates. + */ + node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1323,7 +1325,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); uiItemR(layout, ptr, "projection", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1456,7 +1458,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * imaptr = RNA_pointer_get(ptr, "image"); RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -3352,3 +3354,28 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); // node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); } + +void drawnodesnap(View2D *v2d, const float cent[2], float size, NodeBorder border) +{ + glBegin(GL_LINES); + + if (border & (NODE_LEFT | NODE_RIGHT)) { + glVertex2f(cent[0], v2d->cur.ymin); + glVertex2f(cent[0], v2d->cur.ymax); + } + else { + glVertex2f(cent[0], cent[1] - size); + glVertex2f(cent[0], cent[1] + size); + } + + if (border & (NODE_TOP | NODE_BOTTOM)) { + glVertex2f(v2d->cur.xmin, cent[1]); + glVertex2f(v2d->cur.xmax, cent[1]); + } + else { + glVertex2f(cent[0] - size, cent[1]); + glVertex2f(cent[0] + size, cent[1]); + } + + glEnd(); +} diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c65bbd6e15f..65646c855b7 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -65,6 +65,7 @@ #include "ED_node.h" #include "ED_gpencil.h" +#include "ED_space_api.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -723,6 +724,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); @@ -804,7 +811,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -861,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node->block= NULL; } -static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNode *node) +static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { bNodeSocket *sock; rctf *rct= &node->totr; @@ -878,10 +885,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(color_id); if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } + uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1004,7 +1019,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { if (node->flag & NODE_HIDDEN) - node_draw_hidden(C, ar, snode, node); + node_draw_hidden(C, ar, snode, ntree, node); else node_draw_basis(C, ar, snode, ntree, node); } @@ -1087,6 +1102,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) //uiFreeBlocksWin(&sa->uiblocks, sa->win); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); + /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); @@ -1095,7 +1112,9 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); - UI_view2d_constant_grid_draw(v2d); + /* grid */ + UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); + /* backdrop */ draw_nodespace_back_pix(ar, snode, color_manage); @@ -1137,6 +1156,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + /* draw grease-pencil ('canvas' strokes) */ if (snode->nodetree) draw_gpencil_view2d(C, 1); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 48f772e8008..9a6906c43bc 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1643,7 +1643,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; - ot->description = "Zoom in/out the brackground image"; + ot->description = "Zoom in/out the background image"; /* api callbacks */ ot->exec = backimage_zoom; diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index bf0e539efe7..f12c7941e1d 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -68,11 +68,11 @@ static void node_tag_recursive(bNode *node) bNodeSocket *input; if (!node || (node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag |= NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_tag_recursive(input->link->fromnode); } @@ -82,11 +82,11 @@ static void node_clear_recursive(bNode *node) bNodeSocket *input; if (!node || !(node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag &= ~NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_clear_recursive(input->link->fromnode); } @@ -100,20 +100,20 @@ static void node_remove_linked(bNodeTree *ntree, bNode *rem_node) return; /* tag linked nodes to be removed */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; - + node_tag_recursive(rem_node); /* clear tags on nodes that are still used by other nodes */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (!(node->flag & NODE_TEST)) - for (sock=node->inputs.first; sock; sock=sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->link && sock->link->fromnode != rem_node) node_clear_recursive(sock->link->fromnode); /* remove nodes */ - for (node=ntree->nodes.first; node; node=next) { + for (node = ntree->nodes.first; node; node = next) { next = node->next; if (node->flag & NODE_TEST) { @@ -166,7 +166,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t } /* find existing node that we can use */ - for (node_from=ntree->nodes.first; node_from; node_from=node_from->next) + for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) if (node_from->type == ntemp->type) break; @@ -181,7 +181,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t node_from = node_prev; } else if (!node_from) { - node_from= nodeAddNode(ntree, ntemp); + node_from = nodeAddNode(ntree, ntemp); node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy; @@ -199,11 +199,11 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t if (node_prev && node_from != node_prev) { bNodeSocket *sock_prev, *sock_from; - for (sock_prev=node_prev->inputs.first; sock_prev; sock_prev=sock_prev->next) { - for (sock_from=node_from->inputs.first; sock_from; sock_from=sock_from->next) { + for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) { + for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) { if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) continue; - + if (strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) { bNodeLink *link = sock_prev->link; @@ -239,9 +239,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t /****************************** Node Link Menu *******************************/ -#define UI_NODE_LINK_ADD 0 -#define UI_NODE_LINK_DISCONNECT -1 -#define UI_NODE_LINK_REMOVE -2 +#define UI_NODE_LINK_ADD 0 +#define UI_NODE_LINK_DISCONNECT -1 +#define UI_NODE_LINK_REMOVE -2 typedef struct NodeLinkArg { Main *bmain; @@ -259,7 +259,7 @@ typedef struct NodeLinkArg { static void ui_node_link(bContext *C, void *arg_p, void *event_p) { - NodeLinkArg *arg = (NodeLinkArg*)arg_p; + NodeLinkArg *arg = (NodeLinkArg *)arg_p; Main *bmain = arg->bmain; bNode *node_to = arg->node; bNodeSocket *sock_to = arg->sock; @@ -278,7 +278,7 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) node_socket_remove(bmain, ntree, node_to, sock_to); else node_socket_add_replace(bmain, ntree, node_to, sock_to, &ntemp, arg->output); - + ED_undo_push(C, "Node input modify"); } @@ -290,7 +290,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) if (node->type == NODE_GROUP) { if (node->id) - BLI_strncpy(node_name, node->id->name+2, UI_MAX_NAME_STR); + BLI_strncpy(node_name, node->id->name + 2, UI_MAX_NAME_STR); else BLI_strncpy(node_name, N_("Group"), UI_MAX_NAME_STR); } @@ -331,17 +331,17 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) bNodeTree *ngroup; NodeLinkArg *argN; int first = 1; - int compatibility= 0; + int compatibility = 0; if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(arg->scene)) - compatibility= NODE_NEW_SHADING; + compatibility = NODE_NEW_SHADING; else - compatibility= NODE_OLD_SHADING; + compatibility = NODE_OLD_SHADING; } if (nclass == NODE_CLASS_GROUP) { - for (ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) { + for (ngroup = bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { bNodeSocket *gsock; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -349,11 +349,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ngroup->type != ntree->type) continue; - for (gsock=ngroup->inputs.first; gsock; gsock=gsock->next) + for (gsock = ngroup->inputs.first; gsock; gsock = gsock->next) if (ui_compatible_sockets(gsock->type, sock->type)) num++; - for (i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) { + for (i = 0, j = 0, gsock = ngroup->outputs.first; gsock; gsock = gsock->next, i++) { if (!ui_compatible_sockets(gsock->type, sock->type)) continue; @@ -362,27 +362,27 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } if (num > 1) { if (j == 0) { - uiItemL(column, ngroup->id.name+2, ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + uiItemL(column, ngroup->id.name + 2, ICON_NODE); + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", gsock->name); j++; } else - BLI_strncpy(name, ngroup->id.name+2, UI_MAX_NAME_STR); + BLI_strncpy(name, ngroup->id.name + 2, UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, ngroup->id.name+2, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, ngroup->id.name + 2, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = NODE_GROUP; @@ -393,9 +393,9 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) } } else { - bNodeTreeType *ttype= ntreeGetType(ntree->type); + bNodeTreeType *ttype = ntreeGetType(ntree->type); - for (ntype=ttype->node_types.first; ntype; ntype=ntype->next) { + for (ntype = ttype->node_types.first; ntype; ntype = ntype->next) { bNodeSocketTemplate *stemp; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -406,11 +406,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ntype->nclass != nclass) continue; - for (i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) + for (i = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) if (ui_compatible_sockets(stemp->type, sock->type)) num++; - for (i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { + for (i = 0, j = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { if (!ui_compatible_sockets(stemp->type, sock->type)) continue; @@ -419,8 +419,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } @@ -428,8 +428,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (num > 1) { if (j == 0) { uiItemL(column, IFACE_(ntype->name), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", IFACE_(stemp->name)); @@ -438,8 +438,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) else BLI_strncpy(name, IFACE_(ntype->name), UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = ntype->type; @@ -452,7 +452,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name) { - NodeLinkArg *arg = (NodeLinkArg*)calldata; + NodeLinkArg *arg = (NodeLinkArg *)calldata; if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) ui_node_menu_column(arg, nclass, name); @@ -460,22 +460,22 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char * static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but = (uiBut*)but_p; + uiBut *but = (uiBut *)but_p; uiLayout *split, *column; - NodeLinkArg *arg = (NodeLinkArg*)but->func_argN; + NodeLinkArg *arg = (NodeLinkArg *)but->func_argN; bNodeSocket *sock = arg->sock; - bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type); + bNodeTreeType *ntreetype = ntreeGetType(arg->ntree->type); uiBlockSetCurLayout(block, layout); split = uiLayoutSplit(layout, 0.0f, FALSE); - arg->bmain= bmain; - arg->scene= scene; - arg->layout= split; - + arg->bmain = bmain; + arg->scene = scene; + arg->layout = split; + if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); @@ -484,15 +484,15 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ if (sock->link) { uiItemL(column, IFACE_("Link"), ICON_NONE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; - but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE)); - but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT)); } @@ -517,14 +517,14 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { char name[UI_MAX_NAME_STR]; ui_node_sock_name(sock, name); - but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); - but->type= MENU; - but->flag |= UI_TEXT_LEFT|UI_BUT_NODE_LINK; - but->poin= (char*)but; + but->type = MENU; + but->flag |= UI_TEXT_LEFT | UI_BUT_NODE_LINK; + but->poin = (char *)but; but->func_argN = arg; if (sock->link && sock->link->fromnode) @@ -535,7 +535,7 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo /**************************** Node Tree Layout *******************************/ static void ui_node_draw_input(uiLayout *layout, bContext *C, - bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); + bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, int depth) { @@ -555,8 +555,8 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b } } - for (input=node->inputs.first; input; input=input->next) - ui_node_draw_input(layout, C, ntree, node, input, depth+1); + for (input = node->inputs.first; input; input = input->next) + ui_node_draw_input(layout, C, ntree, node, input, depth + 1); } static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) @@ -567,7 +567,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiLayout *split, *row, *col; bNode *lnode; char label[UI_MAX_NAME_STR]; - int indent = (depth > 1)? 2*(depth - 1): 0; + int indent = (depth > 1) ? 2 * (depth - 1) : 0; int dependency_loop; if (input->flag & SOCK_UNAVAIL) @@ -575,7 +575,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* to avoid eternal loops on cyclic dependencies */ node->flag |= NODE_TEST; - lnode = (input->link)? input->link->fromnode: NULL; + lnode = (input->link) ? input->link->fromnode : NULL; dependency_loop = (lnode && (lnode->flag & NODE_TEST)); if (dependency_loop) @@ -598,21 +598,21 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiBlockSetEmboss(block, UI_EMBOSSN); if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { - int icon = (input->flag & SOCK_COLLAPSED)? ICON_DISCLOSURE_TRI_RIGHT: ICON_DISCLOSURE_TRI_DOWN; + int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } else uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; - bt->x2 = UI_UNIT_X/2; + bt->x2 = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } uiItemL(row, label, ICON_NONE); - bt= block->buttons.last; - bt->flag= UI_TEXT_LEFT; + bt = block->buttons.last; + bt->flag = UI_TEXT_LEFT; if (dependency_loop) { row = uiLayoutRow(split, FALSE); @@ -661,7 +661,7 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * return; /* clear for cycle check */ - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) tnode->flag &= ~NODE_TEST; if (input) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index e069ba2a5fc..349259ad71b 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -4,7 +4,7 @@ * 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. + * 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 @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -63,7 +63,7 @@ #include "RNA_access.h" -#include "node_intern.h" // own include +#include "node_intern.h" // own include /* ******************** manage regions ********************* */ @@ -71,23 +71,23 @@ ARegion *node_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar==NULL) return NULL; - - arnew= MEM_callocN(sizeof(ARegion), "buttons for node"); - + 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->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -97,64 +97,64 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceNode *snode; - - snode= MEM_callocN(sizeof(SpaceNode), "initnode"); - snode->spacetype= SPACE_NODE; - + + snode = MEM_callocN(sizeof(SpaceNode), "initnode"); + snode->spacetype = SPACE_NODE; + /* backdrop */ snode->zoom = 1.0f; - + /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for node"); - + ar = MEM_callocN(sizeof(ARegion), "header for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; - + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for node"); - + ar = MEM_callocN(sizeof(ARegion), "buttons for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + 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"); - + ar = MEM_callocN(sizeof(ARegion), "main area for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; - + ar->regiontype = RGN_TYPE_WINDOW; + ar->v2d.tot.xmin = -256.0f; ar->v2d.tot.ymin = -256.0f; ar->v2d.tot.xmax = 768.0f; ar->v2d.tot.ymax = 768.0f; - + ar->v2d.cur.xmin = -256.0f; ar->v2d.cur.ymin = -256.0f; ar->v2d.cur.xmax = 768.0f; ar->v2d.cur.ymax = 768.0f; - - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 1.0f; - - ar->v2d.max[0]= 32000.0f; - ar->v2d.max[1]= 32000.0f; - - ar->v2d.minzoom= 0.09f; - ar->v2d.maxzoom= 2.31f; - - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - ar->v2d.keeptot= 0; - + + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 1.0f; + + ar->v2d.max[0] = 32000.0f; + ar->v2d.max[1] = 32000.0f; + + ar->v2d.minzoom = 0.09f; + ar->v2d.maxzoom = 2.31f; + + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = 0; + return (SpaceLink *)snode; } /* not spacelink itself */ static void node_free(SpaceLink *UNUSED(sl)) -{ - +{ + } @@ -167,10 +167,10 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static void node_area_listener(ScrArea *sa, wmNotifier *wmn) { /* note, ED_area_tag_refresh will re-execute compositor */ - SpaceNode *snode= sa->spacedata.first; - int type= snode->treetype; + SpaceNode *snode = sa->spacedata.first; + int type = snode->treetype; short shader_type = snode->shaderfrom; - + /* preview renders */ switch (wmn->category) { case NC_SCENE: @@ -183,9 +183,9 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_TRANSFORM_DONE: - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { if (snode->flag & SNODE_AUTO_RENDER) { - snode->recalc= 1; + snode->recalc = 1; ED_area_tag_refresh(sa); } } @@ -193,43 +193,43 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_WM: - if (wmn->data==ND_FILEREAD) + if (wmn->data == ND_FILEREAD) ED_area_tag_refresh(sa); break; - + /* future: add ID checks? */ case NC_MATERIAL: - if (type==NTREE_SHADER) { - if (wmn->data==ND_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_SHADING) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SHADING_DRAW) + else if (wmn->data == ND_SHADING_DRAW) ED_area_tag_refresh(sa); - else if (wmn->action==NA_ADDED && snode->edittree) + else if (wmn->action == NA_ADDED && snode->edittree) nodeSetActiveID(snode->edittree, ID_MA, wmn->reference); - + } break; case NC_TEXTURE: - if (type==NTREE_SHADER || type==NTREE_TEXTURE) { - if (wmn->data==ND_NODES) + if (type == NTREE_SHADER || type == NTREE_TEXTURE) { + if (wmn->data == ND_NODES) ED_area_tag_refresh(sa); } break; case NC_WORLD: - if (type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { - ED_area_tag_refresh(sa); + if (type == NTREE_SHADER && shader_type == SNODE_SHADER_WORLD) { + ED_area_tag_refresh(sa); } break; case NC_OBJECT: - if (type==NTREE_SHADER) { - if (wmn->data==ND_OB_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_OB_SHADING) ED_area_tag_refresh(sa); } break; case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SPACE_NODE_VIEW) + else if (wmn->data == ND_SPACE_NODE_VIEW) ED_area_tag_redraw(sa); break; case NC_NODE: @@ -247,7 +247,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_MASK: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { ED_area_tag_refresh(sa); } } @@ -255,7 +255,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_IMAGE: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { /* note that nodeUpdateID is already called by BKE_image_signal() on all * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ @@ -270,42 +270,42 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) { /* default now: refresh node is starting preview */ - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; snode_set_context(snode, CTX_data_scene(C)); - + if (snode->nodetree) { - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { if (GS(snode->id->name) == ID_MA) { - Material *ma= (Material *)snode->id; + Material *ma = (Material *)snode->id; if (ma->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_LA) { - Lamp *la= (Lamp *)snode->id; + Lamp *la = (Lamp *)snode->id; if (la->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_WO) { - World *wo= (World *)snode->id; + World *wo = (World *)snode->id; if (wo->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } - else if (snode->treetype==NTREE_COMPOSIT) { - Scene *scene= (Scene *)snode->id; + else if (snode->treetype == NTREE_COMPOSIT) { + Scene *scene = (Scene *)snode->id; if (scene->use_nodes) { /* recalc is set on 3d view changes for auto compo */ if (snode->recalc) { - snode->recalc= 0; - node_render_changed_exec((struct bContext*)C, NULL); + snode->recalc = 0; + node_render_changed_exec((struct bContext *)C, NULL); } - else + else snode_composite_job(C, sa); } } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tex= (Tex *)snode->id; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tex = (Tex *)snode->id; if (tex->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } @@ -315,12 +315,12 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) static SpaceLink *node_duplicate(SpaceLink *sl) { - SpaceNode *snoden= MEM_dupallocN(sl); - + SpaceNode *snoden = MEM_dupallocN(sl); + /* clear or remove stuff from old */ - snoden->nodetree= NULL; - snoden->linkdrag.first= snoden->linkdrag.last= NULL; - + snoden->nodetree = NULL; + snoden->linkdrag.first = snoden->linkdrag.last = NULL; + return (SpaceLink *)snoden; } @@ -331,7 +331,7 @@ static void node_buttons_area_init(wmWindowManager *wm, ARegion *ar) 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); } @@ -343,12 +343,12 @@ static void node_buttons_area_draw(const bContext *C, ARegion *ar) static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) { - SpaceNode *snode= sa->spacedata.first; - + SpaceNode *snode = sa->spacedata.first; + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->mx, &snode->my); - + node_set_cursor(win, snode); } @@ -357,26 +357,26 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; ListBase *lb; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* 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 Editor", SPACE_NODE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + /* add drop boxes */ lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); } static void node_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; - + View2D *v2d = &ar->v2d; + drawnodespace(C, ar, v2d); } @@ -385,13 +385,13 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_IM ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_IM) return 1; } - else if (drag->type==WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + else if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ return 1; } return 0; @@ -399,10 +399,10 @@ static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; - + ID *id = (ID *)drag->poin; + if (id) { - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); } if (drag->path[0]) { RNA_string_set(drop->ptr, "filepath", drag->path); @@ -412,10 +412,10 @@ static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) /* this region dropbox definition */ static void node_dropboxes(void) { - ListBase *lb= WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + ListBase *lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); + WM_dropbox_add(lb, "NODE_OT_add_file", node_drop_poll, node_id_path_drop_copy); - + } /* ************* end drop *********** */ @@ -429,8 +429,8 @@ static void node_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) static void node_header_area_draw(const bContext *C, ARegion *ar) { - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); /* find and set the context */ snode_set_context(snode, scene); @@ -444,12 +444,19 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if (wmn->data == ND_GPENCIL) - ED_region_tag_redraw(ar); + switch (wmn->data) { + case ND_GPENCIL: + ED_region_tag_redraw(ar); + break; + case ND_SCREENCAST: + case ND_ANIMPLAY: + ED_region_tag_redraw(ar); + break; + } break; case NC_SCENE: case NC_MATERIAL: @@ -458,7 +465,7 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_OBJECT: - if (wmn->data==ND_OB_SHADING) + if (wmn->data == ND_OB_SHADING) ED_region_tag_redraw(ar); break; case NC_ID: @@ -472,17 +479,17 @@ const char *node_context_dir[] = {"selected_nodes", "active_node", NULL}; static int node_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceNode *snode= CTX_wm_space_node(C); - + SpaceNode *snode = CTX_wm_space_node(C); + if (CTX_data_dir(member)) { CTX_data_dir_set(result, node_context_dir); return 1; } else if (CTX_data_equals(member, "selected_nodes")) { bNode *node; - + if (snode->edittree) { - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { CTX_data_list_add(result, &snode->edittree->id, &RNA_Node, node); } @@ -500,67 +507,67 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_POINTER); return 1; } - + return 0; } /* only called once, from space/spacetypes.c */ void ED_spacetype_node(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype node"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype node"); ARegionType *art; - - st->spaceid= SPACE_NODE; + + st->spaceid = SPACE_NODE; strncpy(st->name, "Node", BKE_ST_MAXNAME); - - st->new= node_new; - st->free= node_free; - st->init= node_init; - st->duplicate= node_duplicate; - st->operatortypes= node_operatortypes; - st->keymap= node_keymap; - st->listener= node_area_listener; - st->refresh= node_area_refresh; - st->context= node_context; + + st->new = node_new; + st->free = node_free; + st->init = node_init; + st->duplicate = node_duplicate; + st->operatortypes = node_operatortypes; + st->keymap = node_keymap; + st->listener = node_area_listener; + st->refresh = node_area_refresh; + st->context = node_context; st->dropboxes = node_dropboxes; - + /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_WINDOW; - art->init= node_main_area_init; - art->draw= node_main_area_draw; - art->listener= node_region_listener; + art->init = node_main_area_init; + art->draw = node_main_area_draw; + art->listener = node_region_listener; art->cursor = node_cursor; art->event_cursor = TRUE; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->listener= node_region_listener; - art->init= node_header_area_init; - art->draw= node_header_area_draw; - + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->listener = node_region_listener; + art->init = node_header_area_init; + art->draw = node_header_area_draw; + BLI_addhead(&st->regiontypes, art); node_menus_register(); - + /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 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; + art->prefsizex = 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); - + node_buttons_register(art); - + BKE_spacetype_register(st); } |