Fix T37463: Increasing window size would add space around menu header

This commit is contained in:
Campbell Barton 2013-12-10 23:54:33 +11:00
parent d07fea2439
commit 91d8519c47
Notes: blender-bot 2023-04-19 22:54:54 +02:00
Referenced by commit e8c9e85401, UI: Revert fix T37463: Y-clamp for header-only spaces
Referenced by issue #37463, Maximizing window causes info panel to open partially
2 changed files with 82 additions and 3 deletions

View File

@ -662,6 +662,10 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
/* test if screen vertices should be scaled */
static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
{
/* clamp Y size of header sized areas when expanding windows
* avoids annoying empty space around file menu */
#define USE_HEADER_SIZE_CLAMP
const int headery_init = ED_area_headersize();
ScrVert *sv = NULL;
ScrArea *sa;
@ -685,7 +689,35 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
sizex = max[0] - min[0] + 1;
sizey = max[1] - min[1] + 1;
#ifdef USE_HEADER_SIZE_CLAMP
#define TEMP_BOTTOM 1
#define TEMP_TOP 2
/* if the window's Y axis grows, clamp header sized areas */
if (sizey < winsizey) { /* growing? */
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 == sizey - 1) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_init + 4) {
sa->temp = TEMP_TOP;
}
}
else if (sa->v1->vec.y == 0) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_init + 4) {
sa->temp = TEMP_BOTTOM;
}
}
}
}
}
#endif
if (sizex != winsizex || sizey != winsizey) {
facx = ((float)winsizex) / ((float)sizex - 1);
facy = ((float)winsizey) / ((float)sizey - 1);
@ -709,7 +741,54 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
CLAMP(sv->vec.y, 0, winsizey - 1);
}
}
#ifdef USE_HEADER_SIZE_CLAMP
if (sizey < winsizey) { /* growing? */
for (sa = sc->areabase.first; sa; sa = sa->next) {
ScrEdge *se = NULL;
if (sa->temp == 0)
continue;
if (sa->v1 == sa->v2)
continue;
/* adjust headery if verts are along the edge of window */
if (sa->temp == TEMP_TOP) {
/* lower edge */
const int yval = sa->v2->vec.y - headery_init;
se = screen_findedge(sc, sa->v4, sa->v1);
select_connected_scredge(sc, se);
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v2 && sv != sa->v3) {
if (sv->flag) {
sv->vec.y = yval;
}
}
}
}
else {
/* upper edge */
const int yval = sa->v1->vec.y + headery_init;
se = screen_findedge(sc, sa->v2, sa->v3);
select_connected_scredge(sc, se);
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v1 && sv != sa->v4) {
if (sv->flag) {
sv->vec.y = yval;
}
}
}
}
}
}
#undef TEMP_BOTTOM
#undef TEMP_TOP
#endif
/* test for collapsed areas. This could happen in some blender version... */
/* ton: removed option now, it needs Context... */

View File

@ -172,7 +172,7 @@ typedef struct ScrArea {
short flag;
short region_active_win; /* index of last used region of 'RGN_TYPE_WINDOW'
* runtuime variable, updated by executing operators */
short pad;
char temp, pad;
struct SpaceType *type; /* callbacks for this space type */