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/windowmanager/intern | |
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/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 75 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 55 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 34 |
5 files changed, 120 insertions, 63 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 27107299863..91e47b67130 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -165,6 +165,11 @@ void wm_operator_register(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); int tot = 0; +#ifdef WITH_REDO_REGION_REMOVAL + op->execution_area = CTX_wm_area(C); + op->execution_region = CTX_wm_region(C); +#endif + BLI_addtail(&wm->operators, op); /* only count registered operators */ @@ -465,7 +470,8 @@ void wm_add_default(Main *bmain, bContext *C) WM_window_set_active_workspace(win, workspace); WM_window_set_active_layout(win, workspace, layout); screen->winid = win->winid; - + ED_screen_global_areas_create(win); + wm->winactive = win; wm->file_saved = 1; wm_window_make_drawable(wm, win); 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; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6ec68614116..218f48e9be6 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -386,6 +386,13 @@ void wm_event_do_notifiers(bContext *C) if (G.debug & G_DEBUG_EVENTS) printf("%s: Workspace set %p\n", __func__, note->reference); } + else if (note->data == ND_WORKSPACE_DELETE) { + WorkSpace *workspace = note->reference; + + ED_workspace_delete(workspace, CTX_data_main(C), C, wm); // XXX hrms, think this over! + if (G.debug & G_DEBUG_EVENTS) + printf("%s: Workspace delete %p\n", __func__, workspace); + } else if (note->data == ND_LAYOUTBROWSE) { bScreen *ref_screen = BKE_workspace_layout_screen_get(note->reference); @@ -455,7 +462,6 @@ void wm_event_do_notifiers(bContext *C) /* pass */ } else { - ScrArea *sa; ARegion *ar; /* XXX context in notifiers? */ @@ -467,8 +473,8 @@ void wm_event_do_notifiers(bContext *C) for (ar = screen->regionbase.first; ar; ar = ar->next) { ED_region_do_listen(screen, NULL, ar, note, scene); } - - for (sa = screen->areabase.first; sa; sa = sa->next) { + + ED_screen_areas_iter(win, screen, sa) { ED_area_do_listen(screen, sa, note, scene, workspace); for (ar = sa->regionbase.first; ar; ar = ar->next) { ED_region_do_listen(screen, sa, ar, note, scene); @@ -938,7 +944,18 @@ int WM_operator_call_notest(bContext *C, wmOperator *op) */ int WM_operator_repeat(bContext *C, wmOperator *op) { +#ifdef WITH_REDO_REGION_REMOVAL + const OperatorRepeatContextHandle *context_info; + int retval; + + context_info = ED_operator_repeat_prepare_context(C, op); + retval = wm_operator_exec(C, op, true, true); + ED_operator_repeat_reset_context(C, context_info); + + return retval; +#else return wm_operator_exec(C, op, true, true); +#endif } /** * \return true if #WM_operator_repeat can run @@ -1528,17 +1545,22 @@ void wm_event_free_handler(wmEventHandler *handler) /* only set context when area/region is part of screen */ static void wm_handler_op_context(bContext *C, wmEventHandler *handler, const wmEvent *event) { + wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); if (screen && handler->op) { if (handler->op_area == NULL) CTX_wm_area_set(C, NULL); else { - ScrArea *sa; - - for (sa = screen->areabase.first; sa; sa = sa->next) - if (sa == handler->op_area) + ScrArea *sa = NULL; + + ED_screen_areas_iter(win, screen, sa_iter) { + if (sa_iter == handler->op_area) { + sa = sa_iter; break; + } + } + if (sa == NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ @@ -2493,13 +2515,15 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) static ScrArea *area_event_inside(bContext *C, const int xy[2]) { + wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); - ScrArea *sa; - if (screen) - for (sa = screen->areabase.first; sa; sa = sa->next) + if (screen) { + ED_screen_areas_iter(win, screen, sa) { if (BLI_rcti_isect_pt_v(&sa->totrct, xy)) return sa; + } + } return NULL; } @@ -2739,7 +2763,6 @@ void wm_event_do_handlers(bContext *C) wm_tweakevent_test(C, event, action); if ((action & WM_HANDLER_BREAK) == 0) { - ScrArea *sa; ARegion *ar; /* Note: setting subwin active should be done here, after modal handlers have been done */ @@ -2755,7 +2778,7 @@ void wm_event_do_handlers(bContext *C) } #endif - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { /* after restoring a screen from SCREENMAXIMIZED we have to wait * with the screen handling till the region coordinates are updated */ if (screen->skip_handling == true) { @@ -2935,24 +2958,26 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) if (handler->type == WM_HANDLER_FILESELECT) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa; + bool cancel_handler = true; /* find the area with the file selector for this handler */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + ED_screen_areas_iter(win, screen, sa) { if (sa->spacetype == SPACE_FILE) { SpaceFile *sfile = sa->spacedata.first; if (sfile->op == handler->op) { CTX_wm_area_set(C, sa); wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL); + cancel_handler = false; break; } } } /* if not found we stop the handler without changing the screen */ - if (!sa) + if (cancel_handler) { wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL); + } } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b6f7603c99f..4c96afff9a1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1498,13 +1498,15 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) if (op->type->flag & OPTYPE_MACRO) { for (op = op->macro.first; op; op = op->next) { - uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE); + uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, + UI_TEMPLATE_OP_PROPS_SHOW_TITLE); if (op->next) uiItemS(layout); } } else { - uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE); + uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, + UI_TEMPLATE_OP_PROPS_SHOW_TITLE); } UI_block_bounds_set_popup(block, 4, 0, 0); @@ -1573,7 +1575,8 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); - uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE); + uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, + UI_TEMPLATE_OP_PROPS_SHOW_TITLE); /* clear so the OK button is left alone */ UI_block_func_set(block, NULL, NULL, NULL); @@ -1612,7 +1615,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); /* since ui is defined the auto-layout args are not used */ - uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'V', 0); + uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0); UI_block_func_set(block, NULL, NULL, NULL); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9b0d8db68ce..166d97d6b5e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -208,6 +208,8 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) CTX_wm_window_set(C, NULL); } + BKE_screen_area_map_free(&win->global_areas); + /* end running jobs, a job end also removes its timer */ for (wt = wm->timers.first; wt; wt = wtnext) { wtnext = wt->next; @@ -302,6 +304,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la WM_window_set_active_workspace(win_dst, workspace); layout_new = duplicate_layout ? ED_workspace_layout_duplicate(workspace, layout_old, win_dst) : layout_old; WM_window_set_active_layout(win_dst, workspace, layout_new); + ED_screen_global_areas_create(win_dst); win_dst->drawmethod = U.wmdrawmethod; @@ -782,6 +785,11 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) WM_event_add_dropbox_handler(&win->handlers, lb); } wm_window_title(wm, win); + + /* add topbar */ + if (BLI_listbase_is_empty(&win->global_areas.areabase)) { + ED_screen_global_areas_create(win); + } } } @@ -1008,6 +1016,8 @@ int wm_window_new_exec(bContext *C, wmOperator *op) win_dst->scene = win_src->scene; screen_new->winid = win_dst->winid; CTX_wm_window_set(C, win_dst); + + ED_screen_global_areas_create(win_dst); ED_screen_refresh(CTX_wm_manager(C), win_dst); } @@ -2074,19 +2084,35 @@ float WM_cursor_pressure(const struct wmWindow *win) /* support for native pixel size */ /* mac retina opens window in size X, but it has up to 2 x more pixels */ -int WM_window_pixels_x(wmWindow *win) +int WM_window_pixels_x(const wmWindow *win) { float f = GHOST_GetNativePixelSize(win->ghostwin); return (int)(f * (float)win->sizex); } - -int WM_window_pixels_y(wmWindow *win) +int WM_window_pixels_y(const wmWindow *win) { float f = GHOST_GetNativePixelSize(win->ghostwin); return (int)(f * (float)win->sizey); - +} + +/** + * Get the total pixels that are usable by the screen-layouts, excluding global areas. + */ +int WM_window_screen_pixels_x(const wmWindow *win) +{ + return WM_window_pixels_x(win); +} +int WM_window_screen_pixels_y(const wmWindow *win) +{ + short screen_size_y = WM_window_pixels_y(win); + + for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { + screen_size_y -= ED_area_global_size_y(sa); + } + + return screen_size_y; } bool WM_window_is_fullscreen(wmWindow *win) |