Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.cc
| Show First 20 Lines • Show All 2,033 Lines • ▼ Show 20 Lines | static void node_draw_extra_info_panel(TreeDrawContext &tree_draw_ctx, | ||||
| } | } | ||||
| const rctf &rct = node.runtime->totr; | const rctf &rct = node.runtime->totr; | ||||
| float color[4]; | float color[4]; | ||||
| rctf extra_info_rect; | rctf extra_info_rect; | ||||
| const float width = (node.width - 6.0f) * U.dpi_fac; | const float width = (node.width - 6.0f) * U.dpi_fac; | ||||
| if (node.type == NODE_FRAME) { | if (node.is_frame()) { | ||||
| extra_info_rect.xmin = rct.xmin; | extra_info_rect.xmin = rct.xmin; | ||||
| extra_info_rect.xmax = rct.xmin + 95.0f * U.dpi_fac; | extra_info_rect.xmax = rct.xmin + 95.0f * U.dpi_fac; | ||||
| extra_info_rect.ymin = rct.ymin + 2.0f * U.dpi_fac; | extra_info_rect.ymin = rct.ymin + 2.0f * U.dpi_fac; | ||||
| extra_info_rect.ymax = rct.ymin + 2.0f * U.dpi_fac; | extra_info_rect.ymax = rct.ymin + 2.0f * U.dpi_fac; | ||||
| } | } | ||||
| else { | else { | ||||
| extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac; | extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac; | ||||
| extra_info_rect.xmax = rct.xmin + width; | extra_info_rect.xmax = rct.xmin + width; | ||||
| extra_info_rect.ymin = rct.ymax; | extra_info_rect.ymin = rct.ymax; | ||||
| extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * U.dpi_fac); | extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * U.dpi_fac); | ||||
| if (node.flag & NODE_MUTED) { | if (node.is_muted()) { | ||||
| UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color); | UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color); | UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color); | ||||
| } | } | ||||
| color[3] -= 0.35f; | color[3] -= 0.35f; | ||||
| UI_draw_roundbox_corner_set( | UI_draw_roundbox_corner_set( | ||||
| UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT & | UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT & | ||||
| Show All 31 Lines | static void node_draw_basis(const bContext &C, | ||||
| const float iconbutw = NODE_HEADER_ICON_SIZE; | const float iconbutw = NODE_HEADER_ICON_SIZE; | ||||
| /* Skip if out of view. */ | /* Skip if out of view. */ | ||||
| if (BLI_rctf_isect(&node.runtime->totr, &v2d.cur, nullptr) == false) { | if (BLI_rctf_isect(&node.runtime->totr, &v2d.cur, nullptr) == false) { | ||||
| UI_block_end(&C, &block); | UI_block_end(&C, &block); | ||||
| return; | return; | ||||
| } | } | ||||
| const bool node_muted = node.is_muted(); | |||||
| const bool node_selec = node.flag & SELECT; | |||||
| /* Shadow. */ | /* Shadow. */ | ||||
| node_draw_shadow(snode, node, BASIS_RAD, 1.0f); | node_draw_shadow(snode, node, BASIS_RAD, 1.0f); | ||||
| const rctf &rct = node.runtime->totr; | const rctf &rct = node.runtime->totr; | ||||
| float color[4]; | float color[4]; | ||||
| int color_id = node_get_colorid(tree_draw_ctx, node); | int color_id = node_get_colorid(tree_draw_ctx, node); | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| node_draw_extra_info_panel(tree_draw_ctx, snode, node, block); | node_draw_extra_info_panel(tree_draw_ctx, snode, node, block); | ||||
| /* Header. */ | /* Header. */ | ||||
| { | { | ||||
| const rctf rect = { | const rctf rect = { | ||||
| rct.xmin, | rct.xmin, | ||||
| rct.xmax, | rct.xmax, | ||||
| rct.ymax - NODE_DY, | rct.ymax - NODE_DY, | ||||
| rct.ymax, | rct.ymax, | ||||
| }; | }; | ||||
| float color_header[4]; | float color_header[4]; | ||||
| /* Muted nodes get a mix of the background with the node color. */ | /* Muted nodes get a mix of the background with the node color. */ | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.1f, color_header); | UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.1f, color_header); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color_header); | UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color_header); | ||||
| } | } | ||||
| 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_4fv(&rect, true, BASIS_RAD, color_header); | UI_draw_roundbox_4fv(&rect, true, BASIS_RAD, color_header); | ||||
| Show All 24 Lines | if (node.typeinfo->flag & NODE_PREVIEW) { | ||||
| /* XXX this does not work when node is activated and the operator called right afterwards, | /* XXX this does not work when node is activated and the operator called right afterwards, | ||||
| * since active ID is not updated yet (needs to process the notifier). | * since active ID is not updated yet (needs to process the notifier). | ||||
| * This can only work as visual indicator! */ | * This can only work as visual indicator! */ | ||||
| // if (!(node.flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))) | // if (!(node.flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))) | ||||
| // UI_but_flag_enable(but, UI_BUT_DISABLED); | // UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| UI_block_emboss_set(&block, UI_EMBOSS); | UI_block_emboss_set(&block, UI_EMBOSS); | ||||
| } | } | ||||
| /* Group edit. */ | /* Group edit. */ | ||||
| if (node.type == NODE_GROUP) { | if (node.is_group()) { | ||||
| iconofs -= iconbutw; | iconofs -= iconbutw; | ||||
| UI_block_emboss_set(&block, UI_EMBOSS_NONE); | UI_block_emboss_set(&block, UI_EMBOSS_NONE); | ||||
| uiBut *but = uiDefIconBut(&block, | uiBut *but = uiDefIconBut(&block, | ||||
| UI_BTYPE_BUT_TOGGLE, | UI_BTYPE_BUT_TOGGLE, | ||||
| 0, | 0, | ||||
| ICON_NODETREE, | ICON_NODETREE, | ||||
| iconofs, | iconofs, | ||||
| rct.ymax - NODE_DY, | rct.ymax - NODE_DY, | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | if (node.type == GEO_NODE_VIEWER) { | ||||
| const char *operator_idname = is_active ? "NODE_OT_deactivate_viewer" : "NODE_OT_select"; | const char *operator_idname = is_active ? "NODE_OT_deactivate_viewer" : "NODE_OT_select"; | ||||
| UI_but_func_set(but, node_toggle_button_cb, &node, (void *)operator_idname); | UI_but_func_set(but, node_toggle_button_cb, &node, (void *)operator_idname); | ||||
| UI_block_emboss_set(&block, UI_EMBOSS); | UI_block_emboss_set(&block, UI_EMBOSS); | ||||
| } | } | ||||
| node_add_error_message_button(tree_draw_ctx, node, block, rct, iconofs); | node_add_error_message_button(tree_draw_ctx, node, block, rct, iconofs); | ||||
| /* Title. */ | /* Title. */ | ||||
| if (node.flag & SELECT) { | if (node_selec) { | ||||
| UI_GetThemeColor4fv(TH_SELECT, color); | UI_GetThemeColor4fv(TH_SELECT, color); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color); | UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color); | ||||
| } | } | ||||
| /* Collapse/expand icon. */ | /* Collapse/expand icon. */ | ||||
| { | { | ||||
| Show All 31 Lines | uiBut *but = uiDefBut(&block, | ||||
| short(iconofs - rct.xmin - (18.0f * U.dpi_fac)), | short(iconofs - rct.xmin - (18.0f * U.dpi_fac)), | ||||
| short(NODE_DY), | short(NODE_DY), | ||||
| nullptr, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| UI_but_flag_enable(but, UI_BUT_INACTIVE); | UI_but_flag_enable(but, UI_BUT_INACTIVE); | ||||
| } | } | ||||
| /* Wire across the node when muted/disabled. */ | /* Wire across the node when muted/disabled. */ | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| node_draw_mute_line(C, v2d, snode, node); | node_draw_mute_line(C, v2d, snode, node); | ||||
| } | } | ||||
| /* Body. */ | /* Body. */ | ||||
| const float outline_width = 1.0f; | const float outline_width = 1.0f; | ||||
| { | { | ||||
| /* Use warning color to indicate undefined types. */ | /* Use warning color to indicate undefined types. */ | ||||
| if (nodeTypeUndefined(&node)) { | if (nodeTypeUndefined(&node)) { | ||||
| UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); | UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); | ||||
| } | } | ||||
| /* Muted nodes get a mix of the background with the node color. */ | /* Muted nodes get a mix of the background with the node color. */ | ||||
| else if (node.flag & NODE_MUTED) { | else if (node_muted) { | ||||
| UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color); | UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color); | ||||
| } | } | ||||
| else if (node.flag & NODE_CUSTOM_COLOR) { | else if (node.flag & NODE_CUSTOM_COLOR) { | ||||
| rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f); | rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColor4fv(TH_NODE, color); | UI_GetThemeColor4fv(TH_NODE, color); | ||||
| } | } | ||||
| /* Draw selected nodes fully opaque. */ | /* Draw selected nodes fully opaque. */ | ||||
| if (node.flag & SELECT) { | if (node_selec) { | ||||
| color[3] = 1.0f; | color[3] = 1.0f; | ||||
| } | } | ||||
| /* Draw muted nodes slightly transparent so the wires inside are visible. */ | /* Draw muted nodes slightly transparent so the wires inside are visible. */ | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| color[3] -= 0.2f; | color[3] -= 0.2f; | ||||
| } | } | ||||
| const rctf rect = { | const rctf rect = { | ||||
| rct.xmin, | rct.xmin, | ||||
| rct.xmax, | rct.xmax, | ||||
| rct.ymin, | rct.ymin, | ||||
| rct.ymax - (NODE_DY + outline_width), | rct.ymax - (NODE_DY + outline_width), | ||||
| }; | }; | ||||
| 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_4fv(&rect, true, BASIS_RAD, color); | UI_draw_roundbox_4fv(&rect, true, BASIS_RAD, color); | ||||
| } | } | ||||
| /* Header underline. */ | /* Header underline. */ | ||||
| { | { | ||||
| float color_underline[4]; | float color_underline[4]; | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| UI_GetThemeColor4fv(TH_WIRE, color_underline); | UI_GetThemeColor4fv(TH_WIRE, color_underline); | ||||
| color_underline[3] = 1.0f; | color_underline[3] = 1.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.2f, color_underline); | UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.2f, color_underline); | ||||
| } | } | ||||
| const rctf rect = { | const rctf rect = { | ||||
| Show All 14 Lines | const rctf rect = { | ||||
| rct.xmax + outline_width, | rct.xmax + outline_width, | ||||
| rct.ymin - outline_width, | rct.ymin - outline_width, | ||||
| rct.ymax + outline_width, | rct.ymax + outline_width, | ||||
| }; | }; | ||||
| /* Color the outline according to active, selected, or undefined status. */ | /* Color the outline according to active, selected, or undefined status. */ | ||||
| float color_outline[4]; | float color_outline[4]; | ||||
| if (node.flag & SELECT) { | if (node_selec) { | ||||
| UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); | UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); | ||||
| } | } | ||||
| else if (nodeTypeUndefined(&node)) { | else if (nodeTypeUndefined(&node)) { | ||||
| UI_GetThemeColor4fv(TH_REDALERT, color_outline); | UI_GetThemeColor4fv(TH_REDALERT, color_outline); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline); | UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline); | ||||
| } | } | ||||
| Show All 33 Lines | static void node_draw_hidden(const bContext &C, | ||||
| bNodeTree &ntree, | bNodeTree &ntree, | ||||
| bNode &node, | bNode &node, | ||||
| uiBlock &block) | uiBlock &block) | ||||
| { | { | ||||
| const rctf &rct = node.runtime->totr; | const rctf &rct = node.runtime->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; | ||||
| const bool node_muted = node.is_muted(); | |||||
| const bool node_select = node.flag & SELECT; | |||||
| float scale; | float scale; | ||||
| UI_view2d_scale_get(&v2d, &scale, nullptr); | UI_view2d_scale_get(&v2d, &scale, nullptr); | ||||
| const int color_id = node_get_colorid(tree_draw_ctx, node); | const int color_id = node_get_colorid(tree_draw_ctx, node); | ||||
| node_draw_extra_info_panel(tree_draw_ctx, snode, node, block); | node_draw_extra_info_panel(tree_draw_ctx, snode, node, block); | ||||
| /* Shadow. */ | /* Shadow. */ | ||||
| node_draw_shadow(snode, node, hiddenrad, 1.0f); | node_draw_shadow(snode, node, hiddenrad, 1.0f); | ||||
| /* Wire across the node when muted/disabled. */ | /* Wire across the node when muted/disabled. */ | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| node_draw_mute_line(C, v2d, snode, node); | node_draw_mute_line(C, v2d, snode, node); | ||||
| } | } | ||||
| /* Body. */ | /* Body. */ | ||||
| float color[4]; | float color[4]; | ||||
| { | { | ||||
| if (nodeTypeUndefined(&node)) { | if (nodeTypeUndefined(&node)) { | ||||
| /* Use warning color to indicate undefined types. */ | /* Use warning color to indicate undefined types. */ | ||||
| UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); | UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); | ||||
| } | } | ||||
| else if (node.flag & NODE_MUTED) { | else if (node_muted) { | ||||
| /* Muted nodes get a mix of the background with the node color. */ | /* Muted nodes get a mix of the background with the node color. */ | ||||
| UI_GetThemeColorBlendShade4fv(TH_BACK, color_id, 0.1f, 0, color); | UI_GetThemeColorBlendShade4fv(TH_BACK, color_id, 0.1f, 0, color); | ||||
| } | } | ||||
| else if (node.flag & NODE_CUSTOM_COLOR) { | else if (node.flag & NODE_CUSTOM_COLOR) { | ||||
| rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f); | rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color); | UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color); | ||||
| } | } | ||||
| /* Draw selected nodes fully opaque. */ | /* Draw selected nodes fully opaque. */ | ||||
| if (node.flag & SELECT) { | if (node_select) { | ||||
| color[3] = 1.0f; | color[3] = 1.0f; | ||||
| } | } | ||||
| /* Draw muted nodes slightly transparent so the wires inside are visible. */ | /* Draw muted nodes slightly transparent so the wires inside are visible. */ | ||||
| if (node.flag & NODE_MUTED) { | if (node_muted) { | ||||
| color[3] -= 0.2f; | color[3] -= 0.2f; | ||||
| } | } | ||||
| UI_draw_roundbox_4fv(&rct, true, hiddenrad, color); | UI_draw_roundbox_4fv(&rct, true, hiddenrad, color); | ||||
| } | } | ||||
| /* Title. */ | /* Title. */ | ||||
| if (node.flag & SELECT) { | if (node_select) { | ||||
| UI_GetThemeColor4fv(TH_SELECT, color); | UI_GetThemeColor4fv(TH_SELECT, color); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color); | UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color); | ||||
| } | } | ||||
| /* Collapse/expand icon. */ | /* Collapse/expand icon. */ | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | const rctf rect = { | ||||
| rct.xmax + outline_width, | rct.xmax + outline_width, | ||||
| rct.ymin - outline_width, | rct.ymin - outline_width, | ||||
| rct.ymax + outline_width, | rct.ymax + outline_width, | ||||
| }; | }; | ||||
| /* Color the outline according to active, selected, or undefined status. */ | /* Color the outline according to active, selected, or undefined status. */ | ||||
| float color_outline[4]; | float color_outline[4]; | ||||
| if (node.flag & SELECT) { | if (node_select) { | ||||
| UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); | UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); | ||||
| } | } | ||||
| else if (nodeTypeUndefined(&node)) { | else if (nodeTypeUndefined(&node)) { | ||||
| UI_GetThemeColor4fv(TH_REDALERT, color_outline); | UI_GetThemeColor4fv(TH_REDALERT, color_outline); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline); | UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline); | ||||
| } | } | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_4fv(&rect, false, hiddenrad, color_outline); | UI_draw_roundbox_4fv(&rect, false, hiddenrad, color_outline); | ||||
| } | } | ||||
| if (node.flag & NODE_MUTED) { | if (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); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| ▲ Show 20 Lines • Show All 772 Lines • Show Last 20 Lines | |||||