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-09-29 18:01:13 +0300
committerJulian Eisel <julian@blender.org>2021-09-29 18:15:23 +0300
commit9d9f205dc4a9ddae3d654c64894eaca8443cacc0 (patch)
treeb41b40fe69987849bb02415ddcd63d465df10501 /source/blender/editors/space_file/filelist.c
parentdf9120b365380cc1d64006e0d37a650eaaff9776 (diff)
Asset Browser: Initial Asset Catalog UI
The Asset Browser now displays a tree with asset catalogs in the left sidebar. This replaces the asset categories. It uses the new UI tree-view API (https://wiki.blender.org/wiki/Source/Interface/Views#Tree-View). Buttons are displayed for adding and removing of catalogs. Parent items can be collapsed, but the collapsed/uncollapsed state is not stored in files yet. Note that edits to catalogs (e.g. new or removed catalogs) are only written to the asset library's catalog definition files when saving a .blend. In the "Current File" asset library, we try to show asset catalogs from a parent asset library, or if that fails, from the directory the file is stored in. See adaf4f56e1ed. There are plenty of TODOs and smaller glitches to be fixed still. Plus a UI polishing pass should be done. Important missing UI features: * Dragging assets into catalogs (WIP, close to being ready). * Renaming catalogs * Proper handling of catalogs in the "Current File" asset library (currently not working well). The "Current File" asset library is especially limited still. Since this is the only place where you can assign assets to a catalog, this makes the catalogs very cumbersome in general. To assign an asset to a catalog, one has to manually copy the Catalog ID (a random hash like number) to the asset metadata through a temporary UI in the Asset Browser Sidebar. These limitations should be addressed over the next few days, they are high priority. Differential Revision: https://developer.blender.org/D12670
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r--source/blender/editors/space_file/filelist.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 60fe5364aba..91178b85823 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -50,6 +50,7 @@
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "BLI_uuid.h"
#ifdef WIN32
# include "BLI_winstuff.h"
@@ -369,6 +370,9 @@ typedef struct FileListFilter {
char filter_glob[FILE_MAXFILE];
char filter_search[66]; /* + 2 for heading/trailing implicit '*' wildcards. */
short flags;
+
+ eFileSel_Params_AssetCatalogVisibility asset_catalog_visibility;
+ bUUID asset_catalog_id;
} FileListFilter;
/* FileListFilter.flags */
@@ -806,6 +810,22 @@ static bool is_filtered_hidden(const char *filename,
return true;
}
+ /* TODO Make catalog activation work properly with the "Current File" asset library. Currently
+ * this will only work for external asset data. */
+ if (file->imported_asset_data) {
+ switch (filter->asset_catalog_visibility) {
+ case FILE_SHOW_ASSETS_WITHOUT_CATALOG:
+ return !BLI_uuid_is_nil(file->imported_asset_data->catalog_id);
+ case FILE_SHOW_ASSETS_FROM_CATALOG:
+ /* TODO show all assets that are in child catalogs of the selected catalog. */
+ return BLI_uuid_is_nil(filter->asset_catalog_id) ||
+ !BLI_uuid_equal(filter->asset_catalog_id, file->imported_asset_data->catalog_id);
+ case FILE_SHOW_ASSETS_ALL_CATALOGS:
+ /* All asset files should be visible. */
+ break;
+ }
+ }
+
return false;
}
@@ -1038,6 +1058,33 @@ void filelist_setfilter_options(FileList *filelist,
}
/**
+ * \param catalog_id: The catalog that should be filtered by if \a catalog_visibility is
+ * #FILE_SHOW_ASSETS_FROM_CATALOG. May be NULL otherwise.
+ */
+void filelist_set_asset_catalog_filter_options(
+ FileList *filelist,
+ eFileSel_Params_AssetCatalogVisibility catalog_visibility,
+ const bUUID *catalog_id)
+{
+ bool update = false;
+
+ if (filelist->filter_data.asset_catalog_visibility != catalog_visibility) {
+ filelist->filter_data.asset_catalog_visibility = catalog_visibility;
+ update = true;
+ }
+
+ if (filelist->filter_data.asset_catalog_visibility == FILE_SHOW_ASSETS_FROM_CATALOG &&
+ catalog_id && !BLI_uuid_equal(filelist->filter_data.asset_catalog_id, *catalog_id)) {
+ filelist->filter_data.asset_catalog_id = *catalog_id;
+ update = true;
+ }
+
+ if (update) {
+ filelist_filter_clear(filelist);
+ }
+}
+
+/**
* Checks two libraries for equality.
* \return True if the libraries match.
*/
@@ -1809,6 +1856,11 @@ void filelist_free(struct FileList *filelist)
filelist->flags &= ~(FL_NEED_SORTING | FL_NEED_FILTERING);
}
+AssetLibrary *filelist_asset_library(FileList *filelist)
+{
+ return filelist->asset_library;
+}
+
void filelist_freelib(struct FileList *filelist)
{
if (filelist->libfiledata) {