Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-04-20 18:14:03 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-04-20 18:14:52 +0300
commit5f6c45498c92b91a710a1317f6d41f73fbe83477 (patch)
tree93b136fb49c656c2c2a5463c91e8a6a38d518354 /source/blender/editors/screen
parent4bfb6d21df96688187f6f1a5d95dd62bcbf85116 (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/editors/screen')
-rw-r--r--source/blender/editors/screen/area.c150
-rw-r--r--source/blender/editors/screen/screen_edit.c344
-rw-r--r--source/blender/editors/screen/screen_intern.h13
-rw-r--r--source/blender/editors/screen/screen_ops.c205
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c4
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c6
7 files changed, 516 insertions, 208 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 105fff38f62..b6e2d2c57d4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1168,7 +1168,7 @@ static bool region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
return 0;
}
-static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
+static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad, bool add_azones)
{
rcti *remainder_prev = remainder;
int prefsizex, prefsizey;
@@ -1195,13 +1195,17 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* user errors */
if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT)
alignment = RGN_ALIGN_NONE;
-
+
/* prefsize, for header we stick to exception (prevent dpi rounding error) */
- prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex);
-
+ const float sizex_dpi_fac = (ar->flag & RGN_SIZEX_DPI_APPLIED) ? 1.0f : UI_DPI_FAC;
+ prefsizex = sizex_dpi_fac * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
+
if (ar->regiontype == RGN_TYPE_HEADER) {
prefsizey = ED_area_headersize();
}
+ else if (ED_area_is_global(sa)) {
+ prefsizey = ED_region_global_size_y();
+ }
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
}
@@ -1397,7 +1401,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
* but accounts for small common rounding problems when scaling the UI,
* must be minimum '4' */
}
- else {
+ else if (add_azones) {
const bScreen *screen = WM_window_get_active_screen(win);
if (ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) {
@@ -1409,23 +1413,36 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
}
- region_rect_recursive(win, sa, ar->next, remainder, quad);
+ region_rect_recursive(win, sa, ar->next, remainder, quad, add_azones);
}
-static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
+static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
{
- short rt = (short) U.pixelsize;
+ short px = (short)U.pixelsize;
+
+ sa->totrct.xmin = sa->v1->vec.x;
+ sa->totrct.xmax = sa->v4->vec.x;
+ sa->totrct.ymin = sa->v1->vec.y;
+ sa->totrct.ymax = sa->v2->vec.y;
+
+ /* scale down totrct by 1 pixel on all sides not matching window borders */
+ if (sa->totrct.xmin > 0) {
+ sa->totrct.xmin += px;
+ }
+ if (sa->totrct.xmax < (window_size_x - 1)) {
+ sa->totrct.xmax -= px;
+ }
+ if (sa->totrct.ymin > 0) {
+ sa->totrct.ymin += px;
+ }
+ if (sa->totrct.ymax < (window_size_y - 1)) {
+ sa->totrct.ymax -= px;
+ }
+ BLI_assert(sa->totrct.xmin >= 0);
+ BLI_assert(sa->totrct.xmax >= 0);
+ BLI_assert(sa->totrct.ymin >= 0);
+ BLI_assert(sa->totrct.ymax >= 0);
- if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + rt;
- else sa->totrct.xmin = sa->v1->vec.x;
- if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - rt;
- else sa->totrct.xmax = sa->v4->vec.x;
-
- if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + rt;
- else sa->totrct.ymin = sa->v1->vec.y;
- if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - rt;
- else sa->totrct.ymax = sa->v2->vec.y;
-
/* for speedup */
sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
@@ -1510,11 +1527,36 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
}
}
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
+{
+ const int size_x = WM_window_pixels_x(win);
+ const int size_y = WM_window_pixels_y(win);
+ rcti rect;
+
+ area_calc_totrct(area, size_x, size_y);
+
+ /* region rect sizes */
+ rect = area->totrct;
+ region_rect_recursive(win, area, area->regionbase.first, &rect, 0, false);
+
+ for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
+ region_subwindow(ar);
+
+ /* region size may have changed, init does necessary adjustments */
+ if (ar->type->init) {
+ ar->type->init(wm, ar);
+ }
+ }
+
+ area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
+}
/* called in screen_refresh, or screens_init, also area size changes */
void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
{
const bScreen *screen = WM_window_get_active_screen(win);
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
ARegion *ar;
rcti rect;
@@ -1528,16 +1570,17 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
-
+
/* area sizes */
- area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
-
+ area_calc_totrct(sa, window_size_x, window_size_y);
+
/* clear all azones, add the area triange widgets */
area_azone_initialize(win, screen, sa);
/* region rect sizes */
rect = sa->totrct;
- region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
+ region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0, true);
+ sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
/* default area handlers */
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
@@ -1832,6 +1875,18 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
/************************ standard UI regions ************************/
+static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
+{
+ switch (region->regiontype) {
+ case RGN_TYPE_HEADER:
+ return ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL;
+ case RGN_TYPE_PREVIEW:
+ return TH_PREVIEW_BACK;
+ default:
+ return TH_BACK;
+ }
+}
+
void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical)
{
const WorkSpace *workspace = CTX_wm_workspace(C);
@@ -2117,17 +2172,25 @@ void ED_region_header(const bContext *C, ARegion *ar)
Header header = {NULL};
int maxco, xco, yco;
int headery = ED_area_headersize();
+ const int start_ofs = 0.4f * UI_UNIT_X;
+ bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
/* clear */
- UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
+ UI_ThemeClearColor(region_background_color_id(C, ar));
glClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
- xco = maxco = 0.4f * UI_UNIT_X;
+ xco = maxco = start_ofs;
yco = headery - floor(0.2f * UI_UNIT_Y);
+ /* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
+ if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) {
+ xco += 1;
+ yco += 1;
+ }
+
/* draw all headers types */
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS);
@@ -2149,13 +2212,23 @@ void ED_region_header(const bContext *C, ARegion *ar)
/* for view2d */
if (xco > maxco)
maxco = xco;
-
+
+ if (region_layout_based && (ar->sizex != (maxco + start_ofs))) {
+ /* region size is layout based and needs to be updated */
+ ScrArea *sa = CTX_wm_area(C);
+
+ ar->sizex = maxco + start_ofs;
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->sizex, ar->winy);
+
+ sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ ar->flag |= RGN_SIZEX_DPI_APPLIED;
+ }
UI_block_end(C, block);
UI_block_draw(C, block);
}
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery);
+ UI_view2d_totRect_set(&ar->v2d, maxco + (region_layout_based ? 0 : UI_UNIT_X + 80), headery);
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -2172,6 +2245,31 @@ int ED_area_headersize(void)
return (int)(HEADERY * UI_DPI_FAC);
}
+/**
+ * \return the final height of a global \a area, accounting for DPI.
+ */
+int ED_area_global_size_y(const ScrArea *area)
+{
+ BLI_assert(ED_area_is_global(area));
+ return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC);
+}
+
+bool ED_area_is_global(const ScrArea *area)
+{
+ return area->global != NULL;
+}
+
+/**
+ * For now we just assume all global areas are made up out of horizontal bars
+ * with the same size. A fixed size could be stored in ARegion instead if needed.
+ *
+ * \return the DPI aware height of a single bar/region in global areas.
+ */
+int ED_region_global_size_y(void)
+{
+ return ED_area_headersize(); /* same size as header */
+}
+
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw)
{
const int header_height = UI_UNIT_Y;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index e961a7f5d64..82093b4326a 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -76,17 +76,21 @@
/* ******************* screen vert, edge, area managing *********************** */
-static ScrVert *screen_addvert(bScreen *sc, short x, short y)
+static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y)
{
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
sv->vec.x = x;
sv->vec.y = y;
- BLI_addtail(&sc->vertbase, sv);
+ BLI_addtail(&area_map->vertbase, sv);
return sv;
}
+static ScrVert *screen_addvert(bScreen *sc, short x, short y)
+{
+ return screen_addvert_ex(AREAMAP_FROM_SCREEN(sc), x, y);
+}
-static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+static ScrEdge *screen_addedge_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
{
ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge");
@@ -94,10 +98,13 @@ static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
se->v1 = v1;
se->v2 = v2;
- BLI_addtail(&sc->edgebase, se);
+ BLI_addtail(&area_map->edgebase, se);
return se;
}
-
+static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+{
+ return screen_addedge_ex(AREAMAP_FROM_SCREEN(sc), v1, v2);
+}
bool scredge_is_horizontal(ScrEdge *se)
{
@@ -105,16 +112,16 @@ bool scredge_is_horizontal(ScrEdge *se)
}
/* need win size to make sure not to include edges along screen edge */
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my)
+ScrEdge *screen_area_map_find_active_scredge(
+ const ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my)
{
- ScrEdge *se;
int safety = U.widget_unit / 10;
-
- if (safety < 2) safety = 2;
-
- for (se = sc->edgebase.first; se; se = se->next) {
+
+ CLAMP_MIN(safety, 2);
+
+ for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
if (scredge_is_horizontal(se)) {
if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
short min, max;
@@ -136,27 +143,56 @@ ScrEdge *screen_find_active_scredge(const bScreen *sc,
}
}
}
-
+
return NULL;
}
+/* need win size to make sure not to include edges along screen edge */
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my)
+{
+ /* Use layout size (screen excluding global areas) for screen-layout area edges */
+ const int screen_x = WM_window_screen_pixels_x(win), screen_y = WM_window_screen_pixels_y(win);
+ ScrEdge *se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), screen_x, screen_y, mx, my);
+
+ if (!se) {
+ /* Use entire window size (screen including global areas) for global area edges */
+ const int win_x = WM_window_pixels_x(win), win_y = WM_window_pixels_y(win);
+ se = screen_area_map_find_active_scredge(&win->global_areas, win_x, win_y, mx, my);
+ }
+ return se;
+}
+
/* adds no space data */
-static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype)
+static ScrArea *screen_addarea_ex(
+ ScrAreaMap *area_map,
+ ScrVert *bottom_left, ScrVert *top_left, ScrVert *top_right, ScrVert *bottom_right,
+ short headertype, short spacetype)
{
ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
- sa->v1 = v1;
- sa->v2 = v2;
- sa->v3 = v3;
- sa->v4 = v4;
+
+ sa->v1 = bottom_left;
+ sa->v2 = top_left;
+ sa->v3 = top_right;
+ sa->v4 = bottom_right;
sa->headertype = headertype;
sa->spacetype = sa->butspacetype = spacetype;
-
- BLI_addtail(&sc->areabase, sa);
-
+
+ BLI_addtail(&area_map->areabase, sa);
+
return sa;
}
+static ScrArea *screen_addarea(
+ bScreen *sc,
+ ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, ScrVert *right_bottom,
+ short headertype, short spacetype)
+{
+ return screen_addarea_ex(AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom,
+ headertype, spacetype);
+}
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
{
@@ -462,10 +498,10 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
return 1;
}
-void select_connected_scredge(bScreen *sc, ScrEdge *edge)
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
{
+ bScreen *sc = WM_window_get_active_screen(win);
ScrEdge *se;
- ScrVert *sv;
int oneselected;
char dir;
@@ -475,12 +511,10 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v';
else dir = 'h';
- sv = sc->vertbase.first;
- while (sv) {
+ ED_screen_verts_iter(win, sc, sv) {
sv->flag = 0;
- sv = sv->next;
}
-
+
edge->v1->flag = 1;
edge->v2->flag = 1;
@@ -508,8 +542,13 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
}
}
-/* test if screen vertices should be scaled */
-static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
+/**
+ * Test if screen vertices should be scaled and do if needed.
+ */
+static void screen_vertices_scale(
+ const wmWindow *win, bScreen *sc,
+ int window_size_x, int window_size_y,
+ int screen_size_x, int screen_size_y)
{
/* clamp Y size of header sized areas when expanding windows
* avoids annoying empty space around file menu */
@@ -518,7 +557,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int headery_init = ED_area_headersize();
ScrVert *sv = NULL;
ScrArea *sa;
- int winsize_x_prev, winsize_y_prev;
+ int screen_size_x_prev, screen_size_y_prev;
float facx, facy, tempf, min[2], max[2];
/* calculate size */
@@ -536,8 +575,8 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
sv->vec.y -= min[1];
}
- winsize_x_prev = (max[0] - min[0]) + 1;
- winsize_y_prev = (max[1] - min[1]) + 1;
+ screen_size_x_prev = (max[0] - min[0]) + 1;
+ screen_size_y_prev = (max[1] - min[1]) + 1;
#ifdef USE_HEADER_SIZE_CLAMP
@@ -545,14 +584,14 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#define TEMP_TOP 2
/* if the window's Y axis grows, clamp header sized areas */
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
const int headery_margin_max = headery_init + 4;
for (sa = sc->areabase.first; sa; sa = sa->next) {
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
sa->temp = 0;
if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
- if (sa->v2->vec.y == winsize_y_prev - 1) {
+ if (sa->v2->vec.y == screen_size_y_prev) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
sa->temp = TEMP_TOP;
}
@@ -568,9 +607,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#endif
- if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) {
- facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1);
- facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1);
+ if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
+ facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
+ facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -581,20 +620,20 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
//sv->vec.x += AREAGRID - 1;
//sv->vec.x -= (sv->vec.x % AREAGRID);
- CLAMP(sv->vec.x, 0, winsize_x - 1);
+ CLAMP(sv->vec.x, 0, screen_size_x - 1);
tempf = ((float)sv->vec.y) * facy;
sv->vec.y = (short)(tempf + 0.5f);
//sv->vec.y += AREAGRID - 1;
//sv->vec.y -= (sv->vec.y % AREAGRID);
- CLAMP(sv->vec.y, 0, winsize_y - 1);
+ CLAMP(sv->vec.y, 0, screen_size_y);
}
}
#ifdef USE_HEADER_SIZE_CLAMP
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
for (sa = sc->areabase.first; sa; sa = sa->next) {
ScrEdge *se = NULL;
@@ -610,7 +649,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int yval = sa->v2->vec.y - headery_init;
se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v2 && sv != sa->v3) {
@@ -625,7 +664,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int yval = sa->v1->vec.y + headery_init;
se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v1 && sv != sa->v4) {
@@ -654,7 +693,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
/* adjust headery if verts are along the edge of window */
if (sa->v1->vec.y > 0)
headery += U.pixelsize;
- if (sa->v2->vec.y < winsize_y - 1)
+ if (sa->v2->vec.y < screen_size_y)
headery += U.pixelsize;
if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
@@ -663,7 +702,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
if (se && sa->v1 != sa->v2) {
int yval;
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
/* all selected vertices get the right offset */
yval = sa->v2->vec.y - headery + 1;
@@ -678,7 +717,17 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
}
}
}
-
+
+ /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set.
+ * TODO Assumes global area to be top-aligned. Should be made more generic */
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ /* width */
+ area->v1->vec.x = area->v2->vec.x = 0;
+ area->v3->vec.x = area->v4->vec.x = window_size_x - 1;
+ /* height */
+ area->v2->vec.y = area->v3->vec.y = window_size_y - 1;
+ area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
+ }
}
@@ -689,7 +738,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
{
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == screen->active_region) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
@@ -751,20 +800,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* exception for bg mode, we only need the screen context */
if (!G.background) {
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
- ScrArea *sa;
-
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
/* header size depends on DPI, let's verify */
WM_window_set_dpi(win);
screen_refresh_headersizes();
-
- screen_test_scale(screen, winsize_x, winsize_y);
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
/* set spacetype and region callbacks, calls init() */
/* sets subwindows for regions, adds handlers */
- ED_area_initialize(wm, win, sa);
+ ED_area_initialize(wm, win, area);
}
/* wake up animtimer */
@@ -782,6 +832,36 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
screen->context = ed_screen_context;
}
+static bool screen_regions_need_size_refresh(
+ const wmWindow *win, const bScreen *screen)
+{
+ ED_screen_areas_iter(win, screen, area) {
+ if (area->flag & AREA_FLAG_REGION_SIZE_UPDATE) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void screen_refresh_region_sizes_only(
+ wmWindowManager *wm, wmWindow *win,
+ bScreen *screen)
+{
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
+ screen_area_update_region_sizes(wm, win, area);
+ /* XXX hack to force drawing */
+ ED_area_tag_redraw(area);
+ }
+}
+
/* file read, set all screens, ... */
void ED_screens_initialize(wmWindowManager *wm)
{
@@ -792,8 +872,21 @@ void ED_screens_initialize(wmWindowManager *wm)
WM_window_set_active_workspace(win, G.main->workspaces.first);
}
+ if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
+ ED_screen_global_areas_create(win);
+ }
+ ED_screen_refresh(wm, win);
+ }
+}
+
+void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *screen)
+{
+ if (screen->do_refresh) {
ED_screen_refresh(wm, win);
}
+ else if (screen_regions_need_size_refresh(win, screen)) {
+ screen_refresh_region_sizes_only(wm, win, screen);
+ }
}
@@ -872,6 +965,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
for (sa = screen->areabase.first; sa; sa = sa->next) {
ED_area_exit(C, sa);
}
+ for (sa = window->global_areas.areabase.first; sa; sa = sa->next) {
+ ED_area_exit(C, sa);
+ }
/* mark it available for use for other windows */
screen->winid = 0;
@@ -893,9 +989,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
static void screen_cursor_set(wmWindow *win, const wmEvent *event)
{
const bScreen *screen = WM_window_get_active_screen(win);
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
-
AZone *az = NULL;
ScrArea *sa;
@@ -914,8 +1007,8 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
}
}
else {
- ScrEdge *actedge = screen_find_active_scredge(screen, winsize_x, winsize_y, event->x, event->y);
-
+ ScrEdge *actedge = screen_find_active_scredge(win, screen, event->x, event->y);
+
if (actedge) {
if (scredge_is_horizontal(actedge))
WM_cursor_set(win, CURSOR_Y_MOVE);
@@ -936,15 +1029,19 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
bScreen *scr = WM_window_get_active_screen(win);
if (scr) {
- ScrArea *sa;
+ ScrArea *sa = NULL;
ARegion *ar;
ARegion *old_ar = scr->active_region;
- for (sa = scr->areabase.first; sa; sa = sa->next) {
- if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
- if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
- if (NULL == is_in_area_actionzone(sa, &event->x))
+ ED_screen_areas_iter(win, scr, area_iter) {
+ if (event->x > area_iter->totrct.xmin && event->x < area_iter->totrct.xmax) {
+ if (event->y > area_iter->totrct.ymin && event->y < area_iter->totrct.ymax) {
+ if (is_in_area_actionzone(area_iter, &event->x) == NULL) {
+ sa = area_iter;
break;
+ }
+ }
+ }
}
if (sa) {
/* make overlap active when mouse over */
@@ -961,17 +1058,21 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
/* check for redraw headers */
if (old_ar != scr->active_region) {
- for (sa = scr->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, scr, area_iter) {
bool do_draw = false;
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == old_ar || ar == scr->active_region)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar == old_ar || ar == scr->active_region) {
do_draw = true;
+ }
+ }
if (do_draw) {
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar->regiontype == RGN_TYPE_HEADER)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_HEADER) {
ED_region_tag_redraw(ar);
+ }
+ }
}
}
}
@@ -1016,6 +1117,47 @@ int ED_screen_area_active(const bContext *C)
return 0;
}
+void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
+{
+ if (screen->temp == 0) {
+ SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
+ SpaceLink *sl = st->new(NULL);
+ ScrArea *sa;
+ const short size_y = 2 * HEADERY;
+ const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
+ const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;
+
+ ScrVert *bottom_left = screen_addvert_ex(&win->global_areas, minx, miny);
+ ScrVert *top_left = screen_addvert_ex(&win->global_areas, minx, maxy);
+ ScrVert *top_right = screen_addvert_ex(&win->global_areas, maxx, maxy);
+ ScrVert *bottom_right = screen_addvert_ex(&win->global_areas, maxx, miny);
+ screen_addedge_ex(&win->global_areas, bottom_left, top_left);
+ screen_addedge_ex(&win->global_areas, top_left, top_right);
+ screen_addedge_ex(&win->global_areas, top_right, bottom_right);
+ screen_addedge_ex(&win->global_areas, bottom_right, bottom_left);
+
+ sa = screen_addarea_ex(&win->global_areas, bottom_left, top_left, top_right, bottom_right,
+ HEADERTOP, SPACE_TOPBAR);
+ sa->regionbase = sl->regionbase;
+
+ /* Data specific to global areas. */
+ sa->global = MEM_callocN(sizeof(*sa->global), __func__);
+ sa->global->cur_fixed_height = size_y;
+ sa->global->size_max = size_y;
+ sa->global->size_min = HEADERY;
+
+ BLI_addhead(&sa->spacedata, sl);
+ BLI_listbase_clear(&sl->regionbase);
+ }
+ /* Do not create more area types here! Function is called on file load (wm_window_ghostwindows_ensure). TODO */
+}
+
+void ED_screen_global_areas_create(wmWindow *win)
+{
+ const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ ED_screen_global_topbar_area_create(win, screen);
+}
+
/* -------------------------------------------------------------------- */
/* Screen changing */
@@ -1168,7 +1310,6 @@ void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *screen = CTX_wm_screen(C);
ScrArea *newsa = NULL;
if (!sa || sa->full == NULL) {
@@ -1176,18 +1317,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
}
if (!newsa) {
- if (sa->full && (screen->state == SCREENMAXIMIZED)) {
- /* if this has been called from the temporary info header generated in
- * temp fullscreen layouts, find the correct fullscreen area to change
- * to create a new space inside */
- for (newsa = screen->areabase.first; newsa; newsa = newsa->next) {
- if (!(sa->flag & AREA_TEMP_INFO))
- break;
- }
- }
- else {
- newsa = sa;
- }
+ newsa = sa;
}
BLI_assert(newsa);
@@ -1308,10 +1438,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* clear full screen state */
old->full = NULL;
- old->flag &= ~AREA_TEMP_INFO;
}
- sa->flag &= ~AREA_TEMP_INFO;
sa->full = NULL;
if (fullsa == NULL) {
@@ -1349,6 +1477,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
ScrArea *newa;
char newname[MAX_ID_NAME - 2];
+ BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL));
+
oldscreen = WM_window_get_active_screen(win);
oldscreen->state = state;
@@ -1367,50 +1497,30 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* use random area when we have no active one, e.g. when the
* mouse is outside of the window and we open a file browser */
- if (!sa)
+ if (!sa) {
sa = oldscreen->areabase.first;
-
- if (state == SCREENMAXIMIZED) {
- /* returns the top small area */
- newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1);
- ED_area_newspace(C, newa, SPACE_INFO, false);
-
- /* copy area */
- newa = newa->prev;
- ED_area_data_swap(newa, sa);
- sa->flag |= AREA_TEMP_INFO;
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- newa->next->full = oldscreen; // XXX
}
- else if (state == SCREENFULL) {
- newa = (ScrArea *)sc->areabase.first;
- /* copy area */
- ED_area_data_swap(newa, sa);
- newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ newa = (ScrArea *)sc->areabase.first;
+
+ /* copy area */
+ ED_area_data_swap(newa, sa);
+ newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ if (state == SCREENFULL) {
/* temporarily hide the side panels/header */
for (ar = newa->regionbase.first; ar; ar = ar->next) {
ar->flagfullscreen = ar->flag;
- if (ELEM(ar->regiontype,
- RGN_TYPE_UI,
- RGN_TYPE_HEADER,
- RGN_TYPE_TOOLS))
- {
+ if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS)){
ar->flag |= RGN_FLAG_HIDDEN;
}
}
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- }
- else {
- BLI_assert(false);
}
+ sa->full = oldscreen;
+ newa->full = oldscreen;
+
ED_screen_change(C, sc);
}
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 606838ae890..045e5ee6b48 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -44,6 +44,7 @@ struct Main;
/* area.c */
void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area);
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
@@ -55,12 +56,16 @@ bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, stru
ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
int area_getorientation(ScrArea *sa, ScrArea *sb);
-void select_connected_scredge(bScreen *sc, ScrEdge *edge);
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge);
bool scredge_is_horizontal(ScrEdge *se);
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my);
+ScrEdge *screen_area_map_find_active_scredge(
+ const struct ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my);
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my);
struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 25d5fbbdc4c..8b889c61deb 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -791,8 +791,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
switch (event->type) {
case MOUSEMOVE:
@@ -816,7 +816,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* once we drag outside the actionzone, register a gesture
* check we're not on an edge so join finds the other area */
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
- (screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y) == NULL));
+ (screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y) == NULL));
}
else {
const int delta_min = 1;
@@ -1049,6 +1050,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
+ ED_screen_global_areas_create(newwin);
/* copy area to new screen */
ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
@@ -1116,25 +1118,73 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
*/
typedef struct sAreaMoveData {
- int bigger, smaller, origval;
+ int bigger, smaller, origval, step;
char dir;
- bool do_snap;
+ enum AreaMoveSnapType {
+ /* Snapping disabled */
+ SNAP_NONE = 0,
+ /* Snap to mid-point and adjacent edges. */
+ SNAP_MIDPOINT_AND_ADJACENT,
+ /* Snap to either bigger or smaller, nothing in-between (used for
+ * global areas). This has priority over other snap types, if it is
+ * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
+ SNAP_BIGGER_SMALLER_ONLY,
+ } snap_type;
} sAreaMoveData;
/* helper call to move area-edge, sets limits
* need window size in order to get correct limits */
-static void area_move_set_limits(bScreen *sc, int dir,
- const int winsize_x, const int winsize_y,
- int *bigger, int *smaller)
+static void area_move_set_limits(
+ wmWindow *win, bScreen *sc, int dir,
+ const int winsize_x, const int winsize_y,
+ int *bigger, int *smaller,
+ bool *use_bigger_smaller_snap)
{
- ScrArea *sa;
int areaminy = ED_area_headersize();
int areamin;
-
+
/* we check all areas and test for free space with MINSIZE */
*bigger = *smaller = 100000;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
+
+ if (use_bigger_smaller_snap != NULL) {
+ *use_bigger_smaller_snap = false;
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ const int size_min = round_fl_to_int(area->global->size_min * UI_DPI_FAC);
+ const int size_max = round_fl_to_int(area->global->size_max * UI_DPI_FAC);
+
+ /* logic here is only tested for lower edge :) */
+ /* left edge */
+ if ((area->v1->editflag && area->v2->editflag)) {
+ *smaller = area->v4->vec.x - size_max;
+ *bigger = area->v4->vec.x - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* top edge */
+ else if ((area->v2->editflag && area->v3->editflag)) {
+ *smaller = area->v1->vec.y + size_min;
+ *bigger = area->v1->vec.y + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* right edge */
+ else if ((area->v3->editflag && area->v4->editflag)) {
+ *smaller = area->v1->vec.x + size_min;
+ *bigger = area->v1->vec.x + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* lower edge */
+ else if ((area->v4->editflag && area->v1->editflag)) {
+ *smaller = area->v2->vec.y - size_max;
+ *bigger = area->v2->vec.y - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ }
+ }
+
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
if (dir == 'h') {
int y1;
areamin = areaminy;
@@ -1180,9 +1230,8 @@ static int area_move_init(bContext *C, wmOperator *op)
wmWindow *win = CTX_wm_window(C);
ScrEdge *actedge;
sAreaMoveData *md;
- ScrVert *v1;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int x, y;
/* required properties */
@@ -1190,7 +1239,7 @@ static int area_move_init(bContext *C, wmOperator *op)
y = RNA_int_get(op->ptr, "y");
/* setup */
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_find_active_scredge(win, sc, x, y);
if (actedge == NULL) return 0;
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
@@ -1200,23 +1249,33 @@ static int area_move_init(bContext *C, wmOperator *op)
if (md->dir == 'h') md->origval = actedge->v1->vec.y;
else md->origval = actedge->v1->vec.x;
- select_connected_scredge(sc, actedge);
- /* now all vertices with 'flag==1' are the ones that can be moved. Move this to editflag */
- for (v1 = sc->vertbase.first; v1; v1 = v1->next)
+ select_connected_scredge(win, actedge);
+ /* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
+ ED_screen_verts_iter(win, sc, v1) {
v1->editflag = v1->flag;
-
- area_move_set_limits(sc, md->dir, winsize_x, winsize_y, &md->bigger, &md->smaller);
-
+ }
+
+ bool use_bigger_smaller_snap = false;
+ area_move_set_limits(win, sc, md->dir, screen_size_x, screen_size_y,
+ &md->bigger, &md->smaller,
+ &use_bigger_smaller_snap);
+
+ md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_NONE;
+
return 1;
}
static int area_snap_calc_location(
- const bScreen *sc, const int delta,
- const int origval, const int dir,
+ const bScreen *sc, const enum AreaMoveSnapType snap_type,
+ const int delta, const int origval, const int dir,
const int bigger, const int smaller)
{
- int final_loc = -1;
+ BLI_assert(snap_type != SNAP_NONE);
+ if (snap_type == SNAP_BIGGER_SMALLER_ONLY) {
+ return ((origval + delta) >= bigger) ? bigger : smaller;
+ }
+ int final_loc = -1;
const int m_loc = origval + delta;
const int axis = (dir == 'v') ? 0 : 1;
int snap_dist;
@@ -1260,29 +1319,29 @@ static void area_move_apply_do(
const bContext *C, int delta,
const int origval, const int dir,
const int bigger, const int smaller,
- const bool do_snap)
+ const enum AreaMoveSnapType snap_type)
{
+ wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
- ScrVert *v1;
bool doredraw = false;
CLAMP(delta, -smaller, bigger);
short final_loc = -1;
- if (do_snap) {
- final_loc = area_snap_calc_location(sc, delta, origval, dir, bigger, smaller);
- }
- else {
+ if (snap_type == SNAP_NONE) {
final_loc = origval + delta;
if (delta != bigger && delta != -smaller) {
final_loc -= (final_loc % AREAGRID);
}
}
+ else {
+ final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
+ }
BLI_assert(final_loc != -1);
short axis = (dir == 'v') ? 0 : 1;
- for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
+ ED_screen_verts_iter(win, sc, v1) {
if (v1->editflag) {
short oldval = (&v1->vec.x)[axis];
(&v1->vec.x)[axis] = final_loc;
@@ -1297,11 +1356,23 @@ static void area_move_apply_do(
/* only redraw if we actually moved a screen vert, for AREAGRID */
if (doredraw) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ bool redraw_all = false;
+ ED_screen_areas_iter(win, sc, sa) {
if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) {
+ if (ED_area_is_global(sa)) {
+ sa->global->cur_fixed_height = round_fl_to_int((sa->v2->vec.y - sa->v1->vec.y) / UI_DPI_FAC);
+ sc->do_refresh = true;
+ redraw_all = true;
+ }
ED_area_tag_redraw(sa);
}
}
+ if (redraw_all) {
+ ED_screen_areas_iter(win, sc, sa) {
+ ED_area_tag_redraw(sa);
+ }
+ }
+
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
/* Update preview thumbnail */
BKE_icon_changed(sc->id.icon_id);
@@ -1313,7 +1384,7 @@ static void area_move_apply(bContext *C, wmOperator *op)
sAreaMoveData *md = op->customdata;
int delta = RNA_int_get(op->ptr, "delta");
- area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->do_snap);
+ area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->snap_type);
}
static void area_move_exit(bContext *C, wmOperator *op)
@@ -1392,10 +1463,14 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
case KM_MODAL_SNAP_ON:
- md->do_snap = true;
+ if (md->snap_type == SNAP_NONE) {
+ md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
+ }
break;
case KM_MODAL_SNAP_OFF:
- md->do_snap = false;
+ if (md->snap_type == SNAP_MIDPOINT_AND_ADJACENT) {
+ md->snap_type = SNAP_NONE;
+ }
break;
}
break;
@@ -1644,8 +1719,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sAreaSplitData *sd;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int dir;
/* no full window splitting allowed */
@@ -1698,7 +1773,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else
y = event->x;
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, x, y);
if (actedge == NULL)
return OPERATOR_CANCELLED;
@@ -1718,7 +1793,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* do the split */
if (area_split_apply(C, op)) {
- area_move_set_limits(sc, dir, winsize_x, winsize_y, &sd->bigger, &sd->smaller);
+ area_move_set_limits(win, sc, dir, screen_size_x, screen_size_y, &sd->bigger, &sd->smaller, NULL);
/* add temp handler for edge move or cancel */
WM_event_add_modal_handler(C, op);
@@ -1836,10 +1911,11 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->previewmode == 0) {
if (sd->do_snap) {
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->bigger, sd->smaller);
sd->delta = snap_loc - sd->origval;
}
- area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false);
+ area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, SNAP_NONE);
}
else {
if (sd->sarea) {
@@ -1863,7 +1939,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->origmin + sd->origsize, -sd->origmin);
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
sd->delta = snap_loc - sd->origval;
@@ -2579,6 +2656,14 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int screen_maximize_area_poll(bContext *C)
+{
+ const bScreen *screen = CTX_wm_screen(C);
+ const ScrArea *area = CTX_wm_area(C);
+ return ED_operator_areaactive(C) &&
+ ((screen->state != SCREENNORMAL) || (area->spacetype != SPACE_TOPBAR));
+}
+
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -2588,7 +2673,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
ot->idname = "SCREEN_OT_screen_full_area";
ot->exec = screen_maximize_area_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = screen_maximize_area_poll;
ot->flag = 0;
prop = RNA_def_boolean(ot->srna, "use_hide_panels", false, "Hide Panels", "Hide all the panels");
@@ -2898,10 +2983,11 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiLayout *layout;
PointerRNA ptr;
ScrEdge *actedge;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y);
+ actedge = screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y);
if (actedge == NULL) return OPERATOR_CANCELLED;
@@ -3305,6 +3391,18 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+static int region_flip_poll(bContext *C)
+{
+ ScrArea *area = CTX_wm_area(C);
+
+ /* don't flip anything around in topbar */
+ if (area->spacetype == SPACE_TOPBAR) {
+ CTX_wm_operator_poll_msg_set(C, "Flipping regions in the Top-bar is not allowed");
+ return 0;
+ }
+
+ return ED_operator_areaactive(C);
+}
static void SCREEN_OT_region_flip(wmOperatorType *ot)
{
@@ -3315,7 +3413,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/* api callbacks */
ot->exec = region_flip_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = region_flip_poll;
ot->flag = 0;
}
@@ -3408,12 +3506,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
uiItemS(layout);
- /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
- if (sa->spacetype != SPACE_FILE) {
- if (sa->full)
- uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
- else
- uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
+ /* file browser should be fullscreen all the time, topbar should
+ * never be. But other regions can be maximized/restored... */
+ if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
+ uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 69891a727d4..2c1cbc3d21d 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -275,7 +275,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
static int screenshot_poll(bContext *C)
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index b40eef8a38f..c8aa4560dc4 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -313,11 +313,9 @@ static void WORKSPACE_OT_workspace_duplicate(wmOperatorType *ot)
static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm);
+ WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, WM_window_get_active_workspace(win));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index d84df160125..a6f991d4bbe 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -50,10 +50,10 @@ WorkSpaceLayout *ED_workspace_layout_add(
wmWindow *win,
const char *name)
{
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- bScreen *screen = screen_add(name, winsize_x, winsize_y);
+ bScreen *screen = screen_add(name, screen_size_x, screen_size_y);
WorkSpaceLayout *layout = BKE_workspace_layout_add(workspace, screen, name);
return layout;