Blender Git Loki

Git Commits -> Revision af008f5

Revision af008f5 by Julian Eisel (master)
December 11, 2020, 22:08 (GMT)
UI: Allow Outliners to pass selected data-blocks to operators via context

The way the Outliner integrates operations on selected tree elements is known
to be quite problematic amongst developers. The context menu is generated in an
unusual way and doesn't use the normal operator system. Instead, changes are
applied via a recursive callback system. Things are quite ad-hoc, and the
callbacks often implement logic that should not be in the Outliner, but in
entirely different modules. Often these modules already contain the logic, but
as proper operators.

This commit is a step into a hopefully better direction that should allow us to
put actual operators into Outliner context menus. It starts solving the problem
of: How can the Outliner pass selected data to operators. It implements it for
data-blocks only, but other data could do it in the same way.

Idea is to keep doing what operators were initially designed to do: Operate on
context.
Operators can now query a "selected_ids" context member
(`CTX_data_selected_ids()` in C, `bpy.context.selected_ids` in .py). If an
Outliner is active, it will generate a list of selected data-blocks as a
response, via its `SpaceType.context` callback.
Any other editor could do the same.

No user visible changes. This new design isn't actually used yet. It will be
soon for asset operators.

Reviewed as part of https://developer.blender.org/D9717.
Reviewed by: Brecht Van Lommel

Commit Details:

Full Hash: af008f553293d91ef624ab4950e6d5dcc91650fe
Parent Commit: ba83ad2
Lines Changed: +90, -0

1 Added Path:

/source/blender/editors/space_outliner/outliner_context.c (+73, -0) (View)

5 Modified Paths:

/source/blender/blenkernel/BKE_context.h (+3, -0) (Diff)
/source/blender/blenkernel/intern/context.c (+5, -0) (Diff)
/source/blender/editors/space_outliner/CMakeLists.txt (+1, -0) (Diff)
/source/blender/editors/space_outliner/outliner_intern.h (+7, -0) (Diff)
/source/blender/editors/space_outliner/space_outliner.c (+1, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021