diff options
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 73 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 2 |
4 files changed, 42 insertions, 46 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 32e4301d492..30f7c637868 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1375,56 +1375,51 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar) } /** - * sa2 to sa1, * we swap spaces for fullscreen to keep all allocated data area vertices were set - * - * \param swap_space - * - 0: overwrite \a sa1 (freeing its data). - * - 1: simply swap. - * - 2: overwrite \a sa1 (when sa1 is calloc'd memory). */ -void area_copy_data(ScrArea *sa1, ScrArea *sa2, const char swap_space) +void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free) { SpaceType *st; ARegion *ar; - int spacetype = sa1->spacetype; - - sa1->headertype = sa2->headertype; - sa1->spacetype = sa2->spacetype; - sa1->type = sa2->type; - sa1->butspacetype = sa2->butspacetype; + const char spacetype = sa_dst->spacetype; - if (swap_space == 0) { - BKE_spacedata_freelist(&sa1->spacedata); - BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); - } - else if (swap_space == 1) { - SWAP(ListBase, sa1->spacedata, sa2->spacedata); - } - else if (swap_space == 2) { - BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); + sa_dst->headertype = sa_src->headertype; + sa_dst->spacetype = sa_src->spacetype; + sa_dst->type = sa_src->type; + sa_dst->butspacetype = sa_src->butspacetype; + + /* area */ + if (do_free) { + BKE_spacedata_freelist(&sa_dst->spacedata); } - + BKE_spacedata_copylist(&sa_dst->spacedata, &sa_src->spacedata); + /* Note; SPACE_EMPTY is possible on new screens */ - + /* regions */ - if (swap_space == 0) { + if (do_free) { st = BKE_spacetype_from_id(spacetype); - for (ar = sa1->regionbase.first; ar; ar = ar->next) + for (ar = sa_dst->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); - BLI_freelistN(&sa1->regionbase); + BLI_freelistN(&sa_dst->regionbase); } - else if (swap_space == 1) { - SWAP(ListBase, sa1->regionbase, sa2->regionbase); + st = BKE_spacetype_from_id(sa_src->spacetype); + for (ar = sa_src->regionbase.first; ar; ar = ar->next) { + ARegion *newar = BKE_area_region_copy(st, ar); + BLI_addtail(&sa_dst->regionbase, newar); } +} - if (swap_space != 1) { - st = BKE_spacetype_from_id(sa2->spacetype); - for (ar = sa2->regionbase.first; ar; ar = ar->next) { - ARegion *newar = BKE_area_region_copy(st, ar); - BLI_addtail(&sa1->regionbase, newar); - } - } +void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src) +{ + sa_dst->headertype = sa_src->headertype; + sa_dst->spacetype = sa_src->spacetype; + sa_dst->type = sa_src->type; + sa_dst->butspacetype = sa_src->butspacetype; + + + SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata); + SWAP(ListBase, sa_dst->regionbase, sa_src->regionbase); } /* *********** Space switching code *********** */ @@ -1436,9 +1431,9 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) ED_area_exit(C, sa1); ED_area_exit(C, sa2); - area_copy_data(tmp, sa1, 2); - area_copy_data(sa1, sa2, 0); - area_copy_data(sa2, tmp, 0); + ED_area_data_copy(tmp, sa1, false); + ED_area_data_copy(sa1, sa2, true); + ED_area_data_copy(sa2, tmp, true); ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa1); ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa2); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6263199cf4f..2f1ca99ffb9 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -412,7 +412,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) sa->v4 = sv2; } - area_copy_data(newa, sa, 0); + ED_area_data_copy(newa, sa, true); } else { @@ -444,7 +444,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) sa->v2 = sv2; } - area_copy_data(newa, sa, 0); + ED_area_data_copy(newa, sa, true); } /* remove double vertices en edges */ @@ -525,7 +525,7 @@ static void screen_copy(bScreen *to, bScreen *from) BLI_listbase_clear(&sa->actionzones); BLI_listbase_clear(&sa->handlers); - area_copy_data(sa, saf, 0); + ED_area_data_copy(sa, saf, true); } /* put at zero (needed?) */ @@ -1840,7 +1840,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) return NULL; } - area_copy_data(old, sa, 1); + ED_area_data_swap(old, sa); if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; old->full = NULL; @@ -1887,7 +1887,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* copy area */ newa = newa->prev; - area_copy_data(newa, sa, 1); + ED_area_data_swap(newa, sa); sa->flag |= AREA_TEMP_INFO; sa->full = oldscreen; diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index de04f8e3a0f..9e0421b6e99 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -38,7 +38,8 @@ struct Scene; #define AZONESPOT (0.6f * U.widget_unit) /* area.c */ -void area_copy_data(ScrArea *sa1, ScrArea *sa2, const char swap_space); +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 region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade); /* screen_edit.c */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 915ed7679f4..91d99e32559 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -939,7 +939,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) newwin->screen = newsc; /* copy area to new screen */ - area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); + ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true); ED_area_tag_redraw((ScrArea *)newsc->areabase.first); |