[Bf-extensions-cvs] [a4b23075] master: system_demo_mode: fix screen switching

Campbell Barton noreply at git.blender.org
Mon Mar 15 07:02:31 CET 2021


Commit: a4b23075edd0b3f92f0766b04eaf891f5d4a8f00
Author: Campbell Barton
Date:   Mon Mar 15 16:56:41 2021 +1100
Branches: master
https://developer.blender.org/rBAa4b23075edd0b3f92f0766b04eaf891f5d4a8f00

system_demo_mode: fix screen switching

Replace screen switching with workspace switching.

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

M	system_demo_mode/demo_mode.py

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

diff --git a/system_demo_mode/demo_mode.py b/system_demo_mode/demo_mode.py
index 8c45448b..d03dc493 100644
--- a/system_demo_mode/demo_mode.py
+++ b/system_demo_mode/demo_mode.py
@@ -274,17 +274,18 @@ def demo_mode_update():
         if global_config["anim_screen_switch"]:
             # print(time_delta, 1)
             if time_delta > global_config["anim_screen_switch"]:
-
-                screen = bpy.context.window.screen
-                index = bpy.data.screens.keys().index(screen.name)
-                screen_new = bpy.data.screens[(index if index > 0 else len(bpy.data.screens)) - 1]
-                bpy.context.window.screen = screen_new
+                window = bpy.context.window
+                scene = window.scene
+                workspace = window.workspace
+                index = bpy.data.workspaces.keys().index(workspace.name)
+                workspace_new = bpy.data.workspaces[(index + 1) % len(bpy.data.workspaces)]
+                window.workspace = workspace_new
 
                 global_state["last_switch"] = time_current
 
-                # if we also switch scenes then reset last frame
-                # otherwise it could mess up cycle calc.
-                if screen.scene != screen_new.scene:
+                # If we also switch scenes then reset last frame
+                # otherwise it could mess up cycle calculation.
+                if scene != window.scene:
                     global_state["last_frame"] = -1
 
                 #if global_config["mode"] == 'PLAY':



More information about the Bf-extensions-cvs mailing list