[Bf-blender-cvs] [8113a8b0f6d] soc-2020-outliner: Outliner: Add pose mode toggle to left column

Nathan Craddock noreply at git.blender.org
Fri Jun 12 06:11:03 CEST 2020


Commit: 8113a8b0f6db1a031b8b6d59beb25e3a21a7fccc
Author: Nathan Craddock
Date:   Thu Jun 11 19:47:24 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB8113a8b0f6db1a031b8b6d59beb25e3a21a7fccc

Outliner: Add pose mode toggle to left column

Allow adding/removing objects from pose mode through the left column.
Also cleanup the icon drawing code by using the same function for
active and inactive states and only change the icon and add the callback
when needed.

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

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 fbc7decc2df..d399c6cec00 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1929,49 +1929,12 @@ static void outliner_draw_left_column_activation(const bContext *C,
     Object *ob = (Object *)tselem->id;
 
     if (ob->type == OB_CAMERA) {
-      if (tvc->scene->camera == ob) {
-        but = uiDefIconBut(block,
-                           UI_BTYPE_ICON_TOGGLE,
-                           0,
-                           ICON_RADIOBUT_ON,
-                           0,
-                           te->ys,
-                           UI_UNIT_X,
-                           UI_UNIT_Y,
-                           NULL,
-                           0.0,
-                           0.0,
-                           0.0,
-                           0.0,
-                           TIP_(""));
-      }
-      else {
-        but = uiDefIconBut(block,
-                           UI_BTYPE_ICON_TOGGLE,
-                           0,
-                           ICON_RADIOBUT_OFF,
-                           0,
-                           te->ys,
-                           UI_UNIT_X,
-                           UI_UNIT_Y,
-                           NULL,
-                           0.0,
-                           0.0,
-                           0.0,
-                           0.0,
-                           TIP_("Set active camera"));
-        UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
-      }
-    }
-  }
-  else if (tselem->type == 0 && te->idcode == ID_SCE) {
-    Scene *scene = (Scene *)tselem->id;
+      const bool is_active_camera = tvc->scene->camera == ob;
 
-    if (tvc->scene == scene) {
       but = uiDefIconBut(block,
                          UI_BTYPE_ICON_TOGGLE,
                          0,
-                         ICON_RADIOBUT_ON,
+                         (is_active_camera ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF),
                          0,
                          te->ys,
                          UI_UNIT_X,
@@ -1981,36 +1944,82 @@ static void outliner_draw_left_column_activation(const bContext *C,
                          0.0,
                          0.0,
                          0.0,
-                         TIP_(""));
+                         (is_active_camera ? "" : TIP_("Set active camera")));
+
+      if (!is_active_camera) {
+        UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
+      }
     }
-    else {
-      but = uiDefIconBut(block,
-                         UI_BTYPE_ICON_TOGGLE,
-                         0,
-                         ICON_RADIOBUT_OFF,
-                         0,
-                         te->ys,
-                         UI_UNIT_X,
-                         UI_UNIT_Y,
-                         NULL,
-                         0.0,
-                         0.0,
-                         0.0,
-                         0.0,
-                         TIP_("Set active scene"));
+  }
+  else if (tselem->type == 0 && te->idcode == ID_SCE) {
+    Scene *scene = (Scene *)tselem->id;
+    const bool is_active_scene = tvc->scene == scene;
+
+    but = uiDefIconBut(block,
+                       UI_BTYPE_ICON_TOGGLE,
+                       0,
+                       (is_active_scene ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF),
+                       0,
+                       te->ys,
+                       UI_UNIT_X,
+                       UI_UNIT_Y,
+                       NULL,
+                       0.0,
+                       0.0,
+                       0.0,
+                       0.0,
+                       (is_active_scene ? "" : TIP_("Set active scene")));
+
+    if (!is_active_scene) {
       UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
     }
   }
-  else if (ELEM(tselem->type, TSE_VIEW_COLLECTION_BASE, TSE_LAYER_COLLECTION)) {
-    LayerCollection *active = CTX_data_layer_collection(C);
+  else if (outliner_is_collection_tree_element(te)) {
+    Collection *active_collection = CTX_data_layer_collection(C)->collection;
+
+    const bool is_active_collection = active_collection ==
+                                      outliner_collection_from_tree_element(te);
+
+    but = uiDefIconBut(block,
+                       UI_BTYPE_ICON_TOGGLE,
+                       0,
+                       (is_active_collection ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF),
+                       0,
+                       te->ys,
+                       UI_UNIT_X,
+                       UI_UNIT_Y,
+                       NULL,
+                       0.0,
+                       0.0,
+                       0.0,
+                       0.0,
+                       (is_active_collection ? "" : TIP_("Set active collection")));
+
+    if (!is_active_collection) {
+      UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
+    }
+  }
+}
+
+/* Draw icons for adding and removing objects from the current interation mode */
+static void outliner_draw_left_column_mode_toggle(uiBlock *block,
+                                                  TreeViewContext *tvc,
+                                                  TreeElement *te,
+                                                  TreeStoreElem *tselem)
+{
+  uiBut *but;
+
+  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;
 
-    if ((tselem->type == TSE_VIEW_COLLECTION_BASE &&
-         active == tvc->view_layer->layer_collections.first) ||
-        (tselem->type == TSE_LAYER_COLLECTION && active == te->directdata)) {
+      /* Draw mode icon for objects in edit mode */
       but = uiDefIconBut(block,
                          UI_BTYPE_ICON_TOGGLE,
                          0,
-                         ICON_RADIOBUT_ON,
+                         (is_in_editmode ? ICON_EDITMODE_HLT : ICON_DOT),
                          0,
                          te->ys,
                          UI_UNIT_X,
@@ -2020,13 +2029,17 @@ static void outliner_draw_left_column_activation(const bContext *C,
                          0.0,
                          0.0,
                          0.0,
-                         TIP_(""));
+                         TIP_("Toggle edit mode"));
+      UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
     }
-    else {
+    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,
-                         ICON_RADIOBUT_OFF,
+                         (is_in_posemode ? ICON_POSE_HLT : ICON_DOT),
                          0,
                          te->ys,
                          UI_UNIT_X,
@@ -2036,102 +2049,12 @@ static void outliner_draw_left_column_activation(const bContext *C,
                          0.0,
                          0.0,
                          0.0,
-                         TIP_("Set active collection"));
+                         TIP_("Toggle pose mode"));
       UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
     }
   }
 }
 
