mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Refactor: Get asset data via asset representation, not file
The "active_file" context member as a way to get the active asset should be avoided, in favor of "asset". This moves us away from the file browser backend as basis of the asset system,
This commit is contained in:
parent
9ca5289bc1
commit
a6ed013baa
3 changed files with 4 additions and 8 deletions
|
|
@ -25,11 +25,6 @@ class SpaceAssetInfo:
|
|||
def is_asset_browser_poll(cls, context: Context):
|
||||
return cls.is_asset_browser(context.space_data)
|
||||
|
||||
@classmethod
|
||||
def get_active_asset(cls, context: Context):
|
||||
if active_file := getattr(context, "active_file", None):
|
||||
return active_file.asset_data
|
||||
|
||||
|
||||
class AssetBrowserPanel:
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class ASSET_OT_tag_add(AssetBrowserMetadataOperator, Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
active_asset = SpaceAssetInfo.get_active_asset(context)
|
||||
active_asset.tags.new(data_("Tag"))
|
||||
active_asset = context.asset
|
||||
active_asset.asset_data.tags.new(data_("Tag"))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
|
|
|||
|
|
@ -792,7 +792,8 @@ class ASSETBROWSER_PT_metadata_tags(asset_utils.AssetMetaDataPanel, Panel):
|
|||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
asset_data = asset_utils.SpaceAssetInfo.get_active_asset(context)
|
||||
active_asset = context.asset
|
||||
asset_data = active_asset.asset_data
|
||||
|
||||
row = layout.row()
|
||||
row.template_list(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue