[Bf-blender-cvs] [64bb49fa4e3] master: Cleanup: Move reorganize asset files
Julian Eisel
noreply at git.blender.org
Wed Jul 21 20:41:33 CEST 2021
Commit: 64bb49fa4e3c8bd7e02fd6e5252e40f089d787de
Author: Julian Eisel
Date: Wed Jul 21 20:17:34 2021 +0200
Branches: master
https://developer.blender.org/rB64bb49fa4e3c8bd7e02fd6e5252e40f089d787de
Cleanup: Move reorganize asset files
I'm trying to move away from general files with lots of things in them,
and instead have many small & focused files. I find that easier to
work with since everything has clear responsibilities, even if there is
some minor overhead in managing all these files.
I also try to differentiate more clearly between public and internal
files. So source files and internal headers are in a `intern/`
sub-directory, public functions are in a number of headers one level
higher.
For convenience and to make this compatible with our existing general
headers in `editors/include`, I made the `ED_asset.h` there include all
these public headers.
This is of course a bit of an experiment, let's see how it works in
practice.
Also corrected the name of `ED_asset_can_make_single_from_context()`.
===================================================================
M source/blender/editors/asset/CMakeLists.txt
A source/blender/editors/asset/ED_asset_handle.h
A source/blender/editors/asset/ED_asset_library.h
A source/blender/editors/asset/ED_asset_list.h
A source/blender/editors/asset/ED_asset_list.hh
A source/blender/editors/asset/ED_asset_mark_clear.h
A source/blender/editors/asset/ED_asset_temp_id_consumer.h
M source/blender/editors/asset/intern/asset_handle.cc
M source/blender/editors/asset/intern/asset_library_reference_enum.cc
R099 source/blender/editors/asset/asset_list.cc source/blender/editors/asset/intern/asset_list.cc
R092 source/blender/editors/asset/asset_edit.cc source/blender/editors/asset/intern/asset_mark_clear.cc
R100 source/blender/editors/asset/asset_ops.cc source/blender/editors/asset/intern/asset_ops.cc
R097 source/blender/editors/asset/asset_temp_id_consumer.cc source/blender/editors/asset/intern/asset_temp_id_consumer.cc
M source/blender/editors/include/ED_asset.h
M source/blender/editors/interface/interface_context_menu.c
===================================================================
diff --git a/source/blender/editors/asset/CMakeLists.txt b/source/blender/editors/asset/CMakeLists.txt
index 64024eea986..d56edd43d7d 100644
--- a/source/blender/editors/asset/CMakeLists.txt
+++ b/source/blender/editors/asset/CMakeLists.txt
@@ -16,6 +16,7 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
+ .
../include
../../blenkernel
../../blenlib
@@ -30,14 +31,20 @@ set(INC_SYS
)
set(SRC
- asset_edit.cc
- asset_list.cc
- asset_ops.cc
- asset_temp_id_consumer.cc
intern/asset_handle.cc
intern/asset_library_reference.cc
intern/asset_library_reference_enum.cc
+ intern/asset_list.cc
+ intern/asset_mark_clear.cc
+ intern/asset_ops.cc
+ intern/asset_temp_id_consumer.cc
+ ED_asset_handle.h
+ ED_asset_library.h
+ ED_asset_list.h
+ ED_asset_list.hh
+ ED_asset_mark_clear.h
+ ED_asset_temp_id_consumer.h
intern/asset_library_reference.hh
)
diff --git a/source/blender/editors/asset/ED_asset_handle.h b/source/blender/editors/asset/ED_asset_handle.h
new file mode 100644
index 00000000000..c51ce422c25
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_handle.h
@@ -0,0 +1,45 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edasset
+ */
+
+#pragma once
+
+#include "DNA_ID_enums.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AssetHandle;
+struct AssetLibraryReference;
+struct bContext;
+
+const char *ED_asset_handle_get_name(const struct AssetHandle *asset);
+struct AssetMetaData *ED_asset_handle_get_metadata(const struct AssetHandle *asset);
+struct ID *ED_asset_handle_get_local_id(const struct AssetHandle *asset);
+ID_Type ED_asset_handle_get_id_type(const struct AssetHandle *asset);
+int ED_asset_handle_get_preview_icon_id(const struct AssetHandle *asset);
+void ED_asset_handle_get_full_library_path(const struct bContext *C,
+ const struct AssetLibraryReference *asset_library,
+ const struct AssetHandle *asset,
+ char r_full_lib_path[]);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/asset/ED_asset_library.h b/source/blender/editors/asset/ED_asset_library.h
new file mode 100644
index 00000000000..905d097d223
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_library.h
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edasset
+ */
+
+#pragma once
+
+#include "DNA_asset_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library);
+AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
+const struct EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/asset/ED_asset_list.h b/source/blender/editors/asset/ED_asset_list.h
new file mode 100644
index 00000000000..1e7f0f0de55
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_list.h
@@ -0,0 +1,54 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edasset
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AssetFilterSettings;
+struct AssetHandle;
+struct AssetLibraryReference;
+struct bContext;
+struct ID;
+struct wmNotifier;
+
+void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference,
+ const struct AssetFilterSettings *filter_settings,
+ const struct bContext *C);
+void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference,
+ struct bContext *C);
+void ED_assetlist_clear(const struct AssetLibraryReference *library_reference, struct bContext *C);
+bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *library_reference);
+void ED_assetlist_storage_tag_main_data_dirty(void);
+void ED_assetlist_storage_id_remap(struct ID *id_old, struct ID *id_new);
+void ED_assetlist_storage_exit(void);
+
+struct ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle);
+const char *ED_assetlist_library_path(const struct AssetLibraryReference *library_reference);
+
+bool ED_assetlist_listen(const struct AssetLibraryReference *library_reference,
+ const struct wmNotifier *notifier);
+int ED_assetlist_size(const struct AssetLibraryReference *library_reference);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/asset/ED_asset_list.hh b/source/blender/editors/asset/ED_asset_list.hh
new file mode 100644
index 00000000000..7f41fba3457
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_list.hh
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edasset
+ */
+
+#pragma once
+
+#include <string>
+
+#include "BLI_function_ref.hh"
+
+struct AssetLibraryReference;
+struct AssetHandle;
+struct bContext;
+struct FileDirEntry;
+
+std::string ED_assetlist_asset_filepath_get(const bContext *C,
+ const AssetLibraryReference &library_reference,
+ const AssetHandle &asset_handle);
+
+/* Can return false to stop iterating. */
+using AssetListIterFn = blender::FunctionRef<bool(FileDirEntry &)>;
+void ED_assetlist_iterate(const AssetLibraryReference *library_reference, AssetListIterFn fn);
diff --git a/source/blender/editors/asset/ED_asset_mark_clear.h b/source/blender/editors/asset/ED_asset_mark_clear.h
new file mode 100644
index 00000000000..cdd1f0d080b
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_mark_clear.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edasset
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bContext;
+struct ID;
+
+bool ED_asset_mark_id(const struct bContext *C, struct ID *id);
+bool ED_asset_clear_id(struct ID *id);
+
+bool ED_asset_can_mark_single_from_context(const struct bContext *C);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/asset/ED_asset_temp_id_consumer.h b/source/blender/editors/asset/ED_asset_temp_id_consumer.h
new file mode 100644
index 00000000000..8aa53f9ea3b
--- /dev/null
+++ b/source/blender/editors/asset/ED_asset_temp_id_consumer.h
@@ -0,0 +1,48 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list