Page MenuHome

Outliner: Manual object sorting
AbandonedPublic

Authored by Nathan Craddock (natecraddock) on Aug 20 2020, 12:12 AM.

Details

Summary

Add manual object sorting, and sort object by type along side
alphabetical sort that already existed.

Also sort collections alphabetically.

Small cleanups for collection sort.

Diff Detail

Repository
rB Blender
Branch
outliner-sorting (branched from master)
Build Status
Buildable 10321
Build 10321: arc lint + arc unit

Event Timeline

Nathan Craddock (natecraddock) requested review of this revision.Aug 20 2020, 12:12 AM
Nathan Craddock (natecraddock) created this revision.
Nathan Craddock (natecraddock) retitled this revision from Outliner: Add manual object sorting to Outliner: Manual object sorting.
Julian Eisel (Severin) requested changes to this revision.Sep 11 2020, 5:32 PM

This worked well in my simple tests. A few smaller things to address but overall this seems fine.

Two warnings:

blender/software/dev/default/src/source/blender/editors/space_outliner/outliner_tree.c:1808:13: warning: ‘outliner_collections_children_sort’ defined but not used [-Wunused-function]
 1808 | static void outliner_collections_children_sort(ListBase *lb)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
blender/software/dev/default/src/source/blender/editors/space_outliner/outliner_tree.c:1722:12: warning: ‘treesort_alpha_ob’ defined but not used [-Wunused-function]
 1722 | static int treesort_alpha_ob(const void *v1, const void *v2)
      |            ^~~~~~~~~~~~~~~~~
source/blender/editors/space_outliner/outliner_dragdrop.c
292

Always a good idea to encapsulate such low level checks into a function, ie see outliner_item_is_co_over_name_icons(). Then you also don't need a comment to explain what this does ;)

452

Better assert again that the ID is indeed an object.

454–456

I have seen these kind of parent lookups before, haven't I ;) One more case where I think a parent lookup function taking a callback to test the criteria should be used.

514

I could imagine we'd want to support sorting objects in more display modes. So maybe put this into a function, say bool outliner_allows_custom_order(const SpaceOutliner *).

source/blender/editors/space_outliner/outliner_tree.c
1907–1984

There's quite some logic here, some lower level some higher level. So I'd suggest refactoring this into one or more functions, so that you can roughly understand the steps outliner_tree_sort() is taking just by reading a few function names, and without getting distracted by all the details.

source/blender/makesrna/intern/rna_space.c
3010

Maybe "Custom" is a better name? Also, please use the same name for the DNA define. Better not to introduce discrepancies in new code, we already have enough in old code.

This revision now requires changes to proceed.Sep 11 2020, 5:32 PM
Nathan Craddock (natecraddock) marked 3 inline comments as done.

Cleanup DNA/RNA naming
Assert ID
Cleanup code

I'm not sure I'd be happy with adding everything here in 2.91. It works well, but it is incomplete in two ways:

  1. You cannot custom sort child objects
  2. You cannot custom sort bones

I didn't prioritize those behaviors as much during the summer, and got involved in other features
I haven't looked too closely, but I think to add sorting of child objects and bones would require lots of work.


The collection sorting is nice though, and the manual object sorting is useful though incomplete. I'm curious on your thoughts. If you think the mostly working behavior is okay then I'm happy to include it. Otherwise, I would rather make custom object sorting more feature complete and focus more on something like D8638: Outliner: Add properties editor sync on selection for the near future.

Also, working through all the other patches & homework drained me today, so I'll finish this one up tomorrow :)

Nathan Craddock (natecraddock) marked an inline comment as done.
  • Cleanup: Remove unused functions and code
  • Refactor outliner_tree_sort into smaller functions
  • Refactor tree sorting more

@Zachman think this one should be closed? Don't see a reason to keep it open, since we put it on hold.

Yes, thanks for noticing that