From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- source/blender/editors/space_node/node_draw.c | 292 +++++++++++++------------- 1 file changed, 146 insertions(+), 146 deletions(-) (limited to 'source/blender/editors/space_node/node_draw.c') diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 58034f23351..d1374aab02c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -95,7 +95,7 @@ static bNodeTree *node_tree_from_ID(ID *id) { if (id) { short idtype = GS(id->name); - + switch (idtype) { case ID_NT: return (bNodeTree *)id; @@ -113,7 +113,7 @@ static bNodeTree *node_tree_from_ID(ID *id) return ((FreestyleLineStyle *)id)->nodetree; } } - + return NULL; } @@ -132,7 +132,7 @@ void ED_node_tag_update_id(ID *id) if (ntree->type == NTREE_SHADER) { DAG_id_tag_update(id, 0); - + if (GS(id->name) == ID_MA) WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); else if (GS(id->name) == ID_LA) @@ -186,7 +186,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) */ bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0; bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0; - + /* if one is an ancestor of the other */ /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */ for (parent = a->parent; parent; parent = parent->parent) { @@ -215,13 +215,13 @@ static bool compare_nodes(const bNode *a, const bNode *b) return 0; else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) return 1; - + /* if one has a higher selection state (active > selected > nothing) */ if (!b_active && a_active) return 1; else if (!b_select && (a_active || a_select)) return 1; - + return 0; } @@ -234,11 +234,11 @@ void ED_node_sort(bNodeTree *ntree) bNode *first_a, *first_b, *node_a, *node_b, *tmp; int totnodes = BLI_listbase_count(&ntree->nodes); int k, a, b; - + k = 1; while (k < totnodes) { first_a = first_b = ntree->nodes.first; - + do { /* setup first_b pointer */ for (b = 0; b < k && first_b; ++b) { @@ -247,7 +247,7 @@ void ED_node_sort(bNodeTree *ntree) /* all batches merged? */ if (first_b == NULL) break; - + /* merge batches */ node_a = first_a; node_b = first_b; @@ -276,7 +276,7 @@ void ED_node_sort(bNodeTree *ntree) } first_a = first_b; } while (first_b); - + k = k << 1; } } @@ -295,9 +295,9 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) { bNode *node; char uiblockstr[32]; - + /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - + for (node = ntree->nodes.first; node; node = node->next) { /* ui block */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); @@ -339,52 +339,52 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) float locx, locy; float dy; int buty; - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); dy = locy; - + /* header */ dy -= NODE_DY; - + /* little bit space in top */ if (node->outputs.first) dy -= NODE_DYS / 2; - + /* output sockets */ bool add_output_space = false; for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + /* align output buttons to the right */ row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx + NODE_WIDTH(node); /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; @@ -402,28 +402,28 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* preview rect? */ if (node->flag & NODE_PREVIEW) { float aspect = 1.0f; - - if (node->preview_xsize && node->preview_ysize) + + if (node->preview_xsize && node->preview_ysize) aspect = (float)node->preview_ysize / (float)node->preview_xsize; - + dy -= NODE_DYS / 2; node->prvr.ymax = dy; - + if (aspect <= 1.0f) node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY); else { /* width correction of image */ /* XXX huh? (ton) */ float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect; - + node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY); - + node->prvr.xmin += 0.5f * dx; node->prvr.xmax -= 0.5f * dx; } - + dy = node->prvr.ymin - NODE_DYS / 2; - + /* make sure that maximums are bigger or equal to minimums */ if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin); if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); @@ -438,18 +438,18 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS; node->butr.ymin = 0; node->butr.ymax = 0; - - + + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get()); uiLayoutSetContextPointer(layout, "node", &nodeptr); - + node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + dy = buty - NODE_DYS / 2; } @@ -457,35 +457,35 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + row = uiLayoutRow(layout, 1); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx; /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; } - + /* little bit space in end */ if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) dy -= NODE_DYS / 2; @@ -494,7 +494,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->totr.xmax = locx + NODE_WIDTH(node); node->totr.ymax = locy; node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); - + /* Set the block bounds to clip mouse events from underlying nodes. * Add a margin for sockets on each side. */ @@ -513,7 +513,7 @@ static void node_update_hidden(bNode *node) float locx, locy; float rad, drad, hiddenrad = HIDDEN_RAD; int totin = 0, totout = 0, tot; - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); @@ -524,20 +524,20 @@ static void node_update_hidden(bNode *node) for (nsock = node->outputs.first; nsock; nsock = nsock->next) if (!nodeSocketIsHidden(nsock)) totout++; - + tot = MAX2(totin, totout); if (tot > 4) { hiddenrad += 5.0f * (float)(tot - 4); } - + node->totr.xmin = locx; node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth; node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); node->totr.ymin = node->totr.ymax - 2 * hiddenrad; - + /* output sockets */ rad = drad = (float)M_PI / (1.0f + (float)totout); - + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad; @@ -545,10 +545,10 @@ static void node_update_hidden(bNode *node) rad += drad; } } - + /* input sockets */ rad = drad = -(float)M_PI / (1.0f + (float)totin); - + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmin + hiddenrad + sinf(rad) * hiddenrad; @@ -664,7 +664,7 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc { PointerRNA ptr, node_ptr; float color[4]; - + RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color); @@ -729,12 +729,12 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc static void node_draw_preview_background(float tile, rctf *rect) { float x, y; - + /* draw checkerboard backdrop to show alpha */ glColor3ub(120, 120, 120); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ub(160, 160, 160); - + for (y = rect->ymin; y < rect->ymax; y += tile * 2) { for (x = rect->xmin; x < rect->xmax; x += tile * 2) { float tilex = tile, tiley = tile; @@ -770,7 +770,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) float yscale = yrect / ((float)preview->ysize); float scale; rctf draw_rect; - + /* uniform scale and offset */ draw_rect = *prv; if (xscale < yscale) { @@ -785,17 +785,17 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) draw_rect.xmax -= offset; scale = yscale; } - + node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */ - + glColor4f(1.0, 1.0, 1.0, 1.0); glPixelZoom(scale, scale); glaDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect); glPixelZoom(1.0f, 1.0f); - + glDisable(GL_BLEND); UI_ThemeColorShadeAlpha(TH_BACK, -15, +100); @@ -807,23 +807,23 @@ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_ { bNode *node = (bNode *)node_argv; const char *opname = (const char *)op_argv; - + /* select & activate only the button's node */ node_select_single(C, node); - + WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); } void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) { rctf *rct = &node->totr; - + UI_draw_roundbox_corner_set(UI_CNR_ALL); if (node->parent == NULL) ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); else { const float margin = 3.0f; - + glColor4f(0.0f, 0.0f, 0.0f, 0.33f); glEnable(GL_BLEND); UI_draw_roundbox(rct->xmin - margin, rct->ymin - margin, @@ -843,21 +843,21 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN int color_id = node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; - + /* XXX hack: copy values from linked ID data where displayed as sockets */ if (node->block) nodeSynchronizeID(node, false); - + /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { UI_block_end(C, node->block); node->block = NULL; return; } - + /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, 1.0f); - + /* header uses color from backdrop, but we make it opaqie */ if (color_id == TH_NODE) { float col[3]; @@ -866,19 +866,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } else UI_ThemeColor(color_id); - + if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); - + glLineWidth(1.0f); UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); - + /* show/hide icons */ iconofs = rct->xmax - 0.35f * U.widget_unit; - + /* preview */ if (node->typeinfo->flag & NODE_PREVIEW) { uiBut *but; @@ -905,13 +905,13 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); UI_block_emboss_set(node->block, UI_EMBOSS); } - + /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open/close entirely? */ { uiBut *but; @@ -923,24 +923,24 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v'); } - + /* this isn't doing anything for the label, so commenting out */ #if 0 - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); #endif - + nodeLabel(ntree, node, showname, sizeof(showname)); - + //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ - + uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY), (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, @@ -960,43 +960,43 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* outline active and selected emphasis */ if (node->flag & SELECT) { - + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); - + UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(v2d, snode, node); - + /* socket inputs, buttons */ for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* socket outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* preview */ if (node->flag & NODE_PREVIEW && previews) { bNodePreview *preview = BKE_node_instance_hash_lookup(previews, key); @@ -1006,9 +1006,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } } - + UI_ThemeClearColor(color_id); - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1023,7 +1023,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b float socket_size = NODE_SOCKSIZE; int color_id = node_get_colorid(node); char showname[128]; /* 128 is used below */ - + /* shadow */ node_draw_shadow(snode, node, hiddenrad, 1.0f); @@ -1033,18 +1033,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + /* outline active and selected emphasis */ if (node->flag & SELECT) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -1062,11 +1062,11 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open entirely icon */ { uiBut *but; @@ -1078,20 +1078,20 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h'); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(&ar->v2d, snode, node); - - if (node->flag & SELECT) + + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColor(TH_TEXT); - + if (node->miniwidth > 0.0f) { nodeLabel(ntree, node, showname, sizeof(showname)); @@ -1109,7 +1109,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b dx = 10.0f; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); - + UI_ThemeColorShade(color_id, +30); dx -= snode->aspect; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); @@ -1121,13 +1121,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1151,7 +1151,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) bNode *node; bNodeSocket *sock; int wmcursor = CURSOR_STD; - + if (ntree) { if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) { /* pass */ @@ -1168,7 +1168,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) } } } - + WM_cursor_set(win, wmcursor); } @@ -1189,10 +1189,10 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) void node_update_nodetree(const bContext *C, bNodeTree *ntree) { bNode *node; - + /* make sure socket "used" tags are correct, for displaying value buttons */ ntreeTagUsedSockets(ntree); - + /* update nodes front to back, so children sizes get updated before parents */ for (node = ntree->nodes.last; node; node = node->prev) { node_update(C, ntree, node); @@ -1212,7 +1212,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT bNode *node; bNodeLink *link; int a; - + if (ntree == NULL) return; /* groups... */ #ifdef USE_DRAW_TOT_UPDATE @@ -1238,7 +1238,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT node->nr = a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node, key); } - + /* node lines */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1248,7 +1248,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { bNodeInstanceKey key; @@ -1265,9 +1265,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT static void draw_tree_path(SpaceNode *snode) { char info[256]; - + ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info)); - + UI_ThemeColor(TH_TEXT_HI); BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info)); } @@ -1275,11 +1275,11 @@ static void draw_tree_path(SpaceNode *snode) static void snode_setup_v2d(SpaceNode *snode, ARegion *ar, const float center[2]) { View2D *v2d = &ar->v2d; - + /* shift view to node tree center */ UI_view2d_center_set(v2d, center[0], center[1]); UI_view2d_view_ortho(v2d); - + /* aspect+font, set each time */ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx; // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); @@ -1301,14 +1301,14 @@ static void draw_group_overlay(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; rctf rect = v2d->cur; uiBlock *block; - + /* shade node groups to separate them visually */ UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); glEnable(GL_BLEND); UI_draw_roundbox_corner_set(UI_CNR_NONE); UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); glDisable(GL_BLEND); - + /* set the block bounds to clip mouse events from underlying nodes */ block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS); UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -1327,22 +1327,22 @@ void drawnodespace(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); - + /* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->cursor[0], &snode->cursor[1]); snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); - + /* nodes */ snode_set_context(C); - + /* draw parent node trees */ if (snode->treepath.last) { static const int max_depth = 2; @@ -1352,56 +1352,56 @@ void drawnodespace(const bContext *C, ARegion *ar) bNodeTree *ntree; bNodeLinkDrag *nldrag; LinkData *linkdata; - + path = snode->treepath.last; - + /* update tree path name (drawn in the bottom left) */ ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id : snode->id; if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) { BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name)); } - + /* current View2D center, will be set temporarily for parent node trees */ UI_view2d_center_get(v2d, ¢er[0], ¢er[1]); - + /* store new view center in path and current edittree */ copy_v2_v2(path->view_center, center); if (snode->edittree) copy_v2_v2(snode->edittree->view_center, center); - + depth = 0; while (path->prev && depth < max_depth) { path = path->prev; ++depth; } - + /* parent node trees in the background */ for (curdepth = depth; curdepth > 0; path = path->next, --curdepth) { ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, path->view_center); - + draw_nodetree(C, ar, ntree, path->parent_key); - + draw_group_overlay(C, ar); } } - + /* top-level edit tree */ ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, center); - + /* grid, uses theme color based on node path depth */ UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, path->parent_key); - + draw_nodetree(C, ar, ntree, path->parent_key); } - + /* temporary links */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1411,7 +1411,7 @@ void drawnodespace(const bContext *C, ARegion *ar) } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil ('canvas' strokes) */ ED_gpencil_draw_view2d(C, true); @@ -1420,16 +1420,16 @@ void drawnodespace(const bContext *C, ARegion *ar) else { /* default grid */ UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE); } - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - + /* reset view matrix */ UI_view2d_view_restore(C); - + if (snode->treepath.last) { if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil (screen strokes, and also paintbuffer) */ @@ -1439,7 +1439,7 @@ void drawnodespace(const bContext *C, ARegion *ar) /* tree path info */ draw_tree_path(snode); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); -- cgit v1.2.3