2.5
authorTon Roosendaal <ton@blender.org>
Sat, 27 Jun 2009 15:21:37 +0000 (15:21 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 27 Jun 2009 15:21:37 +0000 (15:21 +0000)
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.

source/blender/editors/object/object_edit.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/windowmanager/intern/wm_files.c

index 8102b1bfb9ca3ed934af41b694b9f70490085ba3..c436ccdb328473c6a1f328d9b6ca80dd0b2b220d 100644 (file)
@@ -388,7 +388,7 @@ static int object_add_mesh_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_mesh_add(wmOperatorType *ot)
 {
        /* identifiers */
 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";
        
        ot->description = "Add a mesh object to the scene.";
        ot->idname= "OBJECT_OT_mesh_add";
        
@@ -462,7 +462,7 @@ static int object_add_curve_invoke(bContext *C, wmOperator *op, wmEvent *event)
 void OBJECT_OT_curve_add(wmOperatorType *ot)
 {
        /* identifiers */
 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";
        
        ot->description = "Add a curve object to the scene.";
        ot->idname= "OBJECT_OT_curve_add";
        
@@ -520,7 +520,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_surface_add(wmOperatorType *ot)
 {
        /* identifiers */
 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";
        
        ot->description = "Add a surface object to the scene.";
        ot->idname= "OBJECT_OT_surface_add";
        
@@ -557,7 +557,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_text_add(wmOperatorType *ot)
 {
        /* identifiers */
 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";
        
        ot->description = "Add a text object to the scene";
        ot->idname= "OBJECT_OT_text_add";
        
@@ -602,7 +602,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_armature_add(wmOperatorType *ot)
 {      
        /* identifiers */
 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";
        
        ot->description = "Add an armature object to the scene.";
        ot->idname= "OBJECT_OT_armature_add";
        
index 88af60ac0f489e864d56074efc76edfc96a48851..34a935103a7c7bfd9d5f041532e21726727a0d61 100644 (file)
@@ -148,8 +148,82 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
        uiDefAutoButsRNA(C, pa->layout, &ptr, 1);
 }
 
        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 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;
        Object *obedit= CTX_data_edit_object(C);
 //     Object *obact = CTX_data_active_object(C);
        uiLayout *col;
@@ -157,24 +231,20 @@ static void view3d_panel_tools(const bContext *C, Panel *pa)
        if(obedit) {
                if(obedit->type==OB_MESH) {
                        
        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);
                        
                        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 {
                }
        }
        else {
index d13d8ec6ccc66a8eb7e91424cb85e34b0cb6c727..861080f30ba82a0aaaf1690ec2459d9a7a729407 100644 (file)
@@ -294,8 +294,6 @@ int WM_read_homefile(bContext *C, wmOperator *op)
        G.relbase_valid = 0;
        if (!from_memory) {
                BLI_make_file_string(G.sce, tstr, home, ".B25.blend");
        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 */
        
        }
        strcpy(scestr, G.sce);  /* temporary store */