UI: Region polling support #105088

Merged
Julian Eisel merged 39 commits from JulianEisel/blender:temp-region-poll into main 2023-04-05 15:30:46 +02:00
3 changed files with 25 additions and 19 deletions
Showing only changes of commit a07a2e2369 - Show all commits

View File

@ -84,8 +84,7 @@ class AssetLibrary {
* library. This is just a combination of the other ones, so usually
* iterating over it is redundant.
*/
static void foreach_loaded(FunctionRef<void(AssetLibrary &)> fn,
bool include_all_library = true);
static void foreach_loaded(FunctionRef<void(AssetLibrary &)> fn, bool include_all_library);
void load_catalogs();

View File

@ -155,20 +155,25 @@ AssetLibrary *AssetLibraryService::get_asset_library_all(const Main *bmain)
all_library_ = std::make_unique<AssetLibrary>();
AssetLibrary &all_library = *all_library_;
auto build_catalogs_fn = [&all_library]() {
auto build_catalogs_fn = [&all_library](const bool is_first_load) {
/* Start with empty catalog storage. */
all_library.catalog_service = std::make_unique<AssetCatalogService>();
/* (Re-)load catalogs on refresh. */
AssetLibrary::foreach_loaded([&all_library](AssetLibrary &nested) {
nested.catalog_service->reload_catalogs();
all_library.catalog_service->add_from_existing(*nested.catalog_service);
});
AssetLibrary::foreach_loaded(
[&](AssetLibrary &nested) {
/* On first load the catalogs were read just above, no need to reload. */
if (!is_first_load) {
nested.catalog_service->reload_catalogs();
}
all_library.catalog_service->add_from_existing(*nested.catalog_service);
},
false);
all_library.catalog_service->rebuild_tree();
};
build_catalogs_fn();
all_library.on_refresh_ = build_catalogs_fn;
build_catalogs_fn(true);
all_library.on_refresh_ = [build_catalogs_fn]() { build_catalogs_fn(false); };
return &all_library;
}

View File

@ -3907,18 +3907,20 @@ static void filelist_readjob_all_asset_library(FileListReadJob *job_params,
/* The "All" asset library was loaded, which means all other asset libraries are also loaded.
* Load their assets from disk into the "All" library. */
asset_system::AssetLibrary::foreach_loaded([&](asset_system::AssetLibrary &nested_library) {
StringRefNull root_path = nested_library.root_path();
if (root_path.is_empty()) {
return;
}
asset_system::AssetLibrary::foreach_loaded(
[&](asset_system::AssetLibrary &nested_library) {
StringRefNull root_path = nested_library.root_path();
if (root_path.is_empty()) {
return;
}
/* Override library info to read this library. */
job_params->load_asset_library = &nested_library;
BLI_strncpy(filelist->filelist.root, root_path.c_str(), sizeof(filelist->filelist.root));
/* Override library info to read this library. */
job_params->load_asset_library = &nested_library;
BLI_strncpy(filelist->filelist.root, root_path.c_str(), sizeof(filelist->filelist.root));
filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);
});
filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);
},
false);
}
/**