[Bf-blender-cvs] [80e127089cd] temp-asset-browser-poselib-merge: Asset Browser: Python mixin utility for category-specific panels

Sybren A. Stüvel noreply at git.blender.org
Wed Jul 14 22:53:11 CEST 2021


Commit: 80e127089cd25d4d89bf9fdb5347daa596610fd0
Author: Sybren A. Stüvel
Date:   Mon Jul 12 13:27:09 2021 +0200
Branches: temp-asset-browser-poselib-merge
https://developer.blender.org/rB80e127089cd25d4d89bf9fdb5347daa596610fd0

Asset Browser: Python mixin utility for category-specific panels

Using this mixin for a panel definition, it's possible to set in which
categories the panel should appear. This is used by the Pose Library
add-on.

===================================================================

M	release/scripts/modules/bpy_extras/asset_utils.py

===================================================================

diff --git a/release/scripts/modules/bpy_extras/asset_utils.py b/release/scripts/modules/bpy_extras/asset_utils.py
index e41eeeed4fa..2cd5dddefbc 100644
--- a/release/scripts/modules/bpy_extras/asset_utils.py
+++ b/release/scripts/modules/bpy_extras/asset_utils.py
@@ -56,6 +56,17 @@ class AssetBrowserPanel:
         return SpaceAssetInfo.is_asset_browser_poll(context)
 
 
+class AssetBrowserSpecificCategoryPanel(AssetBrowserPanel):
+    asset_categories = set()  # Set of strings like 'ANIMATIONS', see `asset_category_items` in rna_space.c
+
+    @classmethod
+    def poll(cls, context):
+        return (
+            SpaceAssetInfo.is_asset_browser_poll(context)
+            and context.space_data.params.asset_category in cls.asset_categories
+        )
+
+
 class AssetMetaDataPanel:
     bl_space_type = 'FILE_BROWSER'
     bl_region_type = 'TOOL_PROPS'



More information about the Bf-blender-cvs mailing list