diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-07-12 14:27:09 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-07-15 17:12:36 +0300 |
commit | f52e3aa210003656665cfb321b074dfc17363338 (patch) | |
tree | a081e90d02859309213ae118bb9289c1f382ffda | |
parent | 8925d3b7bf989e1db364d989fbd0c6cdb9a2acdb (diff) |
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.
-rw-r--r-- | release/scripts/modules/bpy_extras/asset_utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
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' |