Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuho Vepsalainen <bebraw@gmail.com>2008-01-07 22:38:01 +0300
committerJuho Vepsalainen <bebraw@gmail.com>2008-01-07 22:38:01 +0300
commitaa1c0281c6df642d6c9673c00ac660a36a75f286 (patch)
treeb062ce961329087d2791c118a5f84bfd944cf1cb /source/blender/src/drawnode.c
parent7da95822f0fabf1b554c34f5bcd7c4d6dcb4ae24 (diff)
Custom Names for Nodes
This commit makes it possible to add a custom name to a node. The feature can be accessed either by using a menu or shortcut ctrl-r. It currently works only when a single node is selected. Invoking the feature gives a popup menu in which a new name can be entered. If the given name is not empty, it will be shown like "(myCustomName) NodeName" in the node header. This feature is particularly useful when documenting complex node setups. I also fixed the size of blur node. It was too short before due to my previous commit. Thanks to David Millan Escriva for contribution!
Diffstat (limited to 'source/blender/src/drawnode.c')
-rw-r--r--source/blender/src/drawnode.c71
1 files changed, 66 insertions, 5 deletions
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index a69021a66b4..633d4ab5c1b 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -1129,7 +1129,7 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
}
uiBlockEndAlign(block);
}
- return 57;
+ return 77;
}
static int node_composit_buts_dblur(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
@@ -2043,6 +2043,45 @@ void init_node_butfuncs(void)
/* ************** Generic drawing ************** */
+void node_rename_but(char *s)
+{
+ uiBlock *block;
+ ListBase listb={0, 0};
+ int dy, x1, y1, sizex=80, sizey=30;
+ short pivot[2], mval[2], ret=0;
+
+ getmouseco_sc(mval);
+
+ pivot[0]= CLAMPIS(mval[0], (sizex+10), G.curscreen->sizex-30);
+ pivot[1]= CLAMPIS(mval[1], (sizey/2)+10, G.curscreen->sizey-(sizey/2)-10);
+
+ if (pivot[0]!=mval[0] || pivot[1]!=mval[1])
+ warp_pointer(pivot[0], pivot[1]);
+
+ mywinset(G.curscreen->mainwin);
+
+ x1= pivot[0]-sizex+10;
+ y1= pivot[1]-sizey/2;
+ dy= sizey/2;
+
+ block= uiNewBlock(&listb, "button", UI_EMBOSS, UI_HELV, G.curscreen->mainwin);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_ENTER_OK);
+
+ /* buttons have 0 as return event, to prevent menu to close on hotkeys */
+ uiBlockBeginAlign(block);
+
+ uiDefBut(block, TEX, B_NOP, "Name: ", (short)(x1),(short)(y1+dy), 150, 19, s, 0.0, 19.0, 0, 0, "Node user name");
+
+ uiBlockEndAlign(block);
+
+ uiDefBut(block, BUT, 32767, "OK", (short)(x1+150), (short)(y1+dy), 29, 19, NULL, 0, 0, 0, 0, "");
+
+ uiBoundsBlock(block, 2);
+
+ ret= uiDoBlocks(&listb, 0, 0);
+}
+
+
static void draw_nodespace_grid(SpaceNode *snode)
{
float start, step= 25.0f;
@@ -2486,6 +2525,7 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
rctf *rct= &node->totr;
float slen, iconofs;
int ofs, color_id= node_get_colorid(node);
+ char showname[64];
uiSetRoundBox(15-4);
ui_dropshadow(rct, BASIS_RAD, snode->aspect, node->flag & SELECT);
@@ -2564,8 +2604,18 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
BIF_ThemeColor(TH_TEXT);
ui_rasterpos_safe(rct->xmin+19.0f, rct->ymax-NODE_DY+5.0f, snode->aspect);
- snode_drawstring(snode, node->name, (int)(iconofs - rct->xmin-18.0f));
-
+
+ if(node->username[0]) {
+ strcpy(showname,"(");
+ strcat(showname, node->username);
+ strcat(showname,") ");
+ strcat(showname, node->name);
+ }
+ else
+ strcpy(showname, node->name);
+
+ snode_drawstring(snode, showname, (int)(iconofs - rct->xmin-18.0f));
+
/* body */
BIF_ThemeColor4(TH_NODE);
glEnable(GL_BLEND);
@@ -2680,13 +2730,14 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
}
-void node_draw_hidden(SpaceNode *snode, bNode *node)
+static void node_draw_hidden(SpaceNode *snode, bNode *node)
{
bNodeSocket *sock;
rctf *rct= &node->totr;
float dx, centy= 0.5f*(rct->ymax+rct->ymin);
float hiddenrad= 0.5f*(rct->ymax-rct->ymin);
int color_id= node_get_colorid(node);
+ char showname[64];
/* shadow */
uiSetRoundBox(15);
@@ -2720,7 +2771,17 @@ void node_draw_hidden(SpaceNode *snode, bNode *node)
if(node->miniwidth>0.0f) {
ui_rasterpos_safe(rct->xmin+21.0f, centy-4.0f, snode->aspect);
- snode_drawstring(snode, node->name, (int)(rct->xmax - rct->xmin-18.0f -12.0f));
+
+ if(node->username[0]) {
+ strcpy(showname,"(");
+ strcat(showname, node->username);
+ strcat(showname,") ");
+ strcat(showname, node->name);
+ }
+ else
+ strcpy(showname, node->name);
+
+ snode_drawstring(snode, showname, (int)(rct->xmax - rct->xmin-18.0f -12.0f));
}
/* scale widget thing */