[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33706] branches/particles-2010/source/ blender: Improved the type selection button for data nodes.

Lukas Toenne lukas.toenne at googlemail.com
Thu Dec 16 11:18:32 CET 2010


Revision: 33706
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33706
Author:   lukastoenne
Date:     2010-12-16 11:18:32 +0100 (Thu, 16 Dec 2010)

Log Message:
-----------
Improved the type selection button for data nodes.

Modified Paths:
--------------
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-12-16 09:55:35 UTC (rev 33705)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-12-16 10:18:32 UTC (rev 33706)
@@ -1366,12 +1366,43 @@
 	case SIM_NODE_SETDATA:	sim_setdata_foreach_type(ntree, node, items, str, node_data_type_foreach_cb);	break;
 	}
 }
+static uiBlock *node_data_type_search_menu(bContext *C, ARegion *ar, void *arg)
+{
+	static char search[256];
+	bNode *node= ((NodeDataArgs*)arg)->node;
+	SimDataNode *data= (SimDataNode*)node->storage;
+	wmEvent event;
+	wmWindow *win= CTX_wm_window(C);
+	uiBlock *block;
+	uiBut *but;
+	
+	/* clear initial search string, then all items show */
+	search[0]= '\0';
+
+	block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+	uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1);
+	
+	/* fake button, it holds space for search items */
+	uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+	
+	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, 0, 0, "");
+	uiButSetSearchFunc(but, node_data_type_search_cb, arg, node_data_type_exec_cb, data->type);
+	
+	uiBoundsBlock(block, 6);
+	uiBlockSetDirection(block, UI_DOWN);
+	uiEndBlock(C, block);
+	
+	event= *(win->eventstate);	/* XXX huh huh? make api call */
+	event.type= EVT_BUT_OPEN;
+	event.val= KM_PRESS;
+	event.customdata= but;
+	event.customdatafree= FALSE;
+	wm_event_add(win, &event);
+	
+	return block;
+}
 static void node_data_type_search(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	/* XXX using static variables here is a hack, only reason is that these arguments must be persistent beyond this functions scope.
-	 * This should not be a problem as long as only one instance of these buttons is used at a time.
-	 */
-	static char search[256];
 	static NodeDataArgs args;
 	uiBlock *block;
 	uiBut *but;
@@ -1383,8 +1414,10 @@
 	block= uiLayoutGetBlock(layout);
 	uiBlockSetCurLayout(block, layout);
 
-	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 0, 0, UI_UNIT_X*25, UI_UNIT_Y, 0, 0, "Select the data node type");
-	uiButSetSearchFunc(but, node_data_type_search_cb, &args, node_data_type_exec_cb, NULL);
+	uiBlockBeginAlign(block);
+	but= uiDefBlockBut(block, node_data_type_search_menu, &args, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Browse data node types");
+	but= uiDefButR(block, TEX, 0, "", 0, 0, UI_UNIT_X*16, UI_UNIT_Y, ptr, "type", -1, 0, 0, -1, -1, NULL);
+	uiBlockEndAlign(block);
 }
 
 /* Search field for adding property sockets */
@@ -1452,18 +1485,12 @@
 
 static void node_simulation_buts_data(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	bNode *node= (bNode*)ptr->data;
-	SimDataNode *data= (SimDataNode*)node->storage;
-	uiLayout *col, *row;
+	uiLayout *col;
 	
 	col= uiLayoutColumn(layout, 0);
 	uiLayoutSetContextPointer(col, "node", ptr);
 
 	uiItemR(col, ptr, "path", 0, NULL, 0);
-
-//	row= uiLayoutRow(col, 0);
-//	uiItemL(row, "Type:", 0);
-//	uiItemL(row, RNA_struct_ui_name(data->type), RNA_struct_ui_icon(data->type));
 }
 
 static void node_simulation_detailbuts_getdata(uiLayout *layout, bContext *C, PointerRNA *ptr)

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-12-16 09:55:35 UTC (rev 33705)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-12-16 10:18:32 UTC (rev 33706)
@@ -185,10 +185,10 @@
 	
 	data->type = type;
 	
-	sprintf(node->name, "Get");
+	sprintf(node->name, "Get ");
 	if (data->type)
 		sprintf(node->name+strlen(node->name), "%s", RNA_struct_ui_name(data->type));
-	sprintf(node->name+strlen(node->name), "Data");
+	sprintf(node->name+strlen(node->name), " Data");
 	nodeUniqueName(ntree, node);
 }
 

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c	2010-12-16 09:55:35 UTC (rev 33705)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c	2010-12-16 10:18:32 UTC (rev 33706)
@@ -177,10 +177,10 @@
 	
 	data->type = type;
 	
-	sprintf(node->name, "Set");
+	sprintf(node->name, "Set ");
 	if (data->type)
 		sprintf(node->name+strlen(node->name), "%s", RNA_struct_ui_name(data->type));
-	sprintf(node->name+strlen(node->name), "Data");
+	sprintf(node->name+strlen(node->name), " Data");
 	nodeUniqueName(ntree, node);
 }
 





More information about the Bf-blender-cvs mailing list