Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/screen/screen_edit.c')
-rw-r--r--source/blender/editors/screen/screen_edit.c95
1 files changed, 60 insertions, 35 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 4429c04bcf9..bddfc661b0b 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -42,6 +42,7 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
+#include "BKE_image.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -1459,25 +1460,26 @@ int ED_screen_area_active(const bContext *C)
return 0;
}
-/* operator call, WM + Window + screen already existed before */
-/* Do NOT call in area/region queues! */
-void ED_screen_set(bContext *C, bScreen *sc)
+/**
+ * operator call, WM + Window + screen already existed before
+ *
+ * \warning Do NOT call in area/region queues!
+ * \returns success.
+ */
+bool ED_screen_set(bContext *C, bScreen *sc)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
bScreen *oldscreen = CTX_wm_screen(C);
- ID *id;
/* validate screen, it's called with notifier reference */
- for (id = bmain->screen.first; id; id = id->next)
- if (sc == (bScreen *)id)
- break;
- if (id == NULL)
- return;
-
+ if (BLI_findindex(&bmain->screen, sc) == -1) {
+ return true;
+ }
- if (sc->state == SCREENFULL) { /* find associated full */
+ if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) {
+ /* find associated full */
bScreen *sc1;
for (sc1 = bmain->screen.first; sc1; sc1 = sc1->id.next) {
ScrArea *sa = sc1->areabase.first;
@@ -1489,8 +1491,9 @@ void ED_screen_set(bContext *C, bScreen *sc)
}
/* check for valid winid */
- if (sc->winid != 0 && sc->winid != win->winid)
- return;
+ if (sc->winid != 0 && sc->winid != win->winid) {
+ return false;
+ }
if (oldscreen != sc) {
wmTimer *wt = oldscreen->animtimer;
@@ -1550,60 +1553,75 @@ void ED_screen_set(bContext *C, bScreen *sc)
}
/* Always do visible update since it's possible new screen will
- * have different layers visible in 3D viewpots. This is possible
- * because of view3d.lock_camera_and_layers option.
+ * 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);
}
+
+ return true;
}
-static int ed_screen_used(wmWindowManager *wm, bScreen *sc)
+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 1;
-
- return 0;
+ 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 */
-void ED_screen_delete(bContext *C, bScreen *sc)
+bool ED_screen_delete(bContext *C, bScreen *sc)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
bScreen *newsc;
- int delete = 1;
/* don't allow deleting temp fullscreens for now */
if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) {
- return;
+ 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))
+ 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))
+ if (!ed_screen_used(wm, newsc) && !newsc->temp)
break;
}
- if (!newsc)
- return;
+ if (!newsc) {
+ return false;
+ }
ED_screen_set(C, newsc);
- if (delete && win->screen != sc)
+ if (win->screen != sc) {
BKE_libblock_free(bmain, sc);
+ return true;
+ }
+ else {
+ return false;
+ }
}
static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, View3D *v3d)
@@ -1697,8 +1715,11 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
}
-/* only call outside of area/region loops */
-void ED_screen_delete_scene(bContext *C, Scene *scene)
+/**
+ * \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;
@@ -1708,11 +1729,13 @@ void ED_screen_delete_scene(bContext *C, Scene *scene)
else if (scene->id.next)
newscene = scene->id.next;
else
- return;
+ return false;
ED_screen_set_scene(C, CTX_wm_screen(C), newscene);
BKE_scene_unlink(bmain, scene, newscene);
+
+ return true;
}
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
@@ -1759,6 +1782,8 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
*/
void ED_screen_full_prevspace(bContext *C, ScrArea *sa, const bool was_prev_temp)
{
+ BLI_assert(sa->full);
+
if (sa->flag & AREA_FLAG_STACKED_FULLSCREEN) {
/* stacked fullscreen -> only go back to previous screen and don't toggle out of fullscreen */
ED_area_prevspace(C, sa);
@@ -2161,7 +2186,7 @@ bool ED_screen_stereo3d_required(bScreen *screen)
/* images should always show in stereo, even if
* the file doesn't have views enabled */
sima = sa->spacedata.first;
- if (sima->image && (sima->image->flag & IMA_IS_STEREO) &&
+ if (sima->image && BKE_image_is_stereo(sima->image) &&
(sima->iuser.flag & IMA_SHOW_STEREO))
{
return true;