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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user