[Bf-blender-cvs] [dd728e15396] master: Asset Browser: UI polish for the asset metadata sidebar

Julian Eisel noreply at git.blender.org
Wed Oct 20 12:32:18 CEST 2021


Commit: dd728e15396eadc2d6f8dcb307343003d0050cfb
Author: Julian Eisel
Date:   Wed Oct 20 11:54:09 2021 +0200
Branches: master
https://developer.blender.org/rBdd728e15396eadc2d6f8dcb307343003d0050cfb

Asset Browser: UI polish for the asset metadata sidebar

* Show asset path in a (read only) text button. Makes it possible to see the
  full path in the tooltip, brings support for copying the path and integrates
  better with the sourrounding layout. Previous label needed lots of space to
  show the full path without clipping.
* Remove "Details" panel, it only contained one item (description). That is
  moved next to the name and asset path button.
* Use property split layout for name source and description buttons. Now that
  there are multiple buttons, it's better to have a label for them.
* Always show operators for asset previews, just gray them out if not
  applicable instead of hiding. Keeps the layout consistent and graying out is
  less confusing than hiding UI elements.

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

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

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

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 25484e905c3..1fb40ad8bc8 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -117,6 +117,8 @@ def register():
         for cls in mod.classes:
             register_class(cls)
 
+    space_filebrowser.register_props()
+
     from bpy.props import (
         EnumProperty,
         StringProperty,
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index f916a9988fd..a811ba93c17 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -661,6 +661,7 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
+        wm = context.window_manager
         asset_file_handle = context.asset_file_handle
 
         if asset_file_handle is None:
@@ -672,20 +673,20 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel):
 
         show_developer_ui = context.preferences.view.show_developer_ui
 
+        layout.use_property_split = True
+        layout.use_property_decorate = False  # No animation.
+
         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="")
+            layout.prop(asset_file_handle.local_id, "name")
 
             if show_developer_ui:
                 col = layout.column(align=True)
                 col.label(text="Asset Catalog:")
                 col.prop(asset_file_handle.local_id.asset_data, "catalog_id", text="UUID")
                 col.prop(asset_file_handle.local_id.asset_data, "catalog_simple_name", text="Simple Name")
-
-            row = layout.row()
-            row.label(text="Source: Current File")
         else:
-            layout.prop(asset_file_handle, "name", text="")
+            layout.prop(asset_file_handle, "name")
 
             if show_developer_ui:
                 col = layout.column(align=True)
@@ -694,13 +695,12 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel):
                 col.prop(asset_file_handle.asset_data, "catalog_id", text="UUID")
                 col.prop(asset_file_handle.asset_data, "catalog_simple_name", text="Simple Name")
 
-            col = layout.column(align=True)  # Just to reduce margin.
-            col.label(text="Source:")
-            row = col.row()
-            row.label(text=asset_lib_path)
-
+        row = layout.row(align=True)
+        row.prop(wm, "asset_path_dummy", text="Source")
         row.operator("asset.open_containing_blend_file", text="", icon='TOOL_SETTINGS')
 
+        layout.prop(asset_file_handle.asset_data, "description")
+
 
 class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel):
     bl_label = "Preview"
@@ -712,24 +712,11 @@ class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel):
         row = layout.row()
         box = row.box()
         box.template_icon(icon_value=active_file.preview_icon_id, scale=5.0)
-        if bpy.ops.ed.lib_id_load_custom_preview.poll():
-            col = row.column(align=True)
-            col.operator("ed.lib_id_load_custom_preview", icon='FILEBROWSER', text="")
-            col.separator()
-            col.operator("ed.lib_id_generate_preview", icon='FILE_REFRESH', text="")
-
-
-class ASSETBROWSER_PT_metadata_details(asset_utils.AssetMetaDataPanel, Panel):
-    bl_label = "Details"
-
-    def draw(self, context):
-        layout = self.layout
-        active_asset = asset_utils.SpaceAssetInfo.get_active_asset(context)
-
-        layout.use_property_split = True
 
-        if active_asset:
-            layout.prop(active_asset, "description")
+        col = row.column(align=True)
+        col.operator("ed.lib_id_load_custom_preview", icon='FILEBROWSER', text="")
+        col.separator()
+        col.operator("ed.lib_id_generate_preview", icon='FILE_REFRESH', text="")
 
 
 class ASSETBROWSER_PT_metadata_tags(asset_utils.AssetMetaDataPanel, Panel):
@@ -810,12 +797,40 @@ classes = (
     ASSETBROWSER_MT_edit,
     ASSETBROWSER_PT_metadata,
     ASSETBROWSER_PT_metadata_preview,
-    ASSETBROWSER_PT_metadata_details,
     ASSETBROWSER_PT_metadata_tags,
     ASSETBROWSER_UL_metadata_tags,
     ASSETBROWSER_MT_context_menu,
 )
 
+def asset_path_str_get(self):
+    asset_file_handle = bpy.context.asset_file_handle
+    if asset_file_handle is None:
+        return None
+
+    if asset_file_handle.local_id:
+        return "Current File"
+
+    asset_library_ref = bpy.context.asset_library_ref
+    return bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library_ref)
+
+
+def register_props():
+    from bpy.props import (
+        StringProperty,
+    )
+    from bpy.types import (
+        WindowManager,
+    )
+
+    # Just a dummy property to be able to show a string in a label button via
+    # UILayout.prop().
+    WindowManager.asset_path_dummy = StringProperty(
+        name="Asset Blend Path",
+        description="Full path to the Blender file containing the active asset",
+        get=asset_path_str_get,
+    )
+
+
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class



More information about the Bf-blender-cvs mailing list