Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-06-04 10:39:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-04 10:39:04 +0300
commit95011f6d484b369db92ae13c674a6522d664ea8f (patch)
tree91ba2719c9f3096fad0f1f768aa7b1c4d79aa32a /source/blender/editors/space_node
parent0911acb5cf49c5ba05b1df045b41697704aa288a (diff)
parent44505b38df557a5711703613685a1dec9fc2c3d9 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/drawnode.c320
-rw-r--r--source/blender/editors/space_node/node_add.c96
-rw-r--r--source/blender/editors/space_node/node_buttons.c36
-rw-r--r--source/blender/editors/space_node/node_draw.c246
-rw-r--r--source/blender/editors/space_node/node_edit.c348
-rw-r--r--source/blender/editors/space_node/node_group.c288
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_ops.c68
-rw-r--r--source/blender/editors/space_node/node_relationships.c64
-rw-r--r--source/blender/editors/space_node/node_select.c182
-rw-r--r--source/blender/editors/space_node/node_templates.c52
-rw-r--r--source/blender/editors/space_node/node_toolbar.c6
-rw-r--r--source/blender/editors/space_node/node_view.c10
-rw-r--r--source/blender/editors/space_node/space_node.c70
14 files changed, 894 insertions, 894 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 0267fd9da2e..a9120430128 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -94,7 +94,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);
}
@@ -106,14 +106,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;
@@ -134,7 +134,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)
@@ -194,7 +194,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);
}
@@ -205,9 +205,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;
@@ -217,16 +217,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
@@ -241,9 +241,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);
@@ -251,7 +251,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);
}
@@ -271,7 +271,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)
@@ -300,11 +300,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 */
@@ -313,14 +313,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;
@@ -330,13 +330,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;
}
@@ -361,7 +361,7 @@ 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_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
BLF_color3ubv(fontid, color);
@@ -369,7 +369,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
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;
@@ -431,7 +431,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
int color_id = node_get_colorid(node);
float 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);
@@ -441,10 +441,10 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
alpha = color[3];
-
+
/* shadow */
node_draw_shadow(snode, node, BASIS_RAD, alpha);
-
+
/* body */
if (node->flag & NODE_CUSTOM_COLOR) {
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
@@ -467,9 +467,9 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
/* 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;
@@ -481,11 +481,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)
@@ -494,7 +494,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;
}
@@ -513,10 +513,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;
@@ -604,7 +604,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;
@@ -644,9 +644,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) {
@@ -715,12 +715,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);
@@ -827,7 +827,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);
@@ -849,11 +849,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);
@@ -1108,15 +1108,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_ATTRIBUTE:
ntype->draw_buttons = node_shader_buts_attribute;
break;
@@ -1237,14 +1237,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);
@@ -1273,17 +1273,17 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer
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);
@@ -1298,7 +1298,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");
@@ -1311,14 +1311,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);
@@ -1334,31 +1334,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);
@@ -1368,7 +1368,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);
@@ -1397,17 +1397,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);
@@ -1417,7 +1417,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);
}
@@ -1427,7 +1427,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);
@@ -1461,11 +1461,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);
@@ -1509,7 +1509,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);
@@ -1539,17 +1539,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);
@@ -1558,18 +1558,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);
@@ -1606,7 +1606,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);
@@ -1615,7 +1615,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);
@@ -1629,7 +1629,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);
@@ -1655,11 +1655,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);
@@ -1669,7 +1669,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);
@@ -1677,7 +1677,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);
@@ -1705,7 +1705,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);
@@ -1743,22 +1743,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) {
@@ -1775,18 +1775,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);
@@ -1795,20 +1795,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);
@@ -1840,7 +1840,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);
@@ -1859,22 +1859,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);
@@ -1882,19 +1882,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);
@@ -1947,7 +1947,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);
}
@@ -2010,7 +2010,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);
@@ -2064,7 +2064,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);
@@ -2093,7 +2093,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);
@@ -2120,11 +2120,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);
@@ -2293,7 +2293,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) {
@@ -2691,11 +2691,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);
@@ -2708,7 +2708,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);
@@ -2752,7 +2752,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);
@@ -2761,7 +2761,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);
@@ -2862,7 +2862,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);
}
@@ -2870,7 +2870,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);
@@ -2916,7 +2916,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;
@@ -2925,12 +2925,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 */
@@ -2941,17 +2941,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;
@@ -3008,16 +3008,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 {
@@ -3026,12 +3026,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);
@@ -3048,7 +3048,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);
@@ -3059,7 +3059,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:
@@ -3088,7 +3088,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:
{
@@ -3156,33 +3156,33 @@ 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;
gpuPushProjectionMatrix();
gpuPushMatrix();
/* somehow the offset has to be calculated inverse */
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 | SNODE_SHOW_ALPHA)) {
-
+
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
if (snode->flag & SNODE_SHOW_R)
@@ -3213,11 +3213,11 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
else {
glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
}
-
+
if (cache_handle)
IMB_display_buffer_release(cache_handle);
}
-
+
/** \note draw selected info on backdrop */
if (snode->edittree) {
bNode *node = snode->edittree->nodes.first;
@@ -3230,7 +3230,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)
@@ -3255,7 +3255,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
gpuPopProjectionMatrix();
gpuPopMatrix();
}
-
+
BKE_image_release_ibuf(ima, ibuf, lock);
}
@@ -3266,14 +3266,14 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
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;
@@ -3352,7 +3352,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;
@@ -3595,10 +3595,10 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
{
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_col2 = TH_ACTIVE;
@@ -3636,7 +3636,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, unsigned pos)
{
immBegin(GWN_PRIM_LINES, 4);
-
+
if (border & (NODE_LEFT | NODE_RIGHT)) {
immVertex2f(pos, cent[0], v2d->cur.ymin);
immVertex2f(pos, cent[0], v2d->cur.ymax);
@@ -3645,7 +3645,7 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder
immVertex2f(pos, cent[0], cent[1] - size);
immVertex2f(pos, cent[0], cent[1] + size);
}
-
+
if (border & (NODE_TOP | NODE_BOTTOM)) {
immVertex2f(pos, v2d->cur.xmin, cent[1]);
immVertex2f(pos, v2d->cur.xmax, cent[1]);
@@ -3654,6 +3654,6 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder
immVertex2f(pos, cent[0] - size, cent[1]);
immVertex2f(pos, cent[0] + size, cent[1]);
}
-
+
immEnd();
}
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index 956fea9b44a..0a8cc838ce5 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;
}
@@ -327,16 +327,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;
}
-
+
node->id = (ID *)ima;
/* When adding new image file via drag-drop we need to load imbuf in order
@@ -349,7 +349,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
snode_notify(C, snode);
snode_dag_update(C, snode);
-
+
return OPERATOR_FINISHED;
}
@@ -357,11 +357,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
@@ -461,7 +461,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);
@@ -470,7 +470,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;
@@ -478,14 +478,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);
@@ -501,10 +501,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;
}
@@ -516,18 +516,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 c1159ccad73..92c055ed12a 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -100,7 +100,7 @@ static bNodeTree *node_tree_from_ID(ID *id)
{
if (id) {
short idtype = GS(id->name);
-
+
switch (idtype) {
case ID_NT:
return (bNodeTree *)id;
@@ -118,7 +118,7 @@ static bNodeTree *node_tree_from_ID(ID *id)
return ((FreestyleLineStyle *)id)->nodetree;
}
}
-
+
return NULL;
}
@@ -137,7 +137,7 @@ void ED_node_tag_update_id(ID *id)
if (ntree->type == NTREE_SHADER) {
DEG_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)
@@ -191,7 +191,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) {
@@ -220,13 +220,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;
}
@@ -239,11 +239,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) {
@@ -252,7 +252,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;
@@ -281,7 +281,7 @@ void ED_node_sort(bNodeTree *ntree)
}
first_a = first_b;
} while (first_b);
-
+
k = k << 1;
}
}
@@ -300,9 +300,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);
@@ -344,52 +344,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;
@@ -407,28 +407,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);
@@ -443,18 +443,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;
}
@@ -462,35 +462,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;
@@ -499,7 +499,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.
*/
@@ -518,7 +518,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);
@@ -529,20 +529,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;
@@ -550,10 +550,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;
@@ -632,10 +632,10 @@ static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, Pointer
{
PointerRNA ptr;
float color[4];
-
+
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color);
-
+
immAttrib4fv(col, color);
immVertex2f(pos, sock->locx, sock->locy);
}
@@ -645,7 +645,7 @@ static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, Pointer
static void node_draw_preview_background(float tile, rctf *rect)
{
float x, y;
-
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -655,7 +655,7 @@ static void node_draw_preview_background(float tile, rctf *rect)
immUniformColor3ub(120, 120, 120);
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
immUniformColor3ub(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;
@@ -692,7 +692,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) {
@@ -707,16 +707,16 @@ 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);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */
-
+
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state, draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect,
scale, scale, NULL);
-
+
glDisable(GL_BLEND);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -731,23 +731,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;
-
+
float color[4] = {0.0f, 0.0f, 0.0f, 0.33f};
UI_draw_roundbox_aa(true, rct->xmin - margin, rct->ymin - margin,
rct->xmax + margin, rct->ymax + margin, radius + margin, color);
@@ -802,7 +802,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
}
-
+
/* socket outputs */
short selected_output_ct = 0;
if (draw_outputs) {
@@ -878,17 +878,17 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
float color[4];
char showname[128]; /* 128 used below */
View2D *v2d = &ar->v2d;
-
+
/* skip if out of view */
if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) {
UI_block_end(C, node->block);
node->block = NULL;
return;
}
-
+
/* shadow */
node_draw_shadow(snode, node, BASIS_RAD, 1.0f);
-
+
if (node->flag & NODE_MUTED) {
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
}
@@ -907,10 +907,10 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
UI_draw_roundbox_aa(true, rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color);
-
+
/* show/hide icons */
iconofs = rct->xmax - 0.35f * U.widget_unit;
-
+
/* preview */
if (node->typeinfo->flag & NODE_PREVIEW) {
uiBut *but;
@@ -937,7 +937,7 @@ 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) {
UI_GetThemeColor4fv(TH_SELECT, color);
@@ -945,7 +945,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
else {
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
-
+
/* open/close entirely? */
{
uiBut *but;
@@ -957,16 +957,16 @@ 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', color);
}
-
+
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,
@@ -991,7 +991,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
}
-
+
/* disable lines */
if (node->flag & NODE_MUTED)
node_draw_mute_line(v2d, snode, node);
@@ -1007,9 +1007,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;
@@ -1027,7 +1027,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
float scale;
UI_view2d_scale_get(v2d, &scale, NULL);
-
+
/* shadow */
node_draw_shadow(snode, node, hiddenrad, 1.0f);
@@ -1036,9 +1036,9 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
else
UI_GetThemeColor4fv(color_id, color);
-
+
UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color);
-
+
/* outline active and selected emphasis */
if (node->flag & SELECT) {
UI_GetThemeColorShadeAlpha4fv((node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
@@ -1064,7 +1064,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
else {
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
-
+
/* open entirely icon */
{
uiBut *but;
@@ -1076,11 +1076,11 @@ 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', color);
}
-
+
/* disable lines */
if (node->flag & NODE_MUTED)
node_draw_mute_line(&ar->v2d, snode, node);
@@ -1150,7 +1150,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 */
@@ -1167,7 +1167,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
}
}
}
-
+
WM_cursor_set(win, wmcursor);
}
@@ -1188,10 +1188,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);
@@ -1211,7 +1211,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
@@ -1237,7 +1237,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);
nodelink_batch_start(snode);
@@ -1247,7 +1247,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
}
nodelink_batch_end(snode);
glDisable(GL_BLEND);
-
+
/* draw foreground nodes, last nodes in front */
for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) {
bNodeInstanceKey key;
@@ -1264,9 +1264,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_FontThemeColor(BLF_default(), TH_TEXT_HI);
BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info));
}
@@ -1274,11 +1274,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);
@@ -1309,7 +1309,7 @@ static void draw_group_overlay(const bContext *C, ARegion *ar)
UI_draw_roundbox_corner_set(UI_CNR_NONE);
UI_draw_roundbox_4fv(true, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0, color);
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);
@@ -1328,21 +1328,21 @@ 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 */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
+
/* nodes */
snode_set_context(C);
-
+
/* draw parent node trees */
if (snode->treepath.last) {
static const int max_depth = 2;
@@ -1352,50 +1352,50 @@ 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, &center[0], &center[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);
@@ -1416,7 +1416,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
draw_nodetree(C, ar, ntree, path->parent_key);
}
-
+
/* temporary links */
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
@@ -1426,7 +1426,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);
@@ -1435,16 +1435,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) */
@@ -1454,7 +1454,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 a26bdfbf037..2d1af3f4578 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -152,7 +152,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
@@ -166,7 +166,7 @@ static int compo_breakjob(void *cjv)
static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
{
CompoJob *cj = cjv;
-
+
*(cj->do_update) = true;
}
@@ -174,7 +174,7 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
static void compo_redrawjob(void *cjv)
{
CompoJob *cj = cjv;
-
+
*(cj->do_update) = true;
}
@@ -209,7 +209,7 @@ static void compo_updatejob(void *UNUSED(cjv))
static void compo_progressjob(void *cjv, float progress)
{
CompoJob *cj = cjv;
-
+
*(cj->progress) = progress;
}
@@ -223,7 +223,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)) {
@@ -435,14 +435,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;
@@ -452,7 +452,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) {
@@ -460,7 +460,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
RNA_float_set(&sockptr, "default_value", strength);
}
-
+
ntreeUpdateTree(CTX_data_main(C), ntree);
}
@@ -470,32 +470,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);
}
@@ -505,27 +505,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);
}
@@ -536,7 +536,7 @@ void snode_set_context(const bContext *C)
bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname);
bNodeTree *ntree = snode->nodetree;
ID *id = snode->id, *from = snode->from;
-
+
/* check the tree type */
if (!treetype ||
(treetype->poll && !treetype->poll(C, treetype)))
@@ -547,25 +547,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))
{
@@ -576,12 +576,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) {
@@ -601,38 +601,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_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);
@@ -652,7 +652,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);
}
@@ -662,27 +662,27 @@ 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");
}
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);
}
@@ -737,13 +737,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;
}
@@ -754,18 +754,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)
@@ -781,7 +781,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;
@@ -803,13 +803,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;
@@ -819,7 +819,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);
@@ -828,7 +828,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;
}
@@ -840,14 +840,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;
@@ -865,7 +865,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;
@@ -873,20 +873,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;
@@ -896,7 +896,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 */
@@ -918,21 +918,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;
}
@@ -942,7 +942,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],
@@ -967,13 +967,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;
}
@@ -984,7 +984,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;
@@ -1025,10 +1025,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) {
@@ -1045,7 +1045,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)) {
@@ -1073,7 +1073,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
}
}
}
-
+
return 0;
}
@@ -1082,9 +1082,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) {
@@ -1110,12 +1110,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. */
@@ -1124,12 +1124,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!
*/
@@ -1154,15 +1154,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;
@@ -1170,32 +1170,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);
@@ -1210,14 +1210,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");
}
@@ -1264,7 +1264,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
snode_notify(C, snode);
snode_dag_update(C, snode);
@@ -1273,15 +1273,15 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
void NODE_OT_read_viewlayers(wmOperatorType *ot)
{
-
+
ot->name = "Read View Layers";
ot->idname = "NODE_OT_read_viewlayers";
ot->description = "Read all render layers of all used scenes";
-
+
ot->exec = node_read_viewlayers_exec;
-
+
ot->poll = composite_node_active;
-
+
/* flags */
ot->flag = 0;
}
@@ -1290,7 +1290,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;
@@ -1298,21 +1298,21 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
}
if (node) {
ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1);
-
+
if (view_layer) {
PointerRNA op_ptr;
-
+
WM_operator_properties_create(&op_ptr, "RENDER_OT_render");
RNA_string_set(&op_ptr, "layer", view_layer->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;
}
}
@@ -1324,11 +1324,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;
}
@@ -1347,12 +1347,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
@@ -1361,12 +1361,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
@@ -1378,11 +1378,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);
@@ -1396,7 +1396,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;
@@ -1489,7 +1489,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);
@@ -1536,12 +1536,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;
}
@@ -1551,11 +1551,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;
}
@@ -1580,14 +1580,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;
}
@@ -1597,11 +1597,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;
}
@@ -1666,7 +1666,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);
@@ -1754,7 +1754,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;
@@ -1766,12 +1766,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;
}
@@ -1781,11 +1781,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;
}
@@ -1800,7 +1800,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)
@@ -1810,13 +1810,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)
@@ -1833,9 +1833,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;
}
@@ -1846,19 +1846,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", "");
}
@@ -1869,13 +1869,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) {
@@ -1934,7 +1934,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 */
@@ -2053,7 +2053,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;
@@ -2108,9 +2108,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";
@@ -2119,7 +2119,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);
@@ -2130,7 +2130,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;
@@ -2138,11 +2138,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;
}
@@ -2152,14 +2152,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", "");
}
@@ -2170,25 +2170,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;
}
@@ -2198,11 +2198,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;
}
@@ -2222,7 +2222,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) {
@@ -2231,7 +2231,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
}
if (!iosock)
return OPERATOR_CANCELLED;
-
+
switch (direction) {
case 1:
{ /* up */
@@ -2254,11 +2254,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;
}
@@ -2268,14 +2268,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", "");
}
@@ -2322,9 +2322,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) {
@@ -2337,7 +2337,7 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende
found = true;
}
}
-
+
return found;
}
@@ -2384,7 +2384,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 3539a36d497..4440b2c6ecd 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 36df855b9d6..6f37c32be40 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,36 +89,36 @@ 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_viewlayers);
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);
@@ -135,7 +135,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);
@@ -149,7 +149,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",
@@ -212,7 +212,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);
@@ -225,17 +225,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
@@ -243,10 +243,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);
@@ -259,13 +259,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);
@@ -283,16 +283,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);
@@ -322,9 +322,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);
@@ -336,7 +336,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 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 5f48b7d7a0f..bc9513a748d 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) {
compatibility = NODE_NEW_SHADING;
}
@@ -483,29 +483,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;
@@ -521,15 +521,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);
}
@@ -736,7 +736,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 ccac730c88f..36886d0ab32 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -73,30 +73,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);
}
@@ -110,44 +110,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);
}
@@ -185,7 +185,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) {
@@ -203,7 +203,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) {
@@ -230,7 +230,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);
@@ -270,24 +270,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;
}
@@ -403,7 +403,7 @@ static void node_area_listener(bScreen *UNUSED(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;
}
@@ -528,7 +528,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) {
@@ -629,14 +629,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. */
@@ -1040,7 +1040,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);