improve node text alignment with different zoom levels

This commit is contained in:
Campbell Barton 2012-07-09 19:50:43 +00:00
parent 18f28e5408
commit e66a02e7e2
3 changed files with 11 additions and 8 deletions

@ -216,15 +216,17 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
int ofs = 0;
const char *ui_name = IFACE_(name);
UI_ThemeColor(TH_TEXT);
slen = snode->aspect_sqrt * UI_GetStringWidth(ui_name);
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
while (slen > node->width) {
ofs++;
slen = snode->aspect_sqrt * UI_GetStringWidth(ui_name + ofs);
slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
}
uiDefBut(block, LABEL, 0, ui_name + ofs,
(int)(sock->locx - (15.0f * snode->aspect_sqrt) - slen), (int)(sock->locy - 9.0f),
(int)(sock->locx - slen), (int)(sock->locy - 9.0f),
(short)(node->width - NODE_DY), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
(void)snode;
}
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
@ -830,7 +832,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColor(TH_TEXT_HI);
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
(int)(rect.xmin + 15), (int)(rect.ymax + group_header),
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + group_header),
MIN2((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);

@ -798,7 +798,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - don't print into self!
uiDefBut(node->block, LABEL, 0, showname,
(int)(rct->xmin + 15), (int)(rct->ymax - NODE_DY),
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(rct->ymax - NODE_DY),
(short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
@ -841,7 +841,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
node->typeinfo->drawinputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
sock->locx + (NODE_DYS / snode->aspect_sqrt), sock->locy-NODE_DYS, node->width-NODE_DY);
}
/* socket outputs */
@ -852,7 +852,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
node->typeinfo->drawoutputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
sock->locx-node->width+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
sock->locx - node->width + (NODE_DYS / snode->aspect_sqrt), sock->locy-NODE_DYS, node->width-NODE_DY);
}
/* preview */
@ -949,7 +949,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - don't print into self!
uiDefBut(node->block, LABEL, 0, showname,
(int)(rct->xmin + 15), (int)(centy - 10),
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
(short)(rct->xmax - rct->xmin-18.0f -12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
}

@ -196,6 +196,7 @@ extern const char *node_context_dir[];
#define BASIS_RAD 8.0f
#define NODE_DYS (U.widget_unit/2)
#define NODE_DY U.widget_unit
#define NODE_MARGIN_X 15
#define NODE_SOCKSIZE 5
// XXX button events (butspace)