diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:31:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:31:30 +0300 |
commit | 44505b38df557a5711703613685a1dec9fc2c3d9 (patch) | |
tree | 3f05bebcc7bfadf56569f2dcca7f95fc56b1b0d0 /source/blender/editors/space_node | |
parent | 6654e109df952be3a3128fae2508a02c196ae593 (diff) |
Cleanup: strip trailing space in editors
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 404 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 96 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_buttons.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 292 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 358 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 288 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_ops.c | 68 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 64 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 182 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_templates.c | 52 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_toolbar.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_view.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 70 |
14 files changed, 964 insertions, 964 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index d7fd808917a..4d12ebfb16b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -87,7 +87,7 @@ static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin static void node_draw_socket_new(bNodeSocket *sock, float size) { float x = sock->locx, y = sock->locy; - + /* 16 values of sin function */ static float si[16] = { 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f, @@ -103,14 +103,14 @@ static void node_draw_socket_new(bNodeSocket *sock, float size) 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f, }; int a; - + glColor3ub(180, 180, 180); - + glBegin(GL_POLYGON); for (a = 0; a < 16; a++) glVertex2f(x + size * si[a], y + size * co[a]); glEnd(); - + glColor4ub(0, 0, 0, 150); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -132,7 +132,7 @@ static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *p bNodeSocket *output = node->outputs.first; PointerRNA sockptr; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -144,14 +144,14 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr PointerRNA sockptr; uiLayout *col; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + col = uiLayoutColumn(layout, false); uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0); uiItemR(col, &sockptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE); } static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *row, *col; bNodeTree *ntree = (bNodeTree *)ptr->id.data; @@ -172,7 +172,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt /* XXX no context access here .. */ bNode *node = ptr->data; CurveMapping *cumap = node->storage; - + if (cumap) { cumap->flag |= CUMA_DRAW_CFRA; if (node->custom1 < node->custom2) @@ -232,7 +232,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA * bNodeSocket *output = node->outputs.first; PointerRNA sockptr; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -243,9 +243,9 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) bNodeTree *ntree = ntree_v; bNode *node = node_v; Tex *tex; - + if (node->menunr < 1) return; - + if (node->id) { id_us_min(node->id); node->id = NULL; @@ -255,16 +255,16 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) node->id = &tex->id; id_us_plus(node->id); BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name)); - + nodeSetActive(ntree, node); - + if (ntree->type == NTREE_TEXTURE) ntreeTexCheckCyclics(ntree); - + // allqueue(REDRAWBUTSSHADING, 0); // allqueue(REDRAWNODE, 0); - NodeTagChanged(ntree, node); - + NodeTagChanged(ntree, node); + node->menunr = 0; } #endif @@ -279,9 +279,9 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA (node->type != CMP_NODE_TEXTURE) && (node->type != TEX_NODE_TEXTURE) ); - + uiItemR(layout, ptr, "texture", 0, "", ICON_NONE); - + if (multi) { /* Number Drawing not optimal here, better have a list*/ uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE); @@ -289,7 +289,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA } static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE); } @@ -309,7 +309,7 @@ static int node_resize_area_default(bNode *node, int x, int y) const float size = 10.0f; rctf totr = node->totr; int dir = 0; - + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) dir |= NODE_RESIZE_RIGHT; if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) @@ -338,11 +338,11 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *tnode; rctf rect, noderect; float xmax, ymax; - + /* init rect from current frame size */ node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax); node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin); - + /* frame can be resized manually only if shrinking is disabled or no children are attached */ data->flag |= NODE_FRAME_RESIZEABLE; /* for shrinking bbox, initialize the rect from first child node */ @@ -351,14 +351,14 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->parent != node) continue; - + /* add margin to node rect */ noderect = tnode->totr; noderect.xmin -= margin; noderect.xmax += margin; noderect.ymin -= margin; noderect.ymax += margin; - + /* first child initializes frame */ if (bbinit) { bbinit = 0; @@ -368,13 +368,13 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, else BLI_rctf_union(&rect, &noderect); } - + /* now adjust the frame size from view-space bounding box */ node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety); node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax); node->width = xmax - node->offsetx; node->height = -ymax + node->offsety; - + node->totr = rect; } @@ -398,14 +398,14 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */ - + /* title color */ UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); width = BLF_width(fontid, label, sizeof(label)); ascender = BLF_ascender(fontid); label_height = ((margin / aspect) + (ascender * aspect)); - + /* 'x' doesn't need aspect correction */ x = BLI_rctf_cent_x(rct) - (0.5f * width); y = rct->ymax - label_height; @@ -467,7 +467,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, int color_id = node_get_colorid(node); unsigned char color[4]; float alpha; - + /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { UI_block_end(C, node->block); @@ -477,10 +477,10 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, UI_GetThemeColor4ubv(TH_NODE_FRAME, color); alpha = (float)(color[3]) / 255.0f; - + /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, alpha); - + /* body */ if (node->flag & NODE_CUSTOM_COLOR) glColor4f(node->color[0], node->color[1], node->color[2], alpha); @@ -495,7 +495,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, if (node->flag & SELECT) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else @@ -504,16 +504,16 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + /* label */ node_draw_frame_label(ntree, node, snode->aspect); - + UI_ThemeClearColor(color_id); - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -525,11 +525,11 @@ static int node_resize_area_frame(bNode *node, int x, int y) NodeFrame *data = (NodeFrame *)node->storage; rctf totr = node->totr; int dir = 0; - + /* shrinking frame size is determined by child nodes */ if (!(data->flag & NODE_FRAME_RESIZEABLE)) return 0; - + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) dir |= NODE_RESIZE_RIGHT; if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) @@ -538,7 +538,7 @@ static int node_resize_area_frame(bNode *node, int x, int y) dir |= NODE_RESIZE_TOP; if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) dir |= NODE_RESIZE_BOTTOM; - + return dir; } @@ -557,10 +557,10 @@ static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUS bNodeSocket *nsock; float locx, locy; float size = NODE_REROUTE_SIZE; - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); - + /* reroute node has exactly one input and one output, both in the same place */ nsock = node->outputs.first; nsock->locx = locx; @@ -653,7 +653,7 @@ static int node_tweak_area_reroute(bNode *node, int x, int y) { /* square of tweak radius */ const float tweak_radius_sq = SQUARE(24); - + bNodeSocket *sock = node->inputs.first; float dx = sock->locx - x; float dy = sock->locy - y; @@ -693,9 +693,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, return; col = uiLayoutColumn(layout, false); - + uiItemR(col, imaptr, "source", 0, "", ICON_NONE); - + source = RNA_enum_get(imaptr, "source"); if (source == IMA_SRC_SEQUENCE) { @@ -732,11 +732,11 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA { bNode *node = ptr->data; uiLayout *col; - + uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL); - + if (!node->id) return; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE); @@ -779,12 +779,12 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin } static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); } static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE); uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE); @@ -915,7 +915,7 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "sky_type", 0, "", ICON_NONE); uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE); uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE); @@ -937,11 +937,11 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); @@ -1203,15 +1203,15 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_VALTORGB: ntype->draw_buttons = node_buts_colorramp; break; - case SH_NODE_MATH: + case SH_NODE_MATH: ntype->draw_buttons = node_buts_math; - break; - case SH_NODE_VECT_MATH: + break; + case SH_NODE_VECT_MATH: ntype->draw_buttons = node_shader_buts_vect_math; - break; - case SH_NODE_VECT_TRANSFORM: + break; + case SH_NODE_VECT_TRANSFORM: ntype->draw_buttons = node_shader_buts_vect_transform; - break; + break; case SH_NODE_GEOMETRY: ntype->draw_buttons = node_shader_buts_geometry; break; @@ -1338,14 +1338,14 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * { bNode *node = ptr->data; PointerRNA imaptr, iuserptr; - + RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); uiLayoutSetContextPointer(layout, "image_user", &iuserptr); uiTemplateID( layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); if (!node->id) return; - + imaptr = RNA_pointer_get(ptr, "image"); node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr, true); @@ -1374,17 +1374,17 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point char scene_name[MAX_ID_NAME - 2]; uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL); - + if (!node->id) return; col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, true); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); - + prop = RNA_struct_find_property(ptr, "layer"); if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) return; - + scn_ptr = RNA_pointer_get(ptr, "scene"); RNA_string_get(&scn_ptr, "name", scene_name); @@ -1399,7 +1399,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point uiLayout *col, *row; int reference; int filter; - + col = uiLayoutColumn(layout, false); filter = RNA_enum_get(ptr, "filter_type"); reference = RNA_boolean_get(ptr, "use_variable_size"); @@ -1412,14 +1412,14 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point } uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE); } - + uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE); - + if (RNA_boolean_get(ptr, "use_relative")) { uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE); row = uiLayoutRow(layout, true); uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE); @@ -1435,31 +1435,31 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Center:"), ICON_NONE); uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE); - + uiItemS(layout); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); - + uiItemS(layout); - + uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE); } static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE); @@ -1469,7 +1469,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiLayout *sub, *col; - + col = uiLayoutColumn(layout, false); uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE); uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE); @@ -1498,17 +1498,17 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA /* qdn: glare node */ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE); uiItemR(layout, ptr, "quality", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "glare_type") != 1) { uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "glare_type") != 0) uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } - + uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); @@ -1518,7 +1518,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin } if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) { uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "glare_type") == 0) uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE); } @@ -1528,7 +1528,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin } static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; col = uiLayoutColumn(layout, false); @@ -1562,11 +1562,11 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Speed:"), ICON_NONE); uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE); @@ -1610,7 +1610,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row, *col; - + col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, false); uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1640,17 +1640,17 @@ static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *sub, *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "size", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min")); uiItemR(sub, ptr, "min", 0, "", ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, false); @@ -1659,18 +1659,18 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), } static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE); } static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_antialias_z", 0, NULL, ICON_NONE); @@ -1707,7 +1707,7 @@ static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1716,7 +1716,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col, *row; - + col = uiLayoutColumn(layout, true); uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); @@ -1730,7 +1730,7 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row, *col; - + uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE); row = uiLayoutRow(layout, false); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1756,11 +1756,11 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1770,7 +1770,7 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1778,7 +1778,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C) } static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col, *row; uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); @@ -1806,7 +1806,7 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1844,22 +1844,22 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi int active_index; const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER; const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; - + node_composit_buts_file_output(layout, C, ptr); uiTemplateImageSettings(layout, &imfptr, false); - + /* disable stereo output for multilayer, too much work for something that no one will use */ /* if someone asks for that we can implement it */ if (is_multiview) uiTemplateImageFormatViews(layout, &imfptr, NULL); uiItemS(layout); - + uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket"); - + row = uiLayoutRow(layout, false); col = uiLayoutColumn(row, true); - + active_index = RNA_int_get(ptr, "active_input_index"); /* using different collection properties if multilayer format is enabled */ if (multilayer) { @@ -1876,18 +1876,18 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi } /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; - + col = uiLayoutColumn(row, true); ot = WM_operatortype_find("NODE_OT_output_file_move_active_socket", false); uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); RNA_enum_set(&op_ptr, "direction", 1); uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); RNA_enum_set(&op_ptr, "direction", 2); - + if (active_input_ptr.data) { if (multilayer) { col = uiLayoutColumn(layout, true); - + uiItemL(col, IFACE_("Layer:"), ICON_NONE); row = uiLayoutRow(col, false); uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE); @@ -1896,20 +1896,20 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi } else { col = uiLayoutColumn(layout, true); - + uiItemL(col, IFACE_("File Subpath:"), ICON_NONE); row = uiLayoutRow(col, false); uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY, NULL); - + /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Format:"), ICON_NONE); uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false); uiTemplateImageSettings(col, &imfptr, false); @@ -1941,7 +1941,7 @@ static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE); @@ -1960,22 +1960,22 @@ static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C) static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *split, *col, *row; - + uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "correction_method") == 0) { - + split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1); row = uiLayoutRow(col, false); @@ -1983,19 +1983,19 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C } else { - + split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "offset_basis", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "power", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1); row = uiLayoutRow(col, false); @@ -2048,7 +2048,7 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), } static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "mode", 0, "", ICON_NONE); } @@ -2111,7 +2111,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, false); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); @@ -2165,7 +2165,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, false); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); @@ -2194,7 +2194,7 @@ static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UN uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - + uiItemL(row, IFACE_("Lift"), ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2221,11 +2221,11 @@ static void node_composit_buts_switch_view_ex(uiLayout *layout, bContext *UNUSED static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, true); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - + row = uiLayoutRow(layout, true); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2376,7 +2376,7 @@ static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { @@ -2774,11 +2774,11 @@ static void node_composit_set_butfunc(bNodeType *ntype) static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); @@ -2791,7 +2791,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe ID *id = ptr->id.data; Tex *tex = (Tex *)node->storage; uiLayout *col, *row; - + RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); col = uiLayoutColumn(layout, false); @@ -2835,7 +2835,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING))); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; - + case TEX_CLOUDS: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); row = uiLayoutRow(col, false); @@ -2844,7 +2844,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); break; - + case TEX_DISTNOISE: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE); @@ -2945,7 +2945,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket { StructRNA *srna = ntype->ext.srna; PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier); - + if (prop) RNA_def_property_update_runtime(prop, node_property_update_default); } @@ -2953,7 +2953,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket static void node_template_properties_update(bNodeType *ntype) { bNodeSocketTemplate *stemp; - + if (ntype->inputs) { for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) node_socket_template_properties_update(ntype, stemp); @@ -2999,7 +2999,7 @@ void ED_node_init_butfuncs(void) /*extern bNodeTreeType NodeTreeTypeUndefined;*/ extern bNodeType NodeTypeUndefined; extern bNodeSocketType NodeSocketTypeUndefined; - + /* default ui functions */ NodeTypeUndefined.draw_nodetype = node_draw_default; NodeTypeUndefined.draw_nodetype_prepare = node_update_default; @@ -3008,12 +3008,12 @@ void ED_node_init_butfuncs(void) NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; NodeTypeUndefined.resize_area_func = node_resize_area_default; - + NodeSocketTypeUndefined.draw = node_socket_undefined_draw; NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color; NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw; NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color; - + /* node type ui functions */ NODE_TYPES_BEGIN(ntype) /* default ui functions */ @@ -3024,17 +3024,17 @@ void ED_node_init_butfuncs(void) ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; ntype->resize_area_func = node_resize_area_default; - + node_common_set_butfunc(ntype); - + node_composit_set_butfunc(ntype); node_shader_set_butfunc(ntype); node_texture_set_butfunc(ntype); - + /* define update callbacks for socket properties */ node_template_properties_update(ntype); NODE_TYPES_END - + /* tree type icons */ ntreeType_Composite->ui_icon = ICON_RENDERLAYERS; ntreeType_Shader->ui_icon = ICON_MATERIAL; @@ -3091,16 +3091,16 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR uiLayout *row; PointerRNA inputptr, imfptr; int imtype; - + row = uiLayoutRow(layout, false); - + imfptr = RNA_pointer_get(node_ptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); if (imtype == R_IMF_IMTYPE_MULTILAYER) { NodeImageMultiFileSocket *input = sock->storage; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); - + uiItemL(row, input->layer, ICON_NONE); } else { @@ -3109,12 +3109,12 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR const char *imtype_name; uiBlock *block; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); - + uiItemL(row, input->path, ICON_NONE); - + if (!RNA_boolean_get(&inputptr, "use_node_format")) imfptr = RNA_pointer_get(&inputptr, "format"); - + imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); @@ -3131,7 +3131,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - + /* XXX not nice, eventually give this node its own socket type ... */ if (node->type == CMP_NODE_OUTPUT_FILE) { node_file_output_socket_draw(C, layout, ptr, node_ptr); @@ -3142,7 +3142,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, node_socket_button_label(C, layout, ptr, node_ptr, text); return; } - + switch (type) { case SOCK_FLOAT: case SOCK_INT: @@ -3171,7 +3171,7 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - + switch (type) { case SOCK_FLOAT: { @@ -3238,40 +3238,40 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b Image *ima; void *lock; ImBuf *ibuf; - + if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) return; - + if (parent_key.value != active_viewer_key.value) return; - + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { - float x, y; - + float x, y; + glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); - + /* somehow the offset has to be calculated inverse */ - + glaDefine2DArea(&ar->winrct); wmOrtho2_region_pixelspace(ar); - + x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof; y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof; - + if (ibuf->rect || ibuf->rect_float) { unsigned char *display_buffer = NULL; void *cache_handle = NULL; - + if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) { int ofs; - + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - + #ifdef __BIG_ENDIAN__ if (snode->flag & SNODE_SHOW_R) ofs = 0; else if (snode->flag & SNODE_SHOW_G) ofs = 1; @@ -3281,25 +3281,25 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b else if (snode->flag & SNODE_SHOW_G) ofs = 2; else ofs = 3; #endif - + glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer - (4 - ofs)); - + glPixelZoom(1.0f, 1.0f); } else if (snode->flag & SNODE_SHOW_ALPHA) { display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - + glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); #endif glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer); - + #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); #endif @@ -3309,24 +3309,24 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); - + glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); } else { glPixelZoom(snode->zoom, snode->zoom); - + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); - + glPixelZoom(1.0f, 1.0f); } - + if (cache_handle) IMB_display_buffer_release(cache_handle); } - + /** \note draw selected info on backdrop */ if (snode->edittree) { bNode *node = snode->edittree->nodes.first; @@ -3339,7 +3339,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b } node = node->next; } - + if ((snode->nodetree->flag & NTREE_VIEWER_BORDER) && viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax) @@ -3354,13 +3354,13 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b glaDrawBorderCorners(&pixel_border, 1.0f, 1.0f); } } - + glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } - + BKE_image_release_ibuf(ima, ibuf, lock); } @@ -3372,14 +3372,14 @@ bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, flo float deltax, deltay; float cursor[2] = {0.0f, 0.0f}; int toreroute, fromreroute; - + /* this function can be called with snode null (via cut_links_intersect) */ /* XXX map snode->cursor back to view space */ if (snode) { cursor[0] = snode->cursor[0] * UI_DPI_FAC; cursor[1] = snode->cursor[1] * UI_DPI_FAC; } - + /* in v0 and v3 we put begin/end points */ if (link->fromsock) { vec[0][0] = link->fromsock->locx; @@ -3448,7 +3448,7 @@ bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, flo coord_array[0] + 0, resol, sizeof(float) * 2); BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2); - + return 1; } return 0; @@ -3461,7 +3461,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, bool do_shaded, int th_col2, bool do_triple, int th_col3) { float coord_array[LINK_RESOL + 1][2]; - + if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) { float dist, spline_step = 0.0f; int i; @@ -3470,12 +3470,12 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, float linew; float arrow[2], arrow1[2], arrow2[2]; glGetFloatv(GL_LINE_WIDTH, &linew); - + /* we can reuse the dist variable here to increment the GL curve eval amount*/ dist = 1.0f / (float)LINK_RESOL; - + glEnable(GL_LINE_SMOOTH); - + drawarrow = ((link->tonode && (link->tonode->type == NODE_REROUTE)) && (link->fromnode && (link->fromnode->type == NODE_REROUTE))); @@ -3496,7 +3496,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); - + glBegin(GL_LINE_STRIP); for (i = 0; i <= LINK_RESOL; i++) { glVertex2fv(coord_array[i]); @@ -3510,7 +3510,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, glEnd(); } } - + /* XXX using GL_LINES for shaded node lines is a workaround * for Intel hardware, this breaks with GL_LINE_STRIP and * changing color in begin/end blocks. @@ -3521,10 +3521,10 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, for (i = 0; i < LINK_RESOL; i++) { UI_ThemeColorBlend(th_col1, th_col2, spline_step); glVertex2fv(coord_array[i]); - + UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist); glVertex2fv(coord_array[i + 1]); - + spline_step += dist; } glEnd(); @@ -3537,7 +3537,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, } glEnd(); } - + if (drawarrow) { glBegin(GL_LINE_STRIP); glVertex2fv(arrow1); @@ -3545,7 +3545,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, glVertex2fv(arrow2); glEnd(); } - + glDisable(GL_LINE_SMOOTH); } } @@ -3578,24 +3578,24 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, { float coord_array[2][2]; int i; - + node_link_straight_points(v2d, snode, link, coord_array); - + glEnable(GL_LINE_SMOOTH); - + if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); - + glBegin(GL_LINES); glVertex2fv(coord_array[0]); glVertex2fv(coord_array[1]); glEnd(); } - + UI_ThemeColor(th_col1); glLineWidth(1.5f); - + /* XXX using GL_LINES for shaded node lines is a workaround * for Intel hardware, this breaks with GL_LINE_STRIP and * changing color in begin/end blocks. @@ -3607,7 +3607,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, UI_ThemeColorBlend(th_col1, th_col2, t); glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); - + t = (float)(i + 1) / (float)(LINK_RESOL - 1); UI_ThemeColorBlend(th_col1, th_col2, t); glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], @@ -3624,7 +3624,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, } glEnd(); } - + glDisable(GL_LINE_SMOOTH); } #endif @@ -3635,10 +3635,10 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) bool do_shaded = false; bool do_triple = false; int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE; - + if (link->fromsock == NULL && link->tosock == NULL) return; - + /* new connection */ if (!link->fromsock || !link->tosock) { th_col1 = TH_ACTIVE; @@ -3678,7 +3678,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border) { glBegin(GL_LINES); - + if (border & (NODE_LEFT | NODE_RIGHT)) { glVertex2f(cent[0], v2d->cur.ymin); glVertex2f(cent[0], v2d->cur.ymax); @@ -3687,7 +3687,7 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder glVertex2f(cent[0], cent[1] - size); glVertex2f(cent[0], cent[1] + size); } - + if (border & (NODE_TOP | NODE_BOTTOM)) { glVertex2f(v2d->cur.xmin, cent[1]); glVertex2f(v2d->cur.xmax, cent[1]); @@ -3696,6 +3696,6 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder glVertex2f(cent[0] - size, cent[1]); glVertex2f(cent[0] + size, cent[1]); } - + glEnd(); } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 2dcc69122dd..edd19617a0f 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -70,32 +70,32 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx SpaceNode *snode = CTX_wm_space_node(C); Main *bmain = CTX_data_main(C); bNode *node = NULL; - + node_deselect_all(snode); - + if (idname) node = nodeAddNode(C, snode->edittree, idname); else node = nodeAddStaticNode(C, snode->edittree, type); BLI_assert(node && node->typeinfo); - + /* generics */ node->locx = locx; node->locy = locy + 60.0f; /* arbitrary... so its visible, (0,0) is top of node */ nodeSetSelected(node, true); - + node->locx = locx; node->locy = locy + 60.0f; - + ntreeUpdateTree(bmain, snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - + snode_update(snode, node); - + if (snode->nodetree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } - + return node; } @@ -122,7 +122,7 @@ static bool add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int typedef struct bNodeSocketLink { struct bNodeSocketLink *next, *prev; - + struct bNodeSocket *sock; struct bNodeLink *link; float point[2]; @@ -131,12 +131,12 @@ typedef struct bNodeSocketLink { static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket *sock, bNodeLink *link, const float point[2]) { bNodeSocketLink *socklink, *prev; - + socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link"); socklink->sock = sock; socklink->link = link; copy_v2_v2(socklink->point, point); - + for (prev = lb->last; prev; prev = prev->prev) { if (prev->sock == sock) break; @@ -153,18 +153,18 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi bNodeSocket *cursock = socklink->sock; float insert_point[2]; int num_links; - + zero_v2(insert_point); num_links = 0; - + while (socklink && socklink->sock == cursock) { if (!(socklink->link->flag & NODE_LINK_TEST)) { socklink->link->flag |= NODE_LINK_TEST; - + /* create the reroute node for this cursock */ if (!reroute_node) { reroute_node = nodeAddStaticNode(C, ntree, NODE_REROUTE); - + /* add a single link to/from the reroute node to replace multiple links */ if (in_out == SOCK_OUT) { nodeAddLink(ntree, socklink->link->fromnode, socklink->link->fromsock, reroute_node, reroute_node->inputs.first); @@ -173,7 +173,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi nodeAddLink(ntree, reroute_node, reroute_node->outputs.first, socklink->link->tonode, socklink->link->tosock); } } - + /* insert the reroute node into the link */ if (in_out == SOCK_OUT) { socklink->link->fromnode = reroute_node; @@ -183,21 +183,21 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi socklink->link->tonode = reroute_node; socklink->link->tosock = reroute_node->inputs.first; } - + add_v2_v2(insert_point, socklink->point); num_links++; } socklink = socklink->next; } - + if (num_links > 0) { /* average cut point from shared links */ mul_v2_fl(insert_point, 1.0f / num_links); - + reroute_node->locx = insert_point[0] / UI_DPI_FAC; reroute_node->locy = insert_point[1] / UI_DPI_FAC; } - + return socklink; } @@ -208,7 +208,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op) bNodeTree *ntree = snode->edittree; float mcoords[256][2]; int i = 0; - + /* Get the cut path */ RNA_BEGIN (op->ptr, itemptr, "path") { @@ -227,12 +227,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op) bNodeLink *link; bNodeSocketLink *socklink; float insert_point[2]; - + /* always first */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + node_deselect_all(snode); - + /* Find cut links and sort them by sockets */ BLI_listbase_clear(&output_links); BLI_listbase_clear(&input_links); @@ -243,12 +243,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op) if (add_reroute_intersect_check(link, mcoords, i, insert_point)) { add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point); add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point); - + /* Clear flag */ link->flag &= ~NODE_LINK_TEST; } } - + /* Create reroute nodes for intersected links. * Only one reroute if links share the same input/output socket. */ @@ -260,18 +260,18 @@ static int add_reroute_exec(bContext *C, wmOperator *op) while (socklink) { socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN); } - + BLI_freelistN(&output_links); BLI_freelistN(&input_links); - + /* always last */ ntreeUpdateTree(CTX_data_main(C), ntree); snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } @@ -330,16 +330,16 @@ static int node_add_file_exec(bContext *C, wmOperator *op) default: return OPERATOR_CANCELLED; } - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + node = node_add_node(C, NULL, type, snode->cursor[0], snode->cursor[1]); - + if (!node) { BKE_report(op->reports, RPT_WARNING, "Could not add an image node"); return OPERATOR_CANCELLED; } - + if (type == SH_NODE_TEXTURE) { Tex *tex = BKE_texture_add(CTX_data_main(C), DATA_(ima->id.name)); tex->ima = ima; @@ -359,7 +359,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -367,11 +367,11 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even { ARegion *ar = CTX_wm_region(C); SpaceNode *snode = CTX_wm_space_node(C); - + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->cursor[0], &snode->cursor[1]); - + if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) return node_add_file_exec(C, op); else @@ -471,7 +471,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) const char *idname; char treename_buf[MAX_ID_NAME - 2]; const char *treename; - + if (RNA_struct_property_is_set(op->ptr, "type")) { prop = RNA_struct_find_property(op->ptr, "type"); RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname); @@ -480,7 +480,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) idname = snode->tree_idname; else return OPERATOR_CANCELLED; - + if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", treename_buf); treename = treename_buf; @@ -488,14 +488,14 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) else { treename = DATA_("NodeTree"); } - + if (!ntreeTypeFind(idname)) { BKE_reportf(op->reports, RPT_ERROR, "Node tree type %s undefined", idname); return OPERATOR_CANCELLED; } - + ntree = ntreeAddTree(bmain, treename, idname); - + /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); @@ -511,10 +511,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) } else if (snode) { snode->nodetree = ntree; - + ED_node_tree_update(C); } - + return OPERATOR_FINISHED; } @@ -526,18 +526,18 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C), Poi void NODE_OT_new_node_tree(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "New Node Tree"; ot->idname = "NODE_OT_new_node_tree"; ot->description = "Create a new node tree"; - + /* api callbacks */ ot->exec = new_node_tree_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Tree Type", ""); RNA_def_enum_funcs(prop, new_node_tree_type_itemf); RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 564176edc7e..0a656ee1deb 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -62,7 +62,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->nodetree); } #endif @@ -70,7 +70,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->nodetree && G.debug_value == 777); } @@ -82,10 +82,10 @@ static void node_sockets_panel(const bContext *C, Panel *pa) bNodeSocket *sock; uiLayout *layout = pa->layout, *split; char name[UI_MAX_NAME_STR]; - + if (ELEM(NULL, ntree, node)) return; - + for (sock = node->inputs.first; sock; sock = sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); @@ -98,7 +98,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) static int node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->edittree && (snode->edittree->inputs.first || snode->edittree->outputs.first)); } @@ -119,7 +119,7 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock, return true; } } - + *r_sock = NULL; *r_in_out = 0; return false; @@ -137,14 +137,14 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) if (!ntree) return; - + RNA_id_pointer_create((ID *)ntree, &ptr); - + node_tree_find_active_socket(ntree, &sock, &in_out); RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, sock, &sockptr); - + row = uiLayoutRow(layout, false); - + split = uiLayoutRow(row, true); col = uiLayoutColumn(split, true); ot = WM_operatortype_find("NODE_OT_tree_socket_add", false); @@ -153,26 +153,26 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) NULL, 0, 0, 0, 0); uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "in_out", SOCK_IN); - + col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("Outputs:"), ICON_NONE); uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output", NULL, 0, 0, 0, 0); uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "in_out", SOCK_OUT); - + ot = WM_operatortype_find("NODE_OT_tree_socket_move", false); col = uiLayoutColumn(row, true); uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "direction", 1); uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "direction", 2); - + if (sock) { row = uiLayoutRow(layout, true); uiItemR(row, &sockptr, "name", 0, NULL, ICON_NONE); uiItemO(row, "", ICON_X, "NODE_OT_tree_socket_remove"); - + if (sock->typeinfo->interface_draw) { uiItemS(layout); sock->typeinfo->interface_draw((bContext *)C, layout, &sockptr); @@ -185,7 +185,7 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) void node_buttons_register(ARegionType *art) { PanelType *pt; - + pt = MEM_callocN(sizeof(PanelType), "spacetype node panel node sockets"); strcpy(pt->idname, "NODE_PT_sockets"); strcpy(pt->label, N_("Sockets")); @@ -208,7 +208,7 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -227,10 +227,10 @@ void NODE_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->description = "Toggle the properties region visibility"; ot->idname = "NODE_OT_properties"; - + ot->exec = node_properties_toggle_exec; ot->poll = node_properties_poll; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 58034f23351..d1374aab02c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -95,7 +95,7 @@ static bNodeTree *node_tree_from_ID(ID *id) { if (id) { short idtype = GS(id->name); - + switch (idtype) { case ID_NT: return (bNodeTree *)id; @@ -113,7 +113,7 @@ static bNodeTree *node_tree_from_ID(ID *id) return ((FreestyleLineStyle *)id)->nodetree; } } - + return NULL; } @@ -132,7 +132,7 @@ void ED_node_tag_update_id(ID *id) if (ntree->type == NTREE_SHADER) { DAG_id_tag_update(id, 0); - + if (GS(id->name) == ID_MA) WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); else if (GS(id->name) == ID_LA) @@ -186,7 +186,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) */ bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0; bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0; - + /* if one is an ancestor of the other */ /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */ for (parent = a->parent; parent; parent = parent->parent) { @@ -215,13 +215,13 @@ static bool compare_nodes(const bNode *a, const bNode *b) return 0; else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) return 1; - + /* if one has a higher selection state (active > selected > nothing) */ if (!b_active && a_active) return 1; else if (!b_select && (a_active || a_select)) return 1; - + return 0; } @@ -234,11 +234,11 @@ void ED_node_sort(bNodeTree *ntree) bNode *first_a, *first_b, *node_a, *node_b, *tmp; int totnodes = BLI_listbase_count(&ntree->nodes); int k, a, b; - + k = 1; while (k < totnodes) { first_a = first_b = ntree->nodes.first; - + do { /* setup first_b pointer */ for (b = 0; b < k && first_b; ++b) { @@ -247,7 +247,7 @@ void ED_node_sort(bNodeTree *ntree) /* all batches merged? */ if (first_b == NULL) break; - + /* merge batches */ node_a = first_a; node_b = first_b; @@ -276,7 +276,7 @@ void ED_node_sort(bNodeTree *ntree) } first_a = first_b; } while (first_b); - + k = k << 1; } } @@ -295,9 +295,9 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) { bNode *node; char uiblockstr[32]; - + /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - + for (node = ntree->nodes.first; node; node = node->next) { /* ui block */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); @@ -339,52 +339,52 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) float locx, locy; float dy; int buty; - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); dy = locy; - + /* header */ dy -= NODE_DY; - + /* little bit space in top */ if (node->outputs.first) dy -= NODE_DYS / 2; - + /* output sockets */ bool add_output_space = false; for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + 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_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + /* align output buttons to the right */ row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx + NODE_WIDTH(node); /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; @@ -402,28 +402,28 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* preview rect? */ if (node->flag & NODE_PREVIEW) { float aspect = 1.0f; - - if (node->preview_xsize && node->preview_ysize) + + if (node->preview_xsize && node->preview_ysize) aspect = (float)node->preview_ysize / (float)node->preview_xsize; - + dy -= NODE_DYS / 2; node->prvr.ymax = dy; - + if (aspect <= 1.0f) node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY); else { /* width correction of image */ /* XXX huh? (ton) */ float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect; - + node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY); - + node->prvr.xmin += 0.5f * dx; node->prvr.xmax -= 0.5f * dx; } - + dy = node->prvr.ymin - NODE_DYS / 2; - + /* make sure that maximums are bigger or equal to minimums */ if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin); if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); @@ -438,18 +438,18 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS; node->butr.ymin = 0; node->butr.ymax = 0; - - + + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get()); uiLayoutSetContextPointer(layout, "node", &nodeptr); - + node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + dy = buty - NODE_DYS / 2; } @@ -457,35 +457,35 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + 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_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + row = uiLayoutRow(layout, 1); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx; /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; } - + /* little bit space in end */ if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) dy -= NODE_DYS / 2; @@ -494,7 +494,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->totr.xmax = locx + NODE_WIDTH(node); node->totr.ymax = locy; node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); - + /* Set the block bounds to clip mouse events from underlying nodes. * Add a margin for sockets on each side. */ @@ -513,7 +513,7 @@ static void node_update_hidden(bNode *node) float locx, locy; float rad, drad, hiddenrad = HIDDEN_RAD; int totin = 0, totout = 0, tot; - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); @@ -524,20 +524,20 @@ static void node_update_hidden(bNode *node) for (nsock = node->outputs.first; nsock; nsock = nsock->next) if (!nodeSocketIsHidden(nsock)) totout++; - + tot = MAX2(totin, totout); if (tot > 4) { hiddenrad += 5.0f * (float)(tot - 4); } - + node->totr.xmin = locx; node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth; node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); node->totr.ymin = node->totr.ymax - 2 * hiddenrad; - + /* output sockets */ rad = drad = (float)M_PI / (1.0f + (float)totout); - + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad; @@ -545,10 +545,10 @@ static void node_update_hidden(bNode *node) rad += drad; } } - + /* input sockets */ rad = drad = -(float)M_PI / (1.0f + (float)totin); - + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmin + hiddenrad + sinf(rad) * hiddenrad; @@ -664,7 +664,7 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc { PointerRNA ptr, node_ptr; float color[4]; - + RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color); @@ -729,12 +729,12 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc static void node_draw_preview_background(float tile, rctf *rect) { float x, y; - + /* draw checkerboard backdrop to show alpha */ glColor3ub(120, 120, 120); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ub(160, 160, 160); - + for (y = rect->ymin; y < rect->ymax; y += tile * 2) { for (x = rect->xmin; x < rect->xmax; x += tile * 2) { float tilex = tile, tiley = tile; @@ -770,7 +770,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) float yscale = yrect / ((float)preview->ysize); float scale; rctf draw_rect; - + /* uniform scale and offset */ draw_rect = *prv; if (xscale < yscale) { @@ -785,17 +785,17 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) draw_rect.xmax -= offset; scale = yscale; } - + node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */ - + glColor4f(1.0, 1.0, 1.0, 1.0); glPixelZoom(scale, scale); glaDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect); glPixelZoom(1.0f, 1.0f); - + glDisable(GL_BLEND); UI_ThemeColorShadeAlpha(TH_BACK, -15, +100); @@ -807,23 +807,23 @@ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_ { bNode *node = (bNode *)node_argv; const char *opname = (const char *)op_argv; - + /* select & activate only the button's node */ node_select_single(C, node); - + WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); } void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) { rctf *rct = &node->totr; - + UI_draw_roundbox_corner_set(UI_CNR_ALL); if (node->parent == NULL) ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); else { const float margin = 3.0f; - + glColor4f(0.0f, 0.0f, 0.0f, 0.33f); glEnable(GL_BLEND); UI_draw_roundbox(rct->xmin - margin, rct->ymin - margin, @@ -843,21 +843,21 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN int color_id = node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; - + /* XXX hack: copy values from linked ID data where displayed as sockets */ if (node->block) nodeSynchronizeID(node, false); - + /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { UI_block_end(C, node->block); node->block = NULL; return; } - + /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, 1.0f); - + /* header uses color from backdrop, but we make it opaqie */ if (color_id == TH_NODE) { float col[3]; @@ -866,19 +866,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } else UI_ThemeColor(color_id); - + if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); - + glLineWidth(1.0f); UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); - + /* show/hide icons */ iconofs = rct->xmax - 0.35f * U.widget_unit; - + /* preview */ if (node->typeinfo->flag & NODE_PREVIEW) { uiBut *but; @@ -905,13 +905,13 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); UI_block_emboss_set(node->block, UI_EMBOSS); } - + /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open/close entirely? */ { uiBut *but; @@ -923,24 +923,24 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ 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 */ #if 0 - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); #endif - + nodeLabel(ntree, node, showname, sizeof(showname)); - + //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ - + uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY), (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, @@ -960,43 +960,43 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* outline active and selected emphasis */ if (node->flag & SELECT) { - + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); - + UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(v2d, snode, node); - + /* socket inputs, buttons */ for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* socket outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* preview */ if (node->flag & NODE_PREVIEW && previews) { bNodePreview *preview = BKE_node_instance_hash_lookup(previews, key); @@ -1006,9 +1006,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } } - + UI_ThemeClearColor(color_id); - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1023,7 +1023,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b float socket_size = NODE_SOCKSIZE; int color_id = node_get_colorid(node); char showname[128]; /* 128 is used below */ - + /* shadow */ node_draw_shadow(snode, node, hiddenrad, 1.0f); @@ -1033,18 +1033,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + /* outline active and selected emphasis */ if (node->flag & SELECT) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -1062,11 +1062,11 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open entirely icon */ { uiBut *but; @@ -1078,20 +1078,20 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h'); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(&ar->v2d, snode, node); - - if (node->flag & SELECT) + + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColor(TH_TEXT); - + if (node->miniwidth > 0.0f) { nodeLabel(ntree, node, showname, sizeof(showname)); @@ -1109,7 +1109,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b dx = 10.0f; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); - + UI_ThemeColorShade(color_id, +30); dx -= snode->aspect; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); @@ -1121,13 +1121,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1151,7 +1151,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) bNode *node; bNodeSocket *sock; int wmcursor = CURSOR_STD; - + if (ntree) { if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) { /* pass */ @@ -1168,7 +1168,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) } } } - + WM_cursor_set(win, wmcursor); } @@ -1189,10 +1189,10 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) void node_update_nodetree(const bContext *C, bNodeTree *ntree) { bNode *node; - + /* make sure socket "used" tags are correct, for displaying value buttons */ ntreeTagUsedSockets(ntree); - + /* update nodes front to back, so children sizes get updated before parents */ for (node = ntree->nodes.last; node; node = node->prev) { node_update(C, ntree, node); @@ -1212,7 +1212,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT bNode *node; bNodeLink *link; int a; - + if (ntree == NULL) return; /* groups... */ #ifdef USE_DRAW_TOT_UPDATE @@ -1238,7 +1238,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT node->nr = a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node, key); } - + /* node lines */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1248,7 +1248,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { bNodeInstanceKey key; @@ -1265,9 +1265,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT static void draw_tree_path(SpaceNode *snode) { char info[256]; - + ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info)); - + UI_ThemeColor(TH_TEXT_HI); BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info)); } @@ -1275,11 +1275,11 @@ static void draw_tree_path(SpaceNode *snode) static void snode_setup_v2d(SpaceNode *snode, ARegion *ar, const float center[2]) { View2D *v2d = &ar->v2d; - + /* shift view to node tree center */ UI_view2d_center_set(v2d, center[0], center[1]); UI_view2d_view_ortho(v2d); - + /* aspect+font, set each time */ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx; // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); @@ -1301,14 +1301,14 @@ static void draw_group_overlay(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; rctf rect = v2d->cur; uiBlock *block; - + /* shade node groups to separate them visually */ UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); glEnable(GL_BLEND); UI_draw_roundbox_corner_set(UI_CNR_NONE); UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); glDisable(GL_BLEND); - + /* set the block bounds to clip mouse events from underlying nodes */ block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS); UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -1327,22 +1327,22 @@ void drawnodespace(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); - + /* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->cursor[0], &snode->cursor[1]); snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); - + /* nodes */ snode_set_context(C); - + /* draw parent node trees */ if (snode->treepath.last) { static const int max_depth = 2; @@ -1352,56 +1352,56 @@ void drawnodespace(const bContext *C, ARegion *ar) bNodeTree *ntree; bNodeLinkDrag *nldrag; LinkData *linkdata; - + path = snode->treepath.last; - + /* update tree path name (drawn in the bottom left) */ ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id : snode->id; if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) { BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name)); } - + /* current View2D center, will be set temporarily for parent node trees */ UI_view2d_center_get(v2d, ¢er[0], ¢er[1]); - + /* store new view center in path and current edittree */ copy_v2_v2(path->view_center, center); if (snode->edittree) copy_v2_v2(snode->edittree->view_center, center); - + depth = 0; while (path->prev && depth < max_depth) { path = path->prev; ++depth; } - + /* parent node trees in the background */ for (curdepth = depth; curdepth > 0; path = path->next, --curdepth) { ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, path->view_center); - + draw_nodetree(C, ar, ntree, path->parent_key); - + draw_group_overlay(C, ar); } } - + /* top-level edit tree */ ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, center); - + /* grid, uses theme color based on node path depth */ UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, path->parent_key); - + draw_nodetree(C, ar, ntree, path->parent_key); } - + /* temporary links */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1411,7 +1411,7 @@ void drawnodespace(const bContext *C, ARegion *ar) } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil ('canvas' strokes) */ ED_gpencil_draw_view2d(C, true); @@ -1420,16 +1420,16 @@ void drawnodespace(const bContext *C, ARegion *ar) else { /* default grid */ UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE); } - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - + /* reset view matrix */ UI_view2d_view_restore(C); - + if (snode->treepath.last) { if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil (screen strokes, and also paintbuffer) */ @@ -1439,7 +1439,7 @@ void drawnodespace(const bContext *C, ARegion *ar) /* tree path info */ draw_tree_path(snode); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index d353ea2cba4..59cfbac2e25 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -151,7 +151,7 @@ static int compo_get_recalc_flags(const bContext *C) static int compo_breakjob(void *cjv) { CompoJob *cj = cjv; - + /* without G.is_break 'ESC' wont quit - which annoys users */ return (*(cj->stop) #ifdef USE_ESC_COMPO @@ -165,7 +165,7 @@ static int compo_breakjob(void *cjv) static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -173,7 +173,7 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) static void compo_redrawjob(void *cjv) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -208,7 +208,7 @@ static void compo_updatejob(void *UNUSED(cjv)) static void compo_progressjob(void *cjv, float progress) { CompoJob *cj = cjv; - + *(cj->progress) = progress; } @@ -222,7 +222,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog if (scene->use_nodes == false) return; - + cj->stop = stop; cj->do_update = do_update; cj->progress = progress; @@ -388,7 +388,7 @@ void ED_node_shader_default(const bContext *C, ID *id) bNodeTree *ntree; int output_type, shader_type; float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f; - + ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); switch (GS(id->name)) { @@ -441,14 +441,14 @@ void ED_node_shader_default(const bContext *C, ID *id) printf("ED_node_shader_default called on wrong ID type.\n"); return; } - + out = nodeAddStaticNode(C, ntree, output_type); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, ntree, shader_type); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); - + /* only a link from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; @@ -459,7 +459,7 @@ void ED_node_shader_default(const bContext *C, ID *id) PointerRNA sockptr; sock = in->inputs.first; RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr); - + RNA_float_set_array(&sockptr, "default_value", color); if (strength != 0.0f) { @@ -468,7 +468,7 @@ void ED_node_shader_default(const bContext *C, ID *id) RNA_float_set(&sockptr, "default_value", strength); } } - + ntreeUpdateTree(CTX_data_main(C), ntree); } @@ -478,32 +478,32 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (sce->nodetree) { if (G.debug & G_DEBUG) printf("error in composite initialize\n"); return; } - + sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname); - + sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; - + out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE); out->locx = 300.0f; out->locy = 400.0f; - + in = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_R_LAYERS); in->locx = 10.0f; in->locy = 400.0f; nodeSetActive(sce->nodetree, in); - + /* links from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), sce->nodetree); } @@ -513,27 +513,27 @@ void ED_node_texture_default(const bContext *C, Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (tx->nodetree) { if (G.debug & G_DEBUG) printf("error in texture initialize\n"); return; } - + tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); - + out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - + fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), tx->nodetree); } @@ -544,13 +544,13 @@ void snode_set_context(const bContext *C) bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname); bNodeTree *ntree = snode->nodetree; ID *id = snode->id, *from = snode->from; - + /* we use this to signal warnings, when node shaders are drawn in wrong render engine */ if (BKE_scene_use_new_shading_nodes(CTX_data_scene(C))) snode->flag |= SNODE_NEW_SHADERS; else snode->flag &= ~SNODE_NEW_SHADERS; - + /* check the tree type */ if (!treetype || (treetype->poll && !treetype->poll(C, treetype))) @@ -561,25 +561,25 @@ void snode_set_context(const bContext *C) */ return; } - + if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) { /* current tree does not match selected type, clear tree path */ ntree = NULL; id = NULL; from = NULL; } - + if (!(snode->flag & SNODE_PIN) || ntree == NULL) { if (treetype->get_from_context) { /* reset and update from context */ ntree = NULL; id = NULL; from = NULL; - + treetype->get_from_context(C, treetype, &ntree, &id, &from); } } - + if (snode->nodetree != ntree || snode->id != id || snode->from != from || (snode->treepath.last == NULL && ntree)) { @@ -590,12 +590,12 @@ void snode_set_context(const bContext *C) void snode_update(SpaceNode *snode, bNode *node) { bNodeTreePath *path; - + /* XXX this only updates nodes in the current node space tree path. * The function supposedly should update any potential group node linking to changed tree, * this really requires a working depsgraph ... */ - + /* update all edited group nodes */ path = snode->treepath.last; if (path) { @@ -615,38 +615,38 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0; nodeSetActive(ntree, node); - + if (node->type != NODE_GROUP) { const bool was_output = (node->flag & NODE_DO_OUTPUT) != 0; bool do_update = false; - + /* generic node group output: set node as active output */ if (node->type == NODE_GROUP_OUTPUT) { bNode *tnode; for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == NODE_GROUP_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (!was_output) do_update = 1; } - + /* tree specific activate calls */ if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - + if (ELEM(node->type, SH_NODE_OUTPUT, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == node->type) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); @@ -666,7 +666,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) for (wo = bmain->world.first; wo; wo = wo->id.next) if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) GPU_material_free(&wo->gpumaterial); - + WM_main_add_notifier(NC_IMAGE, NULL); } @@ -676,16 +676,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) /* make active viewer, currently only 1 supported... */ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); - + /* addnode() doesnt link this yet... */ node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } @@ -708,11 +708,11 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) else if (node->type == CMP_NODE_COMPOSITE) { if (was_output == 0) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; ED_node_tag_update_nodetree(bmain, ntree, node); } @@ -767,13 +767,13 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) else RNA_string_set(op->ptr, "node", node->name); } - + if (!RNA_struct_property_is_set(op->ptr, "in_out")) RNA_enum_set(op->ptr, "in_out", SOCK_IN); - + if (!RNA_struct_property_is_set(op->ptr, "socket")) RNA_int_set(op->ptr, "socket", 0); - + return 1; } @@ -784,18 +784,18 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r char nodename[MAX_NAME]; int sockindex; int in_out; - + RNA_string_get(op->ptr, "node", nodename); node = nodeFindNodebyName(ntree, nodename); - + in_out = RNA_enum_get(op->ptr, "in_out"); - + sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } - + if (rnode) *rnode = node; if (rsock) @@ -811,7 +811,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r static bNode *visible_node(SpaceNode *snode, const rctf *rct) { bNode *node; - + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_rctf_isect(&node->totr, rct, NULL)) break; @@ -833,13 +833,13 @@ typedef struct NodeSizeWidget { static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir) { SpaceNode *snode = CTX_wm_space_node(C); - + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - + op->customdata = nsw; nsw->mxstart = snode->cursor[0]; nsw->mystart = snode->cursor[1]; - + /* store old */ nsw->oldlocx = node->locx; nsw->oldlocy = node->locy; @@ -849,7 +849,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( nsw->oldheight = node->height; nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; - + WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir)); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -858,7 +858,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel)) { WM_cursor_modal_restore(CTX_wm_window(C)); - + MEM_freeN(op->customdata); op->customdata = NULL; } @@ -870,14 +870,14 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) bNode *node = nodeGetActive(snode->edittree); NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; - + switch (event->type) { case MOUSEMOVE: - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); dx = (mx - nsw->mxstart) / UI_DPI_FAC; dy = (my - nsw->mystart) / UI_DPI_FAC; - + if (node) { /* width can use node->width or node->miniwidth (hidden nodes) */ float *pwidth; @@ -895,7 +895,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) widthmin = node->typeinfo->minwidth; } widthmax = node->typeinfo->maxwidth; - + { if (nsw->directions & NODE_RESIZE_RIGHT) { *pwidth = oldwidth + dx; @@ -903,20 +903,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + oldwidth; - + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); *pwidth = locmax - node->locx; } } - + /* height works the other way round ... */ { float heightmin = UI_DPI_FAC * node->typeinfo->minheight; float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); node->height = node->locy - locmin; @@ -926,7 +926,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) CLAMP(node->height, heightmin, heightmax); } } - + /* XXX make callback? */ if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ @@ -948,21 +948,21 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - + ED_region_tag_redraw(ar); break; - + case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: - + node_resize_exit(C, op, false); ED_node_post_apply_transform(C, snode->edittree); - + return OPERATOR_FINISHED; } - + return OPERATOR_RUNNING_MODAL; } @@ -972,7 +972,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); bNode *node = nodeGetActive(snode->edittree); int dir; - + if (node) { /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], @@ -997,13 +997,13 @@ void NODE_OT_resize(wmOperatorType *ot) ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; ot->description = "Resize a node"; - + /* api callbacks */ ot->invoke = node_resize_invoke; ot->modal = node_resize_modal; ot->poll = ED_operator_node_active; ot->cancel = node_resize_cancel; - + /* flags */ ot->flag = OPTYPE_BLOCKING; } @@ -1014,7 +1014,7 @@ void NODE_OT_resize(wmOperatorType *ot) int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; @@ -1055,10 +1055,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNode *node; bNodeSocket *sock; rctf rect; - + *nodep = NULL; *sockp = NULL; - + /* check if we click in a socket */ for (node = snode->edittree->nodes.first; node; node = node->next) { @@ -1075,7 +1075,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so rect.xmin -= NODE_SOCKSIZE; } } - + if (in_out & SOCK_IN) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { @@ -1103,7 +1103,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } } - + return 0; } @@ -1112,9 +1112,9 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static void node_duplicate_reparent_recursive(bNode *node) { bNode *parent; - + node->flag |= NODE_TEST; - + /* find first selected parent */ for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { @@ -1140,12 +1140,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) bool do_tag_update = false; ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + lastnode = ntree->nodes.last; for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); - + if (newnode->id) { /* simple id user adjustment, node internal functions don't touch this * but operators and readfile.c do. */ @@ -1154,12 +1154,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_node_tag_update_id(snode->id); } } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + /* copy links between selected nodes * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ @@ -1184,15 +1184,15 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) newlink->fromnode = link->fromnode; newlink->fromsock = link->fromsock; } - + BLI_addtail(&ntree->links, newlink); } - + /* make sure we don't copy new links again! */ if (link == lastlink) break; } - + /* clear flags for recursive depth-first iteration */ for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -1200,32 +1200,32 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); - + /* only has to check old nodes */ if (node == lastnode) break; } - + /* deselect old nodes, select the copies instead */ for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; - + nodeSetSelected(node, false); node->flag &= ~NODE_ACTIVE; nodeSetSelected(newnode, true); do_tag_update |= (do_tag_update || node_connected_to_output(ntree, newnode)); } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); @@ -1240,14 +1240,14 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Nodes"; ot->description = "Duplicate selected nodes"; ot->idname = "NODE_OT_duplicate"; - + /* api callbacks */ ot->exec = node_duplicate_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -1294,7 +1294,7 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + snode_notify(C, snode); snode_dag_update(C, snode); @@ -1303,15 +1303,15 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_read_renderlayers(wmOperatorType *ot) { - + ot->name = "Read Render Layers"; ot->idname = "NODE_OT_read_renderlayers"; ot->description = "Read all render layers of all used scenes"; - + ot->exec = node_read_renderlayers_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1337,15 +1337,15 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) { - + ot->name = "Read Full Sample Layers"; ot->idname = "NODE_OT_read_fullsamplelayers"; ot->description = "Read all render layers of current scene, in full sample"; - + ot->exec = node_read_fullsamplelayers_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1354,7 +1354,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *sce = CTX_data_scene(C); bNode *node; - + for (node = sce->nodetree->nodes.first; node; node = node->next) { if (node->id == (ID *)sce && node->need_exec) { break; @@ -1362,21 +1362,21 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) } if (node) { SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); - + if (srl) { PointerRNA op_ptr; - + WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", srl->name); RNA_string_set(&op_ptr, "scene", sce->id.name + 2); - + /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; - + WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr); WM_operator_properties_free(&op_ptr); - + return OPERATOR_FINISHED; } } @@ -1388,11 +1388,11 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; ot->description = "Render current scene, when input node's layer has been changed"; - + ot->exec = node_render_changed_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1411,12 +1411,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) */ for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if (node->flag & toggle_flag) tot_eq++; else @@ -1425,12 +1425,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) } for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if ((tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else @@ -1442,11 +1442,11 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) return OPERATOR_CANCELLED; - + node_flag_toggle_exec(snode, NODE_HIDDEN); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); @@ -1460,7 +1460,7 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->name = "Hide"; ot->description = "Toggle hiding of selected nodes"; ot->idname = "NODE_OT_hide_toggle"; - + /* callbacks */ ot->exec = node_hide_toggle_exec; ot->poll = ED_operator_node_active; @@ -1553,7 +1553,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); @@ -1600,12 +1600,12 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node)); } } - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1615,11 +1615,11 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->name = "Toggle Node Mute"; ot->description = "Toggle muting of the nodes"; ot->idname = "NODE_OT_mute_toggle"; - + /* callbacks */ ot->exec = node_mute_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1644,14 +1644,14 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) nodeFreeNode(snode->edittree, node); } } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1661,11 +1661,11 @@ void NODE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected nodes"; ot->idname = "NODE_OT_delete"; - + /* api callbacks */ ot->exec = node_delete_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1730,7 +1730,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); - + /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) id_us_min(node->id); @@ -1818,7 +1818,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree = NULL; bNode *node = NULL; - + if (ptr.data) { node = ptr.data; ntree = ptr.id.data; @@ -1830,12 +1830,12 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; - + if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) return OPERATOR_CANCELLED; - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1845,11 +1845,11 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->name = "Remove File Node Socket"; ot->description = "Remove active input from a file output node"; ot->idname = "NODE_OT_output_file_remove_active_socket"; - + /* callbacks */ ot->exec = node_output_file_remove_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1864,7 +1864,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) NodeImageMultiFile *nimf; bNodeSocket *sock; int direction; - + if (ptr.data) node = ptr.data; else if (snode && snode->edittree) @@ -1874,13 +1874,13 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; nimf = node->storage; - + sock = BLI_findlink(&node->inputs, nimf->active_input); if (!sock) return OPERATOR_CANCELLED; - + direction = RNA_enum_get(op->ptr, "direction"); - + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) @@ -1897,9 +1897,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) BLI_insertlinkafter(&node->inputs, after, sock); nimf->active_input++; } - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1910,19 +1910,19 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) {2, "DOWN", 0, "Down", ""}, { 0, NULL, 0, NULL, NULL } }; - + /* identifiers */ ot->name = "Move File Node Socket"; ot->description = "Move the active input of a file output node up or down the list"; ot->idname = "NODE_OT_output_file_move_active_socket"; - + /* callbacks */ ot->exec = node_output_file_move_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -1933,13 +1933,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *node, *tnode; - + if (!ntree) return OPERATOR_CANCELLED; node = nodeGetActive(ntree); if (!node) return OPERATOR_CANCELLED; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { @@ -1998,7 +1998,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op)) for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { bNode *new_node = node->new_node; - + /* ensure valid pointers */ if (new_node->parent) { /* parent pointer must be redirected to new node or detached if parent is not copied */ @@ -2117,7 +2117,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* pasted nodes are selected */ nodeSetSelected(new_node, true); } - + /* reparent copied nodes */ for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; @@ -2172,9 +2172,9 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) PointerRNA ntree_ptr; bNodeSocket *sock, *tsock, *active_sock; const char *default_name; - + RNA_id_pointer_create((ID *)ntree, &ntree_ptr); - + if (in_out == SOCK_IN) { active_sock = ntree_get_active_interface_socket(&ntree->inputs); default_name = "Input"; @@ -2183,7 +2183,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) active_sock = ntree_get_active_interface_socket(&ntree->outputs); default_name = "Output"; } - + if (active_sock) { /* insert a copy of the active socket right after it */ sock = ntreeInsertSocketInterface(ntree, in_out, active_sock->idname, active_sock->next, active_sock->name); @@ -2194,7 +2194,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) /* XXX TODO define default socket type for a tree! */ sock = ntreeAddSocketInterface(ntree, in_out, "NodeSocketFloat", default_name); } - + /* deactivate sockets (has to check both lists) */ for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) tsock->flag &= ~SELECT; @@ -2202,11 +2202,11 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) tsock->flag &= ~SELECT; /* make the new socket active */ sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2216,14 +2216,14 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot) ot->name = "Add Node Tree Interface Socket"; ot->description = "Add an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_add"; - + /* api callbacks */ ot->exec = ntree_socket_add_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", ""); } @@ -2234,25 +2234,25 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNodeSocket *iosock, *active_sock; - + iosock = ntree_get_active_interface_socket(&ntree->inputs); if (!iosock) iosock = ntree_get_active_interface_socket(&ntree->outputs); if (!iosock) return OPERATOR_CANCELLED; - + /* preferably next socket becomes active, otherwise try previous socket */ active_sock = (iosock->next ? iosock->next : iosock->prev); ntreeRemoveSocketInterface(ntree, iosock); - + /* set active socket */ if (active_sock) active_sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2262,11 +2262,11 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot) ot->name = "Remove Node Tree Interface Socket"; ot->description = "Remove an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_remove"; - + /* api callbacks */ ot->exec = ntree_socket_remove_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2286,7 +2286,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); bNodeSocket *iosock; ListBase *lb; - + lb = &ntree->inputs; iosock = ntree_get_active_interface_socket(lb); if (!iosock) { @@ -2295,7 +2295,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) } if (!iosock) return OPERATOR_CANCELLED; - + switch (direction) { case 1: { /* up */ @@ -2318,11 +2318,11 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) break; } } - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2332,14 +2332,14 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot) ot->name = "Move Node Tree Socket"; ot->description = "Move a socket up or down in the current node tree's sockets stack"; ot->idname = "NODE_OT_tree_socket_move"; - + /* api callbacks */ ot->exec = ntree_socket_move_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", ""); } @@ -2386,9 +2386,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende { bool found = false; bNode *node; - + ntree->done = true; - + /* update each script that is using this text datablock */ for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP) { @@ -2401,7 +2401,7 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende found = true; } } - + return found; } @@ -2448,7 +2448,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) if (ntree->type == NTREE_SHADER) ntree->done = false; } FOREACH_NODETREE_END - + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { if (!ntree->done) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 7eaf35c6c4f..7da3d0bf93d 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -69,7 +69,7 @@ static int node_group_operator_active(bContext *C) { if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* Group operators only defined for standard node tree types. * Disabled otherwise to allow pynodes define their own operators * with same keymap. @@ -88,7 +88,7 @@ static int node_group_operator_editable(bContext *C) { if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* Group operators only defined for standard node tree types. * Disabled otherwise to allow pynodes define their own operators * with same keymap. @@ -112,14 +112,14 @@ static const char *group_ntree_idname(bContext *C) static const char *group_node_idname(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - + if (ED_node_is_shader(snode)) return "ShaderNodeGroup"; else if (ED_node_is_compositor(snode)) return "CompositorNodeGroup"; else if (ED_node_is_texture(snode)) return "TextureNodeGroup"; - + return ""; } @@ -127,7 +127,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); - + if (node && STREQ(node->idname, node_idname)) return node; else @@ -142,22 +142,22 @@ static int node_group_edit_exec(bContext *C, wmOperator *op) const char *node_idname = group_node_idname(C); bNode *gnode; const bool exit = RNA_boolean_get(op->ptr, "exit"); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + gnode = node_group_get_active(C, node_idname); - + if (gnode && !exit) { bNodeTree *ngroup = (bNodeTree *)gnode->id; - + if (ngroup) ED_node_tree_push(snode, ngroup, gnode); } else ED_node_tree_pop(snode); - + WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); - + return OPERATOR_FINISHED; } @@ -167,14 +167,14 @@ void NODE_OT_group_edit(wmOperatorType *ot) ot->name = "Edit Group"; ot->description = "Edit node group"; ot->idname = "NODE_OT_group_edit"; - + /* api callbacks */ ot->exec = node_group_edit_exec; ot->poll = node_group_operator_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "exit", false, "Exit", ""); } @@ -188,24 +188,24 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; LinkNode *nodes_delayed_free = NULL; - + ngroup = (bNodeTree *)gnode->id; - + /* clear new pointers, set in copytree */ for (node = ntree->nodes.first; node; node = node->next) node->new_node = NULL; - + /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed * - temp copy. don't change ID usercount */ wgroup = ntreeCopyTree_ex(ngroup, G.main, false); - + /* Add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextnode) { nextnode = node->next; - + /* Remove interface nodes. * This also removes remaining links to and from interface nodes. */ @@ -213,43 +213,43 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* We must delay removal since sockets will reference this node. see: T52092 */ BLI_linklist_prepend(&nodes_delayed_free, node); } - - /* keep track of this node's RNA "base" path (the part of the path identifying the node) + + /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (wgroup->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* migrate node */ BLI_remlink(&wgroup->nodes, node); BLI_addtail(&ntree->nodes, node); - + /* ensure unique node name in the node tree */ nodeUniqueName(ntree, node); - + if (!node->parent) { node->locx += gnode->locx; node->locy += gnode->locy; } - + node->flag |= NODE_SELECT; } - + /* Add internal links to the ntree */ for (link = wgroup->links.first; link; link = linkn) { linkn = link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } - + /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { @@ -258,39 +258,39 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ waction = wgroup->adt->action = BKE_action_copy(G.main, wgroup->adt->action); - + /* now perform the moving */ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } - + /* free temp action too */ if (waction) { BKE_libblock_free(G.main, waction); wgroup->adt->action = NULL; } } - + /* free the group tree (takes care of user count) */ BKE_libblock_free(G.main, wgroup); - + /* restore external links to and from the gnode */ /* note: the nodes have been copied to intermediate wgroup first (so need to use new_node), * then transferred to ntree (new_node pointers remain valid). */ - + /* input links */ for (link = ngroup->links.first; link; link = link->next) { if (link->fromnode->type == NODE_GROUP_INPUT) { const char *identifier = link->fromsock->identifier; int num_external_links = 0; - + /* find external links to this input */ for (tlink = ntree->links.first; tlink; tlink = tlink->next) { if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) { @@ -298,24 +298,24 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) ++num_external_links; } } - + /* if group output is not externally linked, * convert the constant input value to ensure somewhat consistent behavior */ if (num_external_links == 0) { /* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier); BLI_assert(sock);*/ - + /* XXX TODO nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node, ntree, sock, gnode);*/ } } } - + /* output links */ for (link = ntree->links.first; link; link = link->next) { if (link->fromnode == gnode) { const char *identifier = link->fromsock->identifier; int num_internal_links = 0; - + /* find internal links to this output */ for (tlink = ngroup->links.first; tlink; tlink = tlink->next) { /* only use active output node */ @@ -326,18 +326,18 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } } - + /* if group output is not internally linked, * convert the constant output value to ensure somewhat consistent behavior */ if (num_internal_links == 0) { /* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier); BLI_assert(sock);*/ - + /* XXX TODO nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */ } } } - + while (nodes_delayed_free) { node = BLI_linklist_pop(&nodes_delayed_free); nodeFreeNode(ntree, node); @@ -345,9 +345,9 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* delete the group instance */ nodeFreeNode(ntree, gnode); - + ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; - + return 1; } @@ -363,7 +363,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) gnode = node_group_get_active(C, node_idname); if (!gnode) return OPERATOR_CANCELLED; - + if (gnode->id && node_group_ungroup(snode->edittree, gnode)) { ntreeUpdateTree(CTX_data_main(C), snode->nodetree); } @@ -384,11 +384,11 @@ void NODE_OT_group_ungroup(wmOperatorType *ot) ot->name = "Ungroup"; ot->description = "Ungroup selected nodes"; ot->idname = "NODE_OT_group_ungroup"; - + /* api callbacks */ ot->exec = node_group_ungroup_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -401,27 +401,27 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo bNodeLink *link, *link_next; bNode *node, *node_next, *newnode; ListBase anim_basepaths = {NULL, NULL}; - + /* deselect all nodes in the target tree */ for (node = ntree->nodes.first; node; node = node->next) nodeSetSelected(node, false); - + /* clear new pointers, set in nodeCopyNode */ for (node = ngroup->nodes.first; node; node = node->next) node->new_node = NULL; - + /* add selected nodes into the ntree */ for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; if (!(node->flag & NODE_SELECT)) continue; - + /* ignore interface nodes */ if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) { nodeSetSelected(node, false); continue; } - + if (make_copy) { /* make a copy */ newnode = nodeCopyNode(ngroup, node); @@ -430,44 +430,44 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo /* use the existing node */ newnode = node; } - - /* keep track of this node's RNA "base" path (the part of the path identifying the node) + + /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (ngroup->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* ensure valid parent pointers, detach if parent stays inside the group */ if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) nodeDetachNode(newnode); - + /* migrate node */ BLI_remlink(&ngroup->nodes, newnode); BLI_addtail(&ntree->nodes, newnode); - + /* ensure unique node name in the node tree */ nodeUniqueName(ntree, newnode); if (!newnode->parent) { newnode->locx += offx; - newnode->locy += offy; + newnode->locy += offy; } } - + /* add internal links to the ntree */ for (link = ngroup->links.first; link; link = link_next) { const bool fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT)); const bool toselect = (link->tonode && (link->tonode->flag & NODE_SELECT)); link_next = link->next; - + if (make_copy) { /* make a copy of internal links */ if (fromselect && toselect) @@ -484,28 +484,28 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo } } } - + /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { LinkData *ld, *ldn = NULL; - + /* now perform the moving */ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } } - + ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; if (!make_copy) ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; - + return 1; } @@ -539,7 +539,7 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) } /* get node tree offset */ snode_group_offset(snode, &offx, &offy); - + switch (type) { case NODE_GS_COPY: if (!node_group_separate_selected(nparent, ngroup, offx, offy, 1)) { @@ -554,12 +554,12 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) } break; } - + /* switch to parent tree */ ED_node_tree_pop(snode); - + ntreeUpdateTree(CTX_data_main(C), snode->nodetree); - + snode_notify(C, snode); snode_dag_update(C, snode); @@ -570,13 +570,13 @@ static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const { uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Separate"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); - + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY); uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE); - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -586,15 +586,15 @@ void NODE_OT_group_separate(wmOperatorType *ot) ot->name = "Separate"; ot->description = "Separate selected nodes from the node group"; ot->idname = "NODE_OT_group_separate"; - + /* api callbacks */ ot->invoke = node_group_separate_invoke; ot->exec = node_group_separate_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", ""); } @@ -613,10 +613,10 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const bNode *node; bNodeLink *link; int ok = true; - + /* make a local pseudo node tree to pass to the node poll functions */ ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname); - + /* check poll functions for selected nodes */ for (node = ntree->nodes.first; node; node = node->next) { if (node_group_make_use_node(node, gnode)) { @@ -629,13 +629,13 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const node->done = 0; } - + /* free local pseudo node tree again */ ntreeFreeTree(ngroup); MEM_freeN(ngroup); if (!ok) return false; - + /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ for (link = ntree->links.first; link; link = link->next) { @@ -660,7 +660,7 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, bNode *node; float loc[2]; int totselect = 0; - + INIT_MINMAX2(min, max); for (node = ntree->nodes.first; node; node = node->next) { if (node_group_make_use_node(node, gnode)) { @@ -669,12 +669,12 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, ++totselect; } } - + /* sane min/max if no selected nodes */ if (totselect == 0) { min[0] = min[1] = max[0] = max[1] = 0.0f; } - + return totselect; } @@ -689,89 +689,89 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, int totselect; bool expose_all = false; bNode *input_node, *output_node; - + /* XXX rough guess, not nice but we don't have access to UI constants here ... */ static const float offsetx = 200; static const float offsety = 0.0f; - + /* deselect all nodes in the target tree */ for (node = ngroup->nodes.first; node; node = node->next) nodeSetSelected(node, false); - + totselect = node_get_selected_minmax(ntree, gnode, min, max); add_v2_v2v2(center, min, max); mul_v2_fl(center, 0.5f); - + /* auto-add interface for "solo" nodes */ if (totselect == 1) expose_all = true; - + /* move nodes over */ for (node = ntree->nodes.first; node; node = nextn) { nextn = node->next; if (node_group_make_use_node(node, gnode)) { - /* keep track of this node's RNA "base" path (the part of the pat identifying the node) + /* keep track of this node's RNA "base" path (the part of the pat identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (ntree->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* ensure valid parent pointers, detach if parent stays outside the group */ if (node->parent && !(node->parent->flag & NODE_SELECT)) nodeDetachNode(node); - + /* change node-collection membership */ BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); - + /* ensure unique node name in the ngroup */ nodeUniqueName(ngroup, node); } } - + /* move animation data over */ if (ntree->adt) { LinkData *ld, *ldn = NULL; - + BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } } - + /* node groups don't use internal cached data */ ntreeFreeCache(ngroup); - + /* create input node */ input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); input_node->locx = min[0] - center[0] - offsetx; input_node->locy = -offsety; - + /* create output node */ output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); output_node->locx = max[0] - center[0] + offsetx; output_node->locy = -offsety; - + /* relink external sockets */ for (link = ntree->links.first; link; link = linkn) { int fromselect = node_group_make_use_node(link->fromnode, gnode); int toselect = node_group_make_use_node(link->tonode, gnode); - + linkn = link->next; - + if ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode)) { /* remove all links to/from the gnode. * this can remove link information, but there's no general way to preserve it. @@ -785,17 +785,17 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, else if (toselect) { bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock); bNodeSocket *input_sock; - + /* update the group node and interface node sockets, * so the new interface socket can be linked. */ node_group_verify(ntree, gnode, (ID *)ngroup); node_group_input_verify(ngroup, input_node, (ID *)ngroup); - + /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); nodeAddLink(ngroup, input_node, input_sock, link->tonode, link->tosock); - + /* redirect external link */ link->tonode = gnode; link->tosock = node_group_find_input_socket(gnode, iosock->identifier); @@ -842,7 +842,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, node->locy -= center[1]; } } - + /* expose all unlinked sockets too */ if (expose_all) { for (node = ngroup->nodes.first; node; node = node->next) { @@ -858,16 +858,16 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, } if (skip) continue; - + iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - + node_group_input_verify(ngroup, input_node, (ID *)ngroup); - + /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); nodeAddLink(ngroup, input_node, input_sock, node, sock); } - + for (sock = node->outputs.first; sock; sock = sock->next) { bNodeSocket *iosock, *output_sock; bool skip = false; @@ -876,11 +876,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, skip = true; if (skip) continue; - + iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - + node_group_output_verify(ngroup, output_node, (ID *)ngroup); - + /* create new internal link */ output_sock = node_group_output_find_socket(output_node, iosock->identifier); nodeAddLink(ngroup, node, sock, output_node, output_sock); @@ -902,22 +902,22 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree, bNodeTree *ngroup; float min[2], max[2]; int totselect; - + totselect = node_get_selected_minmax(ntree, NULL, min, max); /* don't make empty group */ if (totselect == 0) return NULL; - + /* new nodetree */ ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype); - + /* make group node */ gnode = nodeAddNode(C, ntree, ntype); gnode->id = (ID *)ngroup; - + gnode->locx = 0.5f * (min[0] + max[0]); gnode->locy = 0.5f * (min[1] + max[1]); - + node_group_make_insert_selected(C, ntree, gnode); /* update of the tree containing the group instance node */ @@ -935,29 +935,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op) bNodeTree *ngroup; bNode *gnode; Main *bmain = CTX_data_main(C); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) return OPERATOR_CANCELLED; - + gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname); - + if (gnode) { ngroup = (bNodeTree *)gnode->id; - + nodeSetActive(ntree, gnode); if (ngroup) { ED_node_tree_push(snode, ngroup, gnode); ntreeUpdateTree(bmain, ngroup); } } - + ntreeUpdateTree(bmain, ntree); snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -967,11 +967,11 @@ void NODE_OT_group_make(wmOperatorType *ot) ot->name = "Make Group"; ot->description = "Make group from selected nodes"; ot->idname = "NODE_OT_group_make"; - + /* api callbacks */ ot->exec = node_group_make_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -986,29 +986,29 @@ static int node_group_insert_exec(bContext *C, wmOperator *op) const char *node_idname = group_node_idname(C); bNode *gnode; Main *bmain = CTX_data_main(C); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + gnode = node_group_get_active(C, node_idname); - + if (!gnode || !gnode->id) return OPERATOR_CANCELLED; - + ngroup = (bNodeTree *)gnode->id; if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) return OPERATOR_CANCELLED; - + node_group_make_insert_selected(C, ntree, gnode); - + nodeSetActive(ntree, gnode); ED_node_tree_push(snode, ngroup, gnode); ntreeUpdateTree(bmain, ngroup); - + ntreeUpdateTree(bmain, ntree); - + snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -1018,11 +1018,11 @@ void NODE_OT_group_insert(wmOperatorType *ot) ot->name = "Group Insert"; ot->description = "Insert selected nodes into a node group"; ot->idname = "NODE_OT_group_insert"; - + /* api callbacks */ ot->exec = node_group_insert_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 951257dfd78..f2ed1d1b4ec 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -50,7 +50,7 @@ struct wmKeyConfig; /* temp data to pass on to modal */ typedef struct bNodeLinkDrag { struct bNodeLinkDrag *next, *prev; - + /* List of links dragged by the operator. * Note: This is a list of LinkData structs on top of the actual bNodeLinks. * This way the links can be added to the node tree while being stored in this list. diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index bdbf6c94001..d7ded62a988 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -50,7 +50,7 @@ void node_operatortypes(void) { WM_operatortype_append(NODE_OT_properties); WM_operatortype_append(NODE_OT_toolbar); - + WM_operatortype_append(NODE_OT_select); WM_operatortype_append(NODE_OT_select_all); WM_operatortype_append(NODE_OT_select_linked_to); @@ -60,9 +60,9 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_lasso); WM_operatortype_append(NODE_OT_select_grouped); WM_operatortype_append(NODE_OT_select_same_type_step); - + WM_operatortype_append(NODE_OT_find_node); - + WM_operatortype_append(NODE_OT_view_all); WM_operatortype_append(NODE_OT_view_selected); @@ -72,12 +72,12 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_options_toggle); WM_operatortype_append(NODE_OT_hide_socket_toggle); WM_operatortype_append(NODE_OT_node_copy_color); - + WM_operatortype_append(NODE_OT_duplicate); WM_operatortype_append(NODE_OT_delete); WM_operatortype_append(NODE_OT_delete_reconnect); WM_operatortype_append(NODE_OT_resize); - + WM_operatortype_append(NODE_OT_link); WM_operatortype_append(NODE_OT_link_make); WM_operatortype_append(NODE_OT_links_cut); @@ -89,37 +89,37 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_group_ungroup); WM_operatortype_append(NODE_OT_group_separate); WM_operatortype_append(NODE_OT_group_edit); - + WM_operatortype_append(NODE_OT_link_viewer); - + WM_operatortype_append(NODE_OT_insert_offset); - + WM_operatortype_append(NODE_OT_read_renderlayers); WM_operatortype_append(NODE_OT_read_fullsamplelayers); WM_operatortype_append(NODE_OT_render_changed); - + WM_operatortype_append(NODE_OT_backimage_move); WM_operatortype_append(NODE_OT_backimage_zoom); WM_operatortype_append(NODE_OT_backimage_fit); WM_operatortype_append(NODE_OT_backimage_sample); - + WM_operatortype_append(NODE_OT_add_file); WM_operatortype_append(NODE_OT_add_mask); - + WM_operatortype_append(NODE_OT_new_node_tree); - + WM_operatortype_append(NODE_OT_output_file_add_socket); WM_operatortype_append(NODE_OT_output_file_remove_active_socket); WM_operatortype_append(NODE_OT_output_file_move_active_socket); - + WM_operatortype_append(NODE_OT_parent_set); WM_operatortype_append(NODE_OT_join); WM_operatortype_append(NODE_OT_attach); WM_operatortype_append(NODE_OT_detach); - + WM_operatortype_append(NODE_OT_clipboard_copy); WM_operatortype_append(NODE_OT_clipboard_paste); - + WM_operatortype_append(NODE_OT_shader_script_update); WM_operatortype_append(NODE_OT_viewer_border); @@ -136,7 +136,7 @@ void ED_operatormacros_node(void) { wmOperatorType *ot; wmOperatorTypeMacro *mot; - + ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", "Select node and link it to a viewer node", OPTYPE_UNDO); @@ -150,7 +150,7 @@ void ED_operatormacros_node(void) RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); - + /* NODE_OT_translate_attach with remove_on_canel set to true */ ot = WM_operatortype_append_macro("NODE_OT_translate_attach_remove_on_cancel", "Move and Attach", "Move nodes and attach to frame", @@ -213,7 +213,7 @@ static void node_select_keymap(wmKeyMap *keymap, int extend) const int *mod = (extend ? mod_extend : mod_single); wmKeyMapItem *kmi; int i; - + for (i = 0; mod[i] >= 0; ++i) { kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, mod[i], 0); RNA_boolean_set(kmi->ptr, "extend", extend); @@ -226,17 +226,17 @@ void node_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* Entire Editor only ----------------- */ keymap = WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0); - + WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_toolbar", TKEY, KM_PRESS, 0, 0); - + /* Main Region only ----------------- */ keymap = WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0); - - /* mouse select in nodes used to be both keys, but perhaps this should be reduced? + + /* mouse select in nodes used to be both keys, but perhaps this should be reduced? * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize * NOTE 2: socket select is part of the node select operator, to handle overlapping cases * NOTE 3: select op is registered for various combinations of modifier key, so the specialized @@ -244,10 +244,10 @@ void node_keymap(struct wmKeyConfig *keyconf) */ node_select_keymap(keymap, false); node_select_keymap(keymap, true); - + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_boolean_set(kmi->ptr, "tweak", true); - + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0); @@ -260,13 +260,13 @@ void node_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "detach", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "detach", true); - + WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "NODE_OT_add_reroute", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, 0, 0); RNA_float_set(kmi->ptr, "factor", 0.83333f); @@ -284,16 +284,16 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); /* modified operator call for duplicating with input links */ WM_keymap_add_item(keymap, "NODE_OT_duplicate_move_keep_inputs", DKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_detach", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "NODE_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "NODE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); @@ -323,9 +323,9 @@ void node_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "prev", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_same_type_step", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "prev", true); - + WM_keymap_add_item(keymap, "NODE_OT_find_node", FKEY, KM_PRESS, KM_CTRL, 0); - + /* node group operators */ WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0); @@ -338,7 +338,7 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_read_fullsamplelayers", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "NODE_OT_clipboard_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_clipboard_paste", VKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 70f7553cf41..b0d8b51f8e2 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -556,12 +556,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) bNodeLink *tlink, *tlink_next; int to_count = node_count_links(ntree, to); int from_count = node_count_links(ntree, from); - + for (tlink = ntree->links.first; tlink; tlink = tlink_next) { tlink_next = tlink->next; if (tlink == link) continue; - + if (tlink && tlink->fromsock == from) { if (from_count > from->limit) { nodeRemLink(ntree, tlink); @@ -569,7 +569,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) --from_count; } } - + if (tlink && tlink->tosock == to) { if (to_count > to->limit) { nodeRemLink(ntree, tlink); @@ -607,15 +607,15 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link); if (link->tonode->typeinfo->insert_link) link->tonode->typeinfo->insert_link(ntree, link->tonode, link); - + /* add link to the node tree */ BLI_addtail(&ntree->links, link); - + ntree->update |= NTREE_UPDATE_LINKS; - + /* tag tonode for update */ link->tonode->update |= NODE_UPDATE; - + /* we might need to remove a link */ node_remove_extra_links(snode, link); @@ -628,13 +628,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) } } ntree->is_updating = false; - + ntreeUpdateTree(CTX_data_main(C), ntree); snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + BLI_remlink(&snode->linkdrag, nldrag); /* links->data pointers are either held by the tree or freed already */ BLI_freelistN(&nldrag->links); @@ -653,14 +653,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + /* skip if this is already the target socket */ if (link->tosock == tsock) continue; /* skip if socket is on the same node as the fromsock */ if (tnode && link->fromnode == tnode) continue; - + /* attach links to the socket */ link->tonode = tnode; link->tosock = tsock; @@ -669,7 +669,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) else { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + link->tonode = NULL; link->tosock = NULL; } @@ -679,14 +679,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + /* skip if this is already the target socket */ if (link->fromsock == tsock) continue; /* skip if socket is on the same node as the fromsock */ if (tnode && link->tonode == tnode) continue; - + /* attach links to the socket */ link->fromnode = tnode; link->fromsock = tsock; @@ -695,7 +695,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) else { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + link->fromnode = NULL; link->fromsock = NULL; } @@ -710,30 +710,30 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event) bNodeLinkDrag *nldrag = op->customdata; ARegion *ar = CTX_wm_region(C); float cursor[2]; - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &cursor[0], &cursor[1]); - + switch (event->type) { case MOUSEMOVE: node_link_find_socket(C, op, cursor); - + node_link_update_header(C, nldrag); ED_region_tag_redraw(ar); break; - + case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: { node_link_exit(C, op, true); - + ED_area_headerprint(CTX_wm_area(C), NULL); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } } - + return OPERATOR_RUNNING_MODAL; } @@ -822,7 +822,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det BLI_addtail(&nldrag->links, linkdata); nodeRemLink(snode->edittree, link); - + /* send changed event to original link->tonode */ if (node) snode_update(snode, node); @@ -846,7 +846,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det BLI_addtail(&nldrag->links, linkdata); } } - + return nldrag; } @@ -856,7 +856,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); bNodeLinkDrag *nldrag; float cursor[2]; - + bool detach = RNA_boolean_get(op->ptr, "detach"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], @@ -989,9 +989,9 @@ static int cut_links_exec(bContext *C, wmOperator *op) if (i > 1) { bool found = false; bNodeLink *link, *next; - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + for (link = snode->edittree->links.first; link; link = next) { next = link->next; if (nodeLinkIsHidden(link)) @@ -1294,7 +1294,7 @@ void NODE_OT_attach(wmOperatorType *ot) ot->idname = "NODE_OT_attach"; /* api callbacks */ - + ot->invoke = node_attach_invoke; ot->poll = ED_operator_node_editable; @@ -1413,7 +1413,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, for (link = snode->edittree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; - + if (link->tonode == select || link->fromnode == select) return false; } @@ -1847,18 +1847,18 @@ void ED_node_link_insert(ScrArea *sa) if (link) { bNodeSocket *best_input = socket_best_match(&select->inputs); bNodeSocket *best_output = socket_best_match(&select->outputs); - + if (best_input && best_output) { node = link->tonode; sockto = link->tosock; - + link->tonode = select; link->tosock = best_input; node_remove_extra_links(snode, link); link->flag &= ~NODE_LINKFLAG_HILITE; - + nodeAddLink(snode->edittree, select, best_output, node, sockto); - + /* set up insert offset data, it needs stuff from here */ if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { NodeInsertOfsData *iofsd = MEM_callocN(sizeof(NodeInsertOfsData), __func__); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index b1656ac89ee..3ae542c48db 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -65,7 +65,7 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my) { bNode *node; - + for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->select_area_func) { if (node->typeinfo->select_area_func(node, mx, my)) @@ -78,7 +78,7 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my) static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my) { bNode *node; - + for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->tweak_area_func) { if (node->typeinfo->tweak_area_func(node, mx, my)) @@ -96,7 +96,7 @@ static void node_toggle(bNode *node) void node_socket_select(bNode *node, bNodeSocket *sock) { sock->flag |= SELECT; - + /* select node too */ if (node) node->flag |= SELECT; @@ -105,10 +105,10 @@ void node_socket_select(bNode *node, bNodeSocket *sock) void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node) { sock->flag &= ~SELECT; - + if (node && deselect_node) { bool sel = 0; - + /* if no selected sockets remain, also deselect the node */ for (sock = node->inputs.first; sock; sock = sock->next) { if (sock->flag & SELECT) { @@ -122,7 +122,7 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -140,7 +140,7 @@ static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node void node_deselect_all(SpaceNode *snode) { bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) nodeSetSelected(node, false); } @@ -149,18 +149,18 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes { bNode *node; bNodeSocket *sock; - + /* XXX not calling node_socket_deselect here each time, because this does iteration * over all node sockets internally to check if the node stays selected. * We can do that more efficiently here. */ - + for (node = snode->edittree->nodes.first; node; node = node->next) { int sel = 0; - + for (sock = node->inputs.first; sock; sock = sock->next) sock->flag &= ~SELECT; - + /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { for (sock = node->outputs.first; sock; sock = sock->next) { @@ -169,7 +169,7 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -180,18 +180,18 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node { bNode *node; bNodeSocket *sock; - + /* XXX not calling node_socket_deselect here each time, because this does iteration * over all node sockets internally to check if the node stays selected. * We can do that more efficiently here. */ - + for (node = snode->edittree->nodes.first; node; node = node->next) { bool sel = false; - + for (sock = node->outputs.first; sock; sock = sock->next) sock->flag &= ~SELECT; - + /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { for (sock = node->inputs.first; sock; sock = sock->next) { @@ -200,7 +200,7 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -364,32 +364,32 @@ void node_select_single(bContext *C, bNode *node) Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); bNode *tnode; - + for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) if (tnode != node) nodeSetSelected(tnode, false); nodeSetSelected(node, true); - + ED_node_set_active(bmain, snode->edittree, node); ED_node_set_active_viewer_key(snode); - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); } /* ****** Click Select ****** */ - + static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node, *tnode; bNodeSocket *sock, *tsock; float cursor[2]; int selected = 0; - + /* get mouse coordinates in view2d space */ UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &cursor[0], &cursor[1]); - + if (extend) { /* first do socket selection, these generally overlap with nodes. * socket selection only in extend mode. @@ -417,7 +417,7 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i else { /* find the closest visible node */ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]); - + if (node) { if ((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0) { /* if node is selected but not active make it active @@ -435,10 +435,10 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i } } else { /* extend == 0 */ - + /* find the closest visible node */ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]); - + if (node) { for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) { nodeSetSelected(tnode, false); @@ -448,13 +448,13 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i selected = 1; } } - + /* update node order */ if (selected) { ED_node_set_active_viewer_key(snode); ED_node_sort(snode->edittree); } - + return selected; } @@ -465,18 +465,18 @@ static int node_select_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); int mval[2]; short extend; - + /* get settings from RNA properties for operator */ mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); - + extend = RNA_boolean_get(op->ptr, "extend"); - + /* perform the select */ if (node_mouse_select(bmain, snode, ar, mval, extend)) { /* send notifiers */ WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); - + /* allow tweak event to work too */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } @@ -501,15 +501,15 @@ void NODE_OT_select(wmOperatorType *ot) ot->name = "Select"; ot->idname = "NODE_OT_select"; ot->description = "Select the node under the cursor"; - + /* api callbacks */ ot->invoke = node_select_invoke; ot->exec = node_select_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); @@ -526,10 +526,10 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) rctf rectf; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); - + for (node = snode->edittree->nodes.first; node; node = node->next) { bool is_inside; if (node->type == NODE_FRAME) { @@ -546,9 +546,9 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) nodeSetSelected(node, false); } } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -557,7 +557,7 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { const bool tweak = RNA_boolean_get(op->ptr, "tweak"); - + if (tweak) { /* prevent initiating the border select if the mouse is over a node */ /* this allows border select on empty space, but drag-translate on nodes */ @@ -566,11 +566,11 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent float mx, my; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); - + if (node_under_mouse_tweak(snode->edittree, mx, my)) return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } - + return WM_gesture_border_invoke(C, op, event); } @@ -580,18 +580,18 @@ void NODE_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "NODE_OT_select_border"; ot->description = "Use box selection to select nodes"; - + /* api callbacks */ ot->invoke = node_border_select_invoke; ot->exec = node_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); @@ -767,7 +767,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op) } ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -778,11 +778,11 @@ void NODE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->description = "(De)select all nodes"; ot->idname = "NODE_OT_select_all"; - + /* api callbacks */ ot->exec = node_select_all_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -796,7 +796,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeLink *link; bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -806,14 +806,14 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) link->tonode->flag |= NODE_TEST; } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) nodeSetSelected(node, true); } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -824,11 +824,11 @@ void NODE_OT_select_linked_to(wmOperatorType *ot) ot->name = "Select Linked To"; ot->description = "Select nodes linked to the selected ones"; ot->idname = "NODE_OT_select_linked_to"; - + /* api callbacks */ ot->exec = node_select_linked_to_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -840,7 +840,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeLink *link; bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -850,14 +850,14 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) link->fromnode->flag |= NODE_TEST; } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) nodeSetSelected(node, true); } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -868,11 +868,11 @@ void NODE_OT_select_linked_from(wmOperatorType *ot) ot->name = "Select Linked From"; ot->description = "Select nodes linked from the selected ones"; ot->idname = "NODE_OT_select_linked_from"; - + /* api callbacks */ ot->exec = node_select_linked_from_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -886,29 +886,29 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) int totnodes; const bool revert = RNA_boolean_get(op->ptr, "prev"); const bool same_type = 1; - + ntreeGetDependencyList(snode->edittree, &node_array, &totnodes); - + if (totnodes > 1) { int a; - + for (a = 0; a < totnodes; a++) { if (node_array[a] == active) break; } - + if (same_type) { bNode *node = NULL; - + while (node == NULL) { if (revert) a--; else a++; - + if (a < 0 || a >= totnodes) break; - + node = node_array[a]; - + if (node->type == active->type) break; else node = NULL; @@ -930,7 +930,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) active = node_array[a + 1]; } } - + node_select_single(C, active); /* is note outside view? */ @@ -941,10 +941,10 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx); } } - + if (node_array) MEM_freeN(node_array); - + return OPERATOR_FINISHED; } @@ -954,14 +954,14 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot) ot->name = "Activate Same Type Next/Prev"; ot->description = "Activate and view same node type, step by step"; ot->idname = "NODE_OT_select_same_type_step"; - + /* api callbacks */ ot->exec = node_select_same_type_step_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "prev", 0, "Previous", ""); } @@ -973,12 +973,12 @@ static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char { SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) { - + if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) { char name[256]; - + if (node->label[0]) BLI_snprintf(name, 256, "%s (%s)", node->name, node->label); else @@ -993,11 +993,11 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2 { SpaceNode *snode = CTX_wm_space_node(C); bNode *active = arg2; - + if (active) { ARegion *ar = CTX_wm_region(C); node_select_single(C, active); - + /* is note outside view? */ if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax || active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax) @@ -1016,18 +1016,18 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op) uiBlock *block; uiBut *but; wmOperator *op = (wmOperator *)arg_op; - + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); - + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL); - + /* fake button, it holds space for search items */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); - + UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ - + // UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; @@ -1035,7 +1035,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op) event.customdata = but; event.customdatafree = false; wm_event_add(win, &event); - + return block; } @@ -1053,16 +1053,16 @@ void NODE_OT_find_node(wmOperatorType *ot) ot->name = "Find Node"; ot->description = "Search for named node and allow to select and activate it"; ot->idname = "NODE_OT_find_node"; - + /* api callbacks */ ot->invoke = node_find_node_invoke; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "prev", 0, "Previous", ""); - + } diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index fcfde6f87bf..7788c3938e1 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -64,7 +64,7 @@ typedef struct NodeLinkItem { int socket_type; /* socket type for compatibility check */ const char *socket_name; /* ui label of the socket */ const char *node_name; /* ui label of the node */ - + /* extra settings */ bNodeTree *ngroup; /* group node tree */ } NodeLinkItem; @@ -91,7 +91,7 @@ static void node_link_item_apply(bNode *node, NodeLinkItem *item) else { /* nothing to do for now */ } - + if (node->id) id_us_plus(node->id); } @@ -232,7 +232,7 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode * node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy - (node_from->typeinfo->height * index); } - + node_link_item_apply(node_from, item); } @@ -307,19 +307,19 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it /* XXX this should become a callback for node types! */ NodeLinkItem *items = NULL; int totitems = 0; - + if (arg->node_type->type == NODE_GROUP) { bNodeTree *ngroup; int i; - + for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { ListBase *lb = ((in_out == SOCK_IN) ? &ngroup->inputs : &ngroup->outputs); totitems += BLI_listbase_count(lb); } - + if (totitems > 0) { items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items"); - + i = 0; for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { ListBase *lb = (in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs); @@ -327,7 +327,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it int index; for (stemp = lb->first, index = 0; stemp; stemp = stemp->next, ++index, ++i) { NodeLinkItem *item = &items[i]; - + item->socket_index = index; /* note: int stemp->type is not fully reliable, not used for node group * interface sockets. use the typeinfo->type instead. @@ -344,17 +344,17 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it bNodeSocketTemplate *socket_templates = (in_out == SOCK_IN ? arg->node_type->inputs : arg->node_type->outputs); bNodeSocketTemplate *stemp; int i; - + for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp) ++totitems; - + if (totitems > 0) { items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items"); - + i = 0; for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp, ++i) { NodeLinkItem *item = &items[i]; - + item->socket_index = i; item->socket_type = stemp->type; item->socket_name = stemp->name; @@ -362,7 +362,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it } } } - + *r_items = items; *r_totitems = totitems; } @@ -446,7 +446,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) NodeLinkArg *argN; int first = 1; int compatibility = 0; - + if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(arg->scene)) compatibility = NODE_NEW_SHADING; @@ -486,29 +486,29 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) const char *cur_node_name = NULL; int i, num = 0; int icon = ICON_NONE; - + arg->node_type = ntype; - + ui_node_link_items(arg, SOCK_OUT, &items, &totitems); - + for (i = 0; i < totitems; ++i) if (ui_compatible_sockets(items[i].socket_type, sock->type)) num++; - + for (i = 0; i < totitems; ++i) { if (!ui_compatible_sockets(items[i].socket_type, sock->type)) continue; - + if (first) { column = uiLayoutColumn(layout, 0); UI_block_layout_set_current(block, column); - + uiItemL(column, IFACE_(cname), ICON_NODE); but = block->buttons.last; - + first = 0; } - + if (num > 1) { if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) { cur_node_name = items[i].node_name; @@ -524,15 +524,15 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR); icon = ICON_NONE; } - + but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); - + argN = MEM_dupallocN(arg); argN->item = items[i]; UI_but_funcN_set(but, ui_node_link, argN, NULL); } - + if (items) MEM_freeN(items); } @@ -739,7 +739,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, col = uiLayoutColumn(row, false); uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); break; - + default: row = uiLayoutRow(split, false); break; diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c index 2656c519624..21278dd9fa5 100644 --- a/source/blender/editors/space_node/node_toolbar.c +++ b/source/blender/editors/space_node/node_toolbar.c @@ -55,7 +55,7 @@ static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -74,10 +74,10 @@ void NODE_OT_toolbar(wmOperatorType *ot) ot->name = "Tool Shelf"; ot->description = "Toggles tool shelf display"; ot->idname = "NODE_OT_toolbar"; - + ot->exec = node_toolbar_toggle_exec; ot->poll = node_toolbar_poll; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index b85ef02b971..1cf377643a3 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -73,7 +73,7 @@ int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, float oldasp, asp; int tot = 0; bool has_frame = false; - + oldwidth = BLI_rctf_size_x(&ar->v2d.cur); oldheight = BLI_rctf_size_y(&ar->v2d.cur); @@ -154,11 +154,11 @@ void NODE_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "NODE_OT_view_all"; ot->description = "Resize view so you can see all nodes"; - + /* api callbacks */ ot->exec = node_view_all_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -394,7 +394,7 @@ typedef struct ImageSampleInfo { unsigned char col[4]; float colf[4]; float linearcol[4]; - + int z; float zf; @@ -545,7 +545,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->color_manage = true; } - + if (ibuf->zbuf) { info->z = ibuf->zbuf[y * ibuf->x + x]; info->zp = &info->z; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 2267316d257..c954ebad4c9 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -70,30 +70,30 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) MEM_freeN(path); } BLI_listbase_clear(&snode->treepath); - + if (ntree) { path = MEM_callocN(sizeof(bNodeTreePath), "node tree path"); path->nodetree = ntree; path->parent_key = NODE_INSTANCE_KEY_BASE; - + /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); - + if (id) BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name)); - + BLI_addtail(&snode->treepath, path); - + id_us_ensure_real(&ntree->id); } - + /* update current tree */ snode->nodetree = snode->edittree = ntree; snode->id = id; snode->from = from; - + ED_node_set_active_viewer_key(snode); - + WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } @@ -107,44 +107,44 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) path->parent_key = BKE_node_instance_key(prev_path->parent_key, prev_path->nodetree, gnode); else path->parent_key = NODE_INSTANCE_KEY_BASE; - + BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name)); } else path->parent_key = NODE_INSTANCE_KEY_BASE; - + /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); - + BLI_addtail(&snode->treepath, path); - + id_us_ensure_real(&ntree->id); - + /* update current tree */ snode->edittree = ntree; - + ED_node_set_active_viewer_key(snode); - + WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } void ED_node_tree_pop(SpaceNode *snode) { bNodeTreePath *path = snode->treepath.last; - + /* don't remove root */ if (path == snode->treepath.first) return; - + BLI_remlink(&snode->treepath, path); MEM_freeN(path); - + /* update current tree */ path = snode->treepath.last; snode->edittree = path->nodetree; - + ED_node_set_active_viewer_key(snode); - + /* listener updates the View2D center from edittree */ WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } @@ -182,7 +182,7 @@ void ED_node_tree_path_get(SpaceNode *snode, char *value) { bNodeTreePath *path; int i; - + value[0] = '\0'; for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) { if (i == 0) { @@ -200,7 +200,7 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt { bNodeTreePath *path; int size, i; - + value[0] = '\0'; for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) { if (i == 0) { @@ -227,7 +227,7 @@ void ED_node_set_active_viewer_key(SpaceNode *snode) void snode_group_offset(SpaceNode *snode, float *x, float *y) { bNodeTreePath *path = snode->treepath.last; - + if (path && path->prev) { float dcenter[2]; sub_v2_v2v2(dcenter, path->view_center, path->prev->view_center); @@ -267,24 +267,24 @@ ARegion *node_has_buttons_region(ScrArea *sa) ARegion *node_has_tools_region(ScrArea *sa) { ARegion *ar, *arnew; - + ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "node tools"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_TOOLS; arnew->alignment = RGN_ALIGN_LEFT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -399,7 +399,7 @@ static void node_area_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn) /* shift view to node tree center */ if (ar && path) UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]); - + ED_area_tag_refresh(sa); break; } @@ -524,7 +524,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) { /* default now: refresh node is starting preview */ SpaceNode *snode = sa->spacedata.first; - + snode_set_context(C); if (snode->nodetree) { @@ -625,14 +625,14 @@ static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->cursor[0], &snode->cursor[1]); - + /* here snode->cursor is used to detect the node edge for sizing */ node_set_cursor(win, snode, snode->cursor); /* XXX snode->cursor is in placing new nodes space */ snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - + } /* Initialize main region, setting handlers. */ @@ -963,7 +963,7 @@ void ED_spacetype_node(void) art->init = node_toolbar_region_init; art->draw = node_toolbar_region_draw; BLI_addhead(&st->regiontypes, art); - + node_toolbar_register(art); BKE_spacetype_register(st); |