Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.c
| Show All 16 Lines | |||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spnode | * \ingroup spnode | ||||
| * \brief higher level node drawing for the node editor. | * \brief higher level node drawing for the node editor. | ||||
| */ | */ | ||||
| #include "MEM_guardedalloc.h" | |||||
| #include "DNA_light_types.h" | #include "DNA_light_types.h" | ||||
| #include "DNA_linestyle_types.h" | #include "DNA_linestyle_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_modifier_types.h" | |||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_object.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "GPU_framebuffer.h" | #include "GPU_framebuffer.h" | ||||
| ▲ Show 20 Lines • Show All 1,061 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 int node_error_type_to_icon(const eNodeWarningType type) | |||||
| { | |||||
| switch (type) { | |||||
| case NODE_WARNING_ERROR: | |||||
| return ICON_ERROR; | |||||
| case NODE_WARNING_INFO: | |||||
| return ICON_INFO; | |||||
| } | |||||
| BLI_assert(false); | |||||
| return ICON_ERROR; | |||||
| } | |||||
| static char *node_errros_tooltip_fn(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) | |||||
| { | |||||
| NodeWarning *message = (NodeWarning *)argN; | |||||
| return BLI_strdup(message->message); | |||||
| } | |||||
| #define NODE_HEADER_ICON_SIZE 0.8f * U.widget_unit | |||||
| static int node_add_error_message_button( | |||||
| const bContext *C, bNodeTree *ntree, bNode *node, const rctf *rect, int icon_offset) | |||||
| { | |||||
| const NodeWarning *message = BKE_nodetree_error_message_get(ntree, node); | |||||
| if (message == NULL) { | |||||
| return icon_offset; | |||||
| } | |||||
| // /* The same node tree can be used for multiple objects, only display | |||||
| // * messages for the evaluations corresponding to the active object. */ | |||||
| // const Object *active_object = CTX_data_active_object(C); | |||||
| // if (message->object != active_object) { | |||||
| // return icon_offset; | |||||
| // } | |||||
| // /* The same node tree can be used for multiple modifiers on the same object. Only display | |||||
| // * messages for the active modifier, which will also be displayed in the node tree. */ | |||||
| // ModifierData *active_modifier = BKE_object_active_modifier(message->object); | |||||
| // if (!STREQ(message->modifier_name, active_modifier->name)) { | |||||
| // return icon_offset; | |||||
| // } | |||||
| icon_offset -= NODE_HEADER_ICON_SIZE; | |||||
| UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | |||||
| /* The only reason to allocate this is that the ownership of | |||||
| * #UI_but_func_tooltip_set's argument is transferred to the button. */ | |||||
| NodeWarning *warning_alloc = MEM_mallocN(sizeof(NodeWarning), __func__); | |||||
| warning_alloc->type = message->type; | |||||
| warning_alloc->message = message->message; | |||||
| uiBut *but = uiDefIconBut(node->block, | |||||
| UI_BTYPE_BUT, | |||||
| 0, | |||||
| node_error_type_to_icon(message->type), | |||||
| icon_offset, | |||||
| rect->ymax - NODE_DY, | |||||
| NODE_HEADER_ICON_SIZE, | |||||
| UI_UNIT_Y, | |||||
| NULL, | |||||
| 0, | |||||
| 0, | |||||
| 0, | |||||
| 0, | |||||
| NULL); | |||||
| UI_but_func_tooltip_set(but, node_errros_tooltip_fn, warning_alloc); | |||||
| UI_block_emboss_set(node->block, UI_EMBOSS); | |||||
| return icon_offset; | |||||
| } | |||||
| static void node_draw_basis(const bContext *C, | static void node_draw_basis(const bContext *C, | ||||
| const View2D *v2d, | const View2D *v2d, | ||||
| const 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; | const float iconbutw = NODE_HEADER_ICON_SIZE; | ||||
| /* 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; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | uiDefIconBut(node->block, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| UI_block_emboss_set(node->block, UI_EMBOSS); | UI_block_emboss_set(node->block, UI_EMBOSS); | ||||
| } | } | ||||
| iconofs = node_add_error_message_button(C, ntree, node, rct, iconofs); | |||||
| /* title */ | /* title */ | ||||
| if (node->flag & SELECT) { | if (node->flag & 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 638 Lines • Show Last 20 Lines | |||||