[Bf-blender-cvs] [c0bd1714ab] temp-workspace-multi-window: Merge branch 'workspaces' into temp-workspace-multi-window

Julian Eisel noreply at git.blender.org
Fri Mar 3 14:35:27 CET 2017


Commit: c0bd1714ab2462f0af6a328a8cdbfee9acced83d
Author: Julian Eisel
Date:   Fri Mar 3 13:52:23 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rBc0bd1714ab2462f0af6a328a8cdbfee9acced83d

Merge branch 'workspaces' into temp-workspace-multi-window

Conflicts:
	source/blender/blenkernel/BKE_workspace.h
	source/blender/blenloader/intern/versioning_270.c

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



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

diff --cc source/blender/blenkernel/BKE_workspace.h
index 650fcb979c,17e703718c..6334b32ea9
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@@ -103,41 -89,30 +103,43 @@@ WorkSpaceLayout *BKE_workspace_layout_i
  /* -------------------------------------------------------------------- */
  /* Getters/Setters */
  
 -struct ID *BKE_workspace_id_get(WorkSpace *workspace);
 -const char *BKE_workspace_name_get(const WorkSpace *workspace);
 -WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -void             BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout) ATTR_NONNULL(1);
 -struct bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -void            BKE_workspace_active_screen_set(WorkSpace *ws, struct bScreen *screen) ATTR_NONNULL(1);
 -enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 +#define GETTER_ATTRS ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
 +#define SETTER_ATTRS ATTR_NONNULL(1)
 +
 +struct ID *BKE_workspace_id_get(WorkSpace *workspace) GETTER_ATTRS;
 +const char *BKE_workspace_name_get(const WorkSpace *workspace) GETTER_ATTRS;
 +WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) GETTER_ATTRS;
 +void             BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout) SETTER_ATTRS;
 +struct bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws) GETTER_ATTRS;
 +void            BKE_workspace_active_screen_set(WorkSpace *ws, struct bScreen *screen) SETTER_ATTRS;
 +enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) GETTER_ATTRS;
  #ifdef USE_WORKSPACE_MODE
 -void            BKE_workspace_object_mode_set(WorkSpace *workspace, const enum ObjectMode mode) ATTR_NONNULL();
 +void            BKE_workspace_object_mode_set(WorkSpace *workspace, const enum ObjectMode mode) SETTER_ATTRS;
  #endif
 -struct SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -void               BKE_workspace_render_layer_set(WorkSpace *workspace, struct SceneLayer *layer) ATTR_NONNULL(1);
 -struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -void             BKE_workspace_new_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout) ATTR_NONNULL(1);
 -
 -WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -
 -struct bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -void            BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, struct bScreen *screen) ATTR_NONNULL(1);
 -
 -WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 -WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
++struct SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace) GETTER_ATTRS;
++void               BKE_workspace_render_layer_set(WorkSpace *workspace, struct SceneLayer *layer) SETTER_ATTRS;
 +struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) GETTER_ATTRS;
 +WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(WorkSpace *workspace) GETTER_ATTRS;
 +struct ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace) GETTER_ATTRS;
 +const char      *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType *layout_type) GETTER_ATTRS;
 +WorkSpaceLayoutType *BKE_workspace_layout_type_next_get(WorkSpaceLayoutType *layout_type) GETTER_ATTRS;
 +WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace) GETTER_ATTRS;
 +void             BKE_workspace_new_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout) SETTER_ATTRS;
 +
 +WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace) GETTER_ATTRS;
 +WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace) GETTER_ATTRS;
 +
 +struct bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout) GETTER_ATTRS;
 +void            BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, struct bScreen *screen) SETTER_ATTRS;
 +
 +WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout) GETTER_ATTRS;
 +WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout) GETTER_ATTRS;
 +
 +WorkSpace *BKE_workspace_active_get(const WorkSpaceHook *hook) GETTER_ATTRS;
 +void BKE_workspace_active_set(WorkSpaceHook *hook, WorkSpace *workspace) SETTER_ATTRS;
 +WorkSpace *BKE_workspace_active_delayed_get(const WorkSpaceHook *hook) GETTER_ATTRS;
 +void BKE_workspace_active_delayed_set(WorkSpaceHook *hook, WorkSpace *workspace) SETTER_ATTRS;
 +struct ListBase *BKE_workspace_hook_layouts_get(WorkSpaceHook *workspace_hook) GETTER_ATTRS;
  
  /* -------------------------------------------------------------------- */
  /* Don't use outside of BKE! */
diff --cc source/blender/blenkernel/intern/layer.c
index d5e3e21164,56ac1b647c..372ec15e23
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@@ -76,11 -79,18 +79,18 @@@ SceneLayer *BKE_scene_layer_render_acti
   * Returns the SceneLayer to be used for drawing, outliner, and
   * other context related areas.
   */
