Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.cc
| Show First 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | case NODE_CLASS_GEOMETRY: | ||||
| return TH_NODE_GEOMETRY; | return TH_NODE_GEOMETRY; | ||||
| case NODE_CLASS_ATTRIBUTE: | case NODE_CLASS_ATTRIBUTE: | ||||
| return TH_NODE_ATTRIBUTE; | return TH_NODE_ATTRIBUTE; | ||||
| default: | default: | ||||
| return TH_NODE; | return TH_NODE; | ||||
| } | } | ||||
| } | } | ||||
| static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const bNode *node) | static void node_draw_mute_line(const bContext *C, | ||||
| const View2D *v2d, | |||||
| const SpaceNode *snode, | |||||
| const bNode *node) | |||||
| { | { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| LISTBASE_FOREACH (const bNodeLink *, link, &node->internal_links) { | LISTBASE_FOREACH (const bNodeLink *, link, &node->internal_links) { | ||||
| node_draw_link_bezier(v2d, snode, link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE); | node_draw_link_bezier(C, v2d, snode, link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE); | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| static void node_socket_draw(const bNodeSocket *sock, | static void node_socket_draw(const bNodeSocket *sock, | ||||
| const float color[4], | const float color[4], | ||||
| const float color_outline[4], | const float color_outline[4], | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | static void node_socket_outline_color_get(const bool selected, | ||||
| if (socket_type == SOCK_CUSTOM) { | if (socket_type == SOCK_CUSTOM) { | ||||
| copy_v4_v4(r_outline_color, virtual_node_socket_outline_color); | copy_v4_v4(r_outline_color, virtual_node_socket_outline_color); | ||||
| } | } | ||||
| } | } | ||||
| /* Usual convention here would be node_socket_get_color(), but that's already used (for setting a | /* Usual convention here would be node_socket_get_color(), but that's already used (for setting a | ||||
| * color property socket). */ | * color property socket). */ | ||||
| void node_socket_color_get( | void node_socket_color_get( | ||||
| bContext *C, bNodeTree *ntree, PointerRNA *node_ptr, bNodeSocket *sock, float r_color[4]) | const bContext *C, bNodeTree *ntree, PointerRNA *node_ptr, bNodeSocket *sock, float r_color[4]) | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| BLI_assert(RNA_struct_is_a(node_ptr->type, &RNA_Node)); | BLI_assert(RNA_struct_is_a(node_ptr->type, &RNA_Node)); | ||||
| RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); | RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); | ||||
| sock->typeinfo->draw_color(C, &ptr, node_ptr, r_color); | sock->typeinfo->draw_color((bContext *)C, &ptr, node_ptr, r_color); | ||||
| } | } | ||||
| struct SocketTooltipData { | struct SocketTooltipData { | ||||
| bNodeTree *ntree; | bNodeTree *ntree; | ||||
| bNode *node; | bNode *node; | ||||
| bNodeSocket *socket; | bNodeSocket *socket; | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | static void node_socket_draw_nested(const bContext *C, | ||||
| uint size_id, | uint size_id, | ||||
| uint outline_col_id, | uint outline_col_id, | ||||
| float size, | float size, | ||||
| bool selected) | bool selected) | ||||
| { | { | ||||
| float color[4]; | float color[4]; | ||||
| float outline_color[4]; | float outline_color[4]; | ||||
| node_socket_color_get((bContext *)C, ntree, node_ptr, sock, color); | node_socket_color_get(C, ntree, node_ptr, sock, color); | ||||
| node_socket_outline_color_get(selected, sock->type, outline_color); | node_socket_outline_color_get(selected, sock->type, outline_color); | ||||
| node_socket_draw(sock, | node_socket_draw(sock, | ||||
| color, | color, | ||||
| outline_color, | outline_color, | ||||
| size, | size, | ||||
| sock->locx, | sock->locx, | ||||
| sock->locy, | sock->locy, | ||||
| ▲ Show 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) { | ||||
| } | } | ||||
| const bool is_node_hidden = (node->flag & NODE_HIDDEN); | const bool is_node_hidden = (node->flag & NODE_HIDDEN); | ||||
| const float width = NODE_SOCKSIZE; | const float width = NODE_SOCKSIZE; | ||||
| float height = is_node_hidden ? width : node_socket_calculate_height(socket) - width; | float height = is_node_hidden ? width : node_socket_calculate_height(socket) - width; | ||||
| float color[4]; | float color[4]; | ||||
| float outline_color[4]; | float outline_color[4]; | ||||
| node_socket_color_get((bContext *)C, ntree, &node_ptr, socket, color); | node_socket_color_get(C, ntree, &node_ptr, socket, color); | ||||
| node_socket_outline_color_get(selected, socket->type, outline_color); | node_socket_outline_color_get(selected, socket->type, outline_color); | ||||
| node_socket_draw_multi_input(color, outline_color, width, height, socket->locx, socket->locy); | node_socket_draw_multi_input(color, outline_color, width, height, socket->locx, socket->locy); | ||||
| } | } | ||||
| } | } | ||||
| static int node_error_type_to_icon(const geo_log::NodeWarningType type) | static int node_error_type_to_icon(const geo_log::NodeWarningType type) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | uiBut *but = uiDefBut(node->block, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| 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); | ||||
| } | } | ||||
| /* Wire across the node when muted/disabled. */ | /* Wire across the node when muted/disabled. */ | ||||
| if (node->flag & NODE_MUTED) { | if (node->flag & NODE_MUTED) { | ||||
| node_draw_mute_line(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); | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | static void node_draw_hidden(const bContext *C, | ||||
| const int color_id = node_get_colorid(node); | const int color_id = node_get_colorid(node); | ||||
| /* 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->flag & NODE_MUTED) { | ||||
| node_draw_mute_line(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); | ||||
| ▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| /* Node lines. */ | /* Node lines. */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| nodelink_batch_start(snode); | nodelink_batch_start(snode); | ||||
| LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { | LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { | ||||
| if (!nodeLinkIsHidden(link)) { | if (!nodeLinkIsHidden(link)) { | ||||
| node_draw_link(®ion->v2d, snode, link); | node_draw_link(C, ®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. */ | ||||
| LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| if (node->flag & NODE_BACKGROUND) { | if (node->flag & NODE_BACKGROUND) { | ||||
| ▲ Show 20 Lines • Show All 168 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->runtime->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(C, 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->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && snode->flag & SNODE_SHOW_GPENCIL) { | if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && snode->flag & SNODE_SHOW_GPENCIL) { | ||||
| /* Draw grease-pencil annotations. */ | /* Draw grease-pencil annotations. */ | ||||
| ED_annotation_draw_view2d(C, true); | ED_annotation_draw_view2d(C, true); | ||||
| Show All 28 Lines | |||||