Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-07-29 18:27:46 +0300
committerJulian Eisel <julian@blender.org>2021-07-29 18:35:06 +0300
commit2d3e5eda3f26e59945454cbca0d6533db4d980a8 (patch)
treee74dfd57b37e7a75ffaafda885bb0189b68be88d /source/blender/editors/interface/interface_template_asset_view.cc
parent8cb4e3d0460eadfbbce0b8f6ba5f5da2915830e9 (diff)
Assets/UI: Resolve major asset view UI template limitation
Before this, all asset view templates showing the same asset library would show the same assets, even if they should show different ID types. That was a major limitation since the design did forsee that this template can be put anywhere in the UI to display various sub-sets of assets. Initially I did the ID type filtering close to the asset-list reading, because I wanted to optimize reading so that we would only actually read asset information from disk of the ID type to be shown. But this will be quite complex and I'm not sure if I'll get to work on this anytime soon. So this commit moves the filtering to the template display level solving this limitation. Note: This also adds the code to filter by tags, together with the ID type. But it's not actually used anywhere yet.
Diffstat (limited to 'source/blender/editors/interface/interface_template_asset_view.cc')
-rw-r--r--source/blender/editors/interface/interface_template_asset_view.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_template_asset_view.cc b/source/blender/editors/interface/interface_template_asset_view.cc
index 8babea5d18c..b4ba6a7feab 100644
--- a/source/blender/editors/interface/interface_template_asset_view.cc
+++ b/source/blender/editors/interface/interface_template_asset_view.cc
@@ -154,6 +154,7 @@ uiListType *UI_UL_asset_view()
static void asset_view_template_refresh_asset_collection(
const AssetLibraryReference &asset_library,
+ const AssetFilterSettings &filter_settings,
PointerRNA &assets_dataptr,
const char *assets_propname)
{
@@ -175,6 +176,11 @@ static void asset_view_template_refresh_asset_collection(
RNA_property_collection_clear(&assets_dataptr, assets_prop);
ED_assetlist_iterate(&asset_library, [&](AssetHandle asset) {
+ if (!ED_asset_filter_matches_asset(&filter_settings, &asset)) {
+ /* Don't do anything else, but return true to continue iterating. */
+ return true;
+ }
+
PointerRNA itemptr, fileptr;
RNA_property_collection_add(&assets_dataptr, assets_prop, &itemptr);
@@ -219,11 +225,12 @@ void uiTemplateAssetView(uiLayout *layout,
uiItemO(row, "", ICON_FILE_REFRESH, "ASSET_OT_list_refresh");
}
- ED_assetlist_storage_fetch(&asset_library, filter_settings, C);
+ ED_assetlist_storage_fetch(&asset_library, C);
ED_assetlist_ensure_previews_job(&asset_library, C);
const int tot_items = ED_assetlist_size(&asset_library);
- asset_view_template_refresh_asset_collection(asset_library, *assets_dataptr, assets_propname);
+ asset_view_template_refresh_asset_collection(
+ asset_library, *filter_settings, *assets_dataptr, assets_propname);
AssetViewListData *list_data = (AssetViewListData *)MEM_mallocN(sizeof(*list_data),
"AssetViewListData");