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:
authorDalai Felinto <dfelinto@gmail.com>2012-02-02 03:22:55 +0400
committerDalai Felinto <dfelinto@gmail.com>2012-02-02 03:22:55 +0400
commit28f1fdd39bbb11b1081594e2f41bebef77a31518 (patch)
tree3475d4f0b15d7ba8e59150fec25adc582ae62afb /source/blender/editors/space_node
parent6b39a476cbe83febfe67daa31be6fade83194c7a (diff)
parentd882f05b824f4111ef5c319c89a2f85b1773c579 (diff)
svn merge ^/trunk/blender -r43091:43824(HEAD)
Conflicted file manually update: =============================== readfile.c Note 1: ======= The Double Edge Mask is not in tile since it's not a simple convert. The author of this node is aware of it and should have it working there eventually. (I'm going to add it in COM_Converter.cpp in a next commit) Note 2: ======= In COM_compositor.cpp we are passing only "Compositing" instead of what we have in trunk "Compositing 1 Gamma" If we decide to go with trunk then we need to incorporate the 43283 and 43287 commits. Something like: COM_compositor.cpp:51 - editingtree->stats_draw(editingtree->sdh, (char*)"Compositing"); + char str[128]; + BLI_snprintf(str, sizeof(str), "Compositing %d %s", curnode, node->name) + editingtree->stats_draw(editingtree->sdh, str);
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/drawnode.c241
-rw-r--r--source/blender/editors/space_node/node_draw.c42
-rw-r--r--source/blender/editors/space_node/node_edit.c139
-rw-r--r--source/blender/editors/space_node/node_intern.h4
-rw-r--r--source/blender/editors/space_node/node_ops.c38
-rw-r--r--source/blender/editors/space_node/node_templates.c11
-rw-r--r--source/blender/editors/space_node/space_node.c6
7 files changed, 160 insertions, 321 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 544112ab578..d822677cfe0 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -132,7 +132,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
uiBlock *block;
uiLayout *layout;
- block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS);
+ block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0);
@@ -631,7 +631,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
if (sock->flag & SOCK_DYNAMIC) {
bt = uiDefBut(gnode->block, TEX, 0, "",
sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
- sock->name, 0, 31, 0, 0, "");
+ sock->name, 0, sizeof(sock->name), 0, 0, "");
if (in_out==SOCK_IN)
uiButSetFunc(bt, update_group_input_cb, snode, ngroup);
else
@@ -640,7 +640,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
else {
uiDefBut(gnode->block, LABEL, 0, sock->name,
sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
- NULL, 0, 31, 0, 0, "");
+ NULL, 0, sizeof(sock->name), 0, 0, "");
}
}
@@ -1203,10 +1203,10 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
Scene *scene= CTX_data_scene(C);
ImageUser *iuser= node->storage;
- char tstr[32];
+ char numstr[32];
const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0);
- BLI_snprintf(tstr, sizeof(tstr), "Frame: %d", framenr);
- uiItemL(layout, tstr, ICON_NONE);
+ BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr);
+ uiItemL(layout, numstr, ICON_NONE);
}
if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
@@ -1233,7 +1233,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point
PropertyRNA *prop;
const char *layer_name;
char scene_name[MAX_ID_NAME-2];
-
+ wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
+
+ BLI_assert(ot != 0);
+
uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
if(!node->id) return;
@@ -1249,10 +1252,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point
scn_ptr = RNA_pointer_get(ptr, "scene");
RNA_string_get(&scn_ptr, "name", scene_name);
- WM_operator_properties_create(&op_ptr, "RENDER_OT_render");
+ WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_string_set(&op_ptr, "layer", layer_name);
RNA_string_set(&op_ptr, "scene", scene_name);
- uiItemFullO(row, "RENDER_OT_render", "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
}
@@ -1472,6 +1475,18 @@ static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C)
uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
}
+static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col;
+
+ col= uiLayoutColumn(layout, 0);
+
+ uiItemL(col, "Inner Edge:", ICON_NONE);
+ uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
+ uiItemL(col, "Buffer Edge:", ICON_NONE);
+ uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
+}
+
static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *sub, *col;
@@ -2091,6 +2106,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_ID_MASK:
ntype->uifunc= node_composit_buts_id_mask;
break;
+ case CMP_NODE_DOUBLEEDGEMASK:
+ ntype->uifunc= node_composit_buts_double_edge_mask;
+ break;
case CMP_NODE_MATH:
ntype->uifunc= node_buts_math;
break;
@@ -2465,211 +2483,6 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
}
}
-void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4])
-{
- char str[256];
- float dx= 6;
- /* text colors */
- /* XXX colored text not allowed in Blender UI */
- #if 0
- unsigned char red[3] = {255, 50, 50};
- unsigned char green[3] = {0, 255, 0};
- unsigned char blue[3] = {100, 100, 255};
- #else
- unsigned char red[3] = {255, 255, 255};
- unsigned char green[3] = {255, 255, 255};
- unsigned char blue[3] = {255, 255, 255};
- #endif
- float hue=0, sat=0, val=0, lum=0, u=0, v=0;
- float col[4], finalcol[4];
-
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- /* noisy, high contrast make impossible to read if lower alpha is used. */
- glColor4ub(0, 0, 0, 190);
- glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
- glDisable(GL_BLEND);
-
- BLF_size(blf_mono_font, 11, 72);
-
- glColor3ub(255, 255, 255);
- sprintf(str, "X:%-4d Y:%-4d |", x, y);
- // UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- #if 0 /* XXX no Z value in compo backdrop atm */
- if(zp) {
- glColor3ub(255, 255, 255);
- sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
- }
- if(zpf) {
- glColor3ub(255, 255, 255);
- sprintf(str, " Z:%-.3f |", *zpf);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
- }
- #endif
-
- if(channels >= 3) {
- glColor3ubv(red);
- if (fp)
- sprintf(str, " R:%-.4f", fp[0]);
- else if (cp)
- sprintf(str, " R:%-3d", cp[0]);
- else
- sprintf(str, " R:-");
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- glColor3ubv(green);
- if (fp)
- sprintf(str, " G:%-.4f", fp[1]);
- else if (cp)
- sprintf(str, " G:%-3d", cp[1]);
- else
- sprintf(str, " G:-");
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- glColor3ubv(blue);
- if (fp)
- sprintf(str, " B:%-.4f", fp[2]);
- else if (cp)
- sprintf(str, " B:%-3d", cp[2]);
- else
- sprintf(str, " B:-");
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- if(channels == 4) {
- glColor3ub(255, 255, 255);
- if (fp)
- sprintf(str, " A:%-.4f", fp[3]);
- else if (cp)
- sprintf(str, " A:%-3d", cp[3]);
- else
- sprintf(str, "- ");
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
- }
- }
-
- /* color rectangle */
- if (channels==1) {
- if (fp)
- col[0] = col[1] = col[2] = fp[0];
- else if (cp)
- col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
- else
- col[0] = col[1] = col[2] = 0.0f;
- }
- else if (channels==3) {
- if (fp)
- copy_v3_v3(col, fp);
- else if (cp) {
- col[0] = (float)cp[0]/255.0f;
- col[1] = (float)cp[1]/255.0f;
- col[2] = (float)cp[2]/255.0f;
- }
- else
- zero_v3(col);
- }
- else if (channels==4) {
- if (fp)
- copy_v4_v4(col, fp);
- else if (cp) {
- col[0] = (float)cp[0]/255.0f;
- col[1] = (float)cp[1]/255.0f;
- col[2] = (float)cp[2]/255.0f;
- col[3] = (float)cp[3]/255.0f;
- }
- else
- zero_v4(col);
- }
- if (color_manage) {
- linearrgb_to_srgb_v3_v3(finalcol, col);
- finalcol[3] = col[3];
- }
- else {
- copy_v4_v4(finalcol, col);
- }
- glDisable(GL_BLEND);
- glColor3fv(finalcol);
- dx += 5;
- glBegin(GL_QUADS);
- glVertex2f(dx, 3);
- glVertex2f(dx, 17);
- glVertex2f(dx+30, 17);
- glVertex2f(dx+30, 3);
- glEnd();
- dx += 35;
-
- glColor3ub(255, 255, 255);
- if(channels == 1) {
- if (fp) {
- rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
- rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
- }
- else if (cp) {
- rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val);
- rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
- }
-
- sprintf(str, "V:%-.4f", val);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- sprintf(str, " L:%-.4f", lum);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
- }
- else if(channels >= 3) {
- if (fp) {
- rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val);
- rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
- }
- else if (cp) {
- rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val);
- rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
- }
-
- sprintf(str, "H:%-.4f", hue);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- sprintf(str, " S:%-.4f", sat);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- sprintf(str, " V:%-.4f", val);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
-
- sprintf(str, " L:%-.4f", lum);
- BLF_position(blf_mono_font, dx, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
- }
-
- (void)dx;
-}
-
#if 0
/* note: needs to be userpref or opengl profile option */
static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 7b692f55965..a82ea9e9046 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -195,18 +195,18 @@ static void node_scaling_widget(int color_id, float aspect, float xmin, float ym
static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
{
bNode *node;
- char str[32];
+ 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 */
- sprintf(str, "node buttons %p", (void *)node);
- node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
- uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
-
- /* this cancels events for background nodes */
- uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS);
+ for (node= ntree->nodes.first; node; node= node->next) {
+ /* ui block */
+ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node);
+ node->block= uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS);
+ uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
+
+ /* this cancels events for background nodes */
+ uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS);
}
}
@@ -233,7 +233,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
/* output sockets */
for(nsock= node->outputs.first; nsock; nsock= nsock->next) {
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(nsock)) {
nsock->locx= locx + node->width;
nsock->locy= dy - NODE_DYS;
dy-= NODE_DY;
@@ -312,7 +312,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
/* input sockets */
for(nsock= node->inputs.first; nsock; nsock= nsock->next) {
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(nsock)) {
nsock->locx= locx;
nsock->locy= dy - NODE_DYS;
dy-= NODE_DY;
@@ -351,10 +351,10 @@ static void node_update_hidden(bNode *node)
/* calculate minimal radius */
for(nsock= node->inputs.first; nsock; nsock= nsock->next)
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE))
+ if(!nodeSocketIsHidden(nsock))
totin++;
for(nsock= node->outputs.first; nsock; nsock= nsock->next)
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE))
+ if(!nodeSocketIsHidden(nsock))
totout++;
tot= MAX2(totin, totout);
@@ -371,7 +371,7 @@ static void node_update_hidden(bNode *node)
rad=drad= (float)M_PI/(1.0f + (float)totout);
for(nsock= node->outputs.first; nsock; nsock= nsock->next) {
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) {
+ if(!nodeSocketIsHidden(nsock)) {
nsock->locx= node->totr.xmax - hiddenrad + (float)sin(rad)*hiddenrad;
nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad;
rad+= drad;
@@ -382,7 +382,7 @@ static void node_update_hidden(bNode *node)
rad=drad= - (float)M_PI/(1.0f + (float)totin);
for(nsock= node->inputs.first; nsock; nsock= nsock->next) {
- if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) {
+ if(!nodeSocketIsHidden(nsock)) {
nsock->locx= node->totr.xmin + hiddenrad + (float)sin(rad)*hiddenrad;
nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad;
rad+= drad;
@@ -673,7 +673,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
BLI_strncpy(showname, nodeLabel(node), sizeof(showname));
//if(node->flag & NODE_MUTED)
- // sprintf(showname, "[%s]", showname);
+ // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self!
uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(rct->ymax-NODE_DY),
(int)(iconofs - rct->xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, "");
@@ -713,7 +713,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
for(sock= node->inputs.first; sock; sock= sock->next) {
bNodeSocketType *stype= ntreeGetSocketType(sock->type);
- if(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))
+ if(nodeSocketIsHidden(sock))
continue;
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE);
@@ -736,7 +736,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
RNA_pointer_create((ID*)ntree, &RNA_NodeSocket, sock, &sockptr);
- if(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))
+ if(nodeSocketIsHidden(sock))
continue;
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE);
@@ -835,7 +835,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
BLI_strncpy(showname, nodeLabel(node), sizeof(showname));
//if(node->flag & NODE_MUTED)
- // sprintf(showname, "[%s]", showname);
+ // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self!
uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(centy-10),
(int)(rct->xmax - rct->xmin-18.0f -12.0f), NODE_DY, NULL, 0, 0, 0, 0, "");
@@ -854,12 +854,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
/* sockets */
for(sock= node->inputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (sock->flag & SOCK_IN_USE))
+ if(!nodeSocketIsHidden(sock))
node_socket_circle_draw(snode->nodetree, sock, socket_size);
}
for(sock= node->outputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (sock->flag & SOCK_IN_USE))
+ if(!nodeSocketIsHidden(sock))
node_socket_circle_draw(snode->nodetree, sock, socket_size);
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 7345c1ec6aa..f8c5dfb8e72 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -71,6 +71,7 @@
#include "IMB_imbuf_types.h"
#include "ED_node.h"
+#include "ED_image.h"
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_render.h"
@@ -755,14 +756,14 @@ static int edit_node_poll(bContext *C)
static void edit_node_properties(wmOperatorType *ot)
{
/* XXX could node be a context pointer? */
- RNA_def_string(ot->srna, "node", "", 32, "Node", "");
+ RNA_def_string(ot->srna, "node", "", MAX_NAME, "Node", "");
RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET);
RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Side", "");
}
static int edit_node_invoke_properties(bContext *C, wmOperator *op)
{
- if (!RNA_property_is_set(op->ptr, "node")) {
+ if (!RNA_struct_property_is_set(op->ptr, "node")) {
bNode *node= CTX_data_pointer_get_type(C, "node", &RNA_Node).data;
if (!node)
return 0;
@@ -770,10 +771,10 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op)
RNA_string_set(op->ptr, "node", node->name);
}
- if (!RNA_property_is_set(op->ptr, "in_out"))
+ if (!RNA_struct_property_is_set(op->ptr, "in_out"))
RNA_enum_set(op->ptr, "in_out", SOCK_IN);
- if (!RNA_property_is_set(op->ptr, "socket"))
+ if (!RNA_struct_property_is_set(op->ptr, "socket"))
RNA_int_set(op->ptr, "socket", 0);
return 1;
@@ -783,7 +784,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r
{
bNode *node;
bNodeSocket *sock=NULL;
- char nodename[32];
+ char nodename[MAX_NAME];
int sockindex;
int in_out;
@@ -858,14 +859,13 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
SpaceNode *snode = CTX_wm_space_node(C);
bNode *gnode;
- gnode = nodeGetActive(snode->edittree);
- if (!gnode)
- return OPERATOR_CANCELLED;
-
/* XXX callback? */
- if(gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) {
- uiPupMenuOkee(C, op->type->idname, "Make group local?");
- return OPERATOR_CANCELLED;
+ if (snode->nodetree==snode->edittree) {
+ gnode = nodeGetActive(snode->edittree);
+ if(gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) {
+ uiPupMenuOkee(C, op->type->idname, "Make group local?");
+ return OPERATOR_CANCELLED;
+ }
}
return node_group_edit_exec(C, op);
@@ -893,20 +893,20 @@ static int node_group_socket_add_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
int in_out= -1;
- char name[32]= "";
+ char name[MAX_NAME]= "";
int type= SOCK_FLOAT;
bNodeTree *ngroup= snode->edittree;
/* bNodeSocket *sock; */ /* UNUSED */
ED_preview_kill_jobs(C);
- if (RNA_property_is_set(op->ptr, "name"))
+ if (RNA_struct_property_is_set(op->ptr, "name"))
RNA_string_get(op->ptr, "name", name);
- if (RNA_property_is_set(op->ptr, "type"))
+ if (RNA_struct_property_is_set(op->ptr, "type"))
type = RNA_enum_get(op->ptr, "type");
- if (RNA_property_is_set(op->ptr, "in_out"))
+ if (RNA_struct_property_is_set(op->ptr, "in_out"))
in_out = RNA_enum_get(op->ptr, "in_out");
else
return OPERATOR_CANCELLED;
@@ -936,7 +936,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output");
- RNA_def_string(ot->srna, "name", "", 32, "Name", "Group socket name");
+ RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name");
RNA_def_enum(ot->srna, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of the group socket");
}
@@ -952,12 +952,12 @@ static int node_group_socket_remove_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(C);
- if (RNA_property_is_set(op->ptr, "index"))
+ if (RNA_struct_property_is_set(op->ptr, "index"))
index = RNA_int_get(op->ptr, "index");
else
return OPERATOR_CANCELLED;
- if (RNA_property_is_set(op->ptr, "in_out"))
+ if (RNA_struct_property_is_set(op->ptr, "in_out"))
in_out = RNA_enum_get(op->ptr, "in_out");
else
return OPERATOR_CANCELLED;
@@ -1003,12 +1003,12 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(C);
- if (RNA_property_is_set(op->ptr, "index"))
+ if (RNA_struct_property_is_set(op->ptr, "index"))
index = RNA_int_get(op->ptr, "index");
else
return OPERATOR_CANCELLED;
- if (RNA_property_is_set(op->ptr, "in_out"))
+ if (RNA_struct_property_is_set(op->ptr, "in_out"))
in_out = RNA_enum_get(op->ptr, "in_out");
else
return OPERATOR_CANCELLED;
@@ -1073,12 +1073,12 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(C);
- if (RNA_property_is_set(op->ptr, "index"))
+ if (RNA_struct_property_is_set(op->ptr, "index"))
index = RNA_int_get(op->ptr, "index");
else
return OPERATOR_CANCELLED;
- if (RNA_property_is_set(op->ptr, "in_out"))
+ if (RNA_struct_property_is_set(op->ptr, "in_out"))
in_out = RNA_enum_get(op->ptr, "in_out");
else
return OPERATOR_CANCELLED;
@@ -1337,7 +1337,7 @@ typedef struct ImageSampleInfo {
int channels;
int color_manage;
- char col[4];
+ unsigned char col[4];
float colf[4];
int draw;
@@ -1347,8 +1347,10 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
{
ImageSampleInfo *info= arg_info;
- draw_nodespace_color_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
- info->x, info->y, info->col, info->colf);
+ ED_image_draw_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+ info->x, info->y, info->col, info->colf,
+ NULL, NULL /* zbuf - unused for nodes */
+ );
}
static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
@@ -1604,40 +1606,38 @@ void NODE_OT_resize(wmOperatorType *ot)
/* ********************** hidden sockets ******************** */
-int node_has_hidden_sockets(bNode *node)
+int node_has_hidden_sockets(bNode *node, short flag)
{
bNodeSocket *sock;
for(sock= node->inputs.first; sock; sock= sock->next)
- if(sock->flag & SOCK_HIDDEN)
+ if(sock->flag & flag)
return 1;
for(sock= node->outputs.first; sock; sock= sock->next)
- if(sock->flag & SOCK_HIDDEN)
+ if(sock->flag & flag)
return 1;
return 0;
}
-/* note: call node_tree_verify_groups(snode->nodetree) after this
- */
-void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
+void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set)
{
bNodeSocket *sock;
if(set==0) {
for(sock= node->inputs.first; sock; sock= sock->next)
- sock->flag &= ~SOCK_HIDDEN;
+ sock->flag &= ~flag;
for(sock= node->outputs.first; sock; sock= sock->next)
- sock->flag &= ~SOCK_HIDDEN;
+ sock->flag &= ~flag;
}
else {
/* hide unused sockets */
for(sock= node->inputs.first; sock; sock= sock->next) {
if(sock->link==NULL)
- sock->flag |= SOCK_HIDDEN;
+ sock->flag |= flag;
}
for(sock= node->outputs.first; sock; sock= sock->next) {
if(nodeCountSocketLinks(snode->edittree, sock)==0)
- sock->flag |= SOCK_HIDDEN;
+ sock->flag |= flag;
}
}
}
@@ -1684,14 +1684,14 @@ static void node_link_viewer(SpaceNode *snode, bNode *tonode)
/* find a socket after the previously connected socket */
for(sock=sock->next; sock; sock= sock->next)
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)))
+ if(!nodeSocketIsHidden(sock))
break;
}
/* find a socket starting from the first socket */
if(!sock) {
for(sock= tonode->outputs.first; sock; sock= sock->next)
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)))
+ if(!nodeSocketIsHidden(sock))
break;
}
@@ -1809,7 +1809,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **
if(in_out & SOCK_IN) {
for(sock= node->inputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(sock)) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
if(node == visible_node(snode, &rect)) {
*nodep= node;
@@ -1822,7 +1822,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **
}
if(in_out & SOCK_OUT) {
for(sock= node->outputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(sock)) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
if(node == visible_node(snode, &rect)) {
*nodep= node;
@@ -1840,7 +1840,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **
*/
if(in_out & SOCK_IN) {
for(sock= snode->edittree->outputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(sock)) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
*nodep= NULL; /* NULL node pointer indicates group socket */
*sockp= sock;
@@ -1851,7 +1851,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **
}
if(in_out & SOCK_OUT) {
for(sock= snode->edittree->inputs.first; sock; sock= sock->next) {
- if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
+ if(!nodeSocketIsHidden(sock)) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
*nodep= NULL; /* NULL node pointer indicates group socket */
*sockp= sock;
@@ -1932,15 +1932,14 @@ static int sort_nodes_locx(void *a, void *b)
return 0;
}
-static int socket_is_available(bNodeTree *ntree, bNodeSocket *sock, int allow_used)
+static int socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, int allow_used)
{
- if (sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))
+ if (nodeSocketIsHidden(sock))
+ return 0;
+
+ if (!allow_used && (sock->flag & SOCK_IN_USE))
return 0;
- if (!allow_used) {
- if (nodeCountSocketLinks(ntree, sock) > 0)
- return 0;
- }
return 1;
}
@@ -2250,7 +2249,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL
}
if(sock) {
tlink->tosock= sock;
- sock->flag &= ~SOCK_HIDDEN;
+ sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN);
}
else {
nodeRemLink(snode->edittree, tlink);
@@ -2648,26 +2647,26 @@ static bNodeSocket *socket_best_match(ListBase *sockets, int type)
/* first, match type */
for(sock= sockets->first; sock; sock= sock->next)
- if(!(sock->flag & SOCK_HIDDEN))
+ if(!nodeSocketIsHidden(sock))
if(type == sock->type)
return sock;
/* then just use first unhidden socket */
for(sock= sockets->first; sock; sock= sock->next)
- if(!(sock->flag & SOCK_HIDDEN))
+ if(!nodeSocketIsHidden(sock))
return sock;
/* OK, let's unhide proper one */
for(sock= sockets->first; sock; sock= sock->next) {
if(type == sock->type) {
- sock->flag &= ~SOCK_HIDDEN;
+ sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN);
return sock;
}
}
/* just the first */
sock= sockets->first;
- sock->flag &= ~SOCK_HIDDEN;
+ sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN);
return sockets->first;
}
@@ -3007,10 +3006,20 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
if(toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0)
continue;
- if( (tot_eq && tot_neq) || tot_eq==0)
+ if( (tot_eq && tot_neq) || tot_eq==0) {
node->flag |= toggle_flag;
- else
+
+ /* hide/unhide node also toggles unlinked socket display */
+ if (toggle_flag== NODE_HIDDEN)
+ node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 1);
+ }
+ else {
node->flag &= ~toggle_flag;
+
+ /* hide/unhide node also toggles unlinked socket display */
+ if (toggle_flag== NODE_HIDDEN)
+ node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 0);
+ }
}
}
}
@@ -3123,7 +3132,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
hidden = 0;
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
- if(node_has_hidden_sockets(node)) {
+ if(node_has_hidden_sockets(node, SOCK_HIDDEN)) {
hidden= 1;
break;
}
@@ -3132,7 +3141,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);
+ node_set_hidden_sockets(snode, node, SOCK_HIDDEN, !hidden);
}
}
@@ -3432,7 +3441,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
ntemp.type = -1;
/* check input variables */
- if (RNA_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath"))
{
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
@@ -3446,9 +3455,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
- else if(RNA_property_is_set(op->ptr, "name"))
+ else if(RNA_struct_property_is_set(op->ptr, "name"))
{
- char name[32];
+ char name[MAX_ID_NAME-2];
RNA_string_get(op->ptr, "name", name);
ima= (Image *)find_id("IM", name);
@@ -3492,7 +3501,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->mx, &snode->my);
- if (RNA_property_is_set(op->ptr, "filepath") || RNA_property_is_set(op->ptr, "name"))
+ 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
return WM_operator_filesel(C, op, event);
@@ -3513,8 +3522,8 @@ void NODE_OT_add_file(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path
- RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Datablock name to assign");
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path
+ RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign");
}
/********************** New node tree operator *********************/
@@ -3531,12 +3540,12 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
/* retrieve state */
snode= CTX_wm_space_node(C);
- if (RNA_property_is_set(op->ptr, "type"))
+ if (RNA_struct_property_is_set(op->ptr, "type"))
treetype = RNA_enum_get(op->ptr, "type");
else
treetype = snode->treetype;
- if (RNA_property_is_set(op->ptr, "name"))
+ if (RNA_struct_property_is_set(op->ptr, "name"))
RNA_string_get(op->ptr, "name", treename);
ntree = ntreeAddTree(treename, treetype, 0);
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 9068493360e..186ad3768be 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -118,8 +118,8 @@ void snode_composite_job(const struct bContext *C, ScrArea *sa);
bNode *node_tree_get_editgroup(bNodeTree *ntree);
void node_tree_verify_groups(bNodeTree *nodetree);
void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace);
-int node_has_hidden_sockets(bNode *node);
-void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set);
+int node_has_hidden_sockets(bNode *node, short flag);
+void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set);
int node_render_changed_exec(bContext *, wmOperator *);
void NODE_OT_duplicate(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index b5c435b50e8..508021540b5 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -34,6 +34,8 @@
#include "BKE_context.h"
+#include "BLI_utildefines.h"
+
#include "ED_node.h"
#include "ED_screen.h"
#include "ED_transform.h"
@@ -112,8 +114,10 @@ void ED_operatormacros_node(void)
/* modified operator call for duplicating with input links */
ot= WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
ot->description = "Duplicate selected nodes keeping input links and move them";
+
mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate");
- RNA_boolean_set(mot->ptr, "keep_inputs", 1);
+ RNA_boolean_set(mot->ptr, "keep_inputs", TRUE);
+
WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
ot= WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO);
@@ -138,13 +142,16 @@ void node_keymap(struct wmKeyConfig *keyconf)
/* 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
*/
- WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
- kmi= WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "extend", 1);
- kmi= WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "extend", 1);
- RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0)->ptr, "tweak", 1);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", TRUE);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", 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);
/* each of these falls through if not handled... */
WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
@@ -159,10 +166,12 @@ void node_keymap(struct wmKeyConfig *keyconf)
kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, KM_ALT, 0);
RNA_float_set(kmi->ptr, "factor", 1.2f);
WM_keymap_add_item(keymap, "NODE_OT_backimage_sample", ACTIONMOUSE, KM_PRESS, KM_ALT, 0);
-
- WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "replace", 1);
-
+
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "replace", FALSE);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_boolean_set(kmi->ptr, "replace", TRUE);
+
WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
/* modified operator call for duplicating with input links */
@@ -176,7 +185,10 @@ void node_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
+
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "tweak", FALSE);
+
WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", XKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index a733d45c20b..8d82dd3fb53 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -49,6 +49,8 @@
#include "RNA_access.h"
+#include "NOD_socket.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -205,12 +207,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
nodeRemLink(ntree, link);
}
- if(sock_prev->default_value) {
- if(sock_from->default_value)
- MEM_freeN(sock_from->default_value);
-
- sock_from->default_value = MEM_dupallocN(sock_prev->default_value);
- }
+ node_socket_free_default_value(sock_from->type, sock_from->default_value);
+ sock_from->default_value = node_socket_make_default_value(sock_from->type);
+ node_socket_copy_default_value(sock_from->type, sock_from->default_value, sock_prev->default_value);
}
}
}
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 9d4c5705bd1..493fb854585 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -169,6 +169,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
/* note, ED_area_tag_refresh will re-execute compositor */
SpaceNode *snode= sa->spacedata.first;
int type= snode->treetype;
+ short shader_type = snode->shaderfrom;
/* preview renders */
switch(wmn->category) {
@@ -214,6 +215,11 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
}
break;
+ case NC_WORLD:
+ if(type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) {
+ ED_area_tag_refresh(sa);
+ }
+ break;
case NC_OBJECT:
if(type==NTREE_SHADER) {
if(wmn->data==ND_OB_SHADING)