Minor changes to node rename tool

Rename was changed to work on the last selected node. Also size of a couple of
character arrays was changed to avoid buffer overflows.

Custom name shows up now just fine in group header in case it is being edited
as it did not before.
This commit is contained in:
Juho Vepsalainen
2008-01-08 19:06:46 +00:00
parent 5b6f977970
commit 2630c2c9f3
2 changed files with 18 additions and 11 deletions

View File

@@ -2525,7 +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];
char showname[128];
uiSetRoundBox(15-4);
ui_dropshadow(rct, BASIS_RAD, snode->aspect, node->flag & SELECT);
@@ -2737,7 +2737,7 @@ static void node_draw_hidden(SpaceNode *snode, bNode *node)
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];
char showname[128];
/* shadow */
uiSetRoundBox(15);
@@ -2983,6 +2983,7 @@ static void node_draw_group(ScrArea *sa, SpaceNode *snode, bNode *gnode)
bNodeTree *ngroup= (bNodeTree *)gnode->id;
bNodeSocket *sock;
rctf rect= gnode->totr;
char showname[128];
/* backdrop header */
glEnable(GL_BLEND);
@@ -3006,7 +3007,17 @@ static void node_draw_group(ScrArea *sa, SpaceNode *snode, bNode *gnode)
/* backdrop title */
BIF_ThemeColor(TH_TEXT_HI);
ui_rasterpos_safe(rect.xmin+8.0f, rect.ymax+5.0f, snode->aspect);
BIF_DrawString(snode->curfont, ngroup->id.name+2, 0);
if(gnode->username[0]) {
strcpy(showname,"(");
strcat(showname, gnode->username);
strcat(showname,") ");
strcat(showname, ngroup->id.name+2);
}
else
strcpy(showname, ngroup->id.name+2);
BIF_DrawString(snode->curfont, showname, 0);
/* links from groupsockets to the internal nodes */
node_draw_group_links(snode, gnode);

View File

@@ -1089,21 +1089,17 @@ void node_rename(SpaceNode *snode)
{
bNode *node, *rename_node;
short found_node= 0;
/* don't rename if more than one node is selected */
/* a nice alternative for this would be to rename last selected node */
/* check if a node is selected */
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
if(found_node) {
error("Can rename only one selected node at time");
return;
}
rename_node= node;
found_node= 1;
break;
}
}
if(found_node) {
rename_node= nodeGetActive(snode->edittree);
node_rename_but((char *)rename_node->username);
BIF_undo_push("Rename Node");