[Bf-blender-cvs] [0898c577c4f] asset-browser-poselib: Show asset path in asset browser sidebar + Open Blend File button

Julian Eisel noreply at git.blender.org
Fri May 21 02:19:11 CEST 2021


Commit: 0898c577c4f5bc79998a5eccc6bbbf45eaf8499a
Author: Julian Eisel
Date:   Fri May 21 02:16:38 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rB0898c577c4f5bc79998a5eccc6bbbf45eaf8499a

Show asset path in asset browser sidebar + Open Blend File button

This is useful information to have and the Open Blend File makes sense to have
next to it.

A general Asset Browser feature really, but the Open Blend File operator is
only available in this branch, so committing that here.

Also added a TODO note about something that would be especially good to have
for this change.

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

M	release/scripts/addons
M	release/scripts/startup/bl_operators/assets.py
M	release/scripts/startup/bl_ui/space_filebrowser.py

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

diff --git a/release/scripts/addons b/release/scripts/addons
index 4fcdbfe7c20..3f03f1414dd 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 4fcdbfe7c20edfc1204c0aa46c98ea25354abcd9
+Subproject commit 3f03f1414ddb3f7852cf9f8453871a9a6c584927
diff --git a/release/scripts/startup/bl_operators/assets.py b/release/scripts/startup/bl_operators/assets.py
index d253a72484c..81d5f35f0ae 100644
--- a/release/scripts/startup/bl_operators/assets.py
+++ b/release/scripts/startup/bl_operators/assets.py
@@ -91,6 +91,7 @@ class ASSET_OT_open_containing_blend_file(Operator):
         if not asset_file_handle or not asset_library:
             return False
 
+        # TODO add tooltip disabled hint (to explain why the operator isn't available).
         return not asset_file_handle.local_id
 
     def execute(self, context):
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 2e15506a729..424631ac2cd 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -592,15 +592,29 @@ 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
 
+        asset_library = context.asset_library
+        asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library)
+        is_local = asset_file_handle.local_id is not None
+
         # 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="")
+        layout.prop(asset_file_handle.local_id if is_local else asset_file_handle, "name", text="")
+
+        if is_local:
+            row = layout.row()
+            row.label(text="Source: Current File")
+        else:
+            col = layout.column(align=True)  # Just to reduce margin.
+            col.label(text="Source:")
+            row = col.row()
+            row.label(text=asset_lib_path)
+
+        row.operator("asset.open_containing_blend_file", text="", icon='TOOL_SETTINGS')
 
 
 class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel):



More information about the Bf-blender-cvs mailing list