diff options
author | Ton Roosendaal <ton@blender.org> | 2009-07-02 15:23:19 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-07-02 15:23:19 +0400 |
commit | c7bd0d12484d7abf18f74c2ed8405ad6f5888d99 (patch) | |
tree | 1e321658448196aa52d668e17dc4757ee84a259a /source/blender/editors/space_view3d/view3d_toolbar.c | |
parent | 421f44278cebff49a1485251f92a4277934c4e4c (diff) |
2.5
More toolbar functionality for workflow review.
- Split the region in two parts, bottom has the Tool Properties, the
top part shows 2 panels, one for python defined tools, other for a
"tool shelf" which (later) will get saved in files.
- Added a full context driven framework for this toolbar, showing
the tools depending on 3D window 'mode'. Both python defined tools
as the shelf respect this. So - for example - you will see different
tools in editmode mesh, as in vertex paint mode, etc.
- First template for the python tools will be committed after this commit;
it has placeholder tools to just show/test functioning.
NOTE: if you had saved a layout that shows tools region, open/close it
once to get the new region created for properties.
TODO:
- Moving paint properties to tool settings
- Test a layout with horizontal toolbar (without properties)
- Bring back floating panels, and put tool-properties here. (as option)
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_toolbar.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 98 |
1 files changed, 64 insertions, 34 deletions
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index ea365d59ac7..8aba8e11d43 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -150,9 +150,46 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) /* ******************* */ +char *view3d_context_string(const bContext *C) +{ + Object *obedit= CTX_data_edit_object(C); + + if(obedit) { + switch(obedit->type) { + case OB_MESH: + return "editmode_mesh"; + case OB_CURVE: + return "editmode_curve"; + case OB_SURF: + return "editmode_surface"; + case OB_FONT: + return "editmode_text"; + case OB_ARMATURE: + return "editmode_armature"; + case OB_MBALL: + return "editmode_mball"; + case OB_LATTICE: + return "editmode_lattice"; + } + } + else { + Object *ob = CTX_data_active_object(C); + + if(ob && (ob->flag & OB_POSEMODE)) return "posemode"; + else if (G.f & G_SCULPTMODE) return "sculptmode"; + else if (G.f & G_WEIGHTPAINT) return "weightpaint"; + else if (G.f & G_VERTEXPAINT) return "vertexpaint"; + else if (G.f & G_TEXTUREPAINT) return "texturepaint"; + else if(G.f & G_PARTICLEEDIT) return "particlemode"; + } + + return "objectmode"; +} + typedef struct CustomTool { struct CustomTool *next, *prev; char opname[OP_MAX_TYPENAME]; + char context[OP_MAX_TYPENAME]; } CustomTool; static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) @@ -164,6 +201,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); + BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME); } } @@ -221,43 +259,28 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) } -static void view3d_panel_tools(const bContext *C, Panel *pa) +static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) { - static ListBase tools= {NULL, NULL}; - Object *obedit= CTX_data_edit_object(C); -// Object *obact = CTX_data_active_object(C); + SpaceLink *sl= CTX_wm_space_data(C); + SpaceType *st= NULL; uiLayout *col; + const char *context= view3d_context_string(C); - if(obedit) { - if(obedit->type==OB_MESH) { - - 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); - } + if(sl) + st= BKE_spacetype_from_id(sl->spacetype); + + if(st && st->toolshelf.first) { + CustomTool *ct; + + for(ct= st->toolshelf.first; ct; ct= ct->next) { + if(0==strncmp(context, ct->context, OP_MAX_TYPENAME)) { + 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 { - - col= uiLayoutColumn(pa->layout, 1); - uiItemFullO(col, NULL, 0, "OBJECT_OT_delete", NULL, WM_OP_INVOKE_REGION_WIN); - uiItemFullO(col, NULL, 0, "OBJECT_OT_primitive_add", NULL, WM_OP_INVOKE_REGION_WIN); - - col= uiLayoutColumn(pa->layout, 1); - uiItemFullO(col, NULL, 0, "OBJECT_OT_parent_set", NULL, WM_OP_INVOKE_REGION_WIN); - uiItemFullO(col, NULL, 0, "OBJECT_OT_parent_clear", NULL, WM_OP_INVOKE_REGION_WIN); - - } + col= uiLayoutColumn(pa->layout, 1); + uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); } @@ -266,10 +289,15 @@ void view3d_toolbar_register(ARegionType *art) PanelType *pt; pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); - strcpy(pt->idname, "VIEW3D_PT_tools"); - strcpy(pt->label, "Tools"); - pt->draw= view3d_panel_tools; + strcpy(pt->idname, "VIEW3D_PT_tool_shelf"); + strcpy(pt->label, "Tool Shelf"); + pt->draw= view3d_panel_tool_shelf; BLI_addtail(&art->paneltypes, pt); +} + +void view3d_tool_props_register(ARegionType *art) +{ + PanelType *pt; pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); @@ -278,6 +306,8 @@ void view3d_toolbar_register(ARegionType *art) BLI_addtail(&art->paneltypes, pt); } +/* ********** operator to open/close toolbar region */ + static int view3d_toolbar(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); |