diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index d6235384e6e..4acbe360ab4 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -298,7 +298,7 @@ static int rct_fits(rcti *rect, char dir, int size) } } -static void region_rect_recursive(ARegion *ar, rcti *remainder) +static void region_rect_recursive(ARegion *ar, rcti *remainder, int quad) { int prefsizex, prefsizey; @@ -307,7 +307,8 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; - if(ar->next==NULL) + /* user errors */ + if(ar->next==NULL && ar->alignment!=RGN_ALIGN_QSPLIT) ar->alignment= RGN_ALIGN_NONE; prefsizex= ar->type->minsizex; @@ -372,7 +373,7 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) } } } - else { + else if(ar->alignment==RGN_ALIGN_VSPLIT || ar->alignment==RGN_ALIGN_HSPLIT) { /* percentage subdiv*/ ar->winrct= *remainder; @@ -395,11 +396,55 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) } } } + else if(ar->alignment==RGN_ALIGN_QSPLIT) { + ar->winrct= *remainder; + + /* test if there's still 4 regions left */ + if(quad==0) { + ARegion *artest= ar->next; + int count= 1; + + while(artest) { + artest->alignment= RGN_ALIGN_QSPLIT; + artest= artest->next; + count++; + } + + if(count!=4) { + /* let's stop adding regions */ + BLI_init_rcti(remainder, 0, 0, 0, 0); + printf("region quadsplit failed\n"); + } + else quad= 1; + } + if(quad) { + if(quad==1) { /* left bottom */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + } + else if(quad==2) { /* left top */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + } + else if(quad==3) { /* right bottom */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + } + else { /* right top */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + BLI_init_rcti(remainder, 0, 0, 0, 0); + } + + quad++; + } + } + /* for speedup */ ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; - region_rect_recursive(ar->next, remainder); + region_rect_recursive(ar->next, remainder, quad); } static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) @@ -508,14 +553,14 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } for(ar= sa->regionbase.first; ar; ar= ar->next) - ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); + ar->type= BKE_regiontype_from_id(sa->type, ar->regiontype); /* area sizes */ area_calc_totrct(sa, win->sizex, win->sizey); /* region rect sizes */ rect= sa->totrct; - region_rect_recursive(sa->regionbase.first, &rect); + region_rect_recursive(sa->regionbase.first, &rect, 0); /* default area handlers */ ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag); @@ -569,11 +614,13 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); } - /* regions... XXX */ + /* regions */ + for(ar= sa1->regionbase.first; ar; ar= ar->next) + BKE_area_region_free(sa1->type, ar); BLI_freelistN(&sa1->regionbase); for(ar= sa2->regionbase.first; ar; ar= ar->next) { - ARegion *newar= BKE_area_region_copy(ar); + ARegion *newar= BKE_area_region_copy(sa2->type, ar); BLI_addtail(&sa1->regionbase, newar); } |