Cleanup: Remove remaining asset editor headers to C++

This commit is contained in:
Hans Goudey
2024-01-26 15:23:10 -05:00
parent 90c5e0f0c6
commit 0e6aad4742
31 changed files with 126 additions and 244 deletions

View File

@@ -56,7 +56,7 @@
/* TODO(@JulianEisel): For asset shelf region reading/writing. Region read/write should be done via
* a #ARegionType callback. */
#include "../editors/asset/ED_asset_shelf.h"
#include "../editors/asset/ED_asset_shelf.hh"
#ifdef WITH_PYTHON
# include "BPY_extern.h"

View File

@@ -40,19 +40,17 @@ set(SRC
intern/asset_temp_id_consumer.cc
intern/asset_type.cc
ED_asset_catalog.h
ED_asset_catalog.hh
ED_asset_filter.hh
ED_asset_handle.h
ED_asset_handle.hh
ED_asset_import.hh
ED_asset_indexer.h
ED_asset_library.h
ED_asset_list.h
ED_asset_indexer.hh
ED_asset_library.hh
ED_asset_list.hh
ED_asset_mark_clear.h
ED_asset_shelf.h
ED_asset_temp_id_consumer.h
ED_asset_type.h
ED_asset_mark_clear.hh
ED_asset_shelf.hh
ED_asset_temp_id_consumer.hh
ED_asset_type.hh
intern/asset_library_reference.hh
intern/asset_shelf.hh
)

View File

@@ -1,33 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup edasset
*
* Supplement for `ED_asset_catalog.hh`. Part of the same API but usable in C.
*/
#pragma once
#include "BLI_utildefines.h"
#ifdef __cplusplus
extern "C" {
#endif
struct AssetLibrary;
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);
#ifdef __cplusplus
}
#endif

View File

@@ -12,7 +12,7 @@
* true. Generally UI code should disable such functionality in this case, so these functions are
* not called at all.
*
* Note that `ED_asset_catalog.h` is part of this API.
* Note that `ED_asset_catalog.hh` is part of this API.
*/
#pragma once
@@ -26,18 +26,30 @@
struct AssetLibrary;
struct bScreen;
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);
/**
* 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);
[[nodiscard]] bool ED_asset_catalogs_read_only(const ::AssetLibrary &library);
blender::asset_system::AssetCatalog *ED_asset_catalog_add(
AssetLibrary *library, blender::StringRefNull name, blender::StringRef parent_path = nullptr);
void ED_asset_catalog_remove(AssetLibrary *library,
::AssetLibrary *library,
blender::StringRefNull name,
blender::StringRef parent_path = nullptr);
void ED_asset_catalog_remove(::AssetLibrary *library,
const blender::asset_system::CatalogID &catalog_id);
void ED_asset_catalog_rename(AssetLibrary *library,
void ED_asset_catalog_rename(::AssetLibrary *library,
blender::asset_system::CatalogID catalog_id,
blender::StringRefNull new_name);
/**
@@ -52,6 +64,6 @@ void ED_asset_catalog_rename(AssetLibrary *library,
* Nothing is done (debug builds run into an assert) if the given catalog IDs can't be identified.
*/
void ED_asset_catalog_move(
AssetLibrary *library,
::AssetLibrary *library,
blender::asset_system::CatalogID src_catalog_id,
std::optional<blender::asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);

View File

@@ -19,25 +19,13 @@
#include "RNA_types.hh"
#ifdef __cplusplus
namespace blender::asset_system {
class AssetRepresentation;
}
using AssetRepresentationHandle = blender::asset_system::AssetRepresentation;
#else
typedef struct AssetRepresentationHandle AssetRepresentationHandle;
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct AssetHandle;
AssetRepresentationHandle *ED_asset_handle_get_representation(const struct AssetHandle *asset);
blender::asset_system::AssetRepresentation *ED_asset_handle_get_representation(
const struct AssetHandle *asset);
int ED_asset_handle_get_preview_icon_id(const struct AssetHandle *asset);
int ED_asset_handle_get_preview_or_type_icon_id(const struct AssetHandle *asset);
#ifdef __cplusplus
}
#endif

View File

@@ -10,10 +10,6 @@
#include "ED_file_indexer.hh"
#ifdef __cplusplus
extern "C" {
#endif
/**
* File Indexer Service for indexing asset files.
*
@@ -32,7 +28,3 @@ extern "C" {
* additional performance.
*/
extern const FileIndexerType file_indexer_asset;
#ifdef __cplusplus
}
#endif

