diff options
author | Julian Eisel <julian@blender.org> | 2021-07-20 21:58:15 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-07-20 22:30:03 +0300 |
commit | 5a1b1c0ed2e6d085c93b8afd699407f92cc2d07d (patch) | |
tree | dc52de62700959ffedbc786e79ed39f6fe36f90b /source/blender/editors/asset | |
parent | 207df439e1ad50b3af691f91710b886d0e997993 (diff) |
Cleanup: Getters for asset-handle data
While the asset-handle design is supposed to be temporary (see
35affaa971cf), I prefer keeping the fact that it's nothing but a file
entry pointer an implementation detail that is abstracted away. So this
introduces getters for the file data we typically access for
asset-handles.
Diffstat (limited to 'source/blender/editors/asset')
-rw-r--r-- | source/blender/editors/asset/asset_edit.cc | 20 | ||||
-rw-r--r-- | source/blender/editors/asset/asset_list.cc | 8 | ||||
-rw-r--r-- | source/blender/editors/asset/asset_temp_id_consumer.cc | 2 |
3 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/editors/asset/asset_edit.cc b/source/blender/editors/asset/asset_edit.cc index f4860737193..c44960f3b5a 100644 --- a/source/blender/editors/asset/asset_edit.cc +++ b/source/blender/editors/asset/asset_edit.cc @@ -139,6 +139,26 @@ const char *ED_asset_handle_get_name(const AssetHandle *asset) return asset->file_data->name; } +AssetMetaData *ED_asset_handle_get_metadata(const AssetHandle *asset) +{ + return asset->file_data->asset_data; +} + +ID *ED_asset_handle_get_local_id(const AssetHandle *asset) +{ + return asset->file_data->id; +} + +ID_Type ED_asset_handle_get_id_type(const AssetHandle *asset) +{ + return static_cast<ID_Type>(asset->file_data->blentype); +} + +int ED_asset_handle_get_preview_icon_id(const AssetHandle *asset) +{ + return asset->file_data->preview_icon_id; +} + void ED_asset_handle_get_full_library_path(const bContext *C, const AssetLibraryReference *asset_library, const AssetHandle *asset, diff --git a/source/blender/editors/asset/asset_list.cc b/source/blender/editors/asset/asset_list.cc index d9c1c6d862e..3095239b711 100644 --- a/source/blender/editors/asset/asset_list.cc +++ b/source/blender/editors/asset/asset_list.cc @@ -495,7 +495,8 @@ std::string ED_assetlist_asset_filepath_get(const bContext *C, const AssetLibraryReference &library_reference, const AssetHandle &asset_handle) { - if (asset_handle.file_data->id || !asset_handle.file_data->asset_data) { + if (ED_asset_handle_get_local_id(&asset_handle) || + !ED_asset_handle_get_metadata(&asset_handle)) { return {}; } const char *library_path = ED_assetlist_library_path(&library_reference); @@ -513,11 +514,6 @@ std::string ED_assetlist_asset_filepath_get(const bContext *C, return path; } -ID *ED_assetlist_asset_local_id_get(const AssetHandle *asset_handle) -{ - return asset_handle->file_data->asset_data ? asset_handle->file_data->id : nullptr; -} - ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle) { ImBuf *imbuf = filelist_file_getimage(asset_handle->file_data); diff --git a/source/blender/editors/asset/asset_temp_id_consumer.cc b/source/blender/editors/asset/asset_temp_id_consumer.cc index 24e1fc86fef..464320fdce9 100644 --- a/source/blender/editors/asset/asset_temp_id_consumer.cc +++ b/source/blender/editors/asset/asset_temp_id_consumer.cc @@ -53,7 +53,7 @@ class AssetTemporaryIDConsumer : NonCopyable, NonMovable { ID *get_local_id() { - return ED_assetlist_asset_local_id_get(&handle_); + return ED_asset_handle_get_local_id(&handle_); } ID *import_id(const bContext *C, |