diff options
Diffstat (limited to 'release/scripts/startup/bl_ui/space_filebrowser.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_filebrowser.py | 71 |
1 files changed, 43 insertions, 28 deletions
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 |