Page MenuHome

Outliner: Selection refactor
Needs ReviewPublic

Authored by Nathan Craddock (Zachman) on Sep 16 2019, 6:09 PM.

Details

Summary
Motivation

A refactor of the outliner selection functions is needed for two reasons.

  1. After synced selection was added, some operators fail to work as expected because the sync overrides the operator directly setting objects/bones as selected.
  2. 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.
Changes

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.

Diff Detail

Repository
rB Blender
Branch
temp-outliner-select-refactor (branched from master)
Build Status
Buildable 4980
Build 4980: arc lint + arc unit

Event Timeline

source/blender/editors/space_outliner/outliner_select.c
1136

This is a wrapper around the functions to activate certain types of data, with some checks to ensure that cameras, collections, and scenes are not activated on selection.

1187

When the recursive argument of outliner_item_select is true, this is called to select the subtree. This is only used for the object select hierarchy context menu option, but could be expanded to other operators later.

1321

No longer needed as outliner_item_select can offer the same behavior

1378

outliner_item_select now contains a call to outliner_item_select_activate which is called when the activate (2nd) argument is true.