A refactor of the outliner selection functions is needed for two reasons.
- After synced selection was added, some operators fail to work as expected because the sync overrides the operator directly setting objects/bones as selected.
- To prepare for other outliner changes.
For example, in 2.80 scenes view it was possible to select a collection element in the outliner to select the contents of the collection. Because this operator directly selected the objects, the following synced selection would overwrite the collection contents selection.
There are some changes that depend on a refactor of selection
- Selecting object data currently toggles edit mode. This is annoying and not expected behavior.
- Walk select currently moves the selected item, not the active item. This was needed because activating an element in the outliner would toggle modes/change active camera/change scenes, which was disruptive on a walk select.
- There are plans to add a new gutter on the left side of the outliner to toggle edit mode and to set active data like collections, scenes, and cameras T68498: Outliner: Modes & activating cameras or scenes. A refactor of outliner selection makes implementing this easier.
- Properties syncing is another feature that is in development T63991: Outliner - Properties syncing. Selecting object data and toggling edit mode need to be disconnected for this to behave as expected.
Behavior should be the same from before the patch, with a few minor exceptions
- The select hierarchy operator was rewritten to simply use the updated outliner_item_select function. Rather than directly selecting the children of the object, this does an outliner select on the subtree of the element, then syncing handles selecting in the 3D view. This could be expanded to collections
- Collection selection was removed from the scenes view. This could be added back at a later time (it might also be useful in View Layer mode, but could cause conflicts with walk selection)
- `outliner_item_select* can be used by any outliner operator to select and/or activate an element, optionally extending the selection or selecting the subtree recursively.
- The unused tree_element_active_text function was removed
- From the outliner, outliner_item_toggle_mode was added to toggle in or out of edit mode on an element. This will be connected to the gutter in T68498: Outliner: Modes & activating cameras or scenes
- outliner_item_set_active_data was added for setting collections, cameras, and scenes as active, also from the gutter.
- Both outliner_item_set_active_data and outliner_item_toggle_mode are still connected to outliner selection, but it will be simple now to remove that behavior when adding the left gutter.
- outliner_item_do_activate_from_tree_element and a few other functions are no longer needed.
Overall, I'm fairly certain no behavior has changed because the same functions are still used for the actual selection and activation functionality. The only changes I think may be needed are in regards to function naming. I think those could be made more clear.