[Bf-blender-cvs] [add6fa09249] master: Assets: Show asset path in asset browser sidebar

Julian Eisel noreply at git.blender.org
Thu Jul 15 16:14:24 CEST 2021


Commit: add6fa09249636cf5709675c9c0ef9a444bb4443
Author: Julian Eisel
Date:   Fri Jul 9 12:33:38 2021 +0200
Branches: master
https://developer.blender.org/rBadd6fa09249636cf5709675c9c0ef9a444bb4443

Assets: Show asset path in asset browser sidebar

It's useful to know where an asset is stored in, before this there was no way
to tell this. This could probably be displayed nicer in the UI but we're
currently unsure how. But at least the information is there now.

===================================================================

M	release/scripts/startup/bl_ui/space_filebrowser.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 1ad88744b16..96855cb4a07 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -592,15 +592,26 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-        active_file = context.active_file
-        active_asset = asset_utils.SpaceAssetInfo.get_active_asset(context)
+        asset_file_handle = context.asset_file_handle
 
-        if not active_file or not active_asset:
+        if asset_file_handle is None:
             layout.label(text="No asset selected", icon='INFO')
             return
 
-        # If the active file is an ID, use its name directly so renaming is possible from right here.
-        layout.prop(context.id if context.id is not None else active_file, "name", text="")
+        asset_library = context.asset_library
+        asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library)
+
+        if asset_file_handle.local_id:
+            # If the active file is an ID, use its name directly so renaming is possible from right here.
+            layout.prop(asset_file_handle.local_id, "name", text="")
+            row = layout.row()
+            row.label(text="Source: Current File")
+        else:
+            layout.prop(asset_file_handle, "name", text="")
+            col = layout.column(align=True)  # Just to reduce margin.
+            col.label(text="Source:")
+            row = col.row()
+            row.label(text=asset_lib_path)
 
 
 class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel):



More information about the Bf-blender-cvs mailing list