[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21194] branches/blender2.5/blender/source /blender: 2.5

Ton Roosendaal ton at blender.org
Sat Jun 27 17:21:37 CEST 2009


Revision: 21194
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21194
Author:   ton
Date:     2009-06-27 17:21:37 +0200 (Sat, 27 Jun 2009)

Log Message:
-----------
2.5

Test commit; toolbar has 'add operator' menu in mesh editmode.
Nothing stored, freed here...

Also: removed reading .B.blend, since a much better default has
been compiled in now, prevents confusing testers who run 2.5
for the first time. :) Of course .B25.blend still works.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c

Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-06-27 14:35:24 UTC (rev 21193)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-06-27 15:21:37 UTC (rev 21194)
@@ -388,7 +388,7 @@
 void OBJECT_OT_mesh_add(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name= "Mesh";
+	ot->name= "Add Mesh";
 	ot->description = "Add a mesh object to the scene.";
 	ot->idname= "OBJECT_OT_mesh_add";
 	
@@ -462,7 +462,7 @@
 void OBJECT_OT_curve_add(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name= "Curve";
+	ot->name= "Add Curve";
 	ot->description = "Add a curve object to the scene.";
 	ot->idname= "OBJECT_OT_curve_add";
 	
@@ -520,7 +520,7 @@
 void OBJECT_OT_surface_add(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name= "Surface";
+	ot->name= "Add Surface";
 	ot->description = "Add a surface object to the scene.";
 	ot->idname= "OBJECT_OT_surface_add";
 	
@@ -557,7 +557,7 @@
 void OBJECT_OT_text_add(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name= "Text";
+	ot->name= "Add Text";
 	ot->description = "Add a text object to the scene";
 	ot->idname= "OBJECT_OT_text_add";
 	
@@ -602,7 +602,7 @@
 void OBJECT_OT_armature_add(wmOperatorType *ot)
 {	
 	/* identifiers */
-	ot->name= "Armature";
+	ot->name= "Add Armature";
 	ot->description = "Add an armature object to the scene.";
 	ot->idname= "OBJECT_OT_armature_add";
 	

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c	2009-06-27 14:35:24 UTC (rev 21193)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c	2009-06-27 15:21:37 UTC (rev 21194)
@@ -148,8 +148,82 @@
 	uiDefAutoButsRNA(C, pa->layout, &ptr, 1);
 }
 
+/* ******************* */
+
+typedef struct CustomTool {
+	struct CustomTool *next, *prev;
+	char opname[OP_MAX_TYPENAME];
+} CustomTool;
+
+static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2)
+{
+	wmOperatorType *ot= arg2;
+	
+	if(ot) {
+		CustomTool *ct= MEM_callocN(sizeof(CustomTool), "CustomTool");
+		
+		BLI_addtail(arg_listbase, ct);
+		BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME);
+	}
+		
+}
+
+static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items)
+{
+	wmOperatorType *ot = WM_operatortype_first();
+	
+	for(; ot; ot= ot->next) {
+		
+		if(BLI_strcasestr(ot->name, str)) {
+			if(ot->poll==NULL || ot->poll((bContext *)C)) {
+				
+				if(0==uiSearchItemAdd(items, ot->name, ot, 0))
+					break;
+			}
+		}
+	}
+}
+
+
+/* ID Search browse menu, open */
+static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
+{
+	static char search[OP_MAX_TYPENAME];
+	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, OP_MAX_TYPENAME, 10, 0, 150, 19, "");
+	uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb);
+	
+	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 view3d_panel_tools(const bContext *C, Panel *pa)
 {
+	static ListBase tools= {NULL, NULL};
 	Object *obedit= CTX_data_edit_object(C);
 //	Object *obact = CTX_data_active_object(C);
 	uiLayout *col;
@@ -157,24 +231,20 @@
 	if(obedit) {
 		if(obedit->type==OB_MESH) {
 			
-			// void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context)
 			col= uiLayoutColumn(pa->layout, 1);
-			uiItemFullO(col, NULL, 0, "MESH_OT_delete", NULL, WM_OP_INVOKE_REGION_WIN);
-			
-			col= uiLayoutColumn(pa->layout, 1);
-			uiItemFullO(col, NULL, 0, "MESH_OT_subdivide", NULL, WM_OP_INVOKE_REGION_WIN);
-			
-			col= uiLayoutColumn(pa->layout, 1);
-			uiItemFullO(col, NULL, 0, "MESH_OT_primitive_monkey_add", NULL, WM_OP_INVOKE_REGION_WIN);
-			uiItemFullO(col, NULL, 0, "MESH_OT_primitive_uv_sphere_add", NULL, WM_OP_INVOKE_REGION_WIN);
-			
-			col= uiLayoutColumn(pa->layout, 1);
-			uiItemFullO(col, NULL, 0, "MESH_OT_select_all_toggle", NULL, WM_OP_INVOKE_REGION_WIN);
-			
-			col= uiLayoutColumn(pa->layout, 1);
 			uiItemFullO(col, NULL, 0, "MESH_OT_spin", NULL, WM_OP_INVOKE_REGION_WIN);
 			uiItemFullO(col, NULL, 0, "MESH_OT_screw", NULL, WM_OP_INVOKE_REGION_WIN);
 			
+			if(tools.first) {
+				CustomTool *ct;
+				
+				for(ct= tools.first; ct; ct= ct->next) {
+					col= uiLayoutColumn(pa->layout, 1);
+					uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN);
+				}
+			}
+			col= uiLayoutColumn(pa->layout, 1);
+			uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &tools, "Add Operator", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add tool");
 		}
 	}
 	else {

Modified: branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c	2009-06-27 14:35:24 UTC (rev 21193)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c	2009-06-27 15:21:37 UTC (rev 21194)
@@ -294,8 +294,6 @@
 	G.relbase_valid = 0;
 	if (!from_memory) {
 		BLI_make_file_string(G.sce, tstr, home, ".B25.blend");
-		if(!BLI_exists(tstr))
-			BLI_make_file_string(G.sce, tstr, home, ".B.blend");
 	}
 	strcpy(scestr, G.sce);	/* temporary store */
 	





More information about the Bf-blender-cvs mailing list