-/* Draw icons for adding and removing objects from the current interation mode */
-static void outliner_draw_left_column_mode_toggle(uiBlock *block,
-                                                  TreeViewContext *tvc,
-                                                  TreeElement *te,
-                                                  TreeStoreElem *tselem)
-{
-  uiBut *but;
-
-  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) {
-      if (ob->mode == tvc->ob_edit->mode) {
-        /* Draw mode icon for objects in edit mode */
-        but = uiDefIconBut(block,
-                           UI_BTYPE_ICON_TOGGLE,
-                           0,
-                           ICON_EDITMODE_HLT,
-                           0,
-                           te->ys,
-                           UI_UNIT_X,
-                           UI_UNIT_Y,
-                           NULL,
-                           0.0,
-                           0.0,
-                           0.0,
-                           0.0,
-                           TIP_(""));
-        UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
-      }
-      else {
-        /* Draw dot for objects that are compatible with the current edit mode */
-        but = uiDefIconBut(block,
-                           UI_BTYPE_ICON_TOGGLE,
-                           0,
-                           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) {
-      if (ob->mode == tvc->ob_pose->mode) {
-        /* Draw mode icon for armatures in pose mode */
-        but = uiDefIconBut(block,
-                           UI_BTYPE_ICON_TOGGLE,
-                           0,
-                           ICON_POSE_HLT,
-                           0,
-                           te->ys,
-                           UI_UNIT_X,
-                           UI_UNIT_Y,
-                           NULL,
-                           0.0,
-                           0.0,
-                           0.0,
-                           0.0,
-                           TIP_(""));
-        UI_but_func_set(but, outliner_left_column_fn, tselem, NULL);
-      }
-      else {
-        /* Draw 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list