diff options
author | Julian Eisel <julian@blender.org> | 2020-12-14 16:07:42 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-15 19:03:48 +0300 |
commit | 2d6a69ae4e9905a19ac7228b97ed08fb4ea72e75 (patch) | |
tree | 12ebb3ef64af1a91d03e7acd14e48d061482d608 /release/scripts/modules | |
parent | 70474e1a7cc45a1b1cc08d39b3e472c88c8d3225 (diff) |
Asset System: New Asset Browser editor
This introduces the User Interface part of the Asset Browser, based on the
design in T54642.
Additions:
* New Asset Browser (internally a sub-editor of the File Browser).
* Navigation region showing asset categories.
* Main region showing the assets of the selected asset library with previews.
The assets may be stored over multiple .blends in the directory that's
"mounted" as asset library in the Preferences. They will all be shown in this
list.
* Header with an asset library dropdown, allowing to choose the active asset
library to show. Options are the "Current File" as asset library and all
custom libraries.
* Display popover, filter popover and search box (partially dummies, see
T82680).
* Sidebar showing the metadata of the currently active file (name, preview,
description and tags), which can be edited for assets in the "Current File"
asset library. (For others it will reset on reload.)
* The sidebar includes a button to load a custom preview image from a file.
* Make asset files draggable (with preview image).
* If a library with invalid path is selected, a message is drawn in the main
region to help the user understand what's wrong.
* Operators to add and remove asset tags. Exposed in the sidebar.
* "Only Assets" option for Link/Append.
* Internal utilities for asset UI scripts.
For screenshots or demo videos, please see D9725. Or the 2.92 release notes.
Note that there are many things to be tweaked and polished in the Asset Browser
UI still. For example, the filter and display popovers are mostly dummies. See
T82680.
Part of the first Asset Browser milestone. Check the #asset_browser_milestone_1
project milestone on developer.blender.org.
Differential Revision: https://developer.blender.org/D9725
Reviewed by: Brecht Van Lommel, Hans Goudey
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_extras/__init__.py | 1 | ||||
-rw-r--r-- | release/scripts/modules/bpy_extras/asset_utils.py | 63 |
2 files changed, 64 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py index 1caef074d43..cb990b014a1 100644 --- a/release/scripts/modules/bpy_extras/__init__.py +++ b/release/scripts/modules/bpy_extras/__init__.py @@ -24,6 +24,7 @@ Utility modules associated with the bpy module. __all__ = ( "anim_utils", + "asset_utils", "object_utils", "io_utils", "image_utils", diff --git a/release/scripts/modules/bpy_extras/asset_utils.py b/release/scripts/modules/bpy_extras/asset_utils.py new file mode 100644 index 00000000000..db982e119d4 --- /dev/null +++ b/release/scripts/modules/bpy_extras/asset_utils.py @@ -0,0 +1,63 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +""" +Helpers for asset management tasks. +""" + +import bpy +from bpy.types import ( + Context, +) + +__all__ = ( + "SpaceAssetInfo", +) + +class SpaceAssetInfo: + @classmethod + def is_asset_browser(cls, space_data: bpy.types.Space): + return space_data.type == 'FILE_BROWSER' and space_data.browse_mode == 'ASSETS' + + @classmethod + def is_asset_browser_poll(cls, context: Context): + return cls.is_asset_browser(context.space_data) + + @classmethod + def get_active_asset(cls, context: Context): + if hasattr(context, "active_file"): + active_file = context.active_file + return active_file.asset_data if active_file else None + +class AssetBrowserPanel: + bl_space_type = 'FILE_BROWSER' + + @classmethod + def poll(cls, context): + return SpaceAssetInfo.is_asset_browser_poll(context) + +class AssetMetaDataPanel: + bl_space_type = 'FILE_BROWSER' + bl_region_type = 'TOOL_PROPS' + + @classmethod + def poll(cls, context): + active_file = context.active_file + return SpaceAssetInfo.is_asset_browser_poll(context) and active_file and active_file.asset_data |