- SceneLayer *BKE_scene_layer_context_active(Scene *scene)
- {
- 	/* waiting for workspace to get the layer from context*/
- 	TODO_LAYER_CONTEXT;
- 	return BKE_scene_layer_render_active(scene);
+ SceneLayer *BKE_scene_layer_context_active(const Scene *scene)
+ {
+ 	/* XXX iterating over windows here is not so nice, we could pass the workspace or the window as argument. */
+ 	for (wmWindowManager *wm = G.main->wm.first; wm; wm = wm->id.next) {
+ 		for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ 			if (win->scene == scene) {
 -				return BKE_workspace_render_layer_get(win->workspace);
++				return BKE_workspace_render_layer_get(BKE_workspace_active_get(win->workspace_hook));
+ 			}
+ 		}
+ 	}
+ 
+ 	return NULL;
  }
  
  /**
diff --cc source/blender/blenloader/intern/versioning_280.c
index 9d575c8f6d,432f10275a..a6b20467c9
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@@ -47,7 -49,55 +49,70 @@@
  
  #include "MEM_guardedalloc.h"
  
- void do_versions_after_linking_280(Main *main)
++
+ /**
+  * \brief Before lib-link versioning for new workspace design.
+  *
+  * Adds a workspace for each screen of the old file and adds the needed workspace-layout to wrap the screen.
+  * Rest of the conversion is done in #do_version_workspaces_after_lib_link.
+  *
+  * Note that some of the created workspaces might be deleted again in case of reading the default startup.blend.
+  */
+ static void do_version_workspaces_before_lib_link(Main *main)
+ {
+ 	BLI_assert(BLI_listbase_is_empty(&main->workspaces));
+ 
+ 	for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ 		WorkSpace *ws = BKE_workspace_add(main, screen->id.name + 2);
+ 		WorkSpaceLayout *layout = BKE_workspace_layout_add(ws, screen);
+ 
+ 		BKE_workspace_active_layout_set(ws, layout);
+ 
+ 		/* For compatibility, the workspace should be activated that represents the active
+ 		 * screen of the old file. This is done in blo_do_versions_after_linking_270. */
+ 	}
++
++	for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
++		for (wmWindow *win = wm->windows.first; win; win = win->next) {
++			win->workspace_hook = BKE_workspace_hook_new();
++		}
++	}
+ }
+ 
+ /**
+  * \brief After lib-link versioning for new workspace design.
+  *
+  *  *  Active screen isn't stored directly in window anymore, but in the active workspace.
+  *     We already created a new workspace for each screen in #do_version_workspaces_before_lib_link,
+  *     here we need to find and activate the workspace that contains the active screen of the old file.
+  *  *  Active scene isn't stored in screen anymore, but in window.
+  */
+ static void do_version_workspaces_after_lib_link(Main *main)
+ {
+ 	for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
+ 		for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ 			bScreen *screen = win->screen;
 -
 -			win->workspace = BLI_findstring(&main->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
++			WorkSpace *workspace = BLI_findstring(&main->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
++			ListBase *layout_types = BKE_workspace_layout_types_get(workspace);
++			ListBase *layouts = BKE_workspace_hook_layouts_get(win->workspace_hook);
++			WorkSpaceLayout *layout = BKE_workspace_layout_add_from_type(workspace, layout_types->first, screen);
++
++			BLI_assert(BLI_listbase_count(layout_types) == 1);
++			BLI_addhead(layouts, layout);
++			BKE_workspace_active_layout_set(workspace, layout); /* TODO */
++			win->workspace_hook = BKE_workspace_hook_new();
++			BKE_workspace_active_set(win->workspace_hook, workspace);
+ 			win->scene = screen->scene;
 -			BKE_workspace_render_layer_set(win->workspace, win->scene->render_layers.first);
++			BKE_workspace_render_layer_set(workspace, BKE_scene_layer_render_active(win->scene));
+ 
+ 			/* Deprecated from now on! */
+ 			win->screen = NULL;
+ 			screen->scene = NULL;
+ 		}
+ 	}
+ }
+ 
+ void do_versions_after_linking_280(FileData *fd, Main *main)
  {
  	if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
  		for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
diff --cc source/blender/makesdna/dna_workspace_types.h
index 3381858ec7,7af11083ab..9b7e626c5a
--- a/source/blender/makesdna/dna_workspace_types.h
+++ b/source/blender/makesdna/dna_workspace_types.h
@@@ -65,21 -55,8 +65,23 @@@ typedef struct WorkSpace 
  
  	int object_mode; /* enum ObjectMode */
  	int pad;
+ 
+ 	struct SceneLayer *render_layer;
  } WorkSpace;


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list