[Bf-blender-cvs] [4af045fbeff] soc-2020-outliner: Outliner: Show icons for all interaction modes

Nathan Craddock noreply at git.blender.org
Sat Jun 13 01:23:27 CEST 2020


Commit: 4af045fbeffdf4e5556364b75bf34c320e2171d7
Author: Nathan Craddock
Date:   Fri Jun 12 17:21:14 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB4af045fbeffdf4e5556364b75bf34c320e2171d7

Outliner: Show icons for all interaction modes

When not in object mode, show the interaction mode next to the object in
the outliner. Also show a dot next to each icon that could be switched
into the current mode.

Currently this still only works for edit and pose mode. Seeing the icon
next to the object in the mode is already useful. One issue is that
grease pencil mode icon draws green.

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

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

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index d399c6cec00..8d375716cea 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2001,6 +2001,38 @@ static void outliner_draw_left_column_activation(const bContext *C,
   }
 }
 
+/* Return the icon for a given interaction mode
+ * Should this be more generic (in a different file?) */
+static int outliner_get_mode_icon(const int mode)
+{
+  switch (mode) {
+    case OB_MODE_OBJECT:
+      return ICON_OBJECT_DATAMODE;
+    case OB_MODE_EDIT:
+    case OB_MODE_EDIT_GPENCIL:
+      return ICON_EDITMODE_HLT;
+    case OB_MODE_SCULPT:
+    case OB_MODE_SCULPT_GPENCIL:
+      return ICON_SCULPTMODE_HLT;
+    case OB_MODE_VERTEX_PAINT:
+    case OB_MODE_VERTEX_GPENCIL:
+      return ICON_VPAINT_HLT;
+    case OB_MODE_WEIGHT_PAINT:
+    case OB_MODE_WEIGHT_GPENCIL:
+      return ICON_WPAINT_HLT;
+    case OB_MODE_TEXTURE_PAINT:
+      return ICON_TPAINT_HLT;
+    case OB_MODE_PARTICLE_EDIT:
+      return ICON_PARTICLEMODE;
+    case OB_MODE_POSE:
+      return ICON_POSE_HLT;
+    case OB_MODE_PAINT_GPENCIL:
+      return ICON_GREASEPENCIL;
+    default:
+      return ICON_DOT;
+  }
+}
+
 /* Draw icons for adding and removing objects from the current interation mode */
 static void outliner_draw_left_column_mode_toggle(uiBlock *block,
                                                   TreeViewContext *tvc,
@@ -2012,44 +2044,22 @@ static void outliner_draw_left_column_mode_toggle(uiBlock *block,
   if (tselem->type == 0 && te->idcode == ID_OB) {
     Object *ob = (Object *)tselem->id;
 
-    if (tvc->ob_edit && OB_TYPE_SUPPORT_EDITMODE(ob->type) && ob->type == tvc->ob_edit->type) {
-      const bool is_in_editmode = ob->mode == tvc->ob_edit->mode;
-
-      /* Draw mode icon for objects in edit mode */
-      but = uiDefIconBut(block,
-                         UI_BTYPE_ICON_TOGGLE,
-                         0,
-                         (is_in_editmode ? ICON_EDITMODE_HLT : ICON_DOT),
-                         0,
-                         te->ys,
-                         UI_UNIT_X,
-                         UI_UNIT_Y,
-                         NULL,
-                         0.0,
-                         0.0,
-                         0.0,
-                         0.0,
-                         TIP_("Toggle edit mode"));
-      UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
-    }
-    else if (tvc->ob_pose && ob->type == OB_ARMATURE) {
-      const bool is_in_posemode = ob->mode == tvc->ob_pose->mode;
-
-      /* Draw mode icon for armatures in pose mode */
-      but = uiDefIconBut(block,
-                         UI_BTYPE_ICON_TOGGLE,
-                         0,
-                         (is_in_posemode ? ICON_POSE_HLT : ICON_DOT),
-                         0,
-                         te->ys,
-                         UI_UNIT_X,
-                         UI_UNIT_Y,
-                         NULL,
-                         0.0,
-                         0.0,
-                         0.0,
-                         0.0,
-                         TIP_("Toggle pose mode"));
+    if (ob->type == tvc->obact->type) {
+      but = uiDefIconBut(
+          block,
+          UI_BTYPE_ICON_TOGGLE,
+          0,
+          (ob->mode == tvc->obact->mode ? outliner_get_mode_icon(ob->mode) : ICON_DOT),
+          0,
+          te->ys,
+          UI_UNIT_X,
+          UI_UNIT_Y,
+          NULL,
+          0.0,
+          0.0,
+          0.0,
+          0.0,
+          TIP_("Toggle edit mode")); /* TODO: Change tooltip by type */
       UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
     }
   }
@@ -2063,14 +2073,11 @@ static void outliner_draw_left_column(
   LISTBASE_FOREACH (TreeElement *, te, tree) {
     tselem = TREESTORE(te);
 
-    /* Only edit and pose mode support multi-object editing */
-    if (tvc->obact && ELEM(tvc->obact->mode, OB_MODE_EDIT, OB_MODE_POSE)) {
+    if (tvc->obact && tvc->obact->mode != OB_MODE_OBJECT) {
       outliner_draw_left_column_mode_toggle(block, tvc, te, tselem);
     }
-
-    // else {
+    /* TODO: Should the active icons always draw, or be hidden in non-object modes? */
     outliner_draw_left_column_activation(C, block, tvc, te, tselem);
-    // }
 
     if (TSELEM_OPEN(tselem, soops)) {
       outliner_draw_left_column(C, block, tvc, soops, &te->subtree);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 8668d74ccb1..8e093cd3dcb 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -209,6 +209,12 @@ static void do_outliner_item_posemode_toggle(
   }
 }
 
+/* Toggle interaction mode for modes that do not allow multi-object editing */
+static void do_outliner_item_mode_toggle_generic(bContext *C)
+{
+  /* TODO: switch active object and call operator */
+}
+
 /* For draw callback to run mode switching */
 void outliner_object_mode_toggle(bContext *C, Scene *scene, ViewLayer *view_layer, Base *base)
 {
@@ -238,13 +244,15 @@ static void outliner_item_mode_toggle(bContext *C,
         do_outliner_item_editmode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
       }
     }
-
     else if (tvc->ob_pose && ob->type == OB_ARMATURE) {
       Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
       if (base != NULL) {
         do_outliner_item_posemode_toggle(C, tvc->scene, tvc->view_layer, base, extend);
       }
     }
+    else {
+      do_outliner_item_mode_toggle_generic(C);
+    }
   }
 }
 
@@ -1182,10 +1190,7 @@ void outliner_left_column_click(bContext *C, SpaceOutliner *soops, TreeElement *
   outliner_viewcontext_init(C, &tvc);
 
   if (tvc.obact && tvc.obact->mode != OB_MODE_OBJECT) {
-    /* Only edit and pose mode support multi-object editing */
-    if (ELEM(tvc.obact->mode, OB_MODE_EDIT, OB_MODE_POSE)) {
-      outliner_item_mode_toggle(C, &tvc, te, true);
-    }
+    outliner_item_mode_toggle(C, &tvc, te, true);
   }
   else {
     outliner_set_active_data(C, &tvc, soops, te, tselem);



More information about the Bf-blender-cvs mailing list