[Bf-blender-cvs] [f0caf178d01] soc-2020-outliner: Outliner: Add edit mode toggle from left column

Nathan Craddock noreply at git.blender.org
Sat Jun 6 20:15:45 CEST 2020


Commit: f0caf178d0131b076302fe7558dcdfd1047efea0
Author: Nathan Craddock
Date:   Sat Jun 6 11:51:16 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBf0caf178d0131b076302fe7558dcdfd1047efea0

Outliner: Add edit mode toggle from left column

When in edit mode, compatible objects are shown next to a dot icon in
the outliner. These objects can then be toggled into the current edit
mode. When the active object is toggled out of edit mode, all objects
are removed from edit mode.

This currently has a few issues:
* Selection is not synced. Adding an object to edit mode selects it, and
  removing deselects it. This needs to be reflected in the outliner.
* This works for all types that support edit mode with two
  issues/exceptions:
** Grease Pencil edit mode is not supported (perhaps grease pencil needs
a small update)
** Text objects support multi-edit, but it doesn't actually allow you to
edit both objects.

The issues need to be fixed in the related mode-code, not the outliner.
It would be nice to fix so the outliner doesn't have to have cases to
not allow Text and Grease Pencil mode.

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

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

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

diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 03eb1804f12..4f2b9500391 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -229,14 +229,12 @@ static void outliner_item_mode_toggle(bContext *C,
 {
   TreeStoreElem *tselem = TREESTORE(te);
 
-  if (tselem->type == 0) {
-    if (OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
-      Object *ob = (Object *)outliner_search_back(te, ID_OB);
-      if ((ob != NULL) && (ob->data == tselem->id)) {
-        Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
-        if ((base != NULL) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
-          do_outliner_item_editmode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
-        }
+  if (tselem->type == 0 && te->idcode == ID_OB) {
+    Object *ob = (Object *)tselem->id;
+    if (OB_TYPE_SUPPORT_EDITMODE(ob->type)) {
+      Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
+      if ((base != NULL) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
+        do_outliner_item_editmode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
       }
     }
     else if (ELEM(te->idcode, ID_GD)) {
@@ -1158,27 +1156,43 @@ void outliner_set_active_camera(bContext *C, Scene *scene, TreeElement *te)
   WM_event_add_notifier(C, NC_SCENE | NA_EDITED, NULL);
 }
 
-static void outliner_set_active_data(bContext *C, SpaceOutliner *soops, TreeElement *te)
+static void outliner_set_active_data(bContext *C,
+                                     TreeViewContext *tvc,
+                                     SpaceOutliner *soops,
+                                     TreeElement *te,
+                                     TreeStoreElem *tselem)
 {
-  TreeViewContext tvc;
-  TreeStoreElem *tselem = TREESTORE(te);
-
-  outliner_viewcontext_init(C, &tvc);
-
   if (tselem->type == 0 && te->idcode == ID_OB) {
     Object *ob = (Object *)tselem->id;
     if (ob->type == OB_CAMERA) {
-      outliner_set_active_camera(C, tvc.scene, te);
+      outliner_set_active_camera(C, tvc->scene, te);
     }
   }
   else if (tselem->type == 0 && te->idcode == ID_SCE) {
     Scene *scene = (Scene *)tselem->id;
-    if (scene != tvc.scene) {
+    if (scene != tvc->scene) {
       WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), scene);
     }
   }
   else if (ELEM(tselem->type, TSE_VIEW_COLLECTION_BASE, TSE_LAYER_COLLECTION)) {
-    tree_element_type_active(C, &tvc, soops, te, tselem, OL_SETSEL_NORMAL, false);
+    tree_element_type_active(C, tvc, soops, te, tselem, OL_SETSEL_NORMAL, false);
+  }
+}
+
+static void outliner_left_column_click(bContext *C, SpaceOutliner *soops, TreeElement *te)
+{
+  TreeStoreElem *tselem = TREESTORE(te);
+  TreeViewContext tvc;
+  outliner_viewcontext_init(C, &tvc);
+
+  if (tvc.obact && tvc.obact->mode != OB_MODE_OBJECT) {
+    /* Only support edit mode */
+    if (tvc.ob_edit) {
+      outliner_item_mode_toggle(C, &tvc, te, true);
+    }
+  }
+  else {
+    outliner_set_active_data(C, &tvc, soops, te, tselem);
   }
 }
 
@@ -1329,7 +1343,7 @@ void outliner_item_select(bContext *C,
 
     /* Mode toggle on data activate for now, but move later */
     if (select_flag & OL_ITEM_TOGGLE_MODE) {
-      outliner_item_mode_toggle(C, &tvc, te, extend);
+      /* outliner_item_mode_toggle(C, &tvc, te, extend); */
     }
   }
 }
@@ -1444,7 +1458,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
   /* Set active data on left column click */
   /* TODO: Decide if this is best as button callbacks or here in outliner_select */
   else if (soops->flag & SO_LEFT_COLUMN && view_mval[0] < UI_UNIT_X) {
-    outliner_set_active_data(C, soops, te);
+    outliner_left_column_click(C, soops, te);
   }
   else {
     /* The row may also contain children, if one is hovered we want this instead of current te */



More information about the Bf-blender-cvs mailing list