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/asset/intern/asset_list.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/asset/intern/asset_list.cc')
-rw-r--r--source/blender/editors/asset/intern/asset_list.cc27
1 files changed, 9 insertions, 18 deletions
diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc
index d94a2bbf438..57c25e1614b 100644
--- a/source/blender/editors/asset/intern/asset_list.cc
+++ b/source/blender/editors/asset/intern/asset_list.cc
@@ -122,7 +122,7 @@ class AssetList : NonCopyable {
AssetList(AssetList &&other) = default;
~AssetList() = default;
- void setup(const AssetFilterSettings *filter_settings = nullptr);
+ void setup();
void fetch(const bContext &C);
void ensurePreviewsJob(bContext *C);
void clear(bContext *C);
@@ -141,7 +141,7 @@ AssetList::AssetList(eFileSelectType filesel_type, const AssetLibraryReference &
{
}
-void AssetList::setup(const AssetFilterSettings *filter_settings)
+void AssetList::setup()
{
FileList *files = filelist_;
@@ -160,17 +160,13 @@ void AssetList::setup(const AssetFilterSettings *filter_settings)
filelist_setrecursion(files, 1);
filelist_setsorting(files, FILE_SORT_ALPHA, false);
filelist_setlibrary(files, &library_ref_);
- /* TODO different filtering settings require the list to be reread. That's a no-go for when we
- * want to allow showing the same asset library with different filter settings (as in,
- * different ID types). The filelist needs to be made smarter somehow, maybe goes together with
- * the plan to separate the view (preview caching, filtering, etc. ) from the data. */
filelist_setfilter_options(
files,
- filter_settings != nullptr,
+ false,
true,
true, /* Just always hide parent, prefer to not add an extra user option for this. */
FILE_TYPE_BLENDERLIB,
- filter_settings ? filter_settings->id_types : FILTER_ID_ALL,
+ FILTER_ID_ALL,
true,
"",
"");
@@ -333,9 +329,7 @@ class AssetListStorage {
/* Purely static class, can't instantiate this. */
AssetListStorage() = delete;
- static void fetch_library(const AssetLibraryReference &library_reference,
- const bContext &C,
- const AssetFilterSettings *filter_settings = nullptr);
+ static void fetch_library(const AssetLibraryReference &library_reference, const bContext &C);
static void destruct();
static AssetList *lookup_list(const AssetLibraryReference &library_ref);
static void tagMainDataDirty();
@@ -353,8 +347,7 @@ class AssetListStorage {
};
void AssetListStorage::fetch_library(const AssetLibraryReference &library_reference,
- const bContext &C,
- const AssetFilterSettings *filter_settings)
+ const bContext &C)
{
std::optional filesel_type = asset_library_reference_to_fileselect_type(library_reference);
if (!filesel_type) {
@@ -363,7 +356,7 @@ void AssetListStorage::fetch_library(const AssetLibraryReference &library_refere
auto [list, is_new] = ensure_list_storage(library_reference, *filesel_type);
if (is_new || list.needsRefetch()) {
- list.setup(filter_settings);
+ list.setup();
list.fetch(C);
}
}
@@ -440,11 +433,9 @@ using namespace blender::ed::asset;
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
* and may return earlier.
*/
-void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference,
- const AssetFilterSettings *filter_settings,
- const bContext *C)
+void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
{
- AssetListStorage::fetch_library(*library_reference, *C, filter_settings);
+ AssetListStorage::fetch_library(*library_reference, *C);
}
void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference, bContext *C)