From 5f6c45498c92b91a710a1317f6d41f73fbe83477 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 20 Apr 2018 17:14:03 +0200 Subject: UI: New Global Top-Bar (WIP) == Main Features/Changes for Users * Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars. * Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector. * Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here. * Individual sections of the topbar are individually scrollable. * Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting. * Top-bar should scale nicely with DPI. * The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes). * Info editors at the top of the window and using the full window width with be replaced by the top-bar. * In fullscreen modes, no more info editor is added on top, the top-bar replaces it. == Technical Features/Changes * Adds initial support for global areas A global area is part of the window, not part of the regular screen-layout. I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas. * Adds a TOPBAR editor type The editor type is hidden in the UI editor type menu. * Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY) * Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar. * Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds. The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved. * Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code. Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being. NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility. == ToDo's It's a bit hard to predict all the ToDo's here are the known main ones: * Add options for the new active-tool system and for operator redo to the topbar. * Automatically hide the top-bar in fullscreen modes. * General visual polish. * Top-bar drag & drop support (WIP in temp-tab_drag_drop). * Improve dynamic regions (should also fix some layout glitches). * Make internal terminology consistent. * Enable topbar file writing once design is more advanced. * Address TODO's and XXX's in code :) Thanks @brecht for the review! And @sergey for the complaining ;) Differential Revision: D2758 --- source/blender/blenkernel/intern/context.c | 8 ++++++++ source/blender/blenkernel/intern/screen.c | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index f5a0d4e7c60..4efd6dee6f6 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -831,6 +831,14 @@ struct SpaceClip *CTX_wm_space_clip(const bContext *C) return NULL; } +struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype == SPACE_TOPBAR) + return sa->spacedata.first; + return NULL; +} + void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { C->wm.manager = wm; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 8283655503c..77f7b5f847e 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -397,6 +397,7 @@ void BKE_screen_area_free(ScrArea *sa) for (ar = sa->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); + MEM_SAFE_FREE(sa->global); BLI_freelistN(&sa->regionbase); BKE_spacedata_freelist(&sa->spacedata); @@ -404,10 +405,21 @@ void BKE_screen_area_free(ScrArea *sa) BLI_freelistN(&sa->actionzones); } +void BKE_screen_area_map_free(ScrAreaMap *area_map) +{ + for (ScrArea *area = area_map->areabase.first, *area_next; area; area = area_next) { + area_next = area->next; + BKE_screen_area_free(area); + } + + BLI_freelistN(&area_map->vertbase); + BLI_freelistN(&area_map->edgebase); + BLI_freelistN(&area_map->areabase); +} + /** Free (or release) any data used by this screen (does not free the screen itself). */ void BKE_screen_free(bScreen *sc) { - ScrArea *sa, *san; ARegion *ar; /* No animdata here. */ @@ -416,18 +428,11 @@ void BKE_screen_free(bScreen *sc) BKE_area_region_free(NULL, ar); BLI_freelistN(&sc->regionbase); - - for (sa = sc->areabase.first; sa; sa = san) { - san = sa->next; - BKE_screen_area_free(sa); - } - - BLI_freelistN(&sc->vertbase); - BLI_freelistN(&sc->edgebase); - BLI_freelistN(&sc->areabase); + + BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(sc)); BKE_previewimg_free(&sc->preview); - + /* Region and timer are freed by the window manager. */ MEM_SAFE_FREE(sc->tool_tip); } -- cgit v1.2.3