Cleanup: deprecate area.headertype.

This was still used in a few places but not kept in sync with the actual
header position. Always get alignment from the header region now.
This commit is contained in:
Brecht Van Lommel 2018-05-06 18:36:54 +02:00
parent a3e74acd9e
commit 16e220c959
7 changed files with 29 additions and 21 deletions

View File

@ -99,7 +99,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype = RGN_TYPE_HEADER;
if (sa->headertype == HEADERDOWN)
if (sa->headertype == 1)
ar->alignment = RGN_ALIGN_BOTTOM;
else
ar->alignment = RGN_ALIGN_TOP;

View File

@ -135,6 +135,7 @@ void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool s
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
int ED_area_headersize(void);
int ED_area_header_alignment(const ScrArea *area);
int ED_area_global_size_y(const ScrArea *area);
bool ED_area_is_global(const ScrArea *area);
int ED_region_global_size_y(void);

View File

@ -290,7 +290,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
/* for a header menu we set the direction automatic */
if (!pup->slideout && flip) {
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->headertype == HEADERDOWN) {
if (sa && ED_area_header_alignment(sa) == RGN_ALIGN_BOTTOM) {
ARegion *ar = CTX_wm_region(C);
if (ar && ar->regiontype == RGN_TYPE_HEADER) {
UI_block_direction_set(block, UI_DIR_UP);

View File

@ -1729,7 +1729,6 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
const char spacetype = sa_dst->spacetype;
const short flag_copy = HEADER_NO_PULLDOWN;
sa_dst->headertype = sa_src->headertype;
sa_dst->spacetype = sa_src->spacetype;
sa_dst->type = sa_src->type;
@ -1759,7 +1758,6 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
{
SWAP(short, sa_dst->headertype, sa_src->headertype);
SWAP(char, sa_dst->spacetype, sa_src->spacetype);
SWAP(SpaceType *, sa_dst->type, sa_src->type);
@ -2327,6 +2325,18 @@ int ED_area_headersize(void)
return (int)(HEADERY * UI_DPI_FAC);
}
int ED_area_header_alignment(const ScrArea *area)
{
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_HEADER) {
return ar->alignment;
}
}
return RGN_ALIGN_NONE;
}
/**
* \return the final height of a global \a area, accounting for DPI.
*/

View File

@ -170,7 +170,7 @@ ScrEdge *screen_find_active_scredge(
static ScrArea *screen_addarea_ex(
ScrAreaMap *area_map,
ScrVert *bottom_left, ScrVert *top_left, ScrVert *top_right, ScrVert *bottom_right,
short headertype, short spacetype)
short spacetype)
{
ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
@ -178,7 +178,6 @@ static ScrArea *screen_addarea_ex(
sa->v2 = top_left;
sa->v3 = top_right;
sa->v4 = bottom_right;
sa->headertype = headertype;
sa->spacetype = spacetype;
BLI_addtail(&area_map->areabase, sa);
@ -188,10 +187,10 @@ static ScrArea *screen_addarea_ex(
static ScrArea *screen_addarea(
bScreen *sc,
ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, ScrVert *right_bottom,
short headertype, short spacetype)
short spacetype)
{
return screen_addarea_ex(AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom,
headertype, spacetype);
spacetype);
}
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
@ -273,7 +272,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
if (fac > 0.5f) {
/* new areas: top */
newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype);
newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->spacetype);
/* area below */
sa->v2 = sv1;
@ -281,7 +280,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
}
else {
/* new areas: bottom */
newa = screen_addarea(sc, sa->v1, sv1, sv2, sa->v4, sa->headertype, sa->spacetype);
newa = screen_addarea(sc, sa->v1, sv1, sv2, sa->v4, sa->spacetype);
/* area above */
sa->v1 = sv1;
@ -305,7 +304,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
if (fac > 0.5f) {
/* new areas: right */
newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->headertype, sa->spacetype);
newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->spacetype);
/* area left */
sa->v3 = sv2;
@ -313,7 +312,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
}
else {
/* new areas: left */
newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype);
newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->spacetype);
/* area right */
sa->v1 = sv1;
@ -355,7 +354,7 @@ bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y)
screen_addedge(sc, sv4, sv1);
/* dummy type, no spacedata */
screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY);
screen_addarea(sc, sv1, sv2, sv3, sv4, SPACE_EMPTY);
return sc;
}
@ -1093,7 +1092,7 @@ int ED_screen_area_active(const bContext *C)
*/
static ScrArea *screen_area_create_with_geometry(
ScrAreaMap *area_map, const rcti *rect,
short headertype, short spacetype)
short spacetype)
{
ScrVert *bottom_left = screen_addvert_ex(area_map, rect->xmin, rect->ymin);
ScrVert *top_left = screen_addvert_ex(area_map, rect->xmin, rect->ymax);
@ -1105,7 +1104,7 @@ static ScrArea *screen_area_create_with_geometry(
screen_addedge_ex(area_map, top_right, bottom_right);
screen_addedge_ex(area_map, bottom_right, bottom_left);
return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, headertype, spacetype);
return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, spacetype);
}
void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
@ -1120,7 +1119,7 @@ void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
rect.ymin = rect.ymax - size_y;
sa = screen_area_create_with_geometry(&win->global_areas, &rect, HEADERTOP, SPACE_TOPBAR);
sa = screen_area_create_with_geometry(&win->global_areas, &rect, SPACE_TOPBAR);
st = BKE_spacetype_from_id(SPACE_TOPBAR);
sl = st->new(sa, WM_window_get_active_scene(win));
sa->regionbase = sl->regionbase;

View File

@ -2112,7 +2112,8 @@ static int region_scale_get_maxsize(RegionMoveData *rmd)
if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) {
/* this calculation seems overly verbose
* can someone explain why this method is necessary? - campbell */
maxsize = rmd->maxsize - ((rmd->sa->headertype == HEADERTOP) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4);
const bool top_header = ED_area_header_alignment(rmd->sa) == RGN_ALIGN_TOP;
maxsize = rmd->maxsize - ((top_header) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4);
}
return maxsize;

View File

@ -264,7 +264,7 @@ typedef struct ScrArea {
short winx, winy; /* size */
short headertype; /* OLD! 0=no header, 1= down, 2= up */
short headertype DNA_DEPRECATED;/* OLD! 0=no header, 1= down, 2= up */
short do_refresh; /* private, for spacetype refresh callback */
short flag;
short region_active_win; /* index of last used region of 'RGN_TYPE_WINDOW'
@ -355,9 +355,6 @@ enum {
#define AREAMINX 32
#define HEADERY 26
#define HEADERDOWN 1
#define HEADERTOP 2
/* screen->state */
enum {
SCREENNORMAL = 0,