Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-09-20 22:49:56 +0300
committerJulian Eisel <julian@blender.org>2021-09-27 13:24:00 +0300
commit4a278c282fe6d85f0ceea3f3b94592e595b0b189 (patch)
tree7dca60aabf0840d53ef74ad67249a503b581593c
parentb1226da66a49a524ee17053c8f43d356597b18f4 (diff)
Hide Pose Library panels unless in Pose Mode
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. Differential Revision: https://developer.blender.org/D12576
-rw-r--r--pose_library/gui.py53
1 files changed, 31 insertions, 22 deletions
diff --git a/pose_library/gui.py b/pose_library/gui.py
index a2f04a22..2082dff7 100644
--- a/pose_library/gui.py
+++ b/pose_library/gui.py
@@ -33,21 +33,25 @@ from bpy.types import (
from bpy_extras import asset_utils
-class VIEW3D_PT_pose_library(Panel):
+class PoseLibraryPanel:
+ @classmethod
+ def pose_library_panel_poll(cls, context: Context) -> bool:
+ return bool(
+ context.object
+ and context.object.mode == 'POSE'
+ )
+
+ @classmethod
+ def poll(cls, context: Context) -> bool:
+ return cls.pose_library_panel_poll(context);
+
+
+class VIEW3D_PT_pose_library(PoseLibraryPanel, Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Animation"
bl_label = "Pose Library"
- @classmethod
- def poll(cls, context: Context) -> bool:
- exp_prefs = context.preferences.experimental
- try:
- return exp_prefs.use_asset_browser
- except AttributeError:
- # The 'use_asset_browser' experimental option was removed from Blender.
- return True
-
def draw(self, context: Context) -> None:
layout = self.layout
@@ -124,11 +128,18 @@ def pose_library_list_item_context_menu(self: UIList, context: Context) -> None:
layout.operator("asset.open_containing_blend_file")
-class ASSETBROWSER_PT_pose_library_usage(asset_utils.AssetBrowserSpecificCategoryPanel, Panel):
+class ASSETBROWSER_PT_pose_library_usage(PoseLibraryPanel, asset_utils.AssetBrowserSpecificCategoryPanel, Panel):
bl_region_type = "TOOLS"
bl_label = "Pose Library"
asset_categories = {'ANIMATIONS'}
+ @classmethod
+ def poll(cls, context: Context) -> bool:
+ return (
+ cls.pose_library_panel_poll(context)
+ and cls.asset_category_poll(context)
+ )
+
def draw(self, context: Context) -> None:
layout = self.layout
wm = context.window_manager
@@ -149,11 +160,18 @@ class ASSETBROWSER_PT_pose_library_usage(asset_utils.AssetBrowserSpecificCategor
props.select = False
-class ASSETBROWSER_PT_pose_library_editing(asset_utils.AssetBrowserSpecificCategoryPanel, Panel):
+class ASSETBROWSER_PT_pose_library_editing(PoseLibraryPanel, asset_utils.AssetBrowserSpecificCategoryPanel, Panel):
bl_region_type = "TOOL_PROPS"
bl_label = "Pose Library"
asset_categories = {'ANIMATIONS'}
+ @classmethod
+ def poll(cls, context: Context) -> bool:
+ return (
+ cls.pose_library_panel_poll(context)
+ and cls.asset_category_poll(context)
+ )
+
def draw(self, context: Context) -> None:
layout = self.layout
@@ -169,21 +187,12 @@ class ASSETBROWSER_PT_pose_library_editing(asset_utils.AssetBrowserSpecificCateg
col.operator("poselib.paste_asset", icon="PASTEDOWN")
-class DOPESHEET_PT_asset_panel(Panel):
+class DOPESHEET_PT_asset_panel(PoseLibraryPanel, Panel):
bl_space_type = "DOPESHEET_EDITOR"
bl_region_type = "UI"
bl_label = "Create Pose Asset"
bl_category = "Pose Library"
- @classmethod
- def poll(cls, context: Context) -> bool:
- exp_prefs = context.preferences.experimental
- try:
- return exp_prefs.use_asset_browser
- except AttributeError:
- # The 'use_asset_browser' experimental option was removed from Blender.
- return True
-
def draw(self, context: Context) -> None:
layout = self.layout
col = layout.column(align=True)