View File

@@ -10,10 +10,6 @@
#include "DNA_asset_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Return an index that can be used to uniquely identify \a library, assuming
* that all relevant indices were created with this function.
@@ -38,7 +34,3 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
*/
const struct EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
bool include_generated);
#ifdef __cplusplus
}
#endif

View File

@@ -1,95 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup edasset
*/
#pragma once
#include "DNA_asset_types.h"
#ifdef __cplusplus
namespace blender::asset_system {
class AssetRepresentation;
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct AssetLibraryReference;
struct ID;
struct bContext;
struct wmNotifier;
struct wmRegionListenerParams;
/**
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
* and may return earlier.
*
* \warning: Asset list reading involves an #AS_asset_library_load() call which may reload asset
* library data like catalogs (invalidating pointers). Refer to its warning for details.
*/
void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference,
const struct bContext *C);
bool ED_assetlist_is_loaded(const struct AssetLibraryReference *library_reference);
void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference,
const 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);
/**
* Tag all asset lists in the storage that show main data as needing an update (re-fetch).
*
* This only tags the data. If the asset list is visible on screen, the space is still responsible
* for ensuring the necessary redraw. It can use #ED_assetlist_listen() to check if the asset-list
* needs a redraw for a given notifier.
*/
void ED_assetlist_storage_tag_main_data_dirty(void);
/**
* Remapping of ID pointers within the asset lists. Typically called when an ID is deleted to clear
* all references to it (\a id_new is null then).
*/
void ED_assetlist_storage_id_remap(struct ID *id_old, struct ID *id_new);
/**
* Can't wait for static deallocation to run. There's nested data allocated with our guarded
* allocator, it will complain about unfreed memory on exit.
*/
void ED_assetlist_storage_exit(void);
AssetHandle ED_assetlist_asset_handle_get_by_index(const AssetLibraryReference *library_reference,
int asset_index);
#ifdef __cplusplus
blender::asset_system::AssetRepresentation *ED_assetlist_asset_get_by_index(
const AssetLibraryReference &library_reference, int asset_index);
#endif
bool ED_assetlist_asset_image_is_loading(const AssetLibraryReference *library_reference,
const AssetHandle *asset_handle);
struct ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle);
/**
* \return True if the region needs a UI redraw.
*/
bool ED_assetlist_listen(const struct wmNotifier *notifier);
/**
* \return The number of assets stored in the asset list for \a library_reference, or -1 if there
* is no list fetched for it.
*/
int ED_assetlist_size(const struct AssetLibraryReference *library_reference);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
namespace blender::ed::asset {
void asset_reading_region_listen_fn(const wmRegionListenerParams *params);
} // namespace blender::ed::asset
#endif

View File

@@ -14,12 +14,23 @@
struct AssetHandle;
struct AssetLibraryReference;
struct AssetLibraryReference;
struct ID;
struct bContext;
struct wmNotifier;
struct wmRegionListenerParams;
namespace blender::asset_system {
class AssetLibrary;
class AssetRepresentation;
} // namespace blender::asset_system
namespace blender::ed::asset {
void asset_reading_region_listen_fn(const wmRegionListenerParams *params);
} // namespace blender::ed::asset
/**
* Get the asset library being read into an asset-list and identified using \a library_reference.
*
@@ -42,3 +53,55 @@ using AssetListIterFn = blender::FunctionRef<bool(blender::asset_system::AssetRe
void ED_assetlist_iterate(const AssetLibraryReference &library_reference,
AssetListHandleIterFn fn);
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn);
/**
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
* and may return earlier.
*
* \warning: Asset list reading involves an #AS_asset_library_load() call which may reload asset
* library data like catalogs (invalidating pointers). Refer to its warning for details.
*/
void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference,
const struct bContext *C);
bool ED_assetlist_is_loaded(const struct AssetLibraryReference *library_reference);
void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference,
const 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);
/**
* Tag all asset lists in the storage that show main data as needing an update (re-fetch).
*
* This only tags the data. If the asset list is visible on screen, the space is still responsible
* for ensuring the necessary redraw. It can use #ED_assetlist_listen() to check if the asset-list
* needs a redraw for a given notifier.
*/
void ED_assetlist_storage_tag_main_data_dirty(void);
/**
* Remapping of ID pointers within the asset lists. Typically called when an ID is deleted to clear
* all references to it (\a id_new is null then).
*/
void ED_assetlist_storage_id_remap(struct ID *id_old, struct ID *id_new);
/**
* Can't wait for static deallocation to run. There's nested data allocated with our guarded
* allocator, it will complain about unfreed memory on exit.
*/
void ED_assetlist_storage_exit(void);
AssetHandle ED_assetlist_asset_handle_get_by_index(const AssetLibraryReference *library_reference,
int asset_index);
blender::asset_system::AssetRepresentation *ED_assetlist_asset_get_by_index(
const AssetLibraryReference &library_reference, int asset_index);
bool ED_assetlist_asset_image_is_loading(const AssetLibraryReference *library_reference,
const AssetHandle *asset_handle);
struct ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle);
/**
* \return True if the region needs a UI redraw.
*/
bool ED_assetlist_listen(const struct wmNotifier *notifier);
/**
* \return The number of assets stored in the asset list for \a library_reference, or -1 if there
* is no list fetched for it.
*/
int ED_assetlist_size(const struct AssetLibraryReference *library_reference);

