Page MenuHome

Outliner: Use right click target for context menu
ClosedPublic

Authored by Nathan Craddock (natecraddock) on Aug 20 2020, 12:41 AM.

Details

Summary

It would be nice to refactor the outliner context menu, but a project of that scale didn't end up fitting into the gsoc. There are some smaller annoyances that this patch addresses.

When opening the context menu with mixed type selection, the menu does not show operators based on the target of the right click. For example, if a modifier and the parent object are selected, a right click on the modifier does not show the modifier context menu, rather it shows the object context menu. The menu type shown should depend on the target of the right click.

This patch modifies the code to only check the data type of the right click rather than iterating over the tree and trying to determine what type of menu to create. For this to work, the active element is now set on right click so the operators called from the context menu know which type of data to operate on.

Diff Detail

Repository
rB Blender
Branch
outliner-context-menu (branched from master)
Build Status
Buildable 10106
Build 10106: arc lint + arc unit

Event Timeline

Nathan Craddock (natecraddock) requested review of this revision.Aug 20 2020, 12:41 AM
Nathan Craddock (natecraddock) created this revision.
  • Fix: Right click not setting the active object
Nathan Craddock (natecraddock) added a project: Restricted Project.
Julian Eisel (Severin) requested changes to this revision.Sep 9 2020, 9:14 PM

Only one thing to fix. Otherwise, LGTM.

source/blender/editors/space_outliner/outliner_tools.c
403

TSE_LAYER_COLLECTION collection is an ID type, but does not get TreeStoreElem.type set to 0. I think that's because of compatibility from when collections weren't IDs.
If you right click the default collection and do ID Data > Delete, it does nothing.

This revision now requires changes to proceed.Sep 9 2020, 9:14 PM
Nathan Craddock (natecraddock) marked an inline comment as done.
  • Fix: ID Data -> Delete on collections

Only one thing to fix. Otherwise, LGTM.

I had forgotten about my TODO question there, thanks for answering. Replacing the TSE_LAYER_COLLECTION condition caused an assert failure, so I added the TSE_LAYER_COLLECTION as a condition to the assert. I believe that was the proper fix since that is an exception to the ID data case in the tree elements.

This revision is now accepted and ready to land.Sep 10 2020, 4:49 PM
source/blender/editors/space_outliner/outliner_edit.c
495

Just noticed this removes the id null-check. I'd just add another assert for that, because id really shouldn't be NULL.

Nathan Craddock (natecraddock) marked an inline comment as done.
  • Add ID not null assert