Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/drawnode.c
| Show First 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node) | ||||
| node->height = -ymax + node->offsety; | node->height = -ymax + node->offsety; | ||||
| node->totr = rect; | node->totr = rect; | ||||
| } | } | ||||
| static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect) | static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect) | ||||
| { | { | ||||
| /* XXX font id is crap design */ | /* XXX font id is crap design */ | ||||
| const int fontid = UI_GetStyle()->widgetlabel.uifont_id; | const int fontid = UI_style_get()->widgetlabel.uifont_id; | ||||
| NodeFrame *data = (NodeFrame *)node->storage; | NodeFrame *data = (NodeFrame *)node->storage; | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| int color_id = node_get_colorid(node); | int color_id = node_get_colorid(node); | ||||
| char label[MAX_NAME]; | char label[MAX_NAME]; | ||||
| /* XXX a bit hacky, should use separate align values for x and y */ | /* XXX a bit hacky, should use separate align values for x and y */ | ||||
| float width, ascender; | float width, ascender; | ||||
| float x, y; | float x, y; | ||||
| const int font_size = data->label_size / aspect; | const int font_size = data->label_size / aspect; | ||||
| Show All 25 Lines | |||||
| { | { | ||||
| rctf *rct = &node->totr; | rctf *rct = &node->totr; | ||||
| int color_id = node_get_colorid(node); | int color_id = node_get_colorid(node); | ||||
| unsigned char color[4]; | unsigned char color[4]; | ||||
| float alpha; | float alpha; | ||||
| /* 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; | ||||
| } | } | ||||
| UI_GetThemeColor4ubv(TH_NODE_FRAME, color); | UI_GetThemeColor4ubv(TH_NODE_FRAME, color); | ||||
| alpha = (float)(color[3]) / 255.0f; | alpha = (float)(color[3]) / 255.0f; | ||||
| /* shadow */ | /* shadow */ | ||||
| node_draw_shadow(snode, node, BASIS_RAD, alpha); | node_draw_shadow(snode, node, BASIS_RAD, alpha); | ||||
| /* body */ | /* body */ | ||||
| if (node->flag & NODE_CUSTOM_COLOR) | if (node->flag & NODE_CUSTOM_COLOR) | ||||
| glColor4f(node->color[0], node->color[1], node->color[2], alpha); | glColor4f(node->color[0], node->color[1], node->color[2], alpha); | ||||
| else | else | ||||
| UI_ThemeColor4(TH_NODE_FRAME); | UI_ThemeColor4(TH_NODE_FRAME); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| uiSetRoundBox(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); | UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, 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, | UI_draw_roundbox_gl_mode(GL_LINE_LOOP, | ||||
| rct->xmin, rct->ymin, | rct->xmin, rct->ymin, | ||||
| rct->xmax, rct->ymax, BASIS_RAD); | rct->xmax, rct->ymax, BASIS_RAD); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| /* label */ | /* label */ | ||||
| node_draw_frame_label(ntree, node, snode->aspect); | node_draw_frame_label(ntree, node, snode->aspect); | ||||
| 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 int node_resize_area_frame(bNode *node, int x, int y) | static int node_resize_area_frame(bNode *node, int x, int y) | ||||
| { | { | ||||
| const float size = 10.0f; | const float size = 10.0f; | ||||
| NodeFrame *data = (NodeFrame *)node->storage; | NodeFrame *data = (NodeFrame *)node->storage; | ||||
| rctf totr = node->totr; | rctf totr = node->totr; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | #if 0 /* UNUSED */ | ||||
| float size = NODE_REROUTE_SIZE; | float size = NODE_REROUTE_SIZE; | ||||
| #endif | #endif | ||||
| float socket_size = NODE_SOCKSIZE; | float socket_size = NODE_SOCKSIZE; | ||||
| /* skip if out of view */ | /* skip if out of view */ | ||||
| if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax || | if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax || | ||||
| node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) | node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) | ||||
| { | { | ||||
| uiEndBlock(C, node->block); | UI_block_end(C, node->block); | ||||
| node->block = NULL; | node->block = NULL; | ||||
| return; | return; | ||||
| } | } | ||||
| /* XXX only kept for debugging | /* XXX only kept for debugging | ||||
| * selection state is indicated by socket outline below! | * selection state is indicated by socket outline below! | ||||
| */ | */ | ||||
| #if 0 | #if 0 | ||||
| /* body */ | /* body */ | ||||
| uiSetRoundBox(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_ThemeColor4(TH_NODE); | UI_ThemeColor4(TH_NODE); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); | UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); | ||||
| 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); | ||||
| /* using different shades of TH_TEXT_HI for the empasis, like triangle */ | /* using different shades of TH_TEXT_HI for the empasis, like triangle */ | ||||
| if (node->flag & NODE_ACTIVE) | if (node->flag & NODE_ACTIVE) | ||||
| UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); | UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); | ||||
| else | else | ||||
| UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); | UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); | ||||
| uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); | UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| #endif | #endif | ||||
| if (node->label[0] != '\0') { | if (node->label[0] != '\0') { | ||||
| /* draw title (node label) */ | /* draw title (node label) */ | ||||
| BLI_strncpy(showname, node->label, sizeof(showname)); | BLI_strncpy(showname, node->label, sizeof(showname)); | ||||
| uiDefBut(node->block, LABEL, 0, showname, | uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, | ||||
| (int)(rct->xmin - NODE_DYS), (int)(rct->ymax), | (int)(rct->xmin - NODE_DYS), (int)(rct->ymax), | ||||
| (short)512, (short)NODE_DY, | (short)512, (short)NODE_DY, | ||||
| NULL, 0, 0, 0, 0, NULL); | NULL, 0, 0, 0, 0, NULL); | ||||
| } | } | ||||
| /* only draw input socket. as they all are placed on the same position. | /* only draw input socket. as they all are placed on the same position. | ||||
| * highlight also if node itself is selected, since we don't display the node body separately! | * highlight also if node itself is selected, since we don't display the node body separately! | ||||
| */ | */ | ||||
| for (sock = node->inputs.first; sock; sock = sock->next) { | for (sock = node->inputs.first; sock; sock = sock->next) { | ||||
| node_socket_circle_draw(C, ntree, node, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT)); | node_socket_circle_draw(C, ntree, node, sock, socket_size, (sock->flag & SELECT) || (node->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; | ||||
| } | } | ||||
| /* Special tweak area for reroute node. | /* Special tweak area for reroute node. | ||||
| * Since this node is quite small, we use a larger tweak area for grabbing than for selection. | * Since this node is quite small, we use a larger tweak area for grabbing than for selection. | ||||
| */ | */ | ||||
| static int node_tweak_area_reroute(bNode *node, int x, int y) | static int node_tweak_area_reroute(bNode *node, int x, int y) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 2,287 Lines • ▼ Show 20 Lines | else { | ||||
| if (!RNA_boolean_get(&inputptr, "use_node_format")) | if (!RNA_boolean_get(&inputptr, "use_node_format")) | ||||
| imfptr = RNA_pointer_get(&inputptr, "format"); | imfptr = RNA_pointer_get(&inputptr, "format"); | ||||
| imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); | imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); | ||||
| RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, | RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, | ||||
| RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); | RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); | ||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSP); | UI_block_emboss_set(block, UI_EMBOSS_PULLDOWN); | ||||
| uiItemL(row, imtype_name, ICON_NONE); | uiItemL(row, imtype_name, ICON_NONE); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| } | } | ||||
| } | } | ||||
| static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text) | static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text) | ||||
| { | { | ||||
| bNode *node = node_ptr->data; | bNode *node = node_ptr->data; | ||||
| bNodeSocket *sock = ptr->data; | bNodeSocket *sock = ptr->data; | ||||
| int type = sock->typeinfo->type; | int type = sock->typeinfo->type; | ||||
| ▲ Show 20 Lines • Show All 599 Lines • Show Last 20 Lines | |||||