From f52e3aa210003656665cfb321b074dfc17363338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 12 Jul 2021 13:27:09 +0200 Subject: 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. --- release/scripts/modules/bpy_extras/asset_utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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' -- cgit v1.2.3