Blender Git Commit Log

Git Commits -> Revision 0c1d476

Revision 0c1d476 by Julian Eisel (master)
December 11, 2020, 22:08 (GMT)
UI: Allow UI to pass focused data-block to operators via context

This is similar to c4a2067130130d, but applies to the general UI and is only
about single data-blocks. Here there was a similar problem: How can buttons
pass the data they represent to operators? We currently resort to ugly ad-hoc
solutions like `UI_context_active_but_get_tab_ID()`. So the operator would need
to know that it is executed on a tab button that represents a data-block.

A single button can now hand operators a data-block to operate on. The operator
can request it via the "id" context member (`CTX_data_pointer_get_type(C, "id",
&RNA_ID)` in C, `bpy.context.id` in .py).
In this commit, it is already set in the following places:
* Generic RNA button code sets it to the pointed to data-block, if the button
represents a data-block RNA pointer property. (I.e for general data-block
search buttons.)
* Data-block selectors (`templateID`) set it to the currently active data-block.
* The material slot UI-List sets it for each slot to the material it represents.
The button context menu code is modified so its operators use the context set
for the layout of its parent button (i.e. `layout.context_pointer_set()`).

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: 0c1d4769235c95fc976be8988e2d4c529f3fdf49
Parent Commit: af008f5
Lines Changed: +43, -2

8 Modified Paths:

/release/scripts/startup/bl_ui/properties_material.py (+3, -0) (Diff)
/source/blender/blenkernel/BKE_context.h (+2, -1) (Diff)
/source/blender/blenkernel/intern/context.c (+6, -1) (Diff)
/source/blender/editors/include/UI_interface.h (+1, -0) (Diff)
/source/blender/editors/interface/interface.c (+9, -0) (Diff)
/source/blender/editors/interface/interface_context_menu.c (+10, -0) (Diff)
/source/blender/editors/interface/interface_layout.c (+5, -0) (Diff)
/source/blender/editors/interface/interface_templates.c (+7, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021