Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.c
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "node_intern.h" /* own include */ | #include "node_intern.h" /* own include */ | ||||
| #include "COM_compositor.h" | #include "COM_compositor.h" | ||||
| /* XXX interface.h */ | /* XXX interface.h */ | ||||
| extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select); | extern void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select); | ||||
| float ED_node_grid_size(void) | float ED_node_grid_size(void) | ||||
| { | { | ||||
| return U.widget_unit; | return U.widget_unit; | ||||
| } | } | ||||
| void ED_node_tree_update(const bContext *C) | void ED_node_tree_update(const bContext *C) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) | ||||
| bNode *node; | bNode *node; | ||||
| char uiblockstr[32]; | char uiblockstr[32]; | ||||
| /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ | /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ | ||||
| for (node = ntree->nodes.first; node; node = node->next) { | for (node = ntree->nodes.first; node; node = node->next) { | ||||
| /* ui block */ | /* ui block */ | ||||
| BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); | BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); | ||||
| node->block = uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); | node->block = UI_block_begin(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); | ||||
| uiBlockSetHandleFunc(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 */ | ||||
| uiBlockSetFlag(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(struct 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; | ||||
| Show All 32 Lines | static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| /* output sockets */ | /* output sockets */ | ||||
| for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | for (nsock = node->outputs.first; nsock; nsock = nsock->next) { | ||||
| if (nodeSocketIsHidden(nsock)) | if (nodeSocketIsHidden(nsock)) | ||||
| continue; | continue; | ||||
| RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); | RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); | ||||
| layout = uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, | 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_GetStyle()); | locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); | ||||
| /* context pointers for current node and socket */ | /* context pointers for current node and socket */ | ||||
| uiLayoutSetContextPointer(layout, "node", &nodeptr); | uiLayoutSetContextPointer(layout, "node", &nodeptr); | ||||
| uiLayoutSetContextPointer(layout, "socket", &sockptr); | uiLayoutSetContextPointer(layout, "socket", &sockptr); | ||||
| /* align output buttons to the right */ | /* align output buttons to the right */ | ||||
| row = uiLayoutRow(layout, 1); | row = uiLayoutRow(layout, 1); | ||||
| uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); | uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); | ||||
| nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); | nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); | ||||
| uiBlockEndAlign(node->block); | UI_block_align_end(node->block); | ||||
| uiBlockLayoutResolve(node->block, NULL, &buty); | UI_block_layout_resolve(node->block, NULL, &buty); | ||||
| /* ensure minimum socket height in case layout is empty */ | /* ensure minimum socket height in case layout is empty */ | ||||
| buty = min_ii(buty, dy - NODE_DY); | buty = min_ii(buty, dy - NODE_DY); | ||||
| nsock->locx = locx + NODE_WIDTH(node); | nsock->locx = locx + NODE_WIDTH(node); | ||||
| /* place the socket circle in the middle of the layout */ | /* place the socket circle in the middle of the layout */ | ||||
| nsock->locy = 0.5f * (dy + buty); | nsock->locy = 0.5f * (dy + buty); | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (node->typeinfo->draw_buttons && (node->flag & NODE_OPTIONS)) { | ||||
| /* set this for uifunc() that don't use layout engine yet */ | /* set this for uifunc() that don't use layout engine yet */ | ||||
| node->butr.xmin = 0; | node->butr.xmin = 0; | ||||
| node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS; | node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS; | ||||
| node->butr.ymin = 0; | node->butr.ymin = 0; | ||||
| node->butr.ymax = 0; | node->butr.ymax = 0; | ||||
| layout = uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, | layout = UI_block_layout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, | ||||
| locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_GetStyle()); | locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get()); | ||||
| uiLayoutSetContextPointer(layout, "node", &nodeptr); | uiLayoutSetContextPointer(layout, "node", &nodeptr); | ||||
| node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); | node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); | ||||
| uiBlockEndAlign(node->block); | UI_block_align_end(node->block); | ||||
| uiBlockLayoutResolve(node->block, NULL, &buty); | UI_block_layout_resolve(node->block, NULL, &buty); | ||||
| dy = buty - NODE_DYS / 2; | dy = buty - NODE_DYS / 2; | ||||
| } | } | ||||
| /* input sockets */ | /* input sockets */ | ||||
| for (nsock = node->inputs.first; nsock; nsock = nsock->next) { | for (nsock = node->inputs.first; nsock; nsock = nsock->next) { | ||||
| if (nodeSocketIsHidden(nsock)) | if (nodeSocketIsHidden(nsock)) | ||||
| continue; | continue; | ||||
| RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); | RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); | ||||
| layout = uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, | 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_GetStyle()); | locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); | ||||
| /* context pointers for current node and socket */ | /* context pointers for current node and socket */ | ||||
| uiLayoutSetContextPointer(layout, "node", &nodeptr); | uiLayoutSetContextPointer(layout, "node", &nodeptr); | ||||
| uiLayoutSetContextPointer(layout, "socket", &sockptr); | uiLayoutSetContextPointer(layout, "socket", &sockptr); | ||||
| row = uiLayoutRow(layout, 1); | row = uiLayoutRow(layout, 1); | ||||
| nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); | nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); | ||||
| uiBlockEndAlign(node->block); | UI_block_align_end(node->block); | ||||
| uiBlockLayoutResolve(node->block, NULL, &buty); | UI_block_layout_resolve(node->block, NULL, &buty); | ||||
| /* ensure minimum socket height in case layout is empty */ | /* ensure minimum socket height in case layout is empty */ | ||||
| buty = min_ii(buty, dy - NODE_DY); | buty = min_ii(buty, dy - NODE_DY); | ||||
| nsock->locx = locx; | nsock->locx = locx; | ||||
| /* place the socket circle in the middle of the layout */ | /* place the socket circle in the middle of the layout */ | ||||
| nsock->locy = 0.5f * (dy + buty); | nsock->locy = 0.5f * (dy + buty); | ||||
| Show All 9 Lines | static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| node->totr.xmin = locx; | node->totr.xmin = locx; | ||||
| node->totr.xmax = locx + NODE_WIDTH(node); | node->totr.xmax = locx + NODE_WIDTH(node); | ||||
| node->totr.ymax = locy; | node->totr.ymax = locy; | ||||
| node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); | node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); | ||||
| /* Set the block bounds to clip mouse events from underlying nodes. | /* Set the block bounds to clip mouse events from underlying nodes. | ||||
| * Add a margin for sockets on each side. | * Add a margin for sockets on each side. | ||||
| */ | */ | ||||
| uiExplicitBoundsBlock(node->block, | UI_block_bounds_set_explicit( | ||||
| node->block, | |||||
| node->totr.xmin - NODE_SOCKSIZE, | node->totr.xmin - NODE_SOCKSIZE, | ||||
| node->totr.ymin, | node->totr.ymin, | ||||
| node->totr.xmax + NODE_SOCKSIZE, | node->totr.xmax + NODE_SOCKSIZE, | ||||
| node->totr.ymax); | node->totr.ymax); | ||||
| } | } | ||||
| /* 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_hidden(bNode *node) | static void node_update_hidden(bNode *node) | ||||
| { | { | ||||
| bNodeSocket *nsock; | bNodeSocket *nsock; | ||||
| float locx, locy; | float locx, locy; | ||||
| float rad, drad, hiddenrad = HIDDEN_RAD; | float rad, drad, hiddenrad = HIDDEN_RAD; | ||||
| Show All 40 Lines | if (!nodeSocketIsHidden(nsock)) { | ||||
| nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad; | nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad; | ||||
| rad += drad; | rad += drad; | ||||
| } | } | ||||
| } | } | ||||
| /* Set the block bounds to clip mouse events from underlying nodes. | /* Set the block bounds to clip mouse events from underlying nodes. | ||||
| * Add a margin for sockets on each side. | * Add a margin for sockets on each side. | ||||
| */ | */ | ||||
| uiExplicitBoundsBlock(node->block, | UI_block_bounds_set_explicit( | ||||
| node->block, | |||||
| node->totr.xmin - NODE_SOCKSIZE, | node->totr.xmin - NODE_SOCKSIZE, | ||||
| node->totr.ymin, | node->totr.ymin, | ||||
| node->totr.xmax + NODE_SOCKSIZE, | node->totr.xmax + NODE_SOCKSIZE, | ||||
| node->totr.ymax); | node->totr.ymax); | ||||
| } | } | ||||
| void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) | void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| if (node->flag & NODE_HIDDEN) | if (node->flag & NODE_HIDDEN) | ||||
| node_update_hidden(node); | node_update_hidden(node); | ||||
| else | else | ||||
| node_update_basis(C, ntree, node); | node_update_basis(C, ntree, node); | ||||
| ▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv) | ||||
| 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(SpaceNode *snode, bNode *node, float radius, float alpha) | ||||
| { | { | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| uiSetRoundBox(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| if (node->parent == NULL) | if (node->parent == NULL) | ||||
| ui_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); | ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); | ||||
| else { | else { | ||||
| const float margin = 3.0f; | const float margin = 3.0f; | ||||
| glColor4f(0.0f, 0.0f, 0.0f, 0.33f); | glColor4f(0.0f, 0.0f, 0.0f, 0.33f); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| uiRoundBox(rct->xmin - margin, rct->ymin - margin, | UI_draw_roundbox(rct->xmin - margin, rct->ymin - margin, | ||||
| rct->xmax + margin, rct->ymax + margin, radius + margin); | rct->xmax + margin, rct->ymax + margin, radius + margin); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| } | } | ||||
| static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) | static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) | ||||
| { | { | ||||
| bNodeInstanceHash *previews = CTX_data_pointer_get(C, "node_previews").data; | bNodeInstanceHash *previews = CTX_data_pointer_get(C, "node_previews").data; | ||||
| bNodeSocket *sock; | bNodeSocket *sock; | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| float iconofs; | float iconofs; | ||||
| /* 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; | ||||
| int color_id = node_get_colorid(node); | int color_id = node_get_colorid(node); | ||||
| char showname[128]; /* 128 used below */ | char showname[128]; /* 128 used below */ | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| /* XXX hack: copy values from linked ID data where displayed as sockets */ | /* XXX hack: copy values from linked ID data where displayed as sockets */ | ||||
| if (node->block) | if (node->block) | ||||
| nodeSynchronizeID(node, false); | nodeSynchronizeID(node, false); | ||||
| /* skip if out of view */ | /* skip if out of view */ | ||||
| if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { | if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { | ||||
| uiEndBlock(C, node->block); | UI_block_end(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| return; | return; | ||||
| } | } | ||||
| /* shadow */ | /* shadow */ | ||||
| node_draw_shadow(snode, node, BASIS_RAD, 1.0f); | node_draw_shadow(snode, node, BASIS_RAD, 1.0f); | ||||
| /* header uses color from backdrop, but we make it opaqie */ | /* header uses color from backdrop, but we make it opaqie */ | ||||
| Show All 12 Lines | |||||
| #ifdef WITH_COMPOSITOR | #ifdef WITH_COMPOSITOR | ||||
| if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) { | if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) { | ||||
| if (COM_isHighlightedbNode(node)) { | if (COM_isHighlightedbNode(node)) { | ||||
| UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); | UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); | UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); | ||||
| uiRoundBox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); | UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); | ||||
| /* show/hide icons */ | /* show/hide icons */ | ||||
| iconofs = rct->xmax - 0.35f * U.widget_unit; | iconofs = rct->xmax - 0.35f * U.widget_unit; | ||||
| /* preview */ | /* preview */ | ||||
| if (node->typeinfo->flag & NODE_PREVIEW) { | if (node->typeinfo->flag & NODE_PREVIEW) { | ||||
| uiBut *but; | uiBut *but; | ||||
| iconofs -= iconbutw; | iconofs -= iconbutw; | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSSN); | UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | ||||
| but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_MATERIAL, | but = uiDefIconBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, ICON_MATERIAL, | ||||
| iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_preview_toggle"); | UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_preview_toggle"); | ||||
| /* 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))) | ||||
| // uiButSetFlag(but, UI_BUT_DISABLED); | // UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSS); | UI_block_emboss_set(node->block, UI_EMBOSS); | ||||
| } | } | ||||
| /* group edit */ | /* group edit */ | ||||
| if (node->type == NODE_GROUP) { | if (node->type == NODE_GROUP) { | ||||
| uiBut *but; | uiBut *but; | ||||
| iconofs -= iconbutw; | iconofs -= iconbutw; | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSSN); | UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | ||||
| but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_NODETREE, | but = uiDefIconBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, ICON_NODETREE, | ||||
| iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); | UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSS); | UI_block_emboss_set(node->block, UI_EMBOSS); | ||||
| } | } | ||||
| /* title */ | /* title */ | ||||
| if (node->flag & SELECT) | if (node->flag & SELECT) | ||||
| UI_ThemeColor(TH_SELECT); | UI_ThemeColor(TH_SELECT); | ||||
| else | else | ||||
| UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); | UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); | ||||
| /* open/close entirely? */ | /* open/close entirely? */ | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| int but_size = UI_UNIT_X * 0.6f; | int but_size = UI_UNIT_X * 0.6f; | ||||
| /* XXX button uses a custom triangle draw below, so make it invisible without icon */ | /* XXX button uses a custom triangle draw below, so make it invisible without icon */ | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSSN); | UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | ||||
| but = uiDefBut(node->block, TOGBUT, B_REDR, "", | but = uiDefBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, "", | ||||
| rct->xmin + 0.5f * U.widget_unit - but_size / 2, rct->ymax - NODE_DY / 2.0f - but_size / 2, | rct->xmin + 0.5f * U.widget_unit - but_size / 2, rct->ymax - NODE_DY / 2.0f - but_size / 2, | ||||
| but_size, but_size, NULL, 0, 0, 0, 0, ""); | but_size, but_size, NULL, 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); | UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSS); | UI_block_emboss_set(node->block, UI_EMBOSS); | ||||
| /* custom draw function for this button */ | /* custom draw function for this button */ | ||||
| UI_DrawTriIcon(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v'); | 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 */ | /* this isn't doing anything for the label, so commenting out */ | ||||
| #if 0 | #if 0 | ||||
| if (node->flag & SELECT) | if (node->flag & SELECT) | ||||
| UI_ThemeColor(TH_TEXT_HI); | UI_ThemeColor(TH_TEXT_HI); | ||||
| else | else | ||||
| UI_ThemeColor(TH_TEXT); | UI_ThemeColor(TH_TEXT); | ||||
| #endif | #endif | ||||
| nodeLabel(ntree, node, showname, sizeof(showname)); | nodeLabel(ntree, node, showname, sizeof(showname)); | ||||
| //if (node->flag & NODE_MUTED) | //if (node->flag & NODE_MUTED) | ||||
| // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ | // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ | ||||
| uiDefBut(node->block, LABEL, 0, showname, | uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, | ||||
| (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY), | (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY), | ||||
| (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, | (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, | ||||
| NULL, 0, 0, 0, 0, ""); | NULL, 0, 0, 0, 0, ""); | ||||
| /* body */ | /* body */ | ||||
| if (!nodeIsRegistered(node)) | if (!nodeIsRegistered(node)) | ||||
| UI_ThemeColor4(TH_REDALERT); /* use warning color to indicate undefined types */ | UI_ThemeColor4(TH_REDALERT); /* use warning color to indicate undefined types */ | ||||
| else if (node->flag & NODE_CUSTOM_COLOR) | else if (node->flag & NODE_CUSTOM_COLOR) | ||||
| glColor3fv(node->color); | glColor3fv(node->color); | ||||
| else | else | ||||
| UI_ThemeColor4(TH_NODE); | UI_ThemeColor4(TH_NODE); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| uiSetRoundBox(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); | UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); | ||||
| uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD); | UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| /* outline active and selected emphasis */ | /* outline active and selected emphasis */ | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| if (node->flag & NODE_ACTIVE) | if (node->flag & NODE_ACTIVE) | ||||
| UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); | UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); | ||||
| else | else | ||||
| UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); | UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); | ||||
| uiSetRoundBox(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); | UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| /* 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); | ||||
| Show All 22 Lines | if (preview && (preview->xsize && preview->ysize)) { | ||||
| if (preview->rect && !BLI_rctf_is_empty(&node->prvr)) { | if (preview->rect && !BLI_rctf_is_empty(&node->prvr)) { | ||||
| node_draw_preview(preview, &node->prvr); | node_draw_preview(preview, &node->prvr); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| UI_ThemeClearColor(color_id); | UI_ThemeClearColor(color_id); | ||||
| uiEndBlock(C, node->block); | UI_block_end(C, node->block); | ||||
| uiDrawBlock(C, node->block); | UI_block_draw(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| } | } | ||||
| static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key)) | static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key)) | ||||
| { | { | ||||
| bNodeSocket *sock; | bNodeSocket *sock; | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| float dx, centy = BLI_rctf_cent_y(rct); | float dx, centy = BLI_rctf_cent_y(rct); | ||||
| Show All 15 Lines | if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) { | ||||
| if (COM_isHighlightedbNode(node)) { | if (COM_isHighlightedbNode(node)) { | ||||
| UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); | UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); | ||||
| } | } | ||||
| } | } | ||||
| #else | #else | ||||
| (void)ntree; | (void)ntree; | ||||
| #endif | #endif | ||||
| uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); | UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); | ||||
| /* outline active and selected emphasis */ | /* outline active and selected emphasis */ | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| if (node->flag & NODE_ACTIVE) | if (node->flag & NODE_ACTIVE) | ||||
| UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); | UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); | ||||
| else | else | ||||
| UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); | UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); | ||||
| uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); | UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| /* custom color inline */ | /* custom color inline */ | ||||
| if (node->flag & NODE_CUSTOM_COLOR) { | if (node->flag & NODE_CUSTOM_COLOR) { | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| glColor3fv(node->color); | glColor3fv(node->color); | ||||
| uiDrawBox(GL_LINE_LOOP, rct->xmin + 1, rct->ymin + 1, rct->xmax -1, rct->ymax - 1, hiddenrad); | UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin + 1, rct->ymin + 1, rct->xmax -1, rct->ymax - 1, hiddenrad); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| /* title */ | /* title */ | ||||
| if (node->flag & SELECT) | if (node->flag & SELECT) | ||||
| UI_ThemeColor(TH_SELECT); | UI_ThemeColor(TH_SELECT); | ||||
| else | else | ||||
| UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); | UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); | ||||
| /* open entirely icon */ | /* open entirely icon */ | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| int but_size = UI_UNIT_X * 0.6f; | int but_size = UI_UNIT_X * 0.6f; | ||||
| /* XXX button uses a custom triangle draw below, so make it invisible without icon */ | /* XXX button uses a custom triangle draw below, so make it invisible without icon */ | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSSN); | UI_block_emboss_set(node->block, UI_EMBOSS_NONE); | ||||
| but = uiDefBut(node->block, TOGBUT, B_REDR, "", | but = uiDefBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, "", | ||||
| rct->xmin + 10.0f - but_size / 2, centy - but_size / 2, | rct->xmin + 10.0f - but_size / 2, centy - but_size / 2, | ||||
| but_size, but_size, NULL, 0, 0, 0, 0, ""); | but_size, but_size, NULL, 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); | UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); | ||||
| uiBlockSetEmboss(node->block, UI_EMBOSS); | UI_block_emboss_set(node->block, UI_EMBOSS); | ||||
| /* custom draw function for this button */ | /* custom draw function for this button */ | ||||
| UI_DrawTriIcon(rct->xmin + 10.0f, centy, 'h'); | UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h'); | ||||
| } | } | ||||
| /* disable lines */ | /* disable lines */ | ||||
| if (node->flag & NODE_MUTED) | if (node->flag & NODE_MUTED) | ||||
| node_draw_mute_line(&ar->v2d, snode, node); | node_draw_mute_line(&ar->v2d, snode, node); | ||||
| if (node->flag & SELECT) | if (node->flag & SELECT) | ||||
| UI_ThemeColor(TH_SELECT); | UI_ThemeColor(TH_SELECT); | ||||
| else | else | ||||
| UI_ThemeColor(TH_TEXT); | UI_ThemeColor(TH_TEXT); | ||||
| if (node->miniwidth > 0.0f) { | if (node->miniwidth > 0.0f) { | ||||
| nodeLabel(ntree, node, showname, sizeof(showname)); | nodeLabel(ntree, node, showname, sizeof(showname)); | ||||
| //if (node->flag & NODE_MUTED) | //if (node->flag & NODE_MUTED) | ||||
| // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ | // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ | ||||
| uiDefBut(node->block, LABEL, 0, showname, | uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, | ||||
| (int)(rct->xmin + (NODE_MARGIN_X)), (int)(centy - 10), | (int)(rct->xmin + (NODE_MARGIN_X)), (int)(centy - 10), | ||||
| (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, | (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, | ||||
| NULL, 0, 0, 0, 0, ""); | NULL, 0, 0, 0, 0, ""); | ||||
| } | } | ||||
| /* scale widget thing */ | /* scale widget thing */ | ||||
| UI_ThemeColorShade(color_id, -10); | UI_ThemeColorShade(color_id, -10); | ||||
| dx = 10.0f; | dx = 10.0f; | ||||
| Show All 11 Lines | if (!nodeSocketIsHidden(sock)) | ||||
| node_socket_circle_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); | node_socket_circle_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); | ||||
| } | } | ||||
| for (sock = node->outputs.first; sock; sock = sock->next) { | for (sock = node->outputs.first; sock; sock = sock->next) { | ||||
| if (!nodeSocketIsHidden(sock)) | if (!nodeSocketIsHidden(sock)) | ||||
| node_socket_circle_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); | node_socket_circle_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); | ||||
| } | } | ||||
| uiEndBlock(C, node->block); | UI_block_end(C, node->block); | ||||
| uiDrawBlock(C, node->block); | UI_block_draw(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| } | } | ||||
| int node_get_resize_cursor(int directions) | int node_get_resize_cursor(int directions) | ||||
| { | { | ||||
| if (directions == 0) | if (directions == 0) | ||||
| return CURSOR_STD; | return CURSOR_STD; | ||||
| else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) | else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) | ||||
| ▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| rctf rect = v2d->cur; | rctf rect = v2d->cur; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| /* shade node groups to separate them visually */ | /* shade node groups to separate them visually */ | ||||
| UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); | UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| uiSetRoundBox(UI_CNR_NONE); | UI_draw_roundbox_corner_set(UI_CNR_NONE); | ||||
| uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); | UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| /* set the block bounds to clip mouse events from underlying nodes */ | /* set the block bounds to clip mouse events from underlying nodes */ | ||||
| block = uiBeginBlock(C, ar, "node tree bounds block", UI_EMBOSS); | block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS); | ||||
| uiExplicitBoundsBlock(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | ||||
| uiBlockSetFlag(block, UI_BLOCK_CLIP_EVENTS); | UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| } | } | ||||
| void drawnodespace(const bContext *C, ARegion *ar) | void drawnodespace(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View2DScrollers *scrollers; | View2DScrollers *scrollers; | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| ▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines | |||||