/* active node */ static void active_node_panel(const bContext *C, Panel *pa) { SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree= (snode) ? snode->edittree : NULL; bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; // xxx... for editing group nodes uiLayout *layout= pa->layout; uiBlock *block; PointerRNA ptr; /* verify pointers, and create RNA pointer for the node */ if ELEM(NULL, ntree, node) return; //if (node->id) /* for group nodes */ // RNA_pointer_create(node->id, &RNA_Node, node, &ptr); //else RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); /* set update callback */ // xxx is this really needed block= uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_node_region_buttons, NULL); /* draw this node's name, etc. */ uiItemR(layout, &ptr, "label", 0, NULL, ICON_NODE); uiItemS(layout); uiItemR(layout, &ptr, "name", 0, NULL, ICON_NODE); uiItemS(layout); /* draw this node's settings */ if (node->typeinfo && node->typeinfo->uifuncbut) node->typeinfo->uifuncbut(layout, (bContext *)C, &ptr); else if (node->typeinfo && node->typeinfo->uifunc) node->typeinfo->uifunc(layout, (bContext *)C, &ptr); }
static bNode *node_group_get_active(bContext *C, const char *node_idname) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); if (node && STREQ(node->idname, node_idname)) return node; else return NULL; }
static void node_sockets_panel(const bContext *C, Panel *pa) { SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree= (snode) ? snode->edittree : NULL; bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; bNodeSocket *sock; uiLayout *layout= pa->layout, *split; char name[UI_MAX_NAME_STR]; if(ELEM(NULL, ntree, node)) return; for(sock=node->inputs.first; sock; sock=sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); split = uiLayoutSplit(layout, 0.35f, 0); uiItemL(split, name, ICON_NONE); uiTemplateNodeLink(split, ntree, node, sock); } }
static int node_select_grouped_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node_act = nodeGetActive(snode->edittree); bNode *node; bool changed = false; const bool extend = RNA_boolean_get(op->ptr, "extend"); const int type = RNA_enum_get(op->ptr, "type"); if (!extend) { for (node = snode->edittree->nodes.first; node; node = node->next) { nodeSetSelected(node, false); } } nodeSetSelected(node_act, true); switch (type) { case NODE_SELECT_GROUPED_TYPE: changed = node_select_grouped_type(snode, node_act); break; case NODE_SELECT_GROUPED_COLOR: changed = node_select_grouped_color(snode, node_act); break; case NODE_SELECT_GROUPED_PREFIX: changed = node_select_grouped_name(snode, node_act, false); break; case NODE_SELECT_GROUPED_SUFIX: changed = node_select_grouped_name(snode, node_act, true); break; default: break; } if (changed) { ED_node_sort(snode->edittree); WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; }
static int node_select_same_type_step_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); bNode **node_array; bNode *active = nodeGetActive(snode->edittree); int totnodes; const bool revert = RNA_boolean_get(op->ptr, "prev"); const bool same_type = 1; ntreeGetDependencyList(snode->edittree, &node_array, &totnodes); if (totnodes > 1) { int a; for (a = 0; a < totnodes; a++) { if (node_array[a] == active) break; } if (same_type) { bNode *node = NULL; while (node == NULL) { if (revert) a--; else a++; if (a < 0 || a >= totnodes) break; node = node_array[a]; if (node->type == active->type) break; else node = NULL; } if (node) active = node; } else { if (revert) { if (a == 0) active = node_array[totnodes - 1]; else active = node_array[a - 1]; } else { if (a == totnodes - 1) active = node_array[0]; else active = node_array[a + 1]; } } node_select_single(C, active); /* is note outside view? */ if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax || active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx); } } if (node_array) MEM_freeN(node_array); return OPERATOR_FINISHED; }