[Bf-blender-cvs] [8e25a19a052] soc-2019-outliner: Outliner: Fix setting active when in edit mode

Nathan Craddock noreply at git.blender.org
Wed Jul 10 02:41:38 CEST 2019


Commit: 8e25a19a052a6945ad66914c02750926ecccb60a
Author: Nathan Craddock
Date:   Tue Jul 9 18:40:53 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB8e25a19a052a6945ad66914c02750926ecccb60a

Outliner: Fix setting active when in edit mode

Fixes some small issues with setting active elements

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

M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index cbf17ad1e58..e85cff3a72b 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1126,26 +1126,26 @@ static void do_outliner_item_activate_tree_element(bContext *C,
   TreeElement *te_active = outliner_find_active_element(&soops->tree);
   Object *obact = OBACT(view_layer);
 
-  /* Always makes active object, except for some specific types. */
-  if (ELEM(tselem->type,
-           TSE_SEQUENCE,
-           TSE_SEQ_STRIP,
-           TSE_SEQUENCE_DUP,
-           TSE_EBONE,
-           TSE_LAYER_COLLECTION)) {
-    /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects,
-     * we do not want to switch out of edit mode (see T48328 for details). */
-  }
-  else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
+  if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
     /* Support edit-mode toggle, keeping the active object as is. */
   }
   else if (tselem->type == TSE_POSE_BASE) {
     /* Support pose mode toggle, keeping the active object as is. */
   }
-  else if (ELEM(obact->mode, OB_MODE_EDIT, OB_MODE_POSE) && (te != te_active)) {
-    /* Select rather than activate other elements when in edit or pose mode */
+  else if ((obact->mode != OB_MODE_OBJECT) && (te != te_active)) {
+    /* Select rather than activate other elements when ouside of object mode */
     return;
   }
+  /* Always makes active object, except for some specific types. */
+  else if (ELEM(tselem->type,
+                TSE_SEQUENCE,
+                TSE_SEQ_STRIP,
+                TSE_SEQUENCE_DUP,
+                TSE_EBONE,
+                TSE_LAYER_COLLECTION)) {
+    /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects,
+     * we do not want to switch out of edit mode (see T48328 for details). */
+  }
   else if (soops->flag & SO_SYNC_SELECTION) {
     tree_element_set_active_object(C,
                                    scene,
@@ -1157,6 +1157,7 @@ static void do_outliner_item_activate_tree_element(bContext *C,
                                    recursive && tselem->type == 0);
   }
 
+  /* Mark as active in the outliner */
   outliner_flag_set(&soops->tree, TSE_ACTIVE, false);
   tselem->flag |= TSE_ACTIVE;
 
@@ -1695,13 +1696,22 @@ static void do_outliner_select_walk(
 static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
   SpaceOutliner *soops = CTX_wm_space_outliner(C);
+  Scene *scene = CTX_data_scene(C);
+  ViewLayer *view_layer = CTX_data_view_layer(C);
   ARegion *ar = CTX_wm_region(C);
   const int direction = RNA_enum_get(op->ptr, "direction");
   const bool extend = RNA_boolean_get(op->ptr, "extend");
 
   TreeElement *active = outliner_find_active_element(&soops->tree);
 
-  /* Set first element to active if no active exists (may not be needed with synced selection) */
+  Object *obact = OBACT(view_layer);
+  Base *base = BKE_view_layer_base_find(view_layer, obact);
+
+  if (obact->mode != OB_MODE_OBJECT) {
+    do_outliner_activate_obdata(C, scene, view_layer, base, false);
+  }
+
+  /* Set first element to active if no active exists */
   if (!active) {
     active = soops->tree.first;
     TREESTORE(active)->flag |= TSE_SELECTED | TSE_ACTIVE;
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index caf4fe4bfa9..afa1c989959 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -316,7 +316,7 @@ TreeElement *outliner_find_active_element(const ListBase *lb)
   return NULL;
 }
 
-// /* Find if element is visible in the outliner tree */
+/* Find if element is visible in the outliner tree */
 bool outliner_is_element_visible(const TreeElement *te)
 {
   TreeStoreElem *tselem;



More information about the Bf-blender-cvs mailing list