Page MenuHome

Collections: Add color tagging and use in outliner

Authored by Nathan Craddock (Zachman) on Aug 19 2020, 5:53 AM.



Add a color tag to collections and allow tagging from the outliner context menu.

This could be split into two patches if needed, one for the actual collection colors and another for the outliner and menus integration.

This adds a color tagging mechanism to collections similar to those for coloring folders, layers, and other organization units in other software. There are 8 colors and none which is default. The colors may be changed in the user preferences.

There is a simple outliner context menu function to apply a color tag to all selected collections.

The collection icon is now filled in to better show the color. There may be a few instances where the old icon should be replaced with the new icon.

The new icon is used in user interface menus

  • Link to collection, move to collection, add collection instance, instance search, remove collection.

This patch depends on and includes the changes in D8317: UI: Fix drawing of aligned icon buttons in menu rows for drawing the color tagging icons in the outliner context menu.

Remaining todos/thoughts:

  • Pick colors for all themes. The default theme colors are generally okay. They may need some slight changes.
  • There are a few - 1 instances in the code to get the proper color index. This could be solved by making the none color tag have the value of -1 and do versioning to set all the collection color tags to -1.
  • Use new filled collection icon in the user preferences Collection Colors panel header

Diff Detail

rB Blender
outliner-collection-colors (branched from master)
Build Status
Buildable 9739
Build 9739: arc lint + arc unit

Event Timeline

Nathan Craddock (Zachman) requested review of this revision.Aug 19 2020, 5:53 AM
Nathan Craddock (Zachman) created this revision.
  • Outliner: Fix missing argument to UNUSED macro
  • Themes: Use filled collection icon for header
Julian Eisel (Severin) requested changes to this revision.EditedSep 15 2020, 4:20 PM

Overall fine, seems almost ready. Just a few points:

  • Please leave out the change to move the collection checkbox to the right for now. We can check on this during bcon2 still, but I first want to have it discussed with the team.
  • You should bump sub-version when committing this, and put the versioning into a versioning block.
  • The changes to blender_icons.svg are missing here. The next time somebody runs, the new icons will get lost. (Note that when updating the .svg with Inkscape, it usually saves many unrelated changes. These can be cleaned up manually.)
  • The patch does visual changes to the Outliner, which I didn't expect from the patch title and description. Please make that clear for the commit to master.

Just use a for-loop.




Better call this color_id to make clear in the name that this is not the actual color. It's also not clear at all what this relates to. So I'd suggest giving the enum a name, say CollectionColorID and using that named type here (CollectionColorID color_id;). Since the enum definition is in the same header, that will work.


Why not use -1 from the get-go for this, like you suggested?


Could we have a #define for the number of collection colors? You might not be able to use it here, but you can at least mention it in a comment. So that if you want to change the number you only need to search for the define to see where you have to change it.
(Could also be an additional item in the enum.)

This revision now requires changes to proceed.Sep 15 2020, 4:20 PM
Nathan Craddock (Zachman) added a project: Restricted Project.Sep 15 2020, 4:26 PM
Nathan Craddock (Zachman) marked 5 inline comments as done.
  • Cleanup: Use a loop for userdef versioning
  • Bump subversion
  • Rename to color_tag
  • Cleanup layout code

Changed the value of COLLECTION_COLOR_NONE to -1 and applied versioning to ensure old collections are not color tagged. Also set to NONE when creating collections.

One thing (I guess could be fixed later?) Is there is nothing preventing the python api to set the scene collection color tag. I assume we don't want to allow this.

One thing (I guess could be fixed later?) Is there is nothing preventing the python api to set the scene collection color tag. I assume we don't want to allow this.

True, good catch. Am fine with having that fixed after the merge, but it should be done soon.

The checkbox icon is still on the right, but Nathan said he'd leave these changes out of the commit.

This revision is now accepted and ready to land.Sep 15 2020, 7:10 PM