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.
This commit is contained in:
Julian Eisel 2021-10-20 11:54:09 +02:00
parent 381965eb56
commit dd728e1539
2 changed files with 45 additions and 28 deletions

View File

@ -117,6 +117,8 @@ def register():
for cls in mod.classes:
register_class(cls)
space_filebrowser.register_props()
from bpy.props import (
EnumProperty,
StringProperty,

View File

@ -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