Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/workspace/screen_edit.c
- This file was moved from source/blender/editors/screen/screen_edit.c.
| Show All 16 Lines | |||||
| * | * | ||||
| * The Original Code is Copyright (C) 2008 Blender Foundation. | * The Original Code is Copyright (C) 2008 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file blender/editors/screen/screen_edit.c | /** \file blender/editors/workspace/screen_edit.c | ||||
| * \ingroup edscr | * \ingroup edworkspace | ||||
| */ | */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Show All 11 Lines | |||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_library_remap.h" | #include "BKE_library_remap.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_screen_types.h" | #include "ED_screen_types.h" | ||||
| #include "ED_clip.h" | #include "ED_clip.h" | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| bool scredge_is_horizontal(ScrEdge *se) | bool scredge_is_horizontal(ScrEdge *se) | ||||
| { | { | ||||
| return (se->v1->vec.y == se->v2->vec.y); | return (se->v1->vec.y == se->v2->vec.y); | ||||
| } | } | ||||
| /* need win size to make sure not to include edges along screen edge */ | /* need win size to make sure not to include edges along screen edge */ | ||||
| ScrEdge *screen_find_active_scredge(bScreen *sc, | ScrEdge *screen_find_active_scredge(const bScreen *sc, | ||||
| const int winsize_x, const int winsize_y, | const int winsize_x, const int winsize_y, | ||||
| const int mx, const int my) | const int mx, const int my) | ||||
| { | { | ||||
| ScrEdge *se; | ScrEdge *se; | ||||
| int safety = U.widget_unit / 10; | int safety = U.widget_unit / 10; | ||||
| if (safety < 2) safety = 2; | if (safety < 2) safety = 2; | ||||
| ▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) | ||||
| if (merge) | if (merge) | ||||
| removedouble_scrverts(sc); | removedouble_scrverts(sc); | ||||
| removedouble_scredges(sc); | removedouble_scredges(sc); | ||||
| removenotused_scredges(sc); | removenotused_scredges(sc); | ||||
| return newa; | return newa; | ||||
| } | } | ||||
| /* empty screen, with 1 dummy area without spacedata */ | /** | ||||
| /* uses window size */ | * Empty screen, with 1 dummy area without spacedata. Uses window size. | ||||
| bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) | */ | ||||
| bScreen *screen_add(wmWindow *win, const char *name, const int winsize_x, const int winsize_y) | |||||
| { | { | ||||
| const int winsize_x = WM_window_pixels_x(win); | |||||
| const int winsize_y = WM_window_pixels_y(win); | |||||
| bScreen *sc; | bScreen *sc; | ||||
| ScrVert *sv1, *sv2, *sv3, *sv4; | ScrVert *sv1, *sv2, *sv3, *sv4; | ||||
| sc = BKE_libblock_alloc(G.main, ID_SCR, name); | sc = BKE_libblock_alloc(G.main, ID_SCR, name); | ||||
| sc->scene = scene; | |||||
| sc->do_refresh = true; | sc->do_refresh = true; | ||||
| sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; | sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; | ||||
| sc->winid = win->winid; | sc->winid = win->winid; | ||||
| sv1 = screen_addvert(sc, 0, 0); | sv1 = screen_addvert(sc, 0, 0); | ||||
| sv2 = screen_addvert(sc, 0, winsize_y - 1); | sv2 = screen_addvert(sc, 0, winsize_y - 1); | ||||
| sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1); | sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1); | ||||
| sv4 = screen_addvert(sc, winsize_x - 1, 0); | sv4 = screen_addvert(sc, winsize_x - 1, 0); | ||||
| screen_addedge(sc, sv1, sv2); | screen_addedge(sc, sv1, sv2); | ||||
| screen_addedge(sc, sv2, sv3); | screen_addedge(sc, sv2, sv3); | ||||
| screen_addedge(sc, sv3, sv4); | screen_addedge(sc, sv3, sv4); | ||||
| screen_addedge(sc, sv4, sv1); | screen_addedge(sc, sv4, sv1); | ||||
| /* dummy type, no spacedata */ | /* dummy type, no spacedata */ | ||||
| screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY); | screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY); | ||||
| return sc; | return sc; | ||||
| } | } | ||||
| static void screen_copy(bScreen *to, bScreen *from) | void screen_data_copy(bScreen *to, bScreen *from) | ||||
| { | { | ||||
| ScrVert *s1, *s2; | ScrVert *s1, *s2; | ||||
| ScrEdge *se; | ScrEdge *se; | ||||
| ScrArea *sa, *saf; | ScrArea *sa, *saf; | ||||
| /* free contents of 'to', is from blenkernel screen.c */ | /* free contents of 'to', is from blenkernel screen.c */ | ||||
| BKE_screen_free(to); | BKE_screen_free(to); | ||||
| Show All 26 Lines | for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { | ||||
| BLI_listbase_clear(&sa->handlers); | BLI_listbase_clear(&sa->handlers); | ||||
| ED_area_data_copy(sa, saf, true); | ED_area_data_copy(sa, saf, true); | ||||
| } | } | ||||
| /* put at zero (needed?) */ | /* put at zero (needed?) */ | ||||
| for (s1 = from->vertbase.first; s1; s1 = s1->next) | for (s1 = from->vertbase.first; s1; s1 = s1->next) | ||||
| s1->newv = NULL; | s1->newv = NULL; | ||||
| } | |||||
| /** | |||||
| * Prepare a newly created screen for initializing it as active screen. | |||||
| */ | |||||
| void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new) | |||||
| { | |||||
| screen_new->winid = win->winid; | |||||
| screen_new->do_refresh = true; | |||||
| screen_new->do_draw = true; | |||||
| } | } | ||||
| /* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ | /* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ | ||||
| /* -1 = not valid check */ | /* -1 = not valid check */ | ||||
| /* used with join operator */ | /* used with join operator */ | ||||
| int area_getorientation(ScrArea *sa, ScrArea *sb) | int area_getorientation(ScrArea *sa, ScrArea *sb) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ****************** EXPORTED API TO OTHER MODULES *************************** */ | /* ****************** EXPORTED API TO OTHER MODULES *************************** */ | ||||
| bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) | |||||
| { | |||||
| bScreen *newsc; | |||||
| if (sc->state != SCREENNORMAL) return NULL; /* XXX handle this case! */ | |||||
| /* make new empty screen: */ | |||||
| newsc = ED_screen_add(win, sc->scene, sc->id.name + 2); | |||||
| /* copy all data */ | |||||
| screen_copy(newsc, sc); | |||||
| return newsc; | |||||
| } | |||||
| /* screen sets cursor based on swinid */ | /* screen sets cursor based on swinid */ | ||||
| static void region_cursor_set(wmWindow *win, int swinid, int swin_changed) | static void region_cursor_set(wmWindow *win, int swinid, int swin_changed) | ||||
| { | { | ||||
| for (ScrArea *sa = win->screen->areabase.first; sa; sa = sa->next) { | bScreen *screen = WM_window_get_active_screen(win); | ||||
| for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | |||||
| for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | ||||
| if (ar->swinid == swinid) { | if (ar->swinid == swinid) { | ||||
| if (swin_changed || (ar->type && ar->type->event_cursor)) { | if (swin_changed || (ar->type && ar->type->event_cursor)) { | ||||
| if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) { | if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ED_region_cursor_set(win, sa, ar); | ED_region_cursor_set(win, sa, ar); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void ED_screen_do_listen(bContext *C, wmNotifier *note) | void ED_screen_do_listen(bContext *C, wmNotifier *note) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| /* generic notes */ | /* generic notes */ | ||||
| switch (note->category) { | switch (note->category) { | ||||
| case NC_WM: | case NC_WM: | ||||
| if (note->data == ND_FILEREAD) | if (note->data == ND_FILEREAD) | ||||
| win->screen->do_draw = true; | screen->do_draw = true; | ||||
| break; | break; | ||||
| case NC_WINDOW: | case NC_WINDOW: | ||||
| win->screen->do_draw = true; | screen->do_draw = true; | ||||
| break; | break; | ||||
| case NC_SCREEN: | case NC_WORKSPACE: | ||||
| if (note->action == NA_EDITED) | if (note->action == NA_EDITED) | ||||
| win->screen->do_draw = win->screen->do_refresh = true; | screen->do_draw = screen->do_refresh = true; | ||||
| break; | break; | ||||
| case NC_SCENE: | case NC_SCENE: | ||||
| if (note->data == ND_MODE) | if (note->data == ND_MODE) | ||||
| region_cursor_set(win, note->swinid, true); | region_cursor_set(win, note->swinid, true); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* helper call for below, dpi changes headers */ | /* helper call for below, dpi changes headers */ | ||||
| static void screen_refresh_headersizes(void) | static void screen_refresh_headersizes(void) | ||||
| { | { | ||||
| const ListBase *lb = BKE_spacetypes_list(); | const ListBase *lb = BKE_spacetypes_list(); | ||||
| SpaceType *st; | SpaceType *st; | ||||
| for (st = lb->first; st; st = st->next) { | for (st = lb->first; st; st = st->next) { | ||||
| ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); | ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); | ||||
| if (art) art->prefsizey = ED_area_headersize(); | if (art) art->prefsizey = ED_area_headersize(); | ||||
| } | } | ||||
| } | } | ||||
| /* make this screen usable */ | /* make this screen usable */ | ||||
| /* for file read and first use, for scaling window, area moves */ | /* for file read and first use, for scaling window, area moves */ | ||||
| void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) | void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) | ||||
| { | { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | |||||
| /* exception for bg mode, we only need the screen context */ | /* exception for bg mode, we only need the screen context */ | ||||
| if (!G.background) { | if (!G.background) { | ||||
| const int winsize_x = WM_window_pixels_x(win); | const int winsize_x = WM_window_pixels_x(win); | ||||
| const int winsize_y = WM_window_pixels_y(win); | const int winsize_y = WM_window_pixels_y(win); | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| rcti winrct; | rcti winrct; | ||||
| winrct.xmin = 0; | winrct.xmin = 0; | ||||
| winrct.xmax = winsize_x - 1; | winrct.xmax = winsize_x - 1; | ||||
| winrct.ymin = 0; | winrct.ymin = 0; | ||||
| winrct.ymax = winsize_y - 1; | winrct.ymax = winsize_y - 1; | ||||
| /* header size depends on DPI, let's verify */ | /* header size depends on DPI, let's verify */ | ||||
| screen_refresh_headersizes(); | screen_refresh_headersizes(); | ||||
| screen_test_scale(win->screen, winsize_x, winsize_y); | screen_test_scale(screen, winsize_x, winsize_y); | ||||
| if (win->screen->mainwin == 0) { | if (screen->mainwin == 0) { | ||||
| win->screen->mainwin = wm_subwindow_open(win, &winrct, false); | screen->mainwin = wm_subwindow_open(win, &winrct, false); | ||||
| } | } | ||||
| else { | else { | ||||
| wm_subwindow_position(win, win->screen->mainwin, &winrct, false); | wm_subwindow_position(win, screen->mainwin, &winrct, false); | ||||
| } | } | ||||
| for (sa = win->screen->areabase.first; sa; sa = sa->next) { | for (sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| /* set spacetype and region callbacks, calls init() */ | /* set spacetype and region callbacks, calls init() */ | ||||
| /* sets subwindows for regions, adds handlers */ | /* sets subwindows for regions, adds handlers */ | ||||
| ED_area_initialize(wm, win, sa); | ED_area_initialize(wm, win, sa); | ||||
| } | } | ||||
| /* wake up animtimer */ | /* wake up animtimer */ | ||||
| if (win->screen->animtimer) | if (screen->animtimer) | ||||
| WM_event_timer_sleep(wm, win, win->screen->animtimer, false); | WM_event_timer_sleep(wm, win, screen->animtimer, false); | ||||
| } | } | ||||
| if (G.debug & G_DEBUG_EVENTS) { | if (G.debug & G_DEBUG_EVENTS) { | ||||
| printf("%s: set screen\n", __func__); | printf("%s: set screen\n", __func__); | ||||
| } | } | ||||
| win->screen->do_refresh = false; | screen->do_refresh = false; | ||||
| /* prevent multiwin errors */ | |||||
| screen->winid = win->winid; | |||||
| win->screen->context = ed_screen_context; | screen->context = ed_screen_context; | ||||
| } | } | ||||
| /* file read, set all screens, ... */ | /* file read, set all screens, ... */ | ||||
| void ED_screens_initialize(wmWindowManager *wm) | void ED_screens_initialize(wmWindowManager *wm) | ||||
| { | { | ||||
| wmWindow *win; | wmWindow *win; | ||||
| for (win = wm->windows.first; win; win = win->next) { | for (win = wm->windows.first; win; win = win->next) { | ||||
| if (WM_window_get_active_workspace(win) == NULL) { | |||||
| if (win->screen == NULL) | WM_window_set_active_workspace(win, G.main->workspaces.first); | ||||
| win->screen = G.main->screen.first; | } | ||||
| ED_screen_refresh(wm, win); | ED_screen_refresh(wm, win); | ||||
| } | } | ||||
| } | } | ||||
| /* *********** exit calls are for closing running stuff ******** */ | /* *********** exit calls are for closing running stuff ******** */ | ||||
| void ED_region_exit(bContext *C, ARegion *ar) | void ED_region_exit(bContext *C, ARegion *ar) | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | for (ar = screen->regionbase.first; ar; ar = ar->next) | ||||
| ED_region_exit(C, ar); | ED_region_exit(C, ar); | ||||
| for (sa = screen->areabase.first; sa; sa = sa->next) | for (sa = screen->areabase.first; sa; sa = sa->next) | ||||
| ED_area_exit(C, sa); | ED_area_exit(C, sa); | ||||
| /* mark it available for use for other windows */ | /* mark it available for use for other windows */ | ||||
| screen->winid = 0; | screen->winid = 0; | ||||
| if (prevwin->screen->temp == 0) { | if (!WM_window_is_temp_screen(prevwin)) { | ||||
| /* use previous window if possible */ | /* use previous window if possible */ | ||||
| CTX_wm_window_set(C, prevwin); | CTX_wm_window_set(C, prevwin); | ||||
| } | } | ||||
| else { | else { | ||||
| /* none otherwise */ | /* none otherwise */ | ||||
| CTX_wm_window_set(C, NULL); | CTX_wm_window_set(C, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* *********************************** */ | /* *********************************** */ | ||||
| /* case when on area-edge or in azones, or outside window */ | /* case when on area-edge or in azones, or outside window */ | ||||
| static void screen_cursor_set(wmWindow *win, wmEvent *event) | static void screen_cursor_set(wmWindow *win, wmEvent *event) | ||||
| { | { | ||||
| const bScreen *screen = WM_window_get_active_screen(win); | |||||
| const int winsize_x = WM_window_pixels_x(win); | const int winsize_x = WM_window_pixels_x(win); | ||||
| const int winsize_y = WM_window_pixels_y(win); | const int winsize_y = WM_window_pixels_y(win); | ||||
| AZone *az = NULL; | AZone *az = NULL; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| for (sa = win->screen->areabase.first; sa; sa = sa->next) | for (sa = screen->areabase.first; sa; sa = sa->next) | ||||
| if ((az = is_in_area_actionzone(sa, &event->x))) | if ((az = is_in_area_actionzone(sa, &event->x))) | ||||
| break; | break; | ||||
| if (sa) { | if (sa) { | ||||
| if (az->type == AZONE_AREA) | if (az->type == AZONE_AREA) | ||||
| WM_cursor_set(win, CURSOR_EDIT); | WM_cursor_set(win, CURSOR_EDIT); | ||||
| else if (az->type == AZONE_REGION) { | else if (az->type == AZONE_REGION) { | ||||
| if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) | if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) | ||||
| WM_cursor_set(win, CURSOR_X_MOVE); | WM_cursor_set(win, CURSOR_X_MOVE); | ||||
| else | else | ||||
| WM_cursor_set(win, CURSOR_Y_MOVE); | WM_cursor_set(win, CURSOR_Y_MOVE); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ScrEdge *actedge = screen_find_active_scredge(win->screen, winsize_x, winsize_y, event->x, event->y); | ScrEdge *actedge = screen_find_active_scredge(screen, winsize_x, winsize_y, event->x, event->y); | ||||
| if (actedge) { | if (actedge) { | ||||
| if (scredge_is_horizontal(actedge)) | if (scredge_is_horizontal(actedge)) | ||||
| WM_cursor_set(win, CURSOR_Y_MOVE); | WM_cursor_set(win, CURSOR_Y_MOVE); | ||||
| else | else | ||||
| WM_cursor_set(win, CURSOR_X_MOVE); | WM_cursor_set(win, CURSOR_X_MOVE); | ||||
| } | } | ||||
| else | else | ||||
| WM_cursor_set(win, CURSOR_STD); | WM_cursor_set(win, CURSOR_STD); | ||||
| } | } | ||||
| } | } | ||||
| /* called in wm_event_system.c. sets state vars in screen, cursors */ | /* called in wm_event_system.c. sets state vars in screen, cursors */ | ||||
| /* event type is mouse move */ | /* event type is mouse move */ | ||||
| void ED_screen_set_subwinactive(bContext *C, wmEvent *event) | void ED_screen_set_subwinactive(bContext *C, wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| bScreen *scr = WM_window_get_active_screen(win); | |||||
| if (win->screen) { | if (scr) { | ||||
| bScreen *scr = win->screen; | |||||
| ScrArea *sa; | ScrArea *sa; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| int oldswin = scr->subwinactive; | int oldswin = scr->subwinactive; | ||||
| for (sa = scr->areabase.first; sa; sa = sa->next) { | for (sa = scr->areabase.first; sa; sa = sa->next) { | ||||
| if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) | if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) | ||||
| if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) | if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) | ||||
| if (NULL == is_in_area_actionzone(sa, &event->x)) | if (NULL == is_in_area_actionzone(sa, &event->x)) | ||||
| Show All 36 Lines | if (scr) { | ||||
| else { | else { | ||||
| /* notifier invokes freeing the buttons... causing a bit too much redraws */ | /* notifier invokes freeing the buttons... causing a bit too much redraws */ | ||||
| if (oldswin != scr->subwinactive) { | if (oldswin != scr->subwinactive) { | ||||
| region_cursor_set(win, scr->subwinactive, true); | region_cursor_set(win, scr->subwinactive, true); | ||||
| /* this used to be a notifier, but needs to be done immediate | /* this used to be a notifier, but needs to be done immediate | ||||
| * because it can undo setting the right button as active due | * because it can undo setting the right button as active due | ||||
| * to delayed notifier handling */ | * to delayed notifier handling */ | ||||
| UI_screen_free_active_but(C, win->screen); | UI_screen_free_active_but(C, scr); | ||||
| } | } | ||||
| else | else | ||||
| region_cursor_set(win, scr->subwinactive, false); | region_cursor_set(win, scr->subwinactive, false); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| int ED_screen_area_active(const bContext *C) | int ED_screen_area_active(const bContext *C) | ||||
| Show All 11 Lines | if (win && sc && sa) { | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) | for (ar = sa->regionbase.first; ar; ar = ar->next) | ||||
| if (ar->swinid == sc->subwinactive) | if (ar->swinid == sc->subwinactive) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /* Screen changing */ | |||||
| static bScreen *screen_find_associated_fullscreen(const Main *bmain, bScreen *screen) | |||||
| { | |||||
| for (bScreen *screen_iter = bmain->screen.first; screen_iter; screen_iter = screen_iter->id.next) { | |||||
| ScrArea *sa = screen_iter->areabase.first; | |||||
| if (sa->full == screen) { | |||||
| return screen_iter; | |||||
| } | |||||
| } | |||||
| return screen; | |||||
| } | |||||
| /** | /** | ||||
| * operator call, WM + Window + screen already existed before | * \return the screen to activate. | ||||
| * | * \warning The returned screen may not always equal \a screen_new! | ||||
| * \warning Do NOT call in area/region queues! | |||||
| * \returns success. | |||||
| */ | */ | ||||
| bool ED_screen_set(bContext *C, bScreen *sc) | bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, Main *bmain, bContext *C, wmWindow *win) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| wmWindowManager *wm = CTX_wm_manager(C); | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| bScreen *oldscreen = CTX_wm_screen(C); | |||||
| /* validate screen, it's called with notifier reference */ | /* validate screen, it's called with notifier reference */ | ||||
| if (BLI_findindex(&bmain->screen, sc) == -1) { | if (BLI_findindex(&bmain->screen, screen_new) == -1) { | ||||
| return true; | return NULL; | ||||
| } | } | ||||
| if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) { | if (ELEM(screen_new->state, SCREENMAXIMIZED, SCREENFULL)) { | ||||
| /* find associated full */ | screen_new = screen_find_associated_fullscreen(bmain, screen_new); | ||||
| bScreen *sc1; | |||||
| for (sc1 = bmain->screen.first; sc1; sc1 = sc1->id.next) { | |||||
| ScrArea *sa = sc1->areabase.first; | |||||
| if (sa->full == sc) { | |||||
| sc = sc1; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| /* check for valid winid */ | /* check for valid winid */ | ||||
| if (sc->winid != 0 && sc->winid != win->winid) { | if (!(screen_new->winid == 0 || screen_new->winid == win->winid)) { | ||||
| return false; | return NULL; | ||||
| } | } | ||||
| if (oldscreen != sc) { | if (screen_old != screen_new) { | ||||
| wmTimer *wt = oldscreen->animtimer; | wmTimer *wt = screen_old->animtimer; | ||||
| ScrArea *sa; | |||||
| Scene *oldscene = oldscreen->scene; | |||||
| /* remove handlers referencing areas in old screen */ | /* remove handlers referencing areas in old screen */ | ||||
| for (sa = oldscreen->areabase.first; sa; sa = sa->next) { | for (ScrArea *sa = screen_old->areabase.first; sa; sa = sa->next) { | ||||
| WM_event_remove_area_handler(&win->modalhandlers, sa); | WM_event_remove_area_handler(&win->modalhandlers, sa); | ||||
| } | } | ||||
| /* we put timer to sleep, so screen_exit has to think there's no timer */ | /* we put timer to sleep, so screen_exit has to think there's no timer */ | ||||
| oldscreen->animtimer = NULL; | screen_old->animtimer = NULL; | ||||
| if (wt) { | if (wt) { | ||||
| WM_event_timer_sleep(wm, win, wt, true); | WM_event_timer_sleep(CTX_wm_manager(C), win, wt, true); | ||||
| } | } | ||||
| ED_screen_exit(C, win, screen_old); | |||||
| ED_screen_exit(C, win, oldscreen); | |||||
| /* Same scene, "transfer" playback to new screen. */ | /* Same scene, "transfer" playback to new screen. */ | ||||
| if (wt) { | if (wt) { | ||||
| if (oldscene == sc->scene) { | screen_new->animtimer = wt; | ||||
| sc->animtimer = wt; | |||||
| } | } | ||||
| /* Else, stop playback. */ | |||||
| else { | return screen_new; | ||||
| oldscreen->animtimer = wt; | |||||
| ED_screen_animation_play(C, 0, 0); | |||||
| } | } | ||||
| return NULL; | |||||
| } | } | ||||
| win->screen = sc; | void screen_changed_update(bContext *C, wmWindow *win, bScreen *sc) | ||||
| CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf | { | ||||
| Scene *scene = WM_window_get_active_scene(win); | |||||
| /* prevent multiwin errors */ | CTX_wm_window_set(C, win); /* stores C->wm.screen... hrmf */ | ||||
| sc->winid = win->winid; | |||||
| ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); | ED_screen_refresh(CTX_wm_manager(C), win); | ||||
| BKE_screen_view3d_scene_sync(sc, scene); /* sync new screen with scene data */ | |||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, NULL); | ||||
| WM_event_add_notifier(C, NC_SCREEN | ND_SCREENSET, sc); | WM_event_add_notifier(C, NC_WORKSPACE | ND_SCREENSET, sc); | ||||
| /* makes button hilites work */ | /* makes button hilites work */ | ||||
| WM_event_add_mousemove(C); | WM_event_add_mousemove(C); | ||||
| } | |||||
| /* Needed to make sure all the derivedMeshes are | |||||
| * up-to-date before viewport starts acquiring this. | /** | ||||
| * \brief Change the active screen. | |||||
| * | * | ||||
| * This is needed in cases when, for example, boolean | * Operator call, WM + Window + screen already existed before | ||||
| * modifier uses operant from invisible layer. | |||||
| * Without this trick boolean wouldn't apply correct. | |||||
| * | * | ||||
| * Quite the same happens when setting screen's scene, | * \warning Do NOT call in area/region queues! | ||||
| * so perhaps this is in fact correct thing to do. | * \returns if screen changing was successful. | ||||
| */ | |||||
| if (oldscene != sc->scene) { | |||||
| BKE_scene_set_background(bmain, sc->scene); | |||||
| } | |||||
| /* Always do visible update since it's possible new screen will | |||||
| * have different layers visible in 3D view-ports. | |||||
| * This is possible because of view3d.lock_camera_and_layers option. | |||||
| */ | */ | ||||
| DAG_on_visible_update(bmain, false); | bool ED_screen_change(bContext *C, bScreen *sc) | ||||
| } | |||||
| return true; | |||||
| } | |||||
| static bool ed_screen_used(wmWindowManager *wm, bScreen *sc) | |||||
| { | |||||
| wmWindow *win; | |||||
| for (win = wm->windows.first; win; win = win->next) { | |||||
| if (win->screen == sc) { | |||||
| return true; | |||||
| } | |||||
| if (ELEM(win->screen->state, SCREENMAXIMIZED, SCREENFULL)) { | |||||
| ScrArea *sa = win->screen->areabase.first; | |||||
| if (sa->full == sc) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /* only call outside of area/region loops */ | |||||
| bool ED_screen_delete(bContext *C, bScreen *sc) | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | |||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| bScreen *newsc; | bScreen *screen_old = CTX_wm_screen(C); | ||||
| bScreen *screen_new = screen_change_prepare(screen_old, sc, bmain, C, win); | |||||
| /* don't allow deleting temp fullscreens for now */ | |||||
| if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) { | |||||
| return false; | |||||
| } | |||||
| /* screen can only be in use by one window at a time, so as | |||||
| * long as we are able to find a screen that is unused, we | |||||
| * can safely assume ours is not in use anywhere an delete it */ | |||||
| for (newsc = sc->id.prev; newsc; newsc = newsc->id.prev) | |||||
| if (!ed_screen_used(wm, newsc) && !newsc->temp) | |||||
| break; | |||||
| if (!newsc) { | |||||
| for (newsc = sc->id.next; newsc; newsc = newsc->id.next) | |||||
| if (!ed_screen_used(wm, newsc) && !newsc->temp) | |||||
| break; | |||||
| } | |||||
| if (!newsc) { | |||||
| return false; | |||||
| } | |||||
| ED_screen_set(C, newsc); | if (screen_new) { | ||||
| WM_window_set_active_screen(win, sc); | |||||
| screen_changed_update(C, win, screen_new); | |||||
| if (win->screen != sc) { | |||||
| BKE_libblock_free(bmain, sc); | |||||
| return true; | return true; | ||||
| } | } | ||||
| else { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, View3D *v3d) | static void screen_set_3dview_camera(Scene *scene, ScrArea *sa, View3D *v3d) | ||||
| { | { | ||||
| /* fix any cameras that are used in the 3d view but not in the scene */ | /* fix any cameras that are used in the 3d view but not in the scene */ | ||||
| BKE_screen_view3d_sync(v3d, scene); | BKE_screen_view3d_sync(v3d, scene); | ||||
| if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { | if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { | ||||
| v3d->camera = BKE_scene_camera_find(sc->scene); | v3d->camera = BKE_scene_camera_find(scene); | ||||
| // XXX if (sc == curscreen) handle_view3d_lock(); | // XXX if (sc == curscreen) handle_view3d_lock(); | ||||
| if (!v3d->camera) { | if (!v3d->camera) { | ||||
| ARegion *ar; | ARegion *ar; | ||||
| ListBase *regionbase; | ListBase *regionbase; | ||||
| /* regionbase is in different place depending if space is active */ | /* regionbase is in different place depending if space is active */ | ||||
| if (v3d == sa->spacedata.first) | if (v3d == sa->spacedata.first) | ||||
| regionbase = &sa->regionbase; | regionbase = &sa->regionbase; | ||||
| else | else | ||||
| regionbase = &v3d->regionbase; | regionbase = &v3d->regionbase; | ||||
| for (ar = regionbase->first; ar; ar = ar->next) { | for (ar = regionbase->first; ar; ar = ar->next) { | ||||
| if (ar->regiontype == RGN_TYPE_WINDOW) { | if (ar->regiontype == RGN_TYPE_WINDOW) { | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| if (rv3d->persp == RV3D_CAMOB) { | if (rv3d->persp == RV3D_CAMOB) { | ||||
| rv3d->persp = RV3D_PERSP; | rv3d->persp = RV3D_PERSP; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* only call outside of area/region loops */ | void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new) | ||||
| void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| bScreen *sc; | for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| if (screen == NULL) | |||||
| return; | |||||
| if (ed_screen_used(CTX_wm_manager(C), screen)) | |||||
| ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); | |||||
| for (sc = bmain->screen.first; sc; sc = sc->id.next) { | |||||
| if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { | |||||
| if (scene != sc->scene) { | |||||
| /* all areas endlocalview */ | |||||
| // XXX ScrArea *sa = sc->areabase.first; | |||||
| // while (sa) { | |||||
| // endlocalview(sa); | |||||
| // sa = sa->next; | |||||
| // } | |||||
| sc->scene = scene; | |||||
| } | |||||
| } | |||||
| } | |||||
| // copy_view3d_lock(0); /* space.c */ | |||||
| /* are there cameras in the views that are not in the scene? */ | |||||
| for (sc = bmain->screen.first; sc; sc = sc->id.next) { | |||||
| if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { | |||||
| ScrArea *sa = sc->areabase.first; | |||||
| while (sa) { | |||||
| SpaceLink *sl = sa->spacedata.first; | |||||
| while (sl) { | |||||
| if (sl->spacetype == SPACE_VIEW3D) { | if (sl->spacetype == SPACE_VIEW3D) { | ||||
| View3D *v3d = (View3D *) sl; | View3D *v3d = (View3D *)sl; | ||||
| ed_screen_set_3dview_camera(scene, sc, sa, v3d); | screen_set_3dview_camera(scene_new, sa, v3d); | ||||
| } | |||||
| sl = sl->next; | |||||
| } | } | ||||
| sa = sa->next; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| CTX_data_scene_set(C, scene); | |||||
| BKE_scene_set_background(bmain, scene); | |||||
| DAG_on_visible_update(bmain, false); | |||||
| ED_render_engine_changed(bmain); | |||||
| ED_update_for_newframe(bmain, scene, 1); | |||||
| /* complete redraw */ | |||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | |||||
| } | |||||
| /** | |||||
| * \note Only call outside of area/region loops | |||||
| * \return true if successful | |||||
| */ | |||||
| bool ED_screen_delete_scene(bContext *C, Scene *scene) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *newscene; | |||||
| if (scene->id.prev) | |||||
| newscene = scene->id.prev; | |||||
| else if (scene->id.next) | |||||
| newscene = scene->id.next; | |||||
| else | |||||
| return false; | |||||
| ED_screen_set_scene(C, CTX_wm_screen(C), newscene); | |||||
| BKE_libblock_remap(bmain, scene, newscene, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE); | |||||
| BKE_libblock_free(bmain, scene); | |||||
| return true; | |||||
| } | |||||
| ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) | ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| bScreen *screen = CTX_wm_screen(C); | bScreen *screen = CTX_wm_screen(C); | ||||
| ScrArea *newsa = NULL; | ScrArea *newsa = NULL; | ||||
| if (!sa || sa->full == NULL) { | if (!sa || sa->full == NULL) { | ||||
| newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); | newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * this function toggles: if area is maximized/full then the parent will be restored | * this function toggles: if area is maximized/full then the parent will be restored | ||||
| * | * | ||||
| * \warning \a sa may be freed. | * \warning \a sa may be freed. | ||||
| */ | */ | ||||
| ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state) | ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | |||||
| bScreen *sc, *oldscreen; | bScreen *sc, *oldscreen; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| if (sa) { | if (sa) { | ||||
| /* ensure we don't have a button active anymore, can crash when | /* ensure we don't have a button active anymore, can crash when | ||||
| * switching screens with tooltip open because region and tooltip | * switching screens with tooltip open because region and tooltip | ||||
| * are no longer in the same screen */ | * are no longer in the same screen */ | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) { | for (ar = sa->regionbase.first; ar; ar = ar->next) { | ||||
| UI_blocklist_free(C, &ar->uiblocks); | UI_blocklist_free(C, &ar->uiblocks); | ||||
| if (ar->regiontimer) { | if (ar->regiontimer) { | ||||
| WM_event_remove_timer(wm, NULL, ar->regiontimer); | WM_event_remove_timer(wm, NULL, ar->regiontimer); | ||||
| ar->regiontimer = NULL; | ar->regiontimer = NULL; | ||||
| } | } | ||||
| } | } | ||||
| /* prevent hanging header prints */ | /* prevent hanging header prints */ | ||||
| ED_area_headerprint(sa, NULL); | ED_area_headerprint(sa, NULL); | ||||
| } | } | ||||
| if (sa && sa->full) { | if (sa && sa->full) { | ||||
| WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); | |||||
| /* restoring back to SCREENNORMAL */ | /* restoring back to SCREENNORMAL */ | ||||
| ScrArea *old; | ScrArea *old; | ||||
| sc = sa->full; /* the old screen to restore */ | sc = sa->full; /* the old screen to restore */ | ||||
| oldscreen = win->screen; /* the one disappearing */ | oldscreen = WM_window_get_active_screen(win); /* the one disappearing */ | ||||
| sc->state = SCREENNORMAL; | sc->state = SCREENNORMAL; | ||||
| /* find old area */ | /* find old area */ | ||||
| for (old = sc->areabase.first; old; old = old->next) | for (old = sc->areabase.first; old; old = old->next) | ||||
| if (old->full) break; | if (old->full) break; | ||||
| if (old == NULL) { | if (old == NULL) { | ||||
| if (G.debug & G_DEBUG) | if (G.debug & G_DEBUG) | ||||
| Show All 11 Lines | if (sa && sa->full) { | ||||
| ED_area_data_swap(old, sa); | ED_area_data_swap(old, sa); | ||||
| if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; | if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; | ||||
| old->full = NULL; | old->full = NULL; | ||||
| /* animtimer back */ | /* animtimer back */ | ||||
| sc->animtimer = oldscreen->animtimer; | sc->animtimer = oldscreen->animtimer; | ||||
| oldscreen->animtimer = NULL; | oldscreen->animtimer = NULL; | ||||
| ED_screen_set(C, sc); | ED_screen_change(C, sc); | ||||
| BKE_screen_free(oldscreen); | BKE_workspace_layout_remove(workspace, layout_old, CTX_data_main(C)); | ||||
| BKE_libblock_free(CTX_data_main(C), oldscreen); | |||||
| /* After we've restored back to SCREENNORMAL, we have to wait with | /* After we've restored back to SCREENNORMAL, we have to wait with | ||||
| * screen handling as it uses the area coords which aren't updated yet. | * screen handling as it uses the area coords which aren't updated yet. | ||||
| * Without doing so, the screen handling gets wrong area coords, | * Without doing so, the screen handling gets wrong area coords, | ||||
| * which in worst case can lead to crashes (see T43139) */ | * which in worst case can lead to crashes (see T43139) */ | ||||
| sc->skip_handling = true; | sc->skip_handling = true; | ||||
| } | } | ||||
| else { | else { | ||||
| /* change from SCREENNORMAL to new state */ | /* change from SCREENNORMAL to new state */ | ||||
| WorkSpaceLayout *layout_new; | |||||
| ScrArea *newa; | ScrArea *newa; | ||||
| char newname[MAX_ID_NAME - 2]; | char newname[MAX_ID_NAME - 2]; | ||||
| oldscreen = win->screen; | oldscreen = WM_window_get_active_screen(win); | ||||
| oldscreen->state = state; | oldscreen->state = state; | ||||
| BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal"); | BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal"); | ||||
| sc = ED_screen_add(win, oldscreen->scene, newname); | |||||
| layout_new = ED_workspace_layout_add(workspace, win, newname); | |||||
| sc = BKE_workspace_layout_screen_get(layout_new); | |||||
| sc->state = state; | sc->state = state; | ||||
| sc->redraws_flag = oldscreen->redraws_flag; | sc->redraws_flag = oldscreen->redraws_flag; | ||||
| sc->temp = oldscreen->temp; | sc->temp = oldscreen->temp; | ||||
| /* timer */ | /* timer */ | ||||
| sc->animtimer = oldscreen->animtimer; | sc->animtimer = oldscreen->animtimer; | ||||
| oldscreen->animtimer = NULL; | oldscreen->animtimer = NULL; | ||||
| Show All 38 Lines | else if (state == SCREENFULL) { | ||||
| sa->full = oldscreen; | sa->full = oldscreen; | ||||
| newa->full = oldscreen; | newa->full = oldscreen; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| } | } | ||||
| ED_screen_set(C, sc); | ED_screen_change(C, sc); | ||||
| } | } | ||||
| /* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ | /* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ | ||||
| CTX_wm_area_set(C, sc->areabase.first); | CTX_wm_area_set(C, sc->areabase.first); | ||||
| return sc->areabase.first; | return sc->areabase.first; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (enable) { | ||||
| sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME)); | sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME)); | ||||
| screen->animtimer->customdata = sad; | screen->animtimer->customdata = sad; | ||||
| } | } | ||||
| /* notifier catched by top header, for button */ | /* notifier catched by top header, for button */ | ||||
| WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | ND_ANIMPLAY, NULL); | ||||
| } | } | ||||
| /* helper for screen_animation_play() - only to be used for TimeLine */ | /* helper for screen_animation_play() - only to be used for TimeLine */ | ||||
| static ARegion *time_top_left_3dwindow(bScreen *screen) | static ARegion *time_top_left_3dwindow(bScreen *screen) | ||||
| { | { | ||||
| ARegion *aret = NULL; | ARegion *aret = NULL; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| int min = 10000; | int min = 10000; | ||||
| Show All 39 Lines | |||||
| #ifdef DURIAN_CAMERA_SWITCH | #ifdef DURIAN_CAMERA_SWITCH | ||||
| void *camera = BKE_scene_camera_switch_find(scene); | void *camera = BKE_scene_camera_switch_find(scene); | ||||
| if (camera && scene->camera != camera) { | if (camera && scene->camera != camera) { | ||||
| bScreen *sc; | bScreen *sc; | ||||
| scene->camera = camera; | scene->camera = camera; | ||||
| /* are there cameras in the views that are not in the scene? */ | /* are there cameras in the views that are not in the scene? */ | ||||
| for (sc = bmain->screen.first; sc; sc = sc->id.next) { | for (sc = bmain->screen.first; sc; sc = sc->id.next) { | ||||
| BKE_screen_view3d_scene_sync(sc); | BKE_screen_view3d_scene_sync(sc, scene); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| ED_clip_update_frame(bmain, scene->r.cfra); | ED_clip_update_frame(bmain, scene->r.cfra); | ||||
| /* get layers from all windows */ | /* get layers from all windows */ | ||||
| for (window = wm->windows.first; window; window = window->next) | for (window = wm->windows.first; window; window = window->next) | ||||
| layers |= BKE_screen_visible_layers(window->screen, scene); | layers |= BKE_screen_visible_layers(WM_window_get_active_screen(window), scene); | ||||
| /* this function applies the changes too */ | /* this function applies the changes too */ | ||||
| BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, layers); | BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, layers); | ||||
| /* composite */ | /* composite */ | ||||
| if (scene->use_nodes && scene->nodetree) | if (scene->use_nodes && scene->nodetree) | ||||
| ntreeCompositTagAnimated(scene->nodetree); | ntreeCompositTagAnimated(scene->nodetree); | ||||
| /* update animated texture nodes */ | /* update animated texture nodes */ | ||||
| { | { | ||||
| Tex *tex; | Tex *tex; | ||||
| for (tex = bmain->tex.first; tex; tex = tex->id.next) | for (tex = bmain->tex.first; tex; tex = tex->id.next) | ||||
| if (tex->use_nodes && tex->nodetree) { | if (tex->use_nodes && tex->nodetree) { | ||||
| ntreeTexTagAnimated(tex->nodetree); | ntreeTexTagAnimated(tex->nodetree); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* | /* | ||||
| * return true if any active area requires to see in 3D | * return true if any active area requires to see in 3D | ||||
| */ | */ | ||||
| bool ED_screen_stereo3d_required(bScreen *screen) | bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) | ||||
| { | { | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| Scene *sce = screen->scene; | const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; | ||||
| const bool is_multiview = (sce->r.scemode & R_MULTIVIEW) != 0; | |||||
| for (sa = screen->areabase.first; sa; sa = sa->next) { | for (sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| switch (sa->spacetype) { | switch (sa->spacetype) { | ||||
| case SPACE_VIEW3D: | case SPACE_VIEW3D: | ||||
| { | { | ||||
| View3D *v3d; | View3D *v3d; | ||||
| if (!is_multiview) | if (!is_multiview) | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | switch (sa->spacetype) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | |||||
| * Find the scene displayed in \a screen. | |||||
| * \note Assumes \a screen to be visible/active! | |||||
| */ | |||||
| Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm) | |||||
| { | |||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | |||||
| if (WM_window_get_active_screen(win) == screen) { | |||||
| return WM_window_get_active_scene(win); | |||||
| } | |||||
| } | |||||
| BLI_assert(0); | |||||
| return NULL; | |||||
| } | |||||