[Bf-blender-cvs] [d8992192e55] blender2.8: Object Mode: pass edit-object to outliner drawing

Campbell Barton noreply at git.blender.org
Tue Feb 13 08:58:17 CET 2018


Commit: d8992192e5512380f57433df113f3e3f8b22f7cb
Author: Campbell Barton
Date:   Tue Feb 13 18:44:53 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBd8992192e5512380f57433df113f3e3f8b22f7cb

Object Mode: pass edit-object to outliner drawing

Also add 'OBEDIT_FROM_EVAL_CTX' macro.

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

M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/makesdna/DNA_scene_types.h

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 4308a795a9c..c3d0713ca6d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1234,8 +1234,9 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
 #undef ICON_DRAW
 }
 
-static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, SpaceOops *soops,
-                                  ListBase *lb, int level, int xmax, int *offsx, int ys, float alpha_fac)
+static void outliner_draw_iconrow(
+        bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, Object *obedit, SpaceOops *soops,
+        ListBase *lb, int level, int xmax, int *offsx, int ys, float alpha_fac)
 {
 	TreeElement *te;
 	TreeStoreElem *tselem;
@@ -1256,7 +1257,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Vie
 				if (te->idcode == ID_OB) {
 					active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
 				}
-				else if (scene->obedit && scene->obedit->data == tselem->id) {
+				else if (obedit && obedit->data == tselem->id) {
 					active = OL_DRAWSEL_NORMAL;
 				}
 				else {
@@ -1296,7 +1297,9 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Vie
 		
 		/* this tree element always has same amount of branches, so don't draw */
 		if (tselem->type != TSE_R_LAYER)
-			outliner_draw_iconrow(C, block, scene, view_layer, soops, &te->subtree, level + 1, xmax, offsx, ys, alpha_fac);
+			outliner_draw_iconrow(
+			        C, block, scene, view_layer, obedit, soops,
+			        &te->subtree, level + 1, xmax, offsx, ys, alpha_fac);
 	}
 	
 }
@@ -1320,7 +1323,7 @@ static void outliner_set_coord_tree_element(TreeElement *te, int startx, int sta
 
 
 static void outliner_draw_tree_element(
-        bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer,
+        bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer, Object *obedit,
         ARegion *ar, SpaceOops *soops, TreeElement *te, bool draw_grayed_out,
         int startx, int *starty, TreeElement **te_edit, TreeElement **te_floating)
 {
@@ -1384,7 +1387,7 @@ static void outliner_draw_tree_element(
 				}
 			
 			}
-			else if (scene->obedit && scene->obedit->data == tselem->id) {
+			else if (obedit && obedit->data == tselem->id) {
 				rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha);
 				active = OL_DRAWSEL_ACTIVE;
 			}
@@ -1514,8 +1517,9 @@ static void outliner_draw_tree_element(
 						immUnbindProgram();
 					}
 
-					outliner_draw_iconrow(C, block, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx,
-					                      *starty, alpha_fac);
+					outliner_draw_iconrow(
+					        C, block, scene, view_layer, obedit, soops, &te->subtree, 0, xmax, &tempx,
+					        *starty, alpha_fac);
 
 					glDisable(GL_BLEND);
 				}
@@ -1534,8 +1538,10 @@ static void outliner_draw_tree_element(
 			/* check if element needs to be drawn grayed out, but also gray out
 			 * childs of a grayed out parent (pass on draw_grayed_out to childs) */
 			bool draw_childs_grayed_out = draw_grayed_out || (ten->drag_data != NULL);
-			outliner_draw_tree_element(C, block, fstyle, scene, view_layer, ar, soops, ten, draw_childs_grayed_out,
-			                           startx + UI_UNIT_X, starty, te_edit, te_floating);
+			outliner_draw_tree_element(
+			        C, block, fstyle, scene, view_layer, obedit,
+			        ar, soops, ten, draw_childs_grayed_out,
+			        startx + UI_UNIT_X, starty, te_edit, te_floating);
 		}
 	}
 	else {
@@ -1774,8 +1780,8 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx,
 }
 
 static void outliner_draw_tree(
-        bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, ARegion *ar,
-        SpaceOops *soops, const bool has_restrict_icons,
+        bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, Object *obedit,
+        ARegion *ar, SpaceOops *soops, const bool has_restrict_icons,
         TreeElement **te_edit)
 {
 	const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
@@ -1815,8 +1821,10 @@ static void outliner_draw_tree(
 	starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
 	startx = 0;
 	for (TreeElement *te = soops->tree.first; te; te = te->next) {
-		outliner_draw_tree_element(C, block, fstyle, scene, view_layer, ar, soops, te, te->drag_data != NULL,
-		                           startx, &starty, te_edit, &te_floating);
+		outliner_draw_tree_element(
+		        C, block, fstyle, scene, view_layer, obedit,
+		        ar, soops, te, te->drag_data != NULL,
+		        startx, &starty, te_edit, &te_floating);
 	}
 	if (te_floating && te_floating->drag_data->insert_handle) {
 		outliner_draw_tree_element_floating(ar, te_floating);
@@ -1893,6 +1901,7 @@ void draw_outliner(const bContext *C)
 {
 	EvaluationContext eval_ctx;
 	CTX_data_eval_ctx(C, &eval_ctx);
+	Object *obedit = OBEDIT_FROM_EVAL_CTX(&eval_ctx);
 	Main *mainvar = CTX_data_main(C); 
 	Scene *scene = CTX_data_scene(C);
 	ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1955,7 +1964,9 @@ void draw_outliner(const bContext *C)
 	/* draw outliner stuff (background, hierarchy lines and names) */
 	outliner_back(ar);
 	block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
-	outliner_draw_tree((bContext *)C, block, scene, view_layer, ar, soops, has_restrict_icons, &te_edit);
+	outliner_draw_tree(
+	        (bContext *)C, block, scene, view_layer, obedit,
+	        ar, soops, has_restrict_icons, &te_edit);
 
 	if (soops->outlinevis == SO_DATABLOCKS) {
 		/* draw rna buttons */
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index df5f43978e6..16f3aeaf110 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -193,10 +193,10 @@ static eOLDrawState tree_element_set_active_object(
 			WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 		}
 	}
-	
-	if (ob != scene->obedit)
+
+	if (CTX_data_edit_object(C)) {
 		ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
-		
+	}
 	return OL_DRAWSEL_NORMAL;
 }
 
@@ -547,7 +547,7 @@ static eOLDrawState tree_element_active_bone(
 
 
 /* ebones only draw in editmode armature */
-static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel)
+static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmature *arm, EditBone *ebone, short sel)
 {
 	if (sel) {
 		ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL;
@@ -561,34 +561,34 @@ static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature
 		if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL;
 	}
 
-	WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, scene->obedit);
+	WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, obedit);
 }
 static eOLDrawState tree_element_active_ebone(
-        bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set, bool recursive)
+        bContext *C, TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set, bool recursive)
 {
-	BLI_assert(scene->obedit != NULL);
-
-	bArmature *arm = scene->obedit->data;
+	Object *obedit = CTX_data_edit_object(C);
+	BLI_assert(obedit != NULL);
+	bArmature *arm = obedit->data;
 	EditBone *ebone = te->directdata;
 	eOLDrawState status = OL_DRAWSEL_NONE;
 
 	if (set != OL_SETSEL_NONE) {
 		if (set == OL_SETSEL_NORMAL) {
 			if (!(ebone->flag & BONE_HIDDEN_A)) {
-				ED_armature_deselect_all(scene->obedit);
-				tree_element_active_ebone__sel(C, scene, arm, ebone, true);
+				ED_armature_deselect_all(obedit);
+				tree_element_active_ebone__sel(C, obedit, arm, ebone, true);
 				status = OL_DRAWSEL_NORMAL;
 			}
 		}
 		else if (set == OL_SETSEL_EXTEND) {
 			if (!(ebone->flag & BONE_HIDDEN_A)) {
 				if (!(ebone->flag & BONE_SELECTED)) {
-					tree_element_active_ebone__sel(C, scene, arm, ebone, true);
+					tree_element_active_ebone__sel(C, obedit, arm, ebone, true);
 					status = OL_DRAWSEL_NORMAL;
 				}
 				else {
 					/* entirely selected, so de-select */
-					tree_element_active_ebone__sel(C, scene, arm, ebone, false);
+					tree_element_active_ebone__sel(C, obedit, arm, ebone, false);
 					status = OL_DRAWSEL_NONE;
 				}
 			}
@@ -656,7 +656,7 @@ static eOLDrawState tree_element_active_text(
 }
 
 static eOLDrawState tree_element_active_pose(
-        bContext *C, Scene *scene, ViewLayer *view_layer, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
+        bContext *C, ViewLayer *view_layer, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set)
 {
 	const WorkSpace *workspace = CTX_wm_workspace(C);
 	Object *ob = (Object *)tselem->id;
@@ -668,7 +668,7 @@ static eOLDrawState tree_element_active_pose(
 	}
 
 	if (set != OL_SETSEL_NONE) {
-		if (scene->obedit) {
+		if (workspace->object_mode & OB_MODE_EDIT) {
 			ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
 		}
 		if (workspace->object_mode & OB_MODE_POSE) {
@@ -850,7 +850,7 @@ eOLDrawState tree_element_type_active(
 		case TSE_BONE:
 			return tree_element_active_bone(C, view_layer, te, tselem, set, recursive);
 		case TSE_EBONE:
-			return tree_element_active_ebone(C, scene, te, tselem, set, recursive);
+			return tree_element_active_ebone(C, te, tselem, set, recursive);
 		case TSE_MODIFIER:
 			return tree_element_active_modifier(C, scene, view_layer, te, tselem, set);
 		case TSE_LINKED_OB:
@@ -864,7 +864,7 @@ eOLDrawState tree_element_type_active(
 		case TSE_LINKED_PSYS:
 			return tree_element_active_psys(C, scene, te, tselem, set);
 		case TSE_POSE_BASE:
-			return tree_element_active_pose(C, scene, view_layer, te, tselem, set);
+			return tree_element_active_pose(C, view_layer, te, tselem, set);
 		case TSE_POSE_CHANNEL:
 			return tree_element_active_p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list