diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-04-20 18:14:03 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-04-20 18:14:52 +0300 |
commit | 5f6c45498c92b91a710a1317f6d41f73fbe83477 (patch) | |
tree | 93b136fb49c656c2c2a5463c91e8a6a38d518354 /source/blender/blenloader | |
parent | 4bfb6d21df96688187f6f1a5d95dd62bcbf85116 (diff) |
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
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 120 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 57 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 45 |
4 files changed, 155 insertions, 69 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 73109413271..8d90a11f5d9 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -282,7 +282,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) else if (BKE_idcode_is_valid(bhead->code)) { if (BKE_idcode_is_linkable(bhead->code)) { const char *str = BKE_idcode_to_name(bhead->code); - + if (BLI_gset_add(gathered, (void *)str)) { BLI_linklist_prepend(&names, strdup(str)); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5dc98964fbd..b9f9fc638cc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6396,6 +6396,8 @@ static void direct_link_area(FileData *fd, ScrArea *area) area->type = NULL; /* spacetype callbacks */ area->region_active_win = -1; + area->global = newdataadr(fd, area->global); + /* if we do not have the spacetype registered we cannot * free it, so don't allocate any new memory for such spacetypes. */ if (!BKE_spacetype_exists(area->spacetype)) { @@ -6630,9 +6632,9 @@ static void direct_link_area(FileData *fd, ScrArea *area) area->v4 = newdataadr(fd, area->v4); } -static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) +static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) { - area->full = newlibadr(fd, sc->id.lib, area->full); + area->full = newlibadr(fd, parent_id->lib, area->full); for (SpaceLink *sl = area->spacedata.first; sl; sl= sl->next) { switch (sl->spacetype) { @@ -6640,11 +6642,11 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) { View3D *v3d = (View3D*) sl; - v3d->camera= newlibadr(fd, sc->id.lib, v3d->camera); - v3d->ob_centre= newlibadr(fd, sc->id.lib, v3d->ob_centre); + v3d->camera= newlibadr(fd, parent_id->lib, v3d->camera); + v3d->ob_centre= newlibadr(fd, parent_id->lib, v3d->ob_centre); if (v3d->localvd) { - v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera); + v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera); } break; } @@ -6654,15 +6656,15 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) bDopeSheet *ads = sipo->ads; if (ads) { - ads->source = newlibadr(fd, sc->id.lib, ads->source); - ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp); + ads->source = newlibadr(fd, parent_id->lib, ads->source); + ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); } break; } case SPACE_BUTS: { SpaceButs *sbuts = (SpaceButs *)sl; - sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid); + sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid); if (sbuts->pinid == NULL) { sbuts->flag &= ~SB_PIN_CONTEXT; } @@ -6676,24 +6678,24 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) bDopeSheet *ads = &saction->ads; if (ads) { - ads->source = newlibadr(fd, sc->id.lib, ads->source); - ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp); + ads->source = newlibadr(fd, parent_id->lib, ads->source); + ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); } - saction->action = newlibadr(fd, sc->id.lib, saction->action); + saction->action = newlibadr(fd, parent_id->lib, saction->action); break; } case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)sl; - sima->image = newlibadr_real_us(fd, sc->id.lib, sima->image); - sima->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sima->mask_info.mask); + sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image); + sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask); /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so fingers crossed this works fine! */ - sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd); + sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd); break; } case SPACE_SEQ: @@ -6703,7 +6705,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so fingers crossed this works fine! */ - sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd); + sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd); break; } case SPACE_NLA: @@ -6712,8 +6714,8 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) bDopeSheet *ads= snla->ads; if (ads) { - ads->source = newlibadr(fd, sc->id.lib, ads->source); - ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp); + ads->source = newlibadr(fd, parent_id->lib, ads->source); + ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); } break; } @@ -6721,7 +6723,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) { SpaceText *st= (SpaceText *)sl; - st->text= newlibadr(fd, sc->id.lib, st->text); + st->text= newlibadr(fd, parent_id->lib, st->text); break; } case SPACE_SCRIPT: @@ -6729,7 +6731,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) SpaceScript *scpt = (SpaceScript *)sl; /*scpt->script = NULL; - 2.45 set to null, better re-run the script */ if (scpt->script) { - scpt->script = newlibadr(fd, sc->id.lib, scpt->script); + scpt->script = newlibadr(fd, parent_id->lib, scpt->script); if (scpt->script) { SCRIPT_SET_NULL(scpt->script); } @@ -6763,11 +6765,11 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) bNodeTree *ntree; /* node tree can be stored locally in id too, link this first */ - snode->id = newlibadr(fd, sc->id.lib, snode->id); - snode->from = newlibadr(fd, sc->id.lib, snode->from); + snode->id = newlibadr(fd, parent_id->lib, snode->id); + snode->from = newlibadr(fd, parent_id->lib, snode->from); ntree = snode->id ? ntreeFromID(snode->id) : NULL; - snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree); + snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree); for (path = snode->treepath.first; path; path = path->next) { if (path == snode->treepath.first) { @@ -6775,7 +6777,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) path->nodetree = snode->nodetree; } else - path->nodetree = newlibadr_us(fd, sc->id.lib, path->nodetree); + path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree); if (!path->nodetree) break; @@ -6803,9 +6805,8 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) case SPACE_CLIP: { SpaceClip *sclip = (SpaceClip *)sl; - - sclip->clip = newlibadr_real_us(fd, sc->id.lib, sclip->clip); - sclip->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sclip->mask_info.mask); + sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip); + sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask); break; } default: @@ -6814,6 +6815,34 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area) } } +/** + * \return false on error. + */ +static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map) +{ + link_list(fd, &area_map->vertbase); + link_list(fd, &area_map->edgebase); + link_list(fd, &area_map->areabase); + for (ScrArea *area = area_map->areabase.first; area; area = area->next) { + direct_link_area(fd, area); + } + + /* edges */ + for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) { + se->v1 = newdataadr(fd, se->v1); + se->v2 = newdataadr(fd, se->v2); + BKE_screen_sort_scrvert(&se->v1, &se->v2); + + if (se->v1 == NULL) { + BLI_remlink(&area_map->edgebase, se); + + return false; + } + } + + return true; +} + /* ************ READ WM ***************** */ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) @@ -6830,6 +6859,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */ oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0); + direct_link_area_map(fd, &win->global_areas); + win->ghostwin = NULL; win->gwnctx = NULL; win->eventstate = NULL; @@ -6901,6 +6932,10 @@ static void lib_link_windowmanager(FileData *fd, Main *main) win->scene = newlibadr(fd, wm->id.lib, win->scene); /* deprecated, but needed for versioning (will be NULL'ed then) */ win->screen = newlibadr(fd, NULL, win->screen); + + for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + lib_link_area(fd, &wm->id, area); + } } wm->id.tag &= ~LIB_TAG_NEED_LINK; @@ -6927,7 +6962,7 @@ static void lib_link_screen(FileData *fd, Main *main) sc->scrubbing = false; for (ScrArea *area = sc->areabase.first; area; area = area->next) { - lib_link_area(fd, sc, area); + lib_link_area(fd, &sc->id, area); } sc->id.tag &= ~LIB_TAG_NEED_LINK; } @@ -7353,14 +7388,8 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) static bool direct_link_screen(FileData *fd, bScreen *sc) { - ScrArea *sa; - ScrVert *sv; - ScrEdge *se; bool wrong_id = false; - link_list(fd, &(sc->vertbase)); - link_list(fd, &(sc->edgebase)); - link_list(fd, &(sc->areabase)); sc->regionbase.first = sc->regionbase.last= NULL; sc->context = NULL; sc->active_region = NULL; @@ -7368,28 +7397,11 @@ static bool direct_link_screen(FileData *fd, bScreen *sc) sc->preview = direct_link_preview_image(fd, sc->preview); - /* edges */ - for (se = sc->edgebase.first; se; se = se->next) { - se->v1 = newdataadr(fd, se->v1); - se->v2 = newdataadr(fd, se->v2); - if ((intptr_t)se->v1 > (intptr_t)se->v2) { - sv = se->v1; - se->v1 = se->v2; - se->v2 = sv; - } - - if (se->v1 == NULL) { - printf("Error reading Screen %s... removing it.\n", sc->id.name+2); - BLI_remlink(&sc->edgebase, se); - wrong_id = true; - } + if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) { + printf("Error reading Screen %s... removing it.\n", sc->id.name + 2); + wrong_id = true; } - - /* areas */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - direct_link_area(fd, sa); - } - + return wrong_id; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 493bf17a552..18eff782d99 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -65,6 +65,7 @@ #include "BKE_node.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_screen.h" #include "BKE_workspace.h" #include "BLO_readfile.h" @@ -945,4 +946,60 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!DNA_struct_find(fd->filesdna, "SpaceTopBar")) { + /* Remove info editor, but only if at the top of the window. */ + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + /* Calculate window width/height from screen vertices */ + int win_width = 0, win_height = 0; + for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) { + win_width = MAX2(win_width, vert->vec.x); + win_height = MAX2(win_height, vert->vec.y); + } + + for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) { + area_next = area->next; + + if (area->spacetype == SPACE_INFO) { + if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) && (area->v4->vec.x == win_width)) { + BKE_screen_area_free(area); + + BLI_remlink(&screen->areabase, area); + + BKE_screen_remove_double_scredges(screen); + BKE_screen_remove_unused_scredges(screen); + BKE_screen_remove_unused_scrverts(screen); + + MEM_freeN(area); + } + } + /* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas + * which are deleted above, so don't need to unset it. Its slot/bit can be reused */ + } + } + } + +#ifdef WITH_REDO_REGION_REMOVAL + if (!MAIN_VERSION_ATLEAST(main, 280, TO_BE_DETERMINED)) { + /* Remove tool property regions. */ + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) { + ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + + for (ARegion *region = regionbase->first, *region_next; region; region = region_next) { + region_next = region->next; + + if (region->regiontype == RGN_TYPE_TOOL_PROPS) { + BKE_area_region_free(NULL, region); + BLI_freelinkN(regionbase, region); + } + } + } + } + } + } + } +#endif } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d137510b510..ea6a18b2b48 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2878,8 +2878,12 @@ static void write_area_regions(WriteData *wd, ScrArea *area) writedata(wd, DATA, cl->len + 1, cl->line); } writestruct(wd, DATA, SpaceConsole, 1, sl); - } +#ifdef WITH_TOPBAR_WRITING + else if (sl->spacetype == SPACE_TOPBAR) { + writestruct(wd, DATA, SpaceTopBar, 1, sl); + } +#endif else if (sl->spacetype == SPACE_USERPREF) { writestruct(wd, DATA, SpaceUserPref, 1, sl); } @@ -2890,7 +2894,21 @@ static void write_area_regions(WriteData *wd, ScrArea *area) writestruct(wd, DATA, SpaceInfo, 1, sl); } } +} + +static void write_area_map(WriteData *wd, ScrAreaMap *area_map) +{ + writelist(wd, DATA, ScrVert, &area_map->vertbase); + writelist(wd, DATA, ScrEdge, &area_map->edgebase); + for (ScrArea *area = area_map->areabase.first; area; area = area->next) { + writestruct(wd, DATA, ScrArea, 1, area); + +#ifdef WITH_TOPBAR_WRITING + writestruct(wd, DATA, ScrGlobalAreaData, 1, area->global); +#endif + write_area_regions(wd, area); + } } static void write_windowmanager(WriteData *wd, wmWindowManager *wm) @@ -2899,6 +2917,11 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm) write_iddata(wd, &wm->id); for (wmWindow *win = wm->windows.first; win; win = win->next) { +#ifndef WITH_TOPBAR_WRITING + /* Don't write global areas yet, while we make changes to them. */ + ScrAreaMap global_areas = win->global_areas; + memset(&win->global_areas, 0, sizeof(win->global_areas)); +#endif /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */ win->screen = BKE_workspace_active_screen_get(win->workspace_hook); @@ -2907,6 +2930,12 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm) writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook); writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format); +#ifdef WITH_TOPBAR_WRITING + write_area_map(wd, &win->global_areas); +#else + win->global_areas = global_areas; +#endif + /* data is written, clear deprecated data again */ win->screen = NULL; } @@ -2922,19 +2951,7 @@ static void write_screen(WriteData *wd, bScreen *sc) write_previews(wd, sc->preview); /* direct data */ - for (ScrVert *sv = sc->vertbase.first; sv; sv = sv->next) { - writestruct(wd, DATA, ScrVert, 1, sv); - } - - for (ScrEdge *se = sc->edgebase.first; se; se = se->next) { - writestruct(wd, DATA, ScrEdge, 1, se); - } - - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - writestruct(wd, DATA, ScrArea, 1, sa); - - write_area_regions(wd, sa); - } + write_area_map(wd, AREAMAP_FROM_SCREEN(sc)); } static void write_bone(WriteData *wd, Bone *bone) |