This patch allows animation of the collection visibility buttons.
Basically completes the work started by @aligorith in
{rBd1e3ba22a03c}.
In that commit "all necessary data and animation editor support changes"
were implemented. But the depsgraph support was incomplete.
So, in this patch, I only focused on the changes in the depsgraph
(and I trusted the original work).
##Problematic:
In the master, a few things get in the way of implementing animation
for collections. These things are:
**1. Deg nodes and relations are not created for invisible collections.**
Every time a collection flag is changed in rna, depsgraph relations are
recreated which "remove" nodes from hidden collections.
Since an invisible collection has no deg nodes, the operand that updates
them is never called. So if the visibility of a collection is animated
in this case, nothing will change.
**2. The function that updates any changes to a Collection is not thread-safe and adds a lot of overhead.**
When a collection flag is changed in rna, the
`BKE_main_collection_sync(bmain)` function is called. This function
deletes lists, Ghash, arrays from all Blender ViewLayers and Collections
and recreates them no matter if an object was deleted or if a Base flag
was just changed.
It is also not thread-safe, which makes the call unsuitable for an
operand of a depsgraph node.
##Solution:
The solution is similar to what is seen for object visibility animation
(with some changes).
**1. Deg nodes and relations to Collections are always created if the collection is animated.**
This solves the issue of operands not being called if the collection is
invisible.
There are different ways to solve this problem (like calling
`DEG_relations_tag_update` in the callback to set the rna value instead
of the update), but I preferred to follow what is seen for Objects,
that is, always create the relations.
Unlike Objects, relations are only created if the datablock is animated.
**2. Implement an update function that updates only the Base flags of a ViewLayer.**
The lightweight `BKE_layer_base_flags_update` function was implemented
to be called in the operand.
This avoids having to call `BKE_main_collection_sync`.
I feel it would be more ideal to call this function in the rna callback
that sets a flag, since this function would only be called when the flag
changes.
Also, just like the operand function that updates the flags of the
evaluated and original Bases, the operand that updates the ViewLayer
also edits the flags of the original Bases. This could be avoided if
`BKE_layer_base_flags_update` were called in the rna callback for the
original viewlayer. (I am open to suggestions in this part).