[Bf-blender-cvs] [e8575bfd4a3] temp-asset-library-all: General cleanup (comments, remove outdated TODO marks, naming)
Julian Eisel
noreply at git.blender.org
Wed Dec 7 18:20:40 CET 2022
Commit: e8575bfd4a3a27e9ad636f682ff198907472bec5
Author: Julian Eisel
Date: Wed Dec 7 18:19:15 2022 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rBe8575bfd4a3a27e9ad636f682ff198907472bec5
General cleanup (comments, remove outdated TODO marks, naming)
===================================================================
M source/blender/asset_system/AS_asset_library.hh
M source/blender/asset_system/intern/asset_library.cc
M source/blender/asset_system/intern/asset_storage.hh
M source/blender/editors/asset/ED_asset_catalog.h
M source/blender/editors/asset/ED_asset_catalog.hh
M source/blender/editors/asset/ED_asset_library.h
M source/blender/editors/asset/intern/asset_library_reference_enum.cc
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/filelist.cc
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/source/blender/asset_system/AS_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh
index 6526e3e8382..14d356c703e 100644
--- a/source/blender/asset_system/AS_asset_library.hh
+++ b/source/blender/asset_system/AS_asset_library.hh
@@ -109,7 +109,6 @@ class AssetLibrary {
/** Remove an asset from the library that was added using #add_external_asset() or
* #add_local_id_asset(). Can usually be expected to be constant time complexity (worst case may
* differ).
- *
* \note This is save to call if \a asset is freed (dangling reference), will not perform any
* change then.
* \return True on success, false if the asset couldn't be found inside the library (also the
diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc
index 02c5c0dc4f3..f5377734b12 100644
--- a/source/blender/asset_system/intern/asset_library.cc
+++ b/source/blender/asset_system/intern/asset_library.cc
@@ -257,7 +257,6 @@ StringRefNull AssetLibrary::root_path() const
return *root_path_;
}
-/* TODO get rid of this. */
Vector<AssetLibraryReference> all_valid_asset_library_refs()
{
Vector<AssetLibraryReference> result;
diff --git a/source/blender/asset_system/intern/asset_storage.hh b/source/blender/asset_system/intern/asset_storage.hh
index b4866fa9382..2b4614abca5 100644
--- a/source/blender/asset_system/intern/asset_storage.hh
+++ b/source/blender/asset_system/intern/asset_storage.hh
@@ -31,8 +31,6 @@ class AssetStorage {
* faster lookups. Not possible until each asset is only represented once in the storage. */
StorageT local_id_assets_;
- friend class AssetLibrary;
-
public:
/** See #AssetLibrary::add_external_asset(). */
AssetRepresentation &add_external_asset(AssetIdentifier &&identifier,
diff --git a/source/blender/editors/asset/ED_asset_catalog.h b/source/blender/editors/asset/ED_asset_catalog.h
index 04df381bec9..9f6850b7266 100644
--- a/source/blender/editors/asset/ED_asset_catalog.h
+++ b/source/blender/editors/asset/ED_asset_catalog.h
@@ -19,6 +19,8 @@ struct Main;
void ED_asset_catalogs_save_from_main_path(struct AssetLibrary *library, const struct Main *bmain);
+/** Saving catalog edits when the file is saved is a global option shared for each asset library,
+ * and as such ignores the per asset library #ED_asset_catalogs_read_only(). */
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(bool should_save);
bool ED_asset_catalogs_get_save_catalogs_when_file_is_saved(void);
diff --git a/source/blender/editors/asset/ED_asset_catalog.hh b/source/blender/editors/asset/ED_asset_catalog.hh
index d236bdec37f..a423ad6f8ad 100644
--- a/source/blender/editors/asset/ED_asset_catalog.hh
+++ b/source/blender/editors/asset/ED_asset_catalog.hh
@@ -22,6 +22,10 @@
struct AssetLibrary;
+/**
+ * Returns if the catalogs of \a library are allowed to be editable, or if the UI should forbid
+ * edits.
+ */
[[nodiscard]] bool ED_asset_catalogs_read_only(const AssetLibrary &library);
blender::asset_system::AssetCatalog *ED_asset_catalog_add(
diff --git a/source/blender/editors/asset/ED_asset_library.h b/source/blender/editors/asset/ED_asset_library.h
index cc0d97054b6..c4baadc23c8 100644
--- a/source/blender/editors/asset/ED_asset_library.h
+++ b/source/blender/editors/asset/ED_asset_library.h
@@ -29,10 +29,13 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
* Since this is meant for UI display, skips non-displayable libraries, that is, libraries with an
* empty name or path.
*
- * \param include_local_library: Whether to include the "Current File" library or not.
+ * \param include_generated: Whether to include libraries that are generated and thus cannot be
+ * written to. Setting this to false means only custom libraries will be
+ * included, since they are stored on disk with a single root directory,
+ * thus have a well defined location that can be written to.
*/
const struct EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
- bool include_local_library);
+ bool include_generated);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/asset/intern/asset_library_reference_enum.cc b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
index f88afdd8487..d20f3205a77 100644
--- a/source/blender/editors/asset/intern/asset_library_reference_enum.cc
+++ b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
@@ -70,14 +70,13 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
return library;
}
-const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
- const bool include_local_library)
+const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool include_generated)
{
EnumPropertyItem *item = nullptr;
int totitem = 0;
- if (include_local_library) {
- const EnumPropertyItem predefined_items[] = {
+ if (include_generated) {
+ const EnumPropertyItem generated_items[] = {
{ASSET_LIBRARY_ALL,
"ALL",
ICON_NONE,
@@ -91,8 +90,9 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
{0, nullptr, 0, nullptr, nullptr},
};
- /* Add predefined items. */
- RNA_enum_items_add(&item, &totitem, predefined_items);
+ /* Add predefined libraries that are generated and not simple directories that can be written
+ * to. */
+ RNA_enum_items_add(&item, &totitem, generated_items);
}
/* Add separator if needed. */
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7561cd2f6a2..e85a6cbc0d4 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -555,7 +555,6 @@ static void file_draw_preview(const SpaceFile *sfile,
/* path is no more static, cannot give it directly to but... */
else if (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS &&
(file->typeflag & FILE_TYPE_ASSET) != 0) {
- /* TODO enable drag & drop support, get path from asset representation. */
char blend_path[FILE_MAX_LIBEXTRA];
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index 2bf91efc610..234c550d829 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -1643,7 +1643,6 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
BLI_thread_queue_push(cache->previews_done, preview);
}
else {
- /* XXX */
if (entry->redirection_path) {
BLI_strncpy(preview->filepath, entry->redirection_path, FILE_MAXDIR);
}
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index bbb6d3e7de3..54edf795e6c 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -995,7 +995,6 @@ enum eFileDetails {
/** File selector types. */
typedef enum eFileSelectType {
- FILE_SELECT_TYPE_UNSET = 0,
FILE_LOADLIB = 1,
FILE_MAIN = 2,
/** Load assets from #Main. */
More information about the Bf-blender-cvs
mailing list