diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-02-08 15:54:32 +0300 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-02-08 15:54:32 +0300 |
commit | 24db3d17aafd1b2027cd62afd39b2d648e8ec7d5 (patch) | |
tree | 0c27787854b73b384f0d3c46a1b8d9927a341b78 /source/blender/editors | |
parent | cd95dd42d7d8ee6eecde8e08cf406f6fa55f66c3 (diff) |
Per-type node labels and customizable names. The label displayed in the node header is now by default the node type string. A custom label callback can be implemented to display more detailed information. This is currently used by group nodes, which display their internal tree name, and math, vector math, mix and filter nodes, which use their internal operation sub-type. Also the node tree selection/naming box for groups is now displayed only on open groups, to make it clearer that this is the internal type of the group and get a cleaner main tree.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 2 |
3 files changed, 19 insertions, 34 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index aea35e193b8..668a7f338f2 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -78,11 +78,6 @@ /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */ -void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) -{ - uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, ""); -} - static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { PointerRNA sockptr; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index de0616f791e..10697f88173 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -45,6 +45,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_main.h" +#include "BKE_node.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -264,10 +265,6 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) BLI_unlock_thread(LOCK_PREVIEW); } - /* XXX ugly hack, typeinfo for group is generated */ - if(node->type == NODE_GROUP) - node->typeinfo->uifunc= node_buts_group; - /* buttons rect? */ if((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { dy-= NODE_DYS/2; @@ -721,11 +718,10 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else UI_ThemeColor(TH_TEXT); */ - if(node->flag & NODE_CUSTOM_NAME) - BLI_strncpy(showname, node->name, sizeof(showname)); + if (node->typeinfo->labelfunc) + BLI_strncpy(showname, node->typeinfo->labelfunc(node), sizeof(showname)); else - /* todo: auto name display for node types */ - BLI_strncpy(showname, node->name, sizeof(showname)); + BLI_strncpy(showname, node->typeinfo->name, sizeof(showname)); //if(node->flag & NODE_MUTED) // sprintf(showname, "[%s]", showname); @@ -894,14 +890,11 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(TH_TEXT); if(node->miniwidth>0.0f) { - - - if(node->flag & NODE_CUSTOM_NAME) - BLI_strncpy(showname, node->name, sizeof(showname)); + if (node->typeinfo->labelfunc) + BLI_strncpy(showname, node->typeinfo->labelfunc(node), sizeof(showname)); else - /* todo: auto name display */ - BLI_strncpy(showname, node->name, sizeof(showname)); - + BLI_strncpy(showname, node->typeinfo->name, sizeof(showname)); + //if(node->flag & NODE_MUTED) // sprintf(showname, "[%s]", showname); @@ -1012,18 +1005,19 @@ static void node_draw_group_links(View2D *v2d, SpaceNode *snode, bNode *gnode) } /* groups are, on creation, centered around 0,0 */ -static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bNode *gnode) +static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *gnode) { bNodeTree *ngroup= (bNodeTree *)gnode->id; bNodeSocket *sock; rctf rect= gnode->totr; - char showname[128]; + uiLayout *layout; + PointerRNA ptr; /* backdrop header */ glEnable(GL_BLEND); uiSetRoundBox(3); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - uiDrawBox(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+26, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); @@ -1034,21 +1028,19 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiSetRoundBox(15); glColor4ub(200, 200, 200, 140); glEnable( GL_LINE_SMOOTH ); - uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+26, BASIS_RAD); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - if (gnode->flag & NODE_CUSTOM_NAME) - BLI_strncpy(showname, gnode->name, sizeof(showname)); - else - BLI_strncpy(showname, ngroup->id.name+2, sizeof(showname)); - + layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+23), + MIN2((int)(rect.xmax - rect.xmin-18.0f), 140), 20, U.uistyles.first); + RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); + uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL); + uiBlockLayoutResolve(gnode->block, NULL, NULL); - uiDefBut(gnode->block, LABEL, 0, showname, (short)(rect.xmin+15), (short)(rect.ymax), - (int)(rect.xmax - rect.xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); uiEndBlock(C, gnode->block); uiDrawBlock(C, gnode->block); gnode->block= NULL; @@ -1128,7 +1120,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* active group */ for(node= snode->nodetree->nodes.first; node; node= node->next) { if(node->flag & NODE_GROUP_EDIT) - node_draw_group(C, ar, snode, node); + node_draw_group(C, ar, snode, snode->nodetree, node); } } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 5d67eb77e28..831e157deef 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -73,8 +73,6 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp); -void node_buts_group(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); - /* node_edit.c */ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype); void snode_notify(bContext *C, SpaceNode *snode); |