[Bf-blender-cvs] [9d2e660643d] soc-2020-outliner: Outliner: Add sort method enum

Nathan Craddock noreply at git.blender.org
Tue Jul 7 01:46:05 CEST 2020


Commit: 9d2e660643d6c98bcab3ce51e6cec1c8ddbea0c0
Author: Nathan Craddock
Date:   Mon Jul 6 14:15:24 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB9d2e660643d6c98bcab3ce51e6cec1c8ddbea0c0

Outliner: Add sort method enum

Replace the SO_SKIP_SORT_ALPHA with an enum of multiple sort types. The
types are manual, alphabetical, type, and creation order. Only
alphabetical works.

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

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 5d33c17bd42..22f2a932f22 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -360,7 +360,8 @@ class OUTLINER_PT_filter(Panel):
 
         if display_mode != 'DATA_API':
             col = layout.column(align=True)
-            col.prop(space, "use_sort_alpha")
+            col.label(text="Sort by")
+            col.prop(space, "sort_method", expand=True)
             layout.separator()
 
         row = layout.row(align=True)
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 09dc1320c3a..fb527e89a46 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -2481,7 +2481,7 @@ void outliner_build_tree(
     }
   }
 
-  if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
+  if (soops->sort_method == SO_SORT_ALPHA) {
     outliner_sort(&soops->tree);
   }
   else if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 5f044104073..41129e1e294 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -275,6 +275,9 @@ typedef struct SpaceOutliner {
    * Pointers to treestore elements, grouped by (id, type, nr)
    * in hashtable for faster searching */
   void *treehash;
+
+  char sort_method;
+  char _pad[7];
 } SpaceOutliner;
 
 /* SpaceOutliner.flag */
@@ -283,7 +286,7 @@ typedef enum eSpaceOutliner_Flag {
   /* SO_NEWSELECTED = (1 << 1), */        /* UNUSED */
   SO_FLAG_UNUSED_1 = (1 << 2),            /* cleared */
   /* SO_HIDE_KEYINGSETINFO = (1 << 3), */ /* UNUSED */
-  SO_SKIP_SORT_ALPHA = (1 << 4),
+  /* SO_SKIP_SORT_ALPHA = (1 << 4), */    /* UNUSED */
   SO_SYNC_SELECT = (1 << 5),
   SO_MODE_COLUMN = (1 << 6),
 } eSpaceOutliner_Flag;
@@ -383,6 +386,14 @@ typedef enum eSpaceOutliner_Search_Flags {
   SO_SEARCH_RECURSIVE = (1 << 2),
 } eSpaceOutliner_Search_Flags;
 
+/* SpaceOutliner.sort_method */
+typedef enum eSpaceOutliner_Sort_Types {
+  SO_SORT_FREE,
+  SO_SORT_ALPHA,
+  SO_SORT_TYPE,
+  SO_SORT_CREATION_ORDER,
+} eSpaceOutliner_Sort_Types;
+
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 729c07947d5..327bf5b7c18 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3046,6 +3046,18 @@ static void rna_def_space_outliner(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem sort_method_items[] = {
+      {SO_SORT_FREE, "FREE", 0, "Manual", "Sort objects and collections manually"},
+      {SO_SORT_ALPHA, "ALPHA", 0, "Name", "Sort objects and collections by name alphabetically"},
+      {SO_SORT_TYPE, "TYPE", 0, "Type", "Sort objects by type"},
+      {SO_SORT_CREATION_ORDER,
+       "CREATION",
+       0,
+       "Creation Order",
+       "Sort objects and collections in the order they were created"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   static const EnumPropertyItem filter_state_items[] = {
       {SO_FILTER_OB_ALL, "ALL", 0, "All", "Show all objects in the view layer"},
       {SO_FILTER_OB_VISIBLE, "VISIBLE", 0, "Visible", "Show visible objects"},
@@ -3083,9 +3095,10 @@ static void rna_def_space_outliner(BlenderRNA *brna)
       prop, "Complete Matches Only", "Only use complete matches of search string");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
 
-  prop = RNA_def_property(srna, "use_sort_alpha", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SO_SKIP_SORT_ALPHA);
-  RNA_def_property_ui_text(prop, "Sort Alphabetically", "");
+  prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "sort_method");
+  RNA_def_property_enum_items(prop, sort_method_items);
+  RNA_def_property_ui_text(prop, "Sort Type", "Outliner sort method");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
 
   prop = RNA_def_property(srna, "use_sync_select", PROP_BOOLEAN, PROP_NONE);



More information about the Bf-blender-cvs mailing list