diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 6 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 62 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 19 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 1 |
4 files changed, 81 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 60ef3e740c6..0de6907e677 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -178,6 +178,12 @@ void ED_area_update_region_sizes(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); bool ED_area_has_shared_border(struct ScrArea *a, struct ScrArea *b); +ScrArea *ED_area_offscreen_create(struct wmWindowManager *wm, + struct wmWindow *win, + eSpace_Type space_type); +void ED_area_offscreen_free(struct wmWindowManager *wm, + struct wmWindow *win, + struct ScrArea *area); ScrArea *ED_screen_areas_iter_first(const struct wmWindow *win, const bScreen *screen); ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 833c9accf95..d5456482d67 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2001,6 +2001,68 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) } } +static void area_offscreen_init(wmWindowManager *wm, ScrArea *area) +{ + area->type = BKE_spacetype_from_id(area->spacetype); + + if (area->type == NULL) { + area->spacetype = SPACE_VIEW3D; + area->type = BKE_spacetype_from_id(area->spacetype); + } + + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + region->type = BKE_regiontype_from_id_or_first(area->type, region->regiontype); + } +} + +ScrArea *ED_area_offscreen_create(wmWindowManager *wm, wmWindow *win, eSpace_Type space_type) +{ + ScrArea *area = MEM_callocN(sizeof(*area), __func__); + area->spacetype = space_type; + + screen_area_spacelink_add(WM_window_get_active_scene(win), area, space_type); + area_offscreen_init(wm, area); + + return area; +} + +static void area_offscreen_exit(wmWindowManager *wm, wmWindow *win, ScrArea *area) +{ + if (area->type && area->type->exit) { + area->type->exit(wm, area); + } + + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + if (region->type && region->type->exit) { + region->type->exit(wm, region); + } + + WM_event_modal_handler_region_replace(win, region, NULL); + WM_draw_region_free(region, true); + + MEM_SAFE_FREE(region->headerstr); + + if (region->regiontimer) { + WM_event_remove_timer(wm, win, region->regiontimer); + region->regiontimer = NULL; + } + + if (wm->message_bus) { + WM_msgbus_clear_by_owner(wm->message_bus, region); + } + } + + WM_event_modal_handler_area_replace(win, area, NULL); +} + +void ED_area_offscreen_free(wmWindowManager *wm, wmWindow *win, ScrArea *area) +{ + area_offscreen_exit(wm, win, area); + + BKE_screen_area_free(area); + MEM_freeN(area); +} + static void region_update_rect(ARegion *region) { region->winx = BLI_rcti_size_x(®ion->winrct) + 1; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 1c068fdd6e4..02b1e002d86 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -574,6 +574,17 @@ bool screen_area_close(struct bContext *C, bScreen *screen, ScrArea *area) return screen_area_join_ex(C, screen, sa2, area, true); } +void screen_area_spacelink_add(Scene *scene, ScrArea *area, eSpace_Type space_type) +{ + SpaceType *stype = BKE_spacetype_from_id(space_type); + SpaceLink *slink = stype->create(area, scene); + + area->regionbase = slink->regionbase; + + BLI_addhead(&area->spacedata, slink); + BLI_listbase_clear(&slink->regionbase); +} + /* ****************** EXPORTED API TO OTHER MODULES *************************** */ /* screen sets cursor based on active region */ @@ -1023,13 +1034,7 @@ static void screen_global_area_refresh(wmWindow *win, } else { area = screen_area_create_with_geometry(&win->global_areas, rect, space_type); - SpaceType *stype = BKE_spacetype_from_id(space_type); - SpaceLink *slink = stype->create(area, WM_window_get_active_scene(win)); - - area->regionbase = slink->regionbase; - - BLI_addhead(&area->spacedata, slink); - BLI_listbase_clear(&slink->regionbase); + screen_area_spacelink_add(WM_window_get_active_scene(win), area, space_type); /* Data specific to global areas. */ area->global = MEM_callocN(sizeof(*area->global), __func__); diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 04ee62b1631..47229e5e2b5 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -94,6 +94,7 @@ eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b); void area_getoffsets( ScrArea *sa_a, ScrArea *sa_b, const eScreenDir dir, int *r_offset1, int *r_offset2); bool screen_area_close(struct bContext *C, bScreen *screen, ScrArea *area); +void screen_area_spacelink_add(struct Scene *scene, ScrArea *area, eSpace_Type space_type); struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); /* screen_geometry.c */ |