View File

@@ -8,10 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct AssetMetaData;
struct ID;
struct Main;
@@ -58,7 +54,3 @@ bool ED_asset_copy_to_id(const struct AssetMetaData *asset_data, struct ID *dest
void ED_assets_pre_save(struct Main *bmain);
bool ED_asset_can_mark_single_from_context(const struct bContext *C);
#ifdef __cplusplus
}
#endif

View File

@@ -8,10 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct ARegion;
struct ARegionType;
struct AssetShelfSettings;
@@ -70,7 +66,3 @@ int ED_asset_shelf_tile_height(const struct AssetShelfSettings &settings);
int ED_asset_shelf_context(const struct bContext *C,
const char *member,
struct bContextDataResult *result);
#ifdef __cplusplus
}
#endif

View File

@@ -15,31 +15,20 @@
#include "DNA_ID_enums.h"
#ifdef __cplusplus
namespace blender::asset_system {
class AssetRepresentation;
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct AssetTempIDConsumer AssetTempIDConsumer;
struct Main;
struct ReportList;
#ifdef __cplusplus
extern "C++" AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
const blender::asset_system::AssetRepresentation *asset);
#endif
void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer);
struct ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
ID_Type id_type,
struct Main *bmain,
struct ReportList *reports);
#ifdef __cplusplus
}
#endif

View File

@@ -10,10 +10,6 @@
#include "DNA_ID.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ID;
bool ED_asset_type_id_is_non_experimental(const struct ID *id);
@@ -42,7 +38,3 @@ int64_t ED_asset_types_supported_as_filter_flags(void);
*/
#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING \
"Material, Collection, Object, Pose Action, Node Group or World"
#ifdef __cplusplus
}
#endif

View File

@@ -18,7 +18,7 @@
#include "RNA_access.hh"
#include "RNA_prototypes.h"
#include "ED_asset_catalog.h"
#include "ED_asset_catalog.hh"
#include "ED_asset_catalog.hh"
#include "WM_api.hh"

View File

@@ -19,9 +19,9 @@
#include "AS_asset_library.hh"
#include "ED_asset_filter.hh"
#include "ED_asset_handle.h"
#include "ED_asset_library.h"
#include "ED_asset_list.h"
#include "ED_asset_handle.hh"
#include "ED_asset_library.hh"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
using namespace blender;

View File

@@ -22,7 +22,7 @@
#include "RNA_prototypes.h"
#include "ED_asset_handle.h"
#include "ED_asset_handle.hh"
blender::asset_system::AssetRepresentation *ED_asset_handle_get_representation(
const AssetHandle *asset)

View File

@@ -11,7 +11,7 @@
#include <iomanip>
#include <optional>
#include "ED_asset_indexer.h"
#include "ED_asset_indexer.hh"
#include "DNA_asset_types.h"
#include "DNA_userdef_types.h"

View File

