[Bf-blender-cvs] [d8632210bd9] asset-browser: Merge branch 'asset-browser-snap-dragging' into asset-browser
Julian Eisel
noreply at git.blender.org
Sun May 23 19:10:22 CEST 2021
Commit: d8632210bd99dcdb9ed26671c11c436c7ae09d28
Author: Julian Eisel
Date: Fri May 21 02:55:11 2021 +0200
Branches: asset-browser
https://developer.blender.org/rBd8632210bd99dcdb9ed26671c11c436c7ae09d28
Merge branch 'asset-browser-snap-dragging' into asset-browser
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_asset.h
index 50eb2859279,38c053607f5..fdc7ed8c145
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@@ -26,7 -27,7 +27,8 @@@
extern "C" {
#endif
+struct AssetLibraryReference;
+ struct AssetMetaData;
struct BlendDataReader;
struct BlendWriter;
struct ID;
@@@ -46,8 -58,10 +59,12 @@@ struct AssetTagEnsureResult BKE_asset_m
const char *name);
void BKE_asset_metadata_tag_remove(struct AssetMetaData *asset_data, struct AssetTag *tag);
+void BKE_asset_library_reference_init_default(struct AssetLibraryReference *library_ref);
+
+ void BKE_asset_metadata_idprop_ensure(struct AssetMetaData *asset_data, struct IDProperty *prop);
+ struct IDProperty *BKE_asset_metadata_idprop_find(const struct AssetMetaData *asset_data,
+ const char *name) ATTR_WARN_UNUSED_RESULT;
+
struct PreviewImage *BKE_asset_metadata_preview_get_from_id(const struct AssetMetaData *asset_data,
const struct ID *owner_id);
diff --cc source/blender/blenkernel/intern/asset.cc
index f74018b20c5,412fdcf6944..db7b57504ab
--- a/source/blender/blenkernel/intern/asset.cc
+++ b/source/blender/blenkernel/intern/asset.cc
@@@ -110,11 -110,25 +110,31 @@@ void BKE_asset_metadata_tag_remove(Asse
BLI_assert(BLI_listbase_count(&asset_data->tags) == asset_data->tot_tags);
}
+ void BKE_asset_metadata_idprop_ensure(AssetMetaData *asset_data, IDProperty *prop)
+ {
+ if (!asset_data->properties) {
+ IDPropertyTemplate val = {0};
+ asset_data->properties = IDP_New(IDP_GROUP, &val, "AssetMetaData.properties");
+ }
+ /* Important: The property may already exist. For now just allow always allow a newly allocated
+ * property, and replace the existing one as a way of updating. */
+ IDP_ReplaceInGroup(asset_data->properties, prop);
+ }
+
+ IDProperty *BKE_asset_metadata_idprop_find(const AssetMetaData *asset_data, const char *name)
+ {
+ if (!asset_data->properties) {
+ return nullptr;
+ }
+ return IDP_GetPropertyFromGroup(asset_data->properties, name);
+ }
+
+void BKE_asset_library_reference_init_default(AssetLibraryReference *library_ref)
+{
+ memcpy(library_ref, DNA_struct_default_get(AssetLibraryReference), sizeof(*library_ref));
+}
+
++
/* Queries -------------------------------------------- */
PreviewImage *BKE_asset_metadata_preview_get_from_id(const AssetMetaData *UNUSED(asset_data),
diff --cc source/blender/editors/asset/asset_edit.cc
index 57832aa1e20,f695694c77c..e7a45a8be70
--- a/source/blender/editors/asset/asset_edit.cc
+++ b/source/blender/editors/asset/asset_edit.cc
@@@ -18,25 -18,14 +18,27 @@@
* \ingroup edasset
*/
+#include <memory>
+#include <string>
+
#include "BKE_asset.h"
#include "BKE_context.h"
+ #include "BKE_idtype.h"
#include "BKE_lib_id.h"
+#include "BKE_report.h"
+ #include "BKE_main.h"
+#include "BLI_utility_mixins.hh"
+
+#include "BLO_readfile.h"
+
#include "DNA_ID.h"
#include "DNA_asset_types.h"
+#include "DNA_space_types.h"
+
+#include "ED_fileselect.h"
+
+#include "MEM_guardedalloc.h"
#include "UI_interface_icons.h"
diff --cc source/blender/editors/include/ED_asset.h
index c642bc1c372,daa20355af8..3c77d6dbf8d
--- a/source/blender/editors/include/ED_asset.h
+++ b/source/blender/editors/include/ED_asset.h
@@@ -39,45 -29,10 +39,47 @@@ typedef struct AssetTempIDConsumer Asse
bool ED_asset_mark_id(const struct bContext *C, struct ID *id);
bool ED_asset_clear_id(struct ID *id);
+ void ED_assets_pre_save(struct Main *bmain);
+
bool ED_asset_can_make_single_from_context(const struct bContext *C);
+int ED_asset_library_reference_to_enum_value(const struct AssetLibraryReference *library);
+struct AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
+
+const char *ED_asset_handle_get_name(const AssetHandle *asset);
+void ED_asset_handle_get_full_library_path(const struct bContext *C,
+ const AssetLibraryReference *asset_library,
+ const AssetHandle *asset,
+ char r_full_lib_path[]);
+
+AssetTempIDConsumer *ED_asset_temp_id_consumer_create(const AssetHandle *handle);
+void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer);
+struct ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
+ const struct bContext *C,
+ const AssetLibraryReference *asset_library,
+ ID_Type id_type,
+ struct Main *bmain,
+ struct ReportList *reports);
+
+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);
+
+ID *ED_assetlist_asset_local_id_get(const AssetHandle *asset_handle);
+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);
+
void ED_operatortypes_asset(void);
#ifdef __cplusplus
diff --cc source/blender/editors/include/UI_interface.h
index ad2a428f936,b6602756029..e1333e711b2
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@@ -35,7 -34,7 +35,8 @@@ extern "C"
/* Struct Declarations */
struct ARegion;
+struct AssetFilterSettings;
+ struct AssetMetaData;
struct AutoComplete;
struct EnumPropertyItem;
struct FileSelectParams;
diff --cc source/blender/editors/interface/interface_template_asset_view.cc
index 653fc42f370,00000000000..e2bb142a881
mode 100644,000000..100644
--- a/source/blender/editors/interface/interface_template_asset_view.cc
+++ b/source/blender/editors/interface/interface_template_asset_view.cc
@@@ -1,277 -1,0 +1,278 @@@
+/*
+ * 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 edinterface
+ */
+
+#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_screen.h"
+
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_string_ref.hh"
+
+#include "BLO_readfile.h"
+
+#include "ED_asset.h"
+#include "ED_screen.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "interface_intern.h"
+
+struct AssetViewListData {
+ AssetLibraryReference asset_library;
+ bScreen *screen;
+};
+
+static void asset_view_item_but_drag_set(uiBut *but,
+ AssetViewListData *list_data,
+ AssetHandle *asset_handle)
+{
+ if (ID *id = asset_handle->file_data->id) {
+ UI_but_drag_set_id(but, id);
+ }
+ else {
+ const blender::StringRef asset_list_path = ED_assetlist_library_path(
+ &list_data->asset_library);
+ char blend_path[FILE_MAX_LIBEXTRA];
+
+ char path[FILE_MAX_LIBEXTRA];
+ BLI_join_dirfile(path, sizeof(path), asset_list_path.data(), asset_handle->file_data->relpath);
+ if (BLO_library_path_explode(path, blend_path, nullptr, nullptr)) {
+ ImBuf *imbuf = ED_assetlist_asset_image_get(asset_handle);
+ UI_but_drag_set_asset(but,
+ asset_handle->file_data->name,
+ BLI_strdup(blend_path),
+ asset_handle->file_data->blentype,
++ asset_handle->file_data->asset_data,
+ asset_handle->file_data->preview_icon_id,
+ imbuf,
+ 1.0f);
+ }
+ }
+}
+
+static void asset_view_draw_item(uiList *ui_list,
+ bContext *UNUSED(C),
+ uiLayout *layout,
+ PointerRNA *UNUSED(dataptr),
+ PointerRNA *itemptr,
+ int UNUSED(icon),
+ PointerRNA *UNUSED(active_dataptr),
+ const char *UNUSED(active_propname),
+ int UNUSED(index),
+ int UNUSED(flt_flag))
+{
+ AssetViewListData *list_data = (AssetViewListData *)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list