diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-29 13:24:08 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-29 23:11:12 +0300 |
commit | 7a9f64e6657a231289f56b0a8c9949c8f7a23c59 (patch) | |
tree | efee3c4ac1988ad96d743f1d82e7a677096ca0c3 /source/blender/windowmanager/intern | |
parent | 0c512a6f951e36e29d2f6865cc975f7e40c4d31d (diff) |
UI: better support for dynamically sized regions in topbar.
Dynamically sized regions in the topbar were flickering due to only updating
their size after redraws. Now there is an optional layout() callback for
all regions in an area to do UI layout first, then refresh the region layout,
and then do the actual drawing for each region.
Task T54753
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index f111bc3e2d1..685e6f7e216 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -489,12 +489,25 @@ GPUViewport *WM_draw_region_get_bound_viewport(ARegion *ar) static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) { + wmWindowManager *wm = CTX_wm_manager(C); bScreen *screen = WM_window_get_active_screen(win); /* Draw screen areas into own frame buffer. */ ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); + /* Compute UI layouts for dynamically size regions. */ + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->visible && ar->do_draw && ar->type && ar->type->layout) { + CTX_wm_region_set(C, ar); + ED_region_do_layout(C, ar); + CTX_wm_region_set(C, NULL); + } + } + + ED_area_update_region_sizes(wm, win, sa); + + /* Then do actual drawing of regions. */ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->do_draw) { CTX_wm_region_set(C, ar); @@ -539,11 +552,11 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) if (ar->visible) { CTX_wm_menu_set(C, ar); - if (ar->type && ar->type->refresh) { - /* UI code reads the OpenGL state, but we have to - * refresh beforehand in case the menu size changes. */ + if (ar->type && ar->type->layout) { + /* UI code reads the OpenGL state, but we have to refesh + * the UI layout beforehand in case the menu size changes. */ wmViewport(&ar->winrct); - ar->type->refresh(C, ar); + ar->type->layout(C, ar); } wm_draw_region_buffer_create(ar, false, false); |