Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.c
| Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| node->block = UI_block_begin(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); | node->block = UI_block_begin(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); | ||||
| UI_block_func_handle_set(node->block, do_node_internal_buttons, node); | UI_block_func_handle_set(node->block, do_node_internal_buttons, node); | ||||
| /* this cancels events for background nodes */ | /* this cancels events for background nodes */ | ||||
| UI_block_flag_enable(node->block, UI_BLOCK_CLIP_EVENTS); | UI_block_flag_enable(node->block, UI_BLOCK_CLIP_EVENTS); | ||||
| } | } | ||||
| } | } | ||||
| void node_to_view(struct bNode *node, float x, float y, float *rx, float *ry) | void node_to_view(const bNode *node, float x, float y, float *rx, float *ry) | ||||
| { | { | ||||
| nodeToView(node, x, y, rx, ry); | nodeToView(node, x, y, rx, ry); | ||||
| *rx *= UI_DPI_FAC; | *rx *= UI_DPI_FAC; | ||||
| *ry *= UI_DPI_FAC; | *ry *= UI_DPI_FAC; | ||||
| } | } | ||||
| void node_to_updated_rect(struct bNode *node, rctf *r_rect) | void node_to_updated_rect(const bNode *node, rctf *r_rect) | ||||
| { | { | ||||
| node_to_view(node, node->offsetx, node->offsety, &r_rect->xmin, &r_rect->ymax); | node_to_view(node, node->offsetx, node->offsety, &r_rect->xmin, &r_rect->ymax); | ||||
| node_to_view(node, | node_to_view(node, | ||||
| node->offsetx + node->width, | node->offsetx + node->width, | ||||
| node->offsety - node->height, | node->offsety - node->height, | ||||
| &r_rect->xmax, | &r_rect->xmax, | ||||
| &r_rect->ymin); | &r_rect->ymin); | ||||
| } | } | ||||
| void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry) | void node_from_view(const bNode *node, float x, float y, float *rx, float *ry) | ||||
| { | { | ||||
| x /= UI_DPI_FAC; | x /= UI_DPI_FAC; | ||||
| y /= UI_DPI_FAC; | y /= UI_DPI_FAC; | ||||
| nodeFromView(node, x, y, rx, ry); | nodeFromView(node, x, y, rx, ry); | ||||
| } | } | ||||
| /* 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_basis(const bContext *C, bNodeTree *ntree, bNode *node) | static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| ▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | switch (node->typeinfo->nclass) { | ||||
| default: | default: | ||||
| return TH_NODE; | return TH_NODE; | ||||
| } | } | ||||
| } | } | ||||
| /* note: in cmp_util.c is similar code, for node_compo_pass_on() | /* note: in cmp_util.c is similar code, for node_compo_pass_on() | ||||
| * the same goes for shader and texture nodes. */ | * the same goes for shader and texture nodes. */ | ||||
| /* note: in node_edit.c is similar code, for untangle node */ | /* note: in node_edit.c is similar code, for untangle node */ | ||||
| static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) | static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const bNode *node) | ||||
| { | { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| LISTBASE_FOREACH (bNodeLink *, link, &node->internal_links) { | LISTBASE_FOREACH (const bNodeLink *, link, &node->internal_links) { | ||||
| node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1); | node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1); | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| /* flags used in gpu_shader_keyframe_diamond_frag.glsl */ | /* flags used in gpu_shader_keyframe_diamond_frag.glsl */ | ||||
| #define MARKER_SHAPE_DIAMOND 0x1 | #define MARKER_SHAPE_DIAMOND 0x1 | ||||
| ▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv) | ||||
| const char *opname = (const char *)op_argv; | const char *opname = (const char *)op_argv; | ||||
| /* select & activate only the button's node */ | /* select & activate only the button's node */ | ||||
| node_select_single(C, node); | node_select_single(C, node); | ||||
| WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); | WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); | ||||
| } | } | ||||
| void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) | void node_draw_shadow(const SpaceNode *snode, const bNode *node, float radius, float alpha) | ||||
| { | { | ||||
| rctf *rct = &node->totr; | const rctf *rct = &node->totr; | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); | ui_draw_dropshadow(rct, radius, snode->runtime->aspect, alpha, node->flag & SELECT); | ||||
| } | } | ||||
| void node_draw_sockets(View2D *v2d, | void node_draw_sockets(const View2D *v2d, | ||||
| const bContext *C, | const bContext *C, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| bNode *node, | bNode *node, | ||||
| bool draw_outputs, | bool draw_outputs, | ||||
| bool select_all) | bool select_all) | ||||
| { | { | ||||
| const uint total_input_len = BLI_listbase_count(&node->inputs); | const uint total_input_len = BLI_listbase_count(&node->inputs); | ||||
| const uint total_output_len = BLI_listbase_count(&node->outputs); | const uint total_output_len = BLI_listbase_count(&node->outputs); | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | void node_draw_sockets(const View2D *v2d, | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_program_point_size(false); | GPU_program_point_size(false); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| static void node_draw_basis(const bContext *C, | static void node_draw_basis(const bContext *C, | ||||
| ARegion *region, | const View2D *v2d, | ||||
| SpaceNode *snode, | const SpaceNode *snode, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeInstanceKey key) | bNodeInstanceKey key) | ||||
| { | { | ||||
| /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ | /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ | ||||
| float iconbutw = 0.8f * UI_UNIT_X; | float iconbutw = 0.8f * UI_UNIT_X; | ||||
| View2D *v2d = ®ion->v2d; | |||||
| /* skip if out of view */ | /* skip if out of view */ | ||||
| if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) { | if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) { | ||||
| UI_block_end(C, node->block); | UI_block_end(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| return; | return; | ||||
| } | } | ||||
| /* shadow */ | /* shadow */ | ||||
| Show All 12 Lines | else { | ||||
| color[3] = 1.0f; | color[3] = 1.0f; | ||||
| } | } | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); | UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); | ||||
| UI_draw_roundbox_aa( | UI_draw_roundbox_aa( | ||||
| true, rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color); | &(const rctf){ | ||||
| .xmin = rct->xmin, | |||||
| .xmax = rct->xmax, | |||||
| .ymin = rct->ymax - NODE_DY, | |||||
| .ymax = rct->ymax, | |||||
| }, | |||||
| true, | |||||
| BASIS_RAD, | |||||
| color); | |||||
| /* show/hide icons */ | /* show/hide icons */ | ||||
| float iconofs = rct->xmax - 0.35f * U.widget_unit; | float iconofs = rct->xmax - 0.35f * U.widget_unit; | ||||
| /* preview */ | /* preview */ | ||||
| if (node->typeinfo->flag & NODE_PREVIEW) { | if (node->typeinfo->flag & NODE_PREVIEW) { | ||||
| iconofs -= iconbutw; | iconofs -= iconbutw; | ||||
| UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | static void node_draw_basis(const bContext *C, | ||||
| } | } | ||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| color[3] = 0.5f; | color[3] = 0.5f; | ||||
| } | } | ||||
| UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); | UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); | ||||
| UI_draw_roundbox_aa( | UI_draw_roundbox_aa( | ||||
| true, rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD, color); | &(const rctf){ | ||||
| .xmin = rct->xmin, | |||||
| .xmax = rct->xmax, | |||||
| .ymin = rct->ymin, | |||||
| .ymax = rct->ymax - NODE_DY, | |||||
| }, | |||||
| true, | |||||
| BASIS_RAD, | |||||
| color); | |||||
| /* outline active and selected emphasis */ | /* outline active and selected emphasis */ | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| UI_GetThemeColorShadeAlpha4fv( | UI_GetThemeColorShadeAlpha4fv( | ||||
| (node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color); | (node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color); | UI_draw_roundbox_aa( | ||||
| &(const rctf){ | |||||
| .xmin = rct->xmin, | |||||
| .xmax = rct->xmax, | |||||
| .ymin = rct->ymin, | |||||
| .ymax = rct->ymax, | |||||
| }, | |||||
| false, | |||||
| BASIS_RAD, | |||||
| color); | |||||
| } | } | ||||
| /* disable lines */ | /* disable lines */ | ||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| node_draw_mute_line(v2d, snode, node); | node_draw_mute_line(v2d, snode, node); | ||||
| } | } | ||||
| node_draw_sockets(v2d, C, ntree, node, true, false); | node_draw_sockets(v2d, C, ntree, node, true, false); | ||||
| Show All 10 Lines | static void node_draw_basis(const bContext *C, | ||||
| } | } | ||||
| UI_block_end(C, node->block); | UI_block_end(C, node->block); | ||||
| UI_block_draw(C, node->block); | UI_block_draw(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| } | } | ||||
| static void node_draw_hidden(const bContext *C, | static void node_draw_hidden(const bContext *C, | ||||
| ARegion *region, | const View2D *v2d, | ||||
| SpaceNode *snode, | const SpaceNode *snode, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeInstanceKey UNUSED(key)) | bNodeInstanceKey UNUSED(key)) | ||||
| { | { | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| float centy = BLI_rctf_cent_y(rct); | float centy = BLI_rctf_cent_y(rct); | ||||
| float hiddenrad = BLI_rctf_size_y(rct) / 2.0f; | float hiddenrad = BLI_rctf_size_y(rct) / 2.0f; | ||||
| View2D *v2d = ®ion->v2d; | |||||
| float scale; | float scale; | ||||
| UI_view2d_scale_get(v2d, &scale, NULL); | UI_view2d_scale_get(v2d, &scale, NULL); | ||||
| /* shadow */ | /* shadow */ | ||||
| node_draw_shadow(snode, node, hiddenrad, 1.0f); | node_draw_shadow(snode, node, hiddenrad, 1.0f); | ||||
| /* body */ | /* body */ | ||||
| float color[4]; | float color[4]; | ||||
| int color_id = node_get_colorid(node); | int color_id = node_get_colorid(node); | ||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| /* Muted nodes are semi-transparent and colorless. */ | /* Muted nodes are semi-transparent and colorless. */ | ||||
| UI_GetThemeColor4fv(TH_NODE, color); | UI_GetThemeColor4fv(TH_NODE, color); | ||||
| color[3] = 0.25f; | color[3] = 0.25f; | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColor4fv(color_id, color); | UI_GetThemeColor4fv(color_id, color); | ||||
| } | } | ||||
| UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color); | UI_draw_roundbox_aa(rct, true, hiddenrad, color); | ||||
| /* outline active and selected emphasis */ | /* outline active and selected emphasis */ | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| UI_GetThemeColorShadeAlpha4fv( | UI_GetThemeColorShadeAlpha4fv( | ||||
| (node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color); | (node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color); | ||||
| UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color); | UI_draw_roundbox_aa(rct, false, hiddenrad, color); | ||||
| } | } | ||||
| /* custom color inline */ | /* custom color inline */ | ||||
| if (node->flag & NODE_CUSTOM_COLOR) { | if (node->flag & NODE_CUSTOM_COLOR) { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| UI_draw_roundbox_3fv_alpha(false, | UI_draw_roundbox_3fv_alpha( | ||||
| rct->xmin + 1, | &(const rctf){ | ||||
| rct->ymin + 1, | .xmin = rct->xmin + 1, | ||||
| rct->xmax - 1, | .xmax = rct->xmax - 1, | ||||
| rct->ymax - 1, | .ymin = rct->ymin + 1, | ||||
| .ymax = rct->ymax - 1, | |||||
| }, | |||||
| false, | |||||
| hiddenrad, | hiddenrad, | ||||
| node->color, | node->color, | ||||
| 1.0f); | 1.0f); | ||||
| GPU_line_smooth(false); | GPU_line_smooth(false); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| /* title */ | /* title */ | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| UI_GetThemeColor4fv(TH_SELECT, color); | UI_GetThemeColor4fv(TH_SELECT, color); | ||||
| Show All 26 Lines | /* open entirely icon */ | ||||
| UI_GetThemeColor4fv(TH_TEXT, color); | UI_GetThemeColor4fv(TH_TEXT, color); | ||||
| /* custom draw function for this button */ | /* custom draw function for this button */ | ||||
| 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(®ion->v2d, snode, node); | node_draw_mute_line(v2d, snode, node); | ||||
| } | } | ||||
| char showname[128]; /* 128 is used below */ | char showname[128]; /* 128 is used below */ | ||||
| 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); | ||||
| Show All 22 Lines | static void node_draw_hidden(const bContext *C, | ||||
| immUniformThemeColorShade(color_id, -10); | immUniformThemeColorShade(color_id, -10); | ||||
| float dx = 10.0f; | float dx = 10.0f; | ||||
| immBegin(GPU_PRIM_LINES, 4); | immBegin(GPU_PRIM_LINES, 4); | ||||
| immVertex2f(pos, rct->xmax - dx, centy - 4.0f); | immVertex2f(pos, rct->xmax - dx, centy - 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx, centy + 4.0f); | immVertex2f(pos, rct->xmax - dx, centy + 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f); | immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy - 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); | immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy + 4.0f); | ||||
| immEnd(); | immEnd(); | ||||
| immUniformThemeColorShade(color_id, 30); | immUniformThemeColorShade(color_id, 30); | ||||
| dx -= snode->aspect; | dx -= snode->runtime->aspect; | ||||
| immBegin(GPU_PRIM_LINES, 4); | immBegin(GPU_PRIM_LINES, 4); | ||||
| immVertex2f(pos, rct->xmax - dx, centy - 4.0f); | immVertex2f(pos, rct->xmax - dx, centy - 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx, centy + 4.0f); | immVertex2f(pos, rct->xmax - dx, centy + 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f); | immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy - 4.0f); | ||||
| immVertex2f(pos, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); | immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy + 4.0f); | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| node_draw_sockets(v2d, C, ntree, node, true, false); | node_draw_sockets(v2d, C, ntree, node, true, false); | ||||
| UI_block_end(C, node->block); | UI_block_end(C, node->block); | ||||
| UI_block_draw(C, node->block); | UI_block_draw(C, node->block); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| void node_draw_default(const bContext *C, | void node_draw_default(const bContext *C, | ||||
| ARegion *region, | ARegion *region, | ||||
| SpaceNode *snode, | SpaceNode *snode, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeInstanceKey key) | bNodeInstanceKey key) | ||||
| { | { | ||||
| const View2D *v2d = ®ion->v2d; | |||||
| if (node->flag & NODE_HIDDEN) { | if (node->flag & NODE_HIDDEN) { | ||||
| node_draw_hidden(C, region, snode, ntree, node, key); | node_draw_hidden(C, v2d, snode, ntree, node, key); | ||||
| } | } | ||||
| else { | else { | ||||
| node_draw_basis(C, region, snode, ntree, node, key); | node_draw_basis(C, v2d, snode, ntree, node, key); | ||||
| } | } | ||||
| } | } | ||||
| static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) | static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| if (node->typeinfo->draw_nodetype_prepare) { | if (node->typeinfo->draw_nodetype_prepare) { | ||||
| node->typeinfo->draw_nodetype_prepare(C, ntree, node); | node->typeinfo->draw_nodetype_prepare(C, ntree, node); | ||||
| } | } | ||||
| Show All 36 Lines | |||||
| #ifdef USE_DRAW_TOT_UPDATE | #ifdef USE_DRAW_TOT_UPDATE | ||||
| if (ntree->nodes.first) { | if (ntree->nodes.first) { | ||||
| BLI_rctf_init_minmax(®ion->v2d.tot); | BLI_rctf_init_minmax(®ion->v2d.tot); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* draw background nodes, last nodes in front */ | /* draw background nodes, last nodes in front */ | ||||
| int a = 0; | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, a) { | |||||
| #ifdef USE_DRAW_TOT_UPDATE | #ifdef USE_DRAW_TOT_UPDATE | ||||
| /* unrelated to background nodes, update the v2d->tot, | /* unrelated to background nodes, update the v2d->tot, | ||||
| * can be anywhere before we draw the scroll bars */ | * can be anywhere before we draw the scroll bars */ | ||||
| BLI_rctf_union(®ion->v2d.tot, &node->totr); | BLI_rctf_union(®ion->v2d.tot, &node->totr); | ||||
| #endif | #endif | ||||
| if (!(node->flag & NODE_BACKGROUND)) { | if (!(node->flag & NODE_BACKGROUND)) { | ||||
| continue; | continue; | ||||
| Show All 10 Lines | LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { | ||||
| if (!nodeLinkIsHidden(link)) { | if (!nodeLinkIsHidden(link)) { | ||||
| node_draw_link(®ion->v2d, snode, link); | node_draw_link(®ion->v2d, snode, link); | ||||
| } | } | ||||
| } | } | ||||
| nodelink_batch_end(snode); | nodelink_batch_end(snode); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| /* draw foreground nodes, last nodes in front */ | /* draw foreground nodes, last nodes in front */ | ||||
| a = 0; | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, a) { | |||||
| if (node->flag & NODE_BACKGROUND) { | if (node->flag & NODE_BACKGROUND) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); | bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); | ||||
| node_draw(C, region, snode, ntree, node, key); | node_draw(C, region, snode, ntree, node, key); | ||||
| } | } | ||||
| } | } | ||||
| Show All 13 Lines | |||||
| { | { | ||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
| /* shift view to node tree center */ | /* shift view to node tree center */ | ||||
| UI_view2d_center_set(v2d, center[0], center[1]); | UI_view2d_center_set(v2d, center[0], center[1]); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| /* aspect+font, set each time */ | /* aspect+font, set each time */ | ||||
| snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx; | snode->runtime->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx; | ||||
| // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); | // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); | ||||
| } | } | ||||
| static void draw_nodetree(const bContext *C, | static void draw_nodetree(const bContext *C, | ||||
| ARegion *region, | ARegion *region, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| bNodeInstanceKey parent_key) | bNodeInstanceKey parent_key) | ||||
| { | { | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| node_uiblocks_init(C, ntree); | node_uiblocks_init(C, ntree); | ||||
| node_update_nodetree(C, ntree); | node_update_nodetree(C, ntree); | ||||
| node_draw_nodetree(C, region, snode, ntree, parent_key); | node_draw_nodetree(C, region, snode, ntree, parent_key); | ||||
| } | } | ||||
| /* shade the parent node group and add a uiBlock to clip mouse events */ | /* shade the parent node group and add a uiBlock to clip mouse events */ | ||||
| static void draw_group_overlay(const bContext *C, ARegion *region) | static void draw_group_overlay(const bContext *C, ARegion *region) | ||||
| { | { | ||||
| View2D *v2d = ®ion->v2d; | const View2D *v2d = ®ion->v2d; | ||||
| rctf rect = v2d->cur; | const rctf rect = v2d->cur; | ||||
| float color[4]; | float color[4]; | ||||
| /* shade node groups to separate them visually */ | /* shade node groups to separate them visually */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, 0, color); | UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, 0, color); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_NONE); | UI_draw_roundbox_corner_set(UI_CNR_NONE); | ||||
| UI_draw_roundbox_4fv(true, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0, color); | UI_draw_roundbox_4fv(&rect, true, 0, color); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| /* set the block bounds to clip mouse events from underlying nodes */ | /* set the block bounds to clip mouse events from underlying nodes */ | ||||
| uiBlock *block = UI_block_begin(C, region, "node tree bounds block", UI_EMBOSS); | uiBlock *block = UI_block_begin(C, region, "node tree bounds block", UI_EMBOSS); | ||||
| UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | ||||
| UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS); | UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS); | ||||
| UI_block_end(C, block); | UI_block_end(C, block); | ||||
| } | } | ||||
| Show All 10 Lines | void node_draw_space(const bContext *C, ARegion *region) | ||||
| GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| UI_ThemeClearColor(TH_BACK); | UI_ThemeClearColor(TH_BACK); | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| GPU_scissor_test(true); | GPU_scissor_test(true); | ||||
| /* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */ | /* XXX snode->runtime->cursor set in coordspace for placing new nodes, used for drawing noodles | ||||
| * too */ | |||||
| UI_view2d_region_to_view(®ion->v2d, | UI_view2d_region_to_view(®ion->v2d, | ||||
| win->eventstate->x - region->winrct.xmin, | win->eventstate->x - region->winrct.xmin, | ||||
| win->eventstate->y - region->winrct.ymin, | win->eventstate->y - region->winrct.ymin, | ||||
| &snode->cursor[0], | &snode->runtime->cursor[0], | ||||
| &snode->cursor[1]); | &snode->runtime->cursor[1]); | ||||
| snode->cursor[0] /= UI_DPI_FAC; | snode->runtime->cursor[0] /= UI_DPI_FAC; | ||||
| snode->cursor[1] /= UI_DPI_FAC; | snode->runtime->cursor[1] /= UI_DPI_FAC; | ||||
| int grid_levels = UI_GetThemeValueType(TH_NODE_GRID_LEVELS, SPACE_NODE); | int grid_levels = UI_GetThemeValueType(TH_NODE_GRID_LEVELS, SPACE_NODE); | ||||
| ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); | ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); | ||||
| /* only set once */ | /* only set once */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (ntree) { | ||||
| } | } | ||||
| draw_nodetree(C, region, ntree, path->parent_key); | draw_nodetree(C, region, ntree, path->parent_key); | ||||
| } | } | ||||
| /* temporary links */ | /* temporary links */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->linkdrag) { | LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) { | ||||
| LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | ||||
| node_draw_link(v2d, snode, (bNodeLink *)linkdata->data); | node_draw_link(v2d, snode, (bNodeLink *)linkdata->data); | ||||
| } | } | ||||
| } | } | ||||
| GPU_line_smooth(false); | GPU_line_smooth(false); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| if (snode->flag & SNODE_SHOW_GPENCIL) { | if (snode->flag & SNODE_SHOW_GPENCIL) { | ||||
| Show All 30 Lines | |||||