diff options
Diffstat (limited to 'source/blender/editors/space_view3d/space_view3d.c')
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 625b1838951..1ea69d595d3 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -97,29 +97,45 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) ARegion *view3d_has_tools_region(ScrArea *sa) { - ARegion *ar, *arnew; + ARegion *ar, *artool=NULL, *arprops=NULL, *arhead; - for(ar= sa->regionbase.first; ar; ar= ar->next) + for(ar= sa->regionbase.first; ar; ar= ar->next) { if(ar->regiontype==RGN_TYPE_TOOLS) - return ar; - - /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - - /* is error! */ - if(ar==NULL) return NULL; - - arnew= MEM_callocN(sizeof(ARegion), "tools for view3d"); + artool= ar; + if(ar->regiontype==RGN_TYPE_TOOL_PROPS) + arprops= ar; + } - BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_TOOLS; - arnew->alignment= RGN_OVERLAP_LEFT; + /* tool region hide/unhide also hides props */ + if(arprops && artool) return artool; - arnew->flag = RGN_FLAG_HIDDEN; + if(artool==NULL) { + /* add subdiv level; after header */ + for(arhead= sa->regionbase.first; arhead; arhead= arhead->next) + if(arhead->regiontype==RGN_TYPE_HEADER) + break; + + /* is error! */ + if(arhead==NULL) return NULL; + + artool= MEM_callocN(sizeof(ARegion), "tools for view3d"); + + BLI_insertlinkafter(&sa->regionbase, arhead, artool); + artool->regiontype= RGN_TYPE_TOOLS; + artool->alignment= RGN_OVERLAP_LEFT; + artool->flag = RGN_FLAG_HIDDEN; + } + + if(arprops==NULL) { + /* add extra subdivided region for tool properties */ + arprops= MEM_callocN(sizeof(ARegion), "tool props for view3d"); + + BLI_insertlinkafter(&sa->regionbase, artool, arprops); + arprops->regiontype= RGN_TYPE_TOOL_PROPS; + arprops->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + } - return arnew; + return artool; } /* ****************************************************** */ @@ -559,9 +575,11 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); } + + static void view3d_tools_area_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, 1, NULL); + ED_region_panels(C, ar, 1, view3d_context_string(C)); } /* @@ -860,6 +878,20 @@ void ED_spacetype_view3d(void) BLI_addhead(&st->regiontypes, art); view3d_toolbar_register(art); + + /* regions: tool properties */ + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art->regionid = RGN_TYPE_TOOL_PROPS; + art->minsizex= 0; + art->minsizey= 120; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->listener= view3d_buttons_area_listener; + art->init= view3d_tools_area_init; + art->draw= view3d_tools_area_draw; + BLI_addhead(&st->regiontypes, art); + + view3d_tool_props_register(art); + /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); |