Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.c
| Show First 20 Lines • Show All 552 Lines • ▼ Show 20 Lines | UI_block_bounds_set_explicit( | ||||
| node->totr.xmax + NODE_SOCKSIZE, | node->totr.xmax + NODE_SOCKSIZE, | ||||
| node->totr.ymax); | node->totr.ymax); | ||||
| } | } | ||||
| /* based on settings in node, sets drawing rect info. each redraw! */ | /* based on settings in node, sets drawing rect info. each redraw! */ | ||||
| static void node_update_hidden(bNode *node) | static void node_update_hidden(bNode *node) | ||||
| { | { | ||||
| bNodeSocket *nsock; | bNodeSocket *nsock; | ||||
| float locx, locy; | float locx, locy; | ||||
JacquesLucke: I'd prefer to slowly move away from declaring all variables at the top. Better try to minimize… | |||||
| float rad, drad, hiddenrad = HIDDEN_RAD; | float rad, drad, hiddenrad = HIDDEN_RAD; | ||||
| int totin = 0, totout = 0, tot; | int totin = 0, totout = 0, tot; | ||||
| /* get "global" coords */ | /* get "global" coords */ | ||||
| node_to_view(node, 0.0f, 0.0f, &locx, &locy); | node_to_view(node, 0.0f, 0.0f, &locx, &locy); | ||||
| /* calculate minimal radius */ | /* calculate minimal radius */ | ||||
| for (nsock = node->inputs.first; nsock; nsock = nsock->next) { | for (nsock = node->inputs.first; nsock; nsock = nsock->next) { | ||||
| if (!nodeSocketIsHidden(nsock)) { | if (!nodeSocketIsHidden(nsock)) { | ||||
| totin++; | totin++; | ||||
| } | } | ||||
| } | } | ||||
| for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | ||||
| if (!nodeSocketIsHidden(nsock)) { | if (!nodeSocketIsHidden(nsock)) { | ||||
| totout++; | totout++; | ||||
| } | } | ||||
| } | } | ||||
| tot = MAX2(totin, totout); | tot = MAX2(totin, totout); | ||||
| if (tot > 4) { | if (tot > 4) { | ||||
| hiddenrad += 5.0f * (float)(tot - 4); | hiddenrad += 5.0f * (float)(tot - 4); | ||||
| } | } | ||||
| node->totr.xmin = locx; | node->totr.xmin = locx; | ||||
| node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth; | node->totr.xmax = locx + max_ff(NODE_WIDTH(node), 2 * hiddenrad); | ||||
| node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); | node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); | ||||
| node->totr.ymin = node->totr.ymax - 2 * hiddenrad; | node->totr.ymin = node->totr.ymax - 2 * hiddenrad; | ||||
Done Inline Actionsmax_ff JacquesLucke: `max_ff` | |||||
| /* output sockets */ | /* output sockets */ | ||||
| rad = drad = (float)M_PI / (1.0f + (float)totout); | rad = drad = (float)M_PI / (1.0f + (float)totout); | ||||
| for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | ||||
| if (!nodeSocketIsHidden(nsock)) { | if (!nodeSocketIsHidden(nsock)) { | ||||
| nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad; | nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad; | ||||
| nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad; | nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad; | ||||
| ▲ Show 20 Lines • Show All 567 Lines • ▼ Show 20 Lines | /* open entirely icon */ | ||||
| UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, centy, 'h', color); | UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, centy, 'h', color); | ||||
| } | } | ||||
| /* disable lines */ | /* disable lines */ | ||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| node_draw_mute_line(&ar->v2d, snode, node); | node_draw_mute_line(&ar->v2d, snode, node); | ||||
| } | } | ||||
| if (node->miniwidth > 0.0f) { | |||||
| nodeLabel(ntree, node, showname, sizeof(showname)); | nodeLabel(ntree, node, showname, sizeof(showname)); | ||||
| /* XXX - don't print into self! */ | /* XXX - don't print into self! */ | ||||
| //if (node->flag & NODE_MUTED) | //if (node->flag & NODE_MUTED) | ||||
| // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); | // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); | ||||
| uiBut *but = uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, | uiBut *but = uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, | ||||
| round_fl_to_int(rct->xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f), | round_fl_to_int(rct->xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f), | ||||
| (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, | (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, | ||||
| NULL, 0, 0, 0, 0, ""); | NULL, 0, 0, 0, 0, ""); | ||||
Done Inline Actionsminor indentation issue (use spaces for "extra" indentation). JacquesLucke: minor indentation issue (use spaces for "extra" indentation). | |||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| UI_but_flag_enable(but, UI_BUT_INACTIVE); | UI_but_flag_enable(but, UI_BUT_INACTIVE); | ||||
| } | } | ||||
| } | |||||
| /* scale widget thing */ | /* scale widget thing */ | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformThemeColorShade(color_id, -10); | immUniformThemeColorShade(color_id, -10); | ||||
| dx = 10.0f; | dx = 10.0f; | ||||
| ▲ Show 20 Lines • Show All 372 Lines • Show Last 20 Lines | |||||
I'd prefer to slowly move away from declaring all variables at the top. Better try to minimize the vertical scope of a variable.
Also a better name might just be min_hidden_width. Or maybe this variable is not necessary at all with the change below.