From f585aa761292f3180c264c2186aed48ef09faa34 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 2 May 2024 20:53:22 -0400 Subject: [PATCH] Refactor: Move BrushAssetShelf to properties_paint_common Make BrushAssetShelf more easily reusable accross different space_* UI definition files. --- .../startup/bl_ui/properties_paint_common.py | 17 +++++++++++++++++ scripts/startup/bl_ui/space_view3d.py | 19 +++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/scripts/startup/bl_ui/properties_paint_common.py b/scripts/startup/bl_ui/properties_paint_common.py index 3bc7075a25c..c53651387bc 100644 --- a/scripts/startup/bl_ui/properties_paint_common.py +++ b/scripts/startup/bl_ui/properties_paint_common.py @@ -5,6 +5,23 @@ from bpy.types import Menu +class BrushAssetShelf: + bl_options = {'DEFAULT_VISIBLE', 'NO_ASSET_DRAG'} + bl_default_preview_size = 48 + + @classmethod + def poll(cls, context): + prefs = context.preferences + if not prefs.experimental.use_extended_asset_browser: + return False + + return context.mode == 'SCULPT' + + @classmethod + def asset_poll(cls, asset): + return asset.id_type == 'BRUSH' + + class UnifiedPaintPanel: # subclass must set # bl_space_type = 'IMAGE_EDITOR' diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index e04b819780c..0d1f4f4ecd8 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -13,6 +13,7 @@ from bl_ui.properties_paint_common import ( brush_basic_texpaint_settings, brush_basic_gpencil_weight_settings, brush_basic_grease_pencil_weight_settings, + BrushAssetShelf, ) from bl_ui.properties_grease_pencil_common import ( AnnotationDataPanel, @@ -9083,25 +9084,11 @@ class VIEW3D_PT_viewport_debug(Panel): layout.prop(overlay, "use_debug_freeze_view_culling") -class VIEW3D_AST_sculpt_brushes(bpy.types.AssetShelf): +class VIEW3D_AST_sculpt_brushes(BrushAssetShelf, bpy.types.AssetShelf): # Experimental: Asset shelf for sculpt brushes, only shows up if both the # "Asset Shelf" and the "Extended Asset Browser" experimental features are # enabled. - - bl_space_type = 'VIEW_3D' - bl_default_preview_size = 48 - - @classmethod - def poll(cls, context): - prefs = context.preferences - if not prefs.experimental.use_extended_asset_browser: - return False - - return context.mode == 'SCULPT' - - @classmethod - def asset_poll(cls, asset): - return asset.id_type == 'BRUSH' + bl_space_type = "VIEW_3D" classes = (