Page MenuHome

Hide Pose Library panels unless in Pose Mode
ClosedPublic

Authored by Julian Eisel (Severin) on Sep 20 2021, 9:52 PM.

Details

Summary

Otherwise, there will be a useless tab in the sidebar, and panels in the
Asset Browser and Dopesheet that do nothing. So far the Asset Browser
hides these panels unless the Animation category is selected, but this
won't work once asset catalogs replace the categories.

Diff Detail

Event Timeline

Julian Eisel (Severin) requested review of this revision.Sep 20 2021, 9:52 PM
Julian Eisel (Severin) created this revision.
This revision is now accepted and ready to land.Sep 21 2021, 10:45 AM
Julian Eisel (Severin) updated this revision to Diff 42158.EditedSep 21 2021, 3:06 PM
  • Fix broken AssetBrowserSpecificCategoryPanel with this in master

This will have to go along with this change in the main repository:

diff --git a/release/scripts/modules/bpy_extras/asset_utils.py b/release/scripts/modules/bpy_extras/asset_utils.py
index 2cd5dddefbc..adfbd32958a 100644
--- a/release/scripts/modules/bpy_extras/asset_utils.py
+++ b/release/scripts/modules/bpy_extras/asset_utils.py
@@ -60,12 +60,23 @@ class AssetBrowserSpecificCategoryPanel(AssetBrowserPanel):
     asset_categories = set()  # Set of strings like 'ANIMATIONS', see `asset_category_items` in rna_space.c
 
     @classmethod
-    def poll(cls, context):
+    def asset_category_poll(cls, context):
+        """
+        This tries to accesses the static variable `asset_categories` in the
+        sub-class which won't work if there are multiple mixins with their own
+        `poll()` method. The caller would have to explicitly call the `poll()`
+        on the mixin classes, which makes the mixin access the wrong `cls`.
+        Instead the sub-class can call this function directly on its `cls`.
+        """
         return (
             SpaceAssetInfo.is_asset_browser_poll(context)
             and context.space_data.params.asset_category in cls.asset_categories
         )
 
+    @classmethod
+    def poll(cls, context):
+        return cls.asset_category_poll(context)
+
 
 class AssetMetaDataPanel:
     bl_space_type = 'FILE_BROWSER'