@@ -23,7 +23,7 @@
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "ED_asset_library.h"
#include "ED_asset_library.hh"
int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library)
{

View File

@@ -34,8 +34,8 @@
#include "../space_file/file_indexer.hh"
#include "../space_file/filelist.hh"
#include "ED_asset_indexer.h"
#include "ED_asset_list.h"
#include "ED_asset_indexer.hh"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "ED_screen.hh"
#include "asset_library_reference.hh"

View File

@@ -23,9 +23,9 @@
#include "RNA_access.hh"
#include "RNA_prototypes.h"
#include "ED_asset_list.h"
#include "ED_asset_mark_clear.h"
#include "ED_asset_type.h"
#include "ED_asset_list.hh"
#include "ED_asset_mark_clear.hh"
#include "ED_asset_type.hh"
#include "WM_api.hh"
#include "WM_types.hh"

View File

@@ -25,7 +25,7 @@
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "ED_asset_list.h"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "ED_asset_menu_utils.hh"

View File

@@ -23,7 +23,7 @@
#include "DNA_screen_types.h"
#include "ED_asset_list.h"
#include "ED_asset_list.hh"
#include "ED_screen.hh"
#include "RNA_prototypes.h"
@@ -35,7 +35,7 @@
#include "WM_api.hh"
#include "ED_asset_shelf.h"
#include "ED_asset_shelf.hh"
#include "asset_shelf.hh"
using namespace blender;

View File

@@ -20,10 +20,10 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "ED_asset_handle.h"
#include "ED_asset_list.h"
#include "ED_asset_handle.hh"
#include "ED_asset_list.hh"
#include "ED_asset_shelf.h"
#include "ED_asset_list.hh"
#include "ED_asset_shelf.hh"
#include "UI_grid_view.hh"
#include "UI_interface.hh"

View File

@@ -22,7 +22,7 @@
#include "BLT_translation.h"
#include "ED_asset_filter.hh"
#include "ED_asset_list.h"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "RNA_access.hh"

View File

@@ -22,7 +22,7 @@
#include "MEM_guardedalloc.h"
#include "ED_asset_temp_id_consumer.h"
#include "ED_asset_temp_id_consumer.hh"
using namespace blender;

View File

@@ -12,7 +12,7 @@
#include "BKE_lib_id.hh"
#include "ED_asset_type.h"
#include "ED_asset_type.hh"
bool ED_asset_type_id_is_non_experimental(const ID *id)
{

View File

@@ -16,13 +16,13 @@
void ED_operatortypes_asset();
#include "../asset/ED_asset_catalog.h"
#include "../asset/ED_asset_handle.h"
#include "../asset/ED_asset_library.h"
#include "../asset/ED_asset_list.h"
#include "../asset/ED_asset_mark_clear.h"
#include "../asset/ED_asset_temp_id_consumer.h"
#include "../asset/ED_asset_type.h"
#include "../asset/ED_asset_catalog.hh"
#include "../asset/ED_asset_handle.hh"
#include "../asset/ED_asset_library.hh"
#include "../asset/ED_asset_list.hh"
#include "../asset/ED_asset_mark_clear.hh"
#include "../asset/ED_asset_temp_id_consumer.hh"
#include "../asset/ED_asset_type.hh"
#include "../asset/ED_asset_catalog.hh"
#include "../asset/ED_asset_filter.hh"

View File

@@ -34,7 +34,7 @@
#include "WM_types.hh"
#include "ED_asset.hh"
#include "ED_asset_shelf.h"
#include "ED_asset_shelf.hh"
#include "ED_buttons.hh"
#include "ED_screen.hh"
#include "ED_screen_types.hh"

View File

@@ -33,7 +33,7 @@
#include "WM_types.hh"
#include "ED_asset.hh"
#include "ED_asset_indexer.h"
#include "ED_asset_indexer.hh"
#include "ED_fileselect.hh"
#include "ED_screen.hh"
#include "ED_space_api.hh"

View File

@@ -54,7 +54,7 @@
#include "BKE_viewer_path.hh"
#include "BKE_workspace.h"
#include "ED_asset_shelf.h"
#include "ED_asset_shelf.hh"
#include "ED_geometry.hh"
#include "ED_object.hh"
#include "ED_outliner.hh"

View File

@@ -66,8 +66,8 @@ const EnumPropertyItem rna_enum_uilist_layout_type_items[] = {
# include "BKE_report.h"
# include "BKE_screen.hh"
# include "ED_asset_library.h"
# include "ED_asset_shelf.h"
# include "ED_asset_library.hh"
# include "ED_asset_shelf.hh"
# include "WM_api.hh"