[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32701] branches/particles-2010/source/ blender: Modified the search field in the node buttons n-panel to also allow custom property names .

Lukas Toenne lukas.toenne at googlemail.com
Mon Oct 25 15:36:52 CEST 2010


Revision: 32701
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32701
Author:   lukastoenne
Date:     2010-10-25 15:36:52 +0200 (Mon, 25 Oct 2010)

Log Message:
-----------
Modified the search field in the node buttons n-panel to also allow custom property names. These are added as untyped sockets. Also the search field is now cleared afterwards.

Modified Paths:
--------------
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-10-25 11:55:23 UTC (rev 32700)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-10-25 13:36:52 UTC (rev 32701)
@@ -1283,12 +1283,20 @@
 {
 	SpaceNode *snode= CTX_wm_space_node(C);
 	bNode *node= (bNode*)arg1;
+	SimDataNode *data= (SimDataNode*)node->storage;
 	const char *prop= (const char*)arg2;
 	
 	if (prop) {
 		sim_getdata_add_property_socket(node, prop);
-		snode_notify(C, snode);
 	}
+	else {
+		/* add dynamic property */
+		sim_getdata_add_property_socket(node, data->propsearch);
+	}
+	/* clear the search field */
+	data->propsearch[0] = '\0';
+	
+	snode_notify(C, snode);
 }
 static int getdata_add_property_foreach_cb(void *items, const char *str, const char *name, const char *identifier, int icon)
 {
@@ -1303,14 +1311,14 @@
 }
 static void getdata_add_property_search(uiLayout *layout, bNode *node)
 {
+	SimDataNode *data= (SimDataNode*)node->storage;
 	uiBlock *block;
 	uiBut *but;
-	static char search[256]= "";
 		
 	block= uiLayoutGetBlock(layout);
 	uiBlockSetCurLayout(block, layout);
 
-	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X*6, UI_UNIT_Y, 0, 0, "");
+	but= uiDefSearchBut(block, data->propsearch, 0, ICON_VIEWZOOM, sizeof(data->propsearch), 0, 0, UI_UNIT_X*6, UI_UNIT_Y, 0, 0, "");
 	uiButSetSearchFunc(but, getdata_add_property_search_cb, node, getdata_add_property_exec_cb, NULL);
 }
 static void node_simulation_detailbuts_getdata(uiLayout *layout, bContext *C, PointerRNA *ptr)
@@ -1354,12 +1362,20 @@
 {
 	SpaceNode *snode= CTX_wm_space_node(C);
 	bNode *node= (bNode*)arg1;
+	SimDataNode *data= (SimDataNode*)node->storage;
 	const char *prop= (const char*)arg2;
 	
 	if (prop) {
 		sim_setdata_add_property_socket(node, prop);
-		snode_notify(C, snode);
 	}
+	else {
+		/* add dynamic property */
+		sim_setdata_add_property_socket(node, data->propsearch);
+	}
+	/* clear the search field */
+	data->propsearch[0] = '\0';
+	
+	snode_notify(C, snode);
 }
 static int setdata_add_property_foreach_cb(void *items, const char *str, const char *name, const char *identifier, int icon)
 {
@@ -1374,14 +1390,14 @@
 }
 static void setdata_add_property_search(uiLayout *layout, bNode *node)
 {
+	SimDataNode *data= (SimDataNode*)node->storage;
 	uiBlock *block;
 	uiBut *but;
-	static char search[256]= "";
 		
 	block= uiLayoutGetBlock(layout);
 	uiBlockSetCurLayout(block, layout);
 
-	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X*6, UI_UNIT_Y, 0, 0, "");
+	but= uiDefSearchBut(block, data->propsearch, 0, ICON_VIEWZOOM, sizeof(data->propsearch), 0, 0, UI_UNIT_X*6, UI_UNIT_Y, 0, 0, "");
 	uiButSetSearchFunc(but, setdata_add_property_search_cb, node, setdata_add_property_exec_cb, NULL);
 }
 static void node_simulation_detailbuts_setdata(uiLayout *layout, bContext *C, PointerRNA *ptr)

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-25 11:55:23 UTC (rev 32700)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-25 13:36:52 UTC (rev 32701)
@@ -397,6 +397,8 @@
 	/* only used during read/write file! */
 	const char *save_type;			/* identifier string */
 	char path[128];
+	
+	char propsearch[128];			/* used as search string when adding property sockets */
 } SimDataNode;
 
 /* comp channel matte */





More information about the Bf-blender-cvs mailing list