===== Motivation =====**Edit:** I reworked the entire patch to have a smaller scope.
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.**Motivation**
* 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}. A refactor of outliner selection makes implementing this easier.
* Properties syncing is another feature that is in development {T63991}. Selecting object data and toggling edit mode need to be disconnected for this to behave as expected.
===== Changes =====
Behavior should be the same from before the patchA cleanup of the outliner selection functions is needed to fix {T71812}, with a few minor exceptionsand is also to allow other changes during my 2020 gsoc project.
* 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.*Changes**
* The unused `tree_element_active_text` function was removedThere are no functional changes, nothing in the outliner should behave differently than master. There are two major changes here:
* From the * Update `outliner,_item_select` to select, activate, and extend the selection. `outliner_item_toggle_mode` was added to toggle in or out of edit mode on anThis function can be used anywhere from the outliner code to select and activate elements. This will be connected tomakes the gutter in {T68498}code cleaner.
** Use `outliner_item_set_active_data` was added for setting collections, cameras, and scenes as active, also from the gutterlect` in a few places for selection.
* Both `outliner_item_set_active_data` and `outliner_item_toggle_mode` are still connected to outliner selectionMove mode toggling logic to a separate function `outlier_item_mode_toggle`. This function is still called when activating object data, so no behavior has changed, but itthis will be simple nowmake it easier to remove that behaviorfrom the selection code in the future when adding the left gutter{T68498} is implemented.
* `outliner_item_do_activate_from_tree_element` and a few other functions are no longer needed* A few functions were renamed to make purposes more clear.
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 cbut additional testing would be made more clearnice to verify that.