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/windowmanager/intern/wm_draw.c | 75 +++++++++++++-------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_draw.c') diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index c650bfe08c9..99319e009c8 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -162,6 +162,14 @@ static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph * } } +static void wm_draw_region(bContext *C, ARegion *ar) +{ + CTX_wm_region_set(C, ar); + ED_region_do_draw(C, ar); + ar->do_draw = false; + CTX_wm_region_set(C, NULL); +} + /********************** draw all **************************/ /* - reference method, draw all each time */ @@ -208,11 +216,10 @@ static void wm_draw_callbacks(wmWindow *win) static void wm_method_draw_full(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; /* draw area regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { @@ -254,12 +261,11 @@ static void wm_method_draw_full(bContext *C, wmWindow *win) /* same buffer as we swapped to the front */ /* mark area-regions to redraw if overlapped with rect */ -static void wm_flush_regions_down(bScreen *screen, rcti *dirty) +static void wm_flush_regions_down(wmWindow *win, bScreen *screen, rcti *dirty) { - ScrArea *sa; ARegion *ar; - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) { ar->do_draw = RGN_DRAW; @@ -288,24 +294,25 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) { wmWindowManager *wm = CTX_wm_manager(C); bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; static rcti rect = {0, 0, 0, 0}; /* after backbuffer selection draw, we need to redraw */ - for (sa = screen->areabase.first; sa; sa = sa->next) + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->visible && !wm_area_test_invalid_backbuf(sa)) ED_region_tag_redraw(ar); + } /* flush overlapping regions */ if (screen->regionbase.first) { /* flush redraws of area regions up to overlapping regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->visible && ar->do_draw) wm_flush_regions_up(screen, &ar->winrct); - + } + /* flush between overlapping regions */ for (ar = screen->regionbase.last; ar; ar = ar->prev) if (ar->visible && ar->do_draw) @@ -314,12 +321,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) /* flush redraws of overlapping regions down to area regions */ for (ar = screen->regionbase.last; ar; ar = ar->prev) if (ar->visible && ar->do_draw) - wm_flush_regions_down(screen, &ar->winrct); + wm_flush_regions_down(win, screen, &ar->winrct); } /* flush drag item */ if (rect.xmin != rect.xmax) { - wm_flush_regions_down(screen, &rect); + wm_flush_regions_down(win, screen, &rect); rect.xmin = rect.xmax = 0; } if (wm->drags.first) { @@ -328,7 +335,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) } /* draw marked area regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { @@ -526,7 +533,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) wmWindowManager *wm = CTX_wm_manager(C); wmDrawData *dd, *dd_next, *drawdata = win->drawdata.first; bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; bool copytex = false; @@ -567,17 +573,14 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) wmDrawTriple *triple = drawdata->triple; - /* draw marked area regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + /* draw marked area regions (also global ones) */ + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->do_draw) { if (ar->overlap == false) { - CTX_wm_region_set(C, ar); - ED_region_do_draw(C, ar); - ar->do_draw = false; - CTX_wm_region_set(C, NULL); + wm_draw_region(C, ar); copytex = true; } } @@ -594,7 +597,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } if (wm->paintcursors.first) { - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar == screen->active_region) { CTX_wm_area_set(C, sa); @@ -614,16 +617,12 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } /* draw overlapping area regions (always like popups) */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->overlap) { - CTX_wm_region_set(C, ar); - ED_region_do_draw(C, ar); - ar->do_draw = false; - CTX_wm_region_set(C, NULL); - + wm_draw_region(C, ar); wm_draw_region_blend(win, ar, triple); } } @@ -662,7 +661,6 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV wmDrawData *drawdata; wmDrawTriple *triple_data, *triple_all; bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; int copytex = false; int id; @@ -703,7 +701,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV triple_all = ((wmDrawData *) BLI_findlink(&win->drawdata, (sview * 2) + 1))->triple; /* draw marked area regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); switch (sa->spacetype) { @@ -769,7 +767,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV } if (wm->paintcursors.first) { - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar == screen->active_region) { CTX_wm_area_set(C, sa); @@ -789,7 +787,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV } /* draw overlapping area regions (always like popups) */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { @@ -849,7 +847,6 @@ static bool wm_draw_update_test_window(wmWindow *win) /*const*/ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); const bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; bool do_draw = false; @@ -862,7 +859,7 @@ static bool wm_draw_update_test_window(wmWindow *win) do_draw = true; } - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { wm_region_test_render_do_draw(scene, depsgraph, sa, ar); @@ -963,8 +960,7 @@ void wm_draw_update(bContext *C) wm_window_make_drawable(wm, win); /* notifiers for screen redraw */ - if (screen->do_refresh) - ED_screen_refresh(wm, win); + ED_screen_ensure_updated(wm, win, screen); int drawmethod = wm_automatic_draw_method(win); @@ -1011,17 +1007,18 @@ void wm_draw_data_free(wmWindow *win) void wm_draw_window_clear(wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; ARegion *ar; wm_draw_data_free(win); /* clear screen swap flags */ if (screen) { - for (sa = screen->areabase.first; sa; sa = sa->next) - for (ar = sa->regionbase.first; ar; ar = ar->next) + ED_screen_areas_iter(win, screen, sa) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { ar->swap = WIN_NONE_OK; - + } + } + screen->swap = WIN_NONE_OK; } } @@ -1032,7 +1029,7 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar) int drawmethod = wm_automatic_draw_method(win); if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) - wm_flush_regions_down(screen, &ar->winrct); + wm_flush_regions_down(win, screen, &ar->winrct); screen->do_draw = true; } -- cgit v1.2.3