Blender Git Loki

Git Commits -> Revision 8925d3b

Revision 8925d3b by Julian Eisel (master)
July 15, 2021, 14:12 (GMT)
UI/Assets: Initial Asset View UI template

The asset view UI template is a mini-version of the Asset Browser that
can be placed in regular layouts, regions or popups. At this point it's
made specifically for placement in vertical layouts, it can be made more
flexible in the future.
Generally the way this is implemented will likely change a lot still as
the asset system evolves.

The Pose Library add-on will use the asset view to display pose
libraries in the 3D View sidebar.

References:
* https://developer.blender.org/T86139
* https://code.blender.org/2021/06/asset-browser-project-update/#what-are-we-building
* https://code.blender.org/2021/05/pose-library-v2-0/#use-from-3d-viewport

Notes:
* Important limitation: Due to the early & WIP implementation of the
asset list, all asset views showing the same library will show the
same assets. That is despite the ID type filter option the template
provides. The first asset view created will determine what's visible.
Of course this should be made to work eventually.
* The template supports passing an activate and a drag operator name.
The former is called when an asset is clicked on (e.g. to apply the
asset) the latter when dragging (e.g. to .blend a pose asset). If no
drag operator is set, regular asset drag & drop will be executed.
* The template returns the properties for both operators (see example
below).
* The argument list for using the template is quite long, but we can't
avoid that currently. The UI list design requires that we pass a
number of RNA or custom properties to work with, that for the Pose
Libraries should be registered at the Pose Library add-on level, not
in core Blender.
* Idea is that Python scripts or add-ons that want to use the asset view
can register custom properties, to hold data like the list of assets,
and the active asset index. Maybe that will change in future and we
can manage these internally.

As an example, the pose library add-on uses it like this:
```
activate_op_props, drag_op_props = layout.template_asset_view(
"pose_assets",
workspace,
"active_asset_library",
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
filter_id_types={"filter_action"},
activate_operator="poselib.apply_pose_asset",
drag_operator="poselib.blend_pose_asset",
)
drag_op_props.release_confirm = True
drag_op_props.flipped = wm.poselib_flipped
activate_op_props.flipped = wm.poselib_flipped
```

Commit Details:

Full Hash: 8925d3b7bf989e1db364d989fbd0c6cdb9a2acdb
Parent Commit: 6bd42ba
Committed By: Sybren A. Stüvel
Lines Changed: +612, -143

1 Added Path:

/source/blender/editors/interface/interface_template_asset_view.cc (+272, -0) (View)

10 Modified Paths:

/source/blender/blenkernel/BKE_screen.h (+6, -0) (Diff)
/source/blender/editors/include/UI_interface.h (+15, -0) (Diff)
/source/blender/editors/interface/CMakeLists.txt (+1, -0) (Diff)
/source/blender/editors/interface/interface_intern.h (+3, -0) (Diff)
/source/blender/editors/interface/interface_template_list.cc (+5, -0) (Diff)
/source/blender/editors/screen/area.c (+6, -0) (Diff)
/source/blender/makesrna/intern/rna_ID.c (+91, -0) (Diff)
/source/blender/makesrna/intern/rna_space.c (+57, -143) (Diff)
/source/blender/makesrna/intern/rna_ui_api.c (+140, -0) (Diff)
/source/blender/makesrna/RNA_enum_types.h (+16, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021