[Bf-blender-cvs] [974ffaa39d8] blender2.8: Get workspace mode from the workspace view-layer

Julian Eisel noreply at git.blender.org
Sat Nov 25 03:43:48 CET 2017


Commit: 974ffaa39d8dd9f0bdd7bbf74648183b1937d3be
Author: Julian Eisel
Date:   Sat Nov 25 03:37:48 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB974ffaa39d8dd9f0bdd7bbf74648183b1937d3be

Get workspace mode from the workspace view-layer

While this probably isn't the final solution we'll go with, it's nicer
as current one, which was basically broken. So consider this as
temporary solution.

It also allows testing how changing workspace changes mode & active
object, but only by having the workspaces use different view-layers.

Decided to remove WorkSpace.mode for now. If we need to bring it back,
we'll have to version patch it anyway.

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

M	source/blender/blenkernel/BKE_workspace.h
M	source/blender/blenkernel/intern/workspace.c
M	source/blender/makesdna/DNA_workspace_types.h

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

diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index c5351723442..f295af3150a 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -102,6 +102,7 @@ enum eObjectMode BKE_workspace_object_mode_get(const struct WorkSpace *workspace
 #ifdef USE_WORKSPACE_MODE
 void            BKE_workspace_object_mode_set(struct WorkSpace *workspace, const enum eObjectMode mode) SETTER_ATTRS;
 #endif
+struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace);
 struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS;
 struct ViewLayer *BKE_workspace_view_layer_get(const struct WorkSpace *workspace) GETTER_ATTRS;
 void               BKE_workspace_view_layer_set(struct WorkSpace *workspace, struct ViewLayer *layer) SETTER_ATTRS;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 67639b4c7ab..785fd71df69 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -388,14 +388,23 @@ void BKE_workspace_active_screen_set(WorkSpaceInstanceHook *hook, WorkSpace *wor
 #ifdef USE_WORKSPACE_MODE
 eObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace)
 {
-	return workspace->object_mode;
+	Base *active_base = BKE_workspace_active_base_get(workspace);
+	return active_base ? active_base->object->mode : OB_MODE_OBJECT;
 }
 void BKE_workspace_object_mode_set(WorkSpace *workspace, const eObjectMode mode)
 {
-	workspace->object_mode = mode;
+	Base *active_base = BKE_workspace_active_base_get(workspace);
+	if (active_base) {
+		active_base->object->mode = mode;
+	}
 }
 #endif
 
+Base *BKE_workspace_active_base_get(const WorkSpace *workspace)
+{
+	return workspace->view_layer->basact;
+}
+
 ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace)
 {
 	return &workspace->transform_orientations;
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index f69f1b68930..1fc6acb8c2c 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -88,7 +88,7 @@ typedef struct WorkSpace {
 	/* Custom transform orientations */
 	ListBase transform_orientations DNA_PRIVATE_WORKSPACE;
 
-	int object_mode DNA_PRIVATE_WORKSPACE; /* enum eObjectMode */
+	int pad;
 	int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */
 
 	/* should be: '#ifdef USE_WORKSPACE_TOOL'. */



More information about the Bf-blender-cvs mailing list