[Bf-blender-cvs] [56fa168] workspaces: Update RNA and UI scripts to use scene from window

Julian Eisel noreply at git.blender.org
Thu Dec 8 18:37:43 CET 2016


Commit: 56fa168eeb912b44ca0f1c3fcfed78cf6adf30f1
Author: Julian Eisel
Date:   Thu Dec 8 18:36:59 2016 +0100
Branches: workspaces
https://developer.blender.org/rB56fa168eeb912b44ca0f1c3fcfed78cf6adf30f1

Update RNA and UI scripts to use scene from window

===================================================================

M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/makesrna/intern/rna_screen.c
M	source/blender/makesrna/intern/rna_wm.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index 5a1d7e4..8c8f33c 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -44,7 +44,7 @@ class INFO_HT_header(Header):
         else:
             layout.template_ID(window, "workspace", new="workspace.workspace_new", unlink="workspace.workspace_delete")
             layout.template_ID_preview(workspace, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
-            layout.template_ID(screen, "scene", new="scene.new", unlink="scene.delete")
+            layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
 
         layout.separator()
 
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index e8d69ef..caa675f 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -177,7 +177,8 @@ typedef struct wmWindow {
 
 	void *ghostwin;             /* don't want to include ghost.h stuff */
 
-	struct Scene *scene; /* The scene displayed in this window. */
+	struct Scene *scene;     /* The scene displayed in this window. */
+	struct Scene *new_scene; /* temporary when switching */
 
 	struct bScreen *screen DNA_DEPRECATED;
 	struct WorkSpace *workspace; /* active workspace */
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index c07b07c..8b0e7d2 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -64,40 +64,6 @@ EnumPropertyItem rna_enum_region_type_items[] = {
 #  include "BPY_extern.h"
 #endif
 
-static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
-{
-	bScreen *sc = (bScreen *)ptr->data;
-
-	if (value.data == NULL)
-		return;
-
-	sc->newscene = value.data;
-}
-
-static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
-{
-	bScreen *sc = (bScreen *)ptr->data;
-
-	/* exception: must use context so notifier gets to the right window  */
-	if (sc->newscene) {
-#ifdef WITH_PYTHON
-		BPy_BEGIN_ALLOW_THREADS;
-#endif
-
-		ED_screen_set_scene(C, sc, sc->newscene);
-
-#ifdef WITH_PYTHON
-		BPy_END_ALLOW_THREADS;
-#endif
-
-		WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene);
-
-		if (G.debug & G_DEBUG)
-			printf("scene set %p\n", sc->newscene);
-
-		sc->newscene = NULL;
-	}
-}
 
 static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
@@ -107,7 +73,6 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
 	ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME);
 }
 
-
 static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
 {
 	/* can be NULL on file load, T42619 */
@@ -377,14 +342,6 @@ static void rna_def_screen(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Screen", "Screen data-block, defining the layout of areas in a window");
 	RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN);
 
-	/* pointers */
-	prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
-	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
-	RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL);
-	RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen");
-	RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
-	RNA_def_property_update(prop, 0, "rna_Screen_scene_update");
-
 	/* collections */
 	prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index a83fceb..1252d9e 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -465,10 +465,16 @@ EnumPropertyItem rna_enum_wm_report_items[] = {
 
 #include "UI_interface.h"
 
+#include "BKE_global.h"
 #include "BKE_idprop.h"
 
 #include "MEM_guardedalloc.h"
 
+#ifdef WITH_PYTHON
+#  include "BPY_extern.h"
+#endif
+
+
 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
 {
 	wmWindowManager *wm = ptr->id.data;
@@ -623,6 +629,43 @@ static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr)
 	return rptr;
 }
 
+static void rna_Window_scene_set(PointerRNA *ptr, PointerRNA value)
+{
+	wmWindow *win = ptr->data;
+
+	if (value.data == NULL) {
+		return;
+	}
+
+	win->new_scene = value.data;
+}
+
+static void rna_Window_scene_update(bContext *C, PointerRNA *ptr)
+{
+	wmWindow *win = ptr->data;
+	bScreen *screen = WM_window_get_active_screen(win);
+
+	/* exception: must use context so notifier gets to the right window  */
+	if (win->new_scene) {
+#ifdef WITH_PYTHON
+		BPy_BEGIN_ALLOW_THREADS;
+#endif
+
+		ED_screen_set_scene(C, screen, win->new_scene);
+
+#ifdef WITH_PYTHON
+		BPy_END_ALLOW_THREADS;
+#endif
+
+		WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, win->new_scene);
+
+		if (G.debug & G_DEBUG)
+			printf("scene set %p\n", win->new_scene);
+
+		win->new_scene = NULL;
+	}
+}
+
 static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value)
 {
 	wmWindow *win = (wmWindow *)ptr->data;
@@ -1903,6 +1946,13 @@ static void rna_def_window(BlenderRNA *brna)
 
 	rna_def_window_stereo3d(brna);
 
+	prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
+	RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_scene_set", NULL, NULL);
+	RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the window");
+	RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+	RNA_def_property_update(prop, 0, "rna_Window_scene_update");
+
 	prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_NEVER_NULL);
 	RNA_def_property_struct_type(prop, "WorkSpace");




More information about the Bf-blender-cvs mailing list