diff options
author | Ton Roosendaal <ton@blender.org> | 2009-06-27 19:21:37 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-06-27 19:21:37 +0400 |
commit | 9becf3c310b1051d1e9dc7170cb02d73bc4d6e08 (patch) | |
tree | e95731ff3437a74fc30668fe8f2d0eac39888cd3 | |
parent | c9513df56196c119dfa947fe76a96ddf095b3c5c (diff) |
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.
-rw-r--r-- | source/blender/editors/object/object_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 98 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 2 |
3 files changed, 89 insertions, 21 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 8102b1bfb9c..c436ccdb328 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -388,7 +388,7 @@ static int object_add_mesh_exec(bContext *C, wmOperator *op) 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 @@ static int object_add_curve_invoke(bContext *C, wmOperator *op, wmEvent *event) 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 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) 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 @@ static int object_add_text_exec(bContext *C, wmOperator *op) 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 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) 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"; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 88af60ac0f4..34a935103a7 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -148,8 +148,82 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) 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 @@ static void view3d_panel_tools(const bContext *C, Panel *pa) 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 { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index d13d8ec6ccc..861080f30ba 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -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"); - if(!BLI_exists(tstr)) - BLI_make_file_string(G.sce, tstr, home, ".B.blend"); } strcpy(scestr, G.sce); /* temporary store */ |