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:
authorMatt Ebb <matt@mke3.net>2009-11-11 05:15:09 +0300
committerMatt Ebb <matt@mke3.net>2009-11-11 05:15:09 +0300
commitf0fc007c4b4bde845610d93cbae9c3c4a86a1216 (patch)
tree65b70e00d092e85a0de8d81ed23c91961bc0f3cd /source/blender
parent0807bc176a1f406674f60e6fc1936dd310f3dec3 (diff)
Wrapped node input and output sockets in RNA.
This allows you to set and animate the values of socket inputs and outputs, for example the value node. It's also a step on the way to manipulating node trees via python (i.e. linking node sockets to each other). This fixes [#19841] RGB Node in compositor not working
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c2
-rw-r--r--source/blender/editors/include/UI_icons.h6
-rw-r--r--source/blender/editors/space_node/drawnode.c44
-rw-r--r--source/blender/editors/space_node/node_draw.c68
-rw-r--r--source/blender/makesrna/RNA_access.h4
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c194
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c2
8 files changed, 226 insertions, 96 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index ca400973363..7d4ad868b45 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -1867,7 +1867,7 @@ static void dummy_olddraw_gpencil ()
strcpy(treetype, "Material");
sprintf(name, "Nodes:%s", treetype);
- special= ICON_NODE;
+ special= ICON_NODETREE;
}
break;
case SPACE_SEQ:
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index ee1a23f242b..a3dd6426f99 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -54,8 +54,8 @@ DEF_ICON(ICON_BLANK005)
DEF_ICON(ICON_GO_LEFT)
DEF_ICON(ICON_PLUG)
DEF_ICON(ICON_UI)
-DEF_ICON(ICON_TEXNODE)
-DEF_ICON(ICON_TEXNODE_SEL)
+DEF_ICON(ICON_NODE)
+DEF_ICON(ICON_NODE_SEL)
/* ui */
DEF_ICON(ICON_FULLSCREEN)
@@ -157,7 +157,7 @@ DEF_ICON(ICON_ACTION)
DEF_ICON(ICON_NLA)
DEF_ICON(ICON_SCRIPTWIN)
DEF_ICON(ICON_TIME)
-DEF_ICON(ICON_NODE)
+DEF_ICON(ICON_NODETREE)
DEF_ICON(ICON_LOGIC)
DEF_ICON(ICON_CONSOLE)
DEF_ICON(ICON_PREFERENCES)
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 9a17a43620f..b02bede8f07 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -197,40 +197,30 @@ static void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
static void node_buts_value(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- uiBlock *block= uiLayoutAbsoluteBlock(layout);
bNode *node= ptr->data;
- rctf *butr= &node->butr;
- bNodeSocket *sock= node->outputs.first; /* first socket stores value */
+ PointerRNA sockptr;
+ PropertyRNA *prop;
+
+ /* first socket stores value */
+ prop = RNA_struct_find_property(ptr, "outputs");
+ RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
- uiDefButF(block, NUM, B_NODE_EXEC, "",
- (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin, 20,
- sock->ns.vec, sock->ns.min, sock->ns.max, 10, 2, "");
+ uiItemR(layout, "", 0, &sockptr, "default_value", 0);
}
static void node_buts_rgb(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- uiBlock *block= uiLayoutAbsoluteBlock(layout);
+ uiLayout *col;
bNode *node= ptr->data;
- rctf *butr= &node->butr;
- bNodeSocket *sock= node->outputs.first; /* first socket stores value */
-
- if(sock) {
- /* enforce square box drawing */
- uiBlockSetEmboss(block, UI_EMBOSSP);
-
- uiDefButF(block, HSVCUBE, B_NODE_EXEC, "",
- (short)butr->xmin, (short)butr->ymin, butr->xmax-butr->xmin, 12,
- sock->ns.vec, 0.0f, 1.0f, 3, 0, "");
- uiDefButF(block, HSVCUBE, B_NODE_EXEC, "",
- (short)butr->xmin, (short)butr->ymin+15, butr->xmax-butr->xmin, butr->xmax-butr->xmin -15 -15,
- sock->ns.vec, 0.0f, 1.0f, 2, 0, "");
- uiDefButF(block, COL, B_NOP, "",
- (short)butr->xmin, (short)butr->ymax-12, butr->xmax-butr->xmin, 12,
- sock->ns.vec, 0.0, 0.0, -1, 0, "");
- /* the -1 above prevents col button to popup a color picker */
-
- uiBlockSetEmboss(block, UI_EMBOSS);
- }
+ PointerRNA sockptr;
+ PropertyRNA *prop;
+
+ /* first socket stores value */
+ prop = RNA_struct_find_property(ptr, "outputs");
+ RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
+
+ col = uiLayoutColumn(layout, 0);
+ uiItemR(col, "", 0, &sockptr, "default_value", 0);
}
static void node_buts_mix_rgb(uiLayout *layout, bContext *C, PointerRNA *ptr)
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index d63b6403028..3150e170a4f 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -548,55 +548,25 @@ static void node_sync_cb(bContext *C, void *snode_v, void *node_v)
/* ************** Socket callbacks *********** */
-static void socket_vector_menu_cb(bContext *C, void *node_v, void *ntree_v)
-{
- if(node_v && ntree_v) {
- NodeTagChanged(ntree_v, node_v);
- // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC); XXX
- }
-}
-
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *socket_vector_menu(bContext *C, ARegion *ar, void *socket_v)
{
- SpaceNode *snode= CTX_wm_space_node(C);
- ScrArea *sa= CTX_wm_area(C);
- bNode *node;
bNodeSocket *sock= socket_v;
- bNodeStack *ns= &sock->ns;
uiBlock *block;
- uiBut *bt;
- /* a bit ugly... retrieve the node the socket comes from */
- for(node= snode->nodetree->nodes.first; node; node= node->next) {
- bNodeSocket *sockt;
- for(sockt= node->inputs.first; sockt; sockt= sockt->next)
- if(sockt==sock)
- break;
- if(sockt)
- break;
- }
+ SpaceNode *snode= CTX_wm_space_node(C);
+ bNodeTree *ntree = snode->nodetree;
+ PointerRNA ptr;
+ uiLayout *layout;
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
-
- /* use this for a fake extra empy space around the buttons */
- uiDefBut(block, LABEL, 0, "", -4, -4, 188, 68, NULL, 0, 0, 0, 0, "");
- uiBlockBeginAlign(block);
- bt= uiDefButF(block, NUMSLI, 0, "X ", 0,40,180,20, ns->vec, ns->min, ns->max, 10, 0, "");
- uiButSetFunc(bt, socket_vector_menu_cb, node, snode->nodetree);
- bt= uiDefButF(block, NUMSLI, 0, "Y ", 0,20,180,20, ns->vec+1, ns->min, ns->max, 10, 0, "");
- uiButSetFunc(bt, socket_vector_menu_cb, node, snode->nodetree);
- bt= uiDefButF(block, NUMSLI, 0, "Z ", 0,0,180,20, ns->vec+2, ns->min, ns->max, 10, 0, "");
- uiButSetFunc(bt, socket_vector_menu_cb, node, snode->nodetree);
+ layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, sock->locx, sock->locy-8, 140, 20, U.uistyles.first), 0);
- uiBlockSetDirection(block, UI_TOP);
- uiEndBlock(C, block);
-
- ED_area_tag_redraw(sa);
-
- return block;
+ uiItemR(layout, "", 0, &ptr, "default_value", UI_ITEM_R_EXPAND);
}
/* not a callback */
@@ -671,6 +641,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
int /*ofs,*/ color_id= node_get_colorid(node);
char showname[128]; /* 128 used below */
View2D *v2d = &ar->v2d;
+ bNodeTree *ntree = snode->nodetree;
+ PointerRNA ptr;
uiSetRoundBox(15-4);
ui_dropshadow(rct, BASIS_RAD, snode->aspect, node->flag & SELECT);
@@ -705,10 +677,10 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
glEnable(GL_BLEND);
if(node->id->lib) {
float rgb[3] = {1.0f, 0.7f, 0.3f};
- UI_icon_draw_aspect_color(iconofs, rct->ymax-NODE_DY, ICON_NODE, snode->aspect, rgb);
+ UI_icon_draw_aspect_color(iconofs, rct->ymax-NODE_DY, ICON_NODETREE, snode->aspect, rgb);
}
else {
- UI_icon_draw_aspect(iconofs, rct->ymax-NODE_DY, ICON_NODE, snode->aspect, 0.5f);
+ UI_icon_draw_aspect(iconofs, rct->ymax-NODE_DY, ICON_NODETREE, snode->aspect, 0.5f);
}
glDisable(GL_BLEND);
}
@@ -789,13 +761,15 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {
socket_circle_draw(sock, NODE_SOCKSIZE);
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
if(node->block && sock->link==NULL) {
float *butpoin= sock->ns.vec;
if(sock->type==SOCK_VALUE) {
- bt= uiDefButF(node->block, NUM, B_NODE_EXEC, sock->name,
- (short)sock->locx+NODE_DYS, (short)(sock->locy)-9, (short)node->width-NODE_DY, 17,
- butpoin, sock->ns.min, sock->ns.max, 10, 2, "");
+ bt=uiDefButR(node->block, NUM, B_NODE_EXEC, sock->name,
+ (short)sock->locx+NODE_DYS, (short)(sock->locy)-9, (short)node->width-NODE_DY, 17,
+ &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL);
uiButSetFunc(bt, node_sync_cb, snode, node);
}
else if(sock->type==SOCK_VECTOR) {
@@ -808,9 +782,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
if(labelw>0) width= 40; else width= (short)node->width-NODE_DY;
- bt= uiDefButF(node->block, COL, B_NODE_EXEC, "",
- (short)(sock->locx+NODE_DYS), (short)sock->locy-8, width, 15,
- butpoin, 0, 0, 0, 0, "");
+ bt=uiDefButR(node->block, COL, B_NODE_EXEC, "",
+ (short)sock->locx+NODE_DYS, (short)(sock->locy)-8, width, 15,
+ &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL);
uiButSetFunc(bt, node_sync_cb, snode, node);
if(labelw>0) uiDefBut(node->block, LABEL, 0, sock->name,
@@ -820,7 +794,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
else {
- uiDefBut(node->block, LABEL, 0, sock->name, (short)(sock->locx+3.0f), (short)(sock->locy-9.0f),
+ uiDefBut(node->block, LABEL, 0, sock->name, (short)(sock->locx+7), (short)(sock->locy-9.0f),
(short)(node->width-NODE_DY), NODE_DY, NULL, 0, 0, 0, 0, "");
}
}
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index dc730ee46f9..b20914181c8 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -310,6 +310,7 @@ extern StructRNA RNA_NlaStrip;
extern StructRNA RNA_NlaTrack;
extern StructRNA RNA_Node;
extern StructRNA RNA_NodeTree;
+extern StructRNA RNA_NodeSocket;
extern StructRNA RNA_NoiseTexture;
extern StructRNA RNA_NorController;
extern StructRNA RNA_Nurb;
@@ -358,6 +359,7 @@ extern StructRNA RNA_RenderEngine;
extern StructRNA RNA_RenderLayer;
extern StructRNA RNA_RenderPass;
extern StructRNA RNA_RenderResult;
+extern StructRNA RNA_RGBANodeSocket;
extern StructRNA RNA_RigidBodyJointConstraint;
extern StructRNA RNA_Scene;
extern StructRNA RNA_SceneGameData;
@@ -515,7 +517,9 @@ extern StructRNA RNA_UserPreferencesFilePaths;
extern StructRNA RNA_UserPreferencesSystem;
extern StructRNA RNA_UserPreferencesView;
extern StructRNA RNA_UserSolidLight;
+extern StructRNA RNA_ValueNodeSocket;
extern StructRNA RNA_VectorFont;
+extern StructRNA RNA_VectorNodeSocket;
extern StructRNA RNA_VertexGroup;
extern StructRNA RNA_VertexGroupElement;
extern StructRNA RNA_VertexPaint;
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 3de347cf80e..cb1a1211d24 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -53,7 +53,7 @@ EnumPropertyItem id_type_items[] = {
{ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""},
{ID_MB, "META", ICON_META_DATA, "MetaBall", ""},
{ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""},
- {ID_NT, "NODETREE", ICON_NODE, "NodeTree", ""},
+ {ID_NT, "NODETREE", ICON_NODETREE, "NodeTree", ""},
{ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""},
{ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
{ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index e5b8ce3be0b..8d8ed565d1c 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -145,15 +145,59 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
}
}
+static StructRNA *rna_NodeSocketType_refine(struct PointerRNA *ptr)
+{
+ bNodeSocket *ns= (bNodeSocket*)ptr->data;
+
+ switch(ns->type) {
+ case SOCK_VALUE:
+ return &RNA_ValueNodeSocket;
+ case SOCK_VECTOR:
+ return &RNA_VectorNodeSocket;
+ case SOCK_RGBA:
+ return &RNA_RGBANodeSocket;
+ default:
+ return &RNA_UnknownType;
+ }
+}
+
static char *rna_Node_path(PointerRNA *ptr)
{
bNodeTree *ntree= (bNodeTree*)ptr->id.data;
bNode *node= (bNode*)ptr->data;
int index = BLI_findindex(&ntree->nodes, node);
+ /* XXX: node index (and therefore path) gets changed around depending on order of nodetree!
+ * This means that node animation can switch from one node to another if you rearrange them.
+ * Needs a fix to make the path based on unique names/ids! */
return BLI_sprintfN("nodes[%d]", index);
}
+static char *rna_NodeSocket_path(PointerRNA *ptr)
+{
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
+ bNodeSocket *sock= (bNodeSocket*)ptr->data;
+ bNode *node;
+
+ int socketindex, nodeindex;
+
+ if (!nodeFindNode(ntree, sock, &node, NULL)) return;
+
+ /* XXX: node index (and therefore path) gets changed around depending on order of nodetree!
+ * This means that node animation can switch from one node to another if you rearrange them.
+ * Needs a fix to make the path based on unique names/ids! */
+ nodeindex = BLI_findindex(&ntree->nodes, node);
+
+ socketindex = BLI_findindex(&node->inputs, sock);
+ if (socketindex != -1)
+ return BLI_sprintfN("nodes[%d].inputs[%d]", nodeindex, socketindex);
+
+ socketindex = BLI_findindex(&node->outputs, sock);
+ if (socketindex != -1)
+ return BLI_sprintfN("nodes[%d].outputs[%d]", nodeindex, socketindex);
+
+}
+
static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup)
{
bNode *node;
@@ -192,29 +236,35 @@ static void rna_Matte_t2_set(PointerRNA *ptr, float value)
chroma->t2 = value;
}
-static void rna_Node_update(bContext *C, PointerRNA *ptr)
+static void node_update(bContext *C, bNodeTree *ntree, bNode *node)
{
Main *bmain= CTX_data_main(C);
- bNodeTree *ntree= (bNodeTree*)ptr->id.data;
- bNode *node= (bNode*)ptr->data;
Material *ma;
Tex *tex;
Scene *sce;
-
+
/* look through all datablocks, to support groups */
for(ma=bmain->mat.first; ma; ma=ma->id.next)
if(ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree))
ED_node_changed_update(&ma->id, node);
-
+
for(tex=bmain->tex.first; tex; tex=tex->id.next)
if(tex->nodetree && tex->use_nodes && has_nodetree(tex->nodetree, ntree))
ED_node_changed_update(&tex->id, node);
-
+
for(sce=bmain->scene.first; sce; sce=sce->id.next)
if(sce->nodetree && sce->use_nodes && has_nodetree(sce->nodetree, ntree))
ED_node_changed_update(&sce->id, node);
}
+static void rna_Node_update(bContext *C, PointerRNA *ptr)
+{
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
+ bNode *node= (bNode*)ptr->data;
+
+ node_update(C, ntree, node);
+}
+
static void rna_Node_update_name(bContext *C, PointerRNA *ptr)
{
bNode *node= (bNode*)ptr->data;
@@ -255,6 +305,24 @@ static void rna_Node_update_name(bContext *C, PointerRNA *ptr)
rna_Node_update(C, ptr);
}
+static void rna_NodeSocket_update(bContext *C, PointerRNA *ptr)
+{
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
+ bNodeSocket *sock= (bNodeSocket*)ptr->data;
+ bNode *node;
+
+ if (nodeFindNode(ntree, sock, &node, NULL))
+ node_update(C, ntree, node);
+}
+
+static void rna_NodeSocket_defvalue_range(PointerRNA *ptr, float *min, float *max)
+{
+ bNodeSocket *sock= (bNodeSocket*)ptr->data;
+
+ *min = sock->ns.min;
+ *max = sock->ns.max;
+}
+
static void rna_Node_mapping_update(bContext *C, PointerRNA *ptr)
{
bNode *node= (bNode*)ptr->data;
@@ -418,15 +486,9 @@ typedef struct NodeInfo
static NodeInfo nodes[MaxNodes];
-static void reg_node(
- int ID,
- int category,
- const char *enum_name,
- const char *struct_name,
- const char *base_name,
- const char *ui_name,
- const char *ui_desc
-){
+static void reg_node(int ID, int category, const char *enum_name, const char *struct_name,
+ const char *base_name, const char *ui_name, const char *ui_desc)
+{
NodeInfo *ni = nodes + ID;
ni->defined = 1;
@@ -1861,6 +1923,91 @@ static void rna_def_texture_node(BlenderRNA *brna)
/* -------------------------------------------------------------------------- */
+static void rna_def_node_socket(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ srna = RNA_def_struct(brna, "NodeSocket", NULL);
+ RNA_def_struct_ui_text(srna, "Node Socket", "Input or output socket of a node");
+ RNA_def_struct_refine_func(srna, "rna_NodeSocketType_refine");
+ RNA_def_struct_sdna(srna, "bNodeSocket");
+ RNA_def_struct_ui_icon(srna, ICON_PLUG);
+ RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
+
+}
+
+static void rna_def_node_socket_value(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "ValueNodeSocket", NULL);
+ RNA_def_struct_ui_text(srna, "Value Node Socket", "Input or output socket of a node");
+ RNA_def_struct_sdna(srna, "bNodeSocket");
+ RNA_def_struct_ui_icon(srna, ICON_PLUG);
+ RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Name", "Socket name.");
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "ns.vec");
+ RNA_def_property_array(prop, 1);
+ RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached.");
+ RNA_def_property_update(prop, 0, "rna_NodeSocket_update");
+ RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range");
+}
+
+static void rna_def_node_socket_vector(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "VectorNodeSocket", NULL);
+ RNA_def_struct_ui_text(srna, "Vector Node Socket", "Input or output socket of a node");
+ RNA_def_struct_sdna(srna, "bNodeSocket");
+ RNA_def_struct_ui_icon(srna, ICON_PLUG);
+ RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Name", "Socket name.");
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_float_sdna(prop, NULL, "ns.vec");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached.");
+ RNA_def_property_update(prop, 0, "rna_NodeSocket_update");
+ RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range");
+}
+
+static void rna_def_node_socket_rgba(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "RGBANodeSocket", NULL);
+ RNA_def_struct_ui_text(srna, "RGBA Node Socket", "Input or output socket of a node");
+ RNA_def_struct_sdna(srna, "bNodeSocket");
+ RNA_def_struct_ui_icon(srna, ICON_PLUG);
+ RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Name", "Socket name.");
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "ns.vec");
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached.");
+ RNA_def_property_update(prop, 0, "rna_NodeSocket_update");
+ RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range");
+}
+
static void rna_def_node(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1869,6 +2016,7 @@ static void rna_def_node(BlenderRNA *brna)
srna = RNA_def_struct(brna, "Node", NULL);
RNA_def_struct_ui_text(srna, "Node", "Node in a node tree.");
RNA_def_struct_sdna(srna, "bNode");
+ RNA_def_struct_ui_icon(srna, ICON_NODE);
RNA_def_struct_refine_func(srna, "rna_Node_refine");
RNA_def_struct_path_func(srna, "rna_Node_path");
@@ -1881,6 +2029,16 @@ static void rna_def_node(BlenderRNA *brna)
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Node name.");
RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
+ RNA_def_property_struct_type(prop, "NodeSocket");
+ RNA_def_property_ui_text(prop, "Inputs", "");
+
+ prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
+ RNA_def_property_struct_type(prop, "NodeSocket");
+ RNA_def_property_ui_text(prop, "Outputs", "");
}
static void rna_def_nodetree(BlenderRNA *brna)
@@ -1891,7 +2049,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
srna = RNA_def_struct(brna, "NodeTree", "ID");
RNA_def_struct_ui_text(srna, "Node Tree", "Node tree consisting of linked nodes used for materials, textures and compositing.");
RNA_def_struct_sdna(srna, "bNodeTree");
- RNA_def_struct_ui_icon(srna, ICON_NODE);
+ RNA_def_struct_ui_icon(srna, ICON_NODETREE);
rna_def_animdata_common(srna);
@@ -1913,6 +2071,10 @@ void RNA_def_nodetree(BlenderRNA *brna)
{
init();
rna_def_nodetree(brna);
+ rna_def_node_socket(brna);
+ rna_def_node_socket_value(brna);
+ rna_def_node_socket_vector(brna);
+ rna_def_node_socket_rgba(brna);
rna_def_node(brna);
rna_def_shader_node(brna);
rna_def_compositor_node(brna);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index a54e1b84709..6343a60cde8 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1434,7 +1434,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{8, "PROPERTIES", ICON_BUTS, "Properties", ""},
{9, "TEXT_EDITOR", ICON_TEXT, "Text Editor", ""},
{10, "TIMELINE", ICON_TIME, "Timeline", ""},
- {11, "NODE_EDITOR", ICON_NODE, "Node Editor", ""},
+ {11, "NODE_EDITOR", ICON_NODETREE, "Node Editor", ""},
{12, "LOGIC_EDITOR", ICON_LOGIC, "Logic Editor", ""},
{13, "OUTLINER", ICON_OOPS, "Outliner", ""},
{14, "INFO", ICON_INFO, "Info", ""},