Cleanup: Move remaining asset editors code to C++ namespace

This commit is contained in:
Hans Goudey
2024-01-26 18:30:55 -05:00
parent 38647b6dc2
commit fb0d6198c0
51 changed files with 443 additions and 408 deletions

View File

@@ -77,7 +77,7 @@ class AssetLibrary {
bCallbackFuncStore on_save_callback_store_{};
public:
/* Controlled by #ED_asset_catalogs_set_save_catalogs_when_file_is_saved,
/* Controlled by #ed::asset::catalogs_set_save_catalogs_when_file_is_saved,
* for managing the "Save Catalog Changes" in the quit-confirmation dialog box. */
static bool save_catalogs_when_file_is_saved;

View File

@@ -1044,7 +1044,7 @@ static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
}
if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
ED_asset_shelf_region_blend_write(writer, region);
blender::ed::asset::shelf::region_blend_write(writer, region);
return;
}
@@ -1208,7 +1208,7 @@ static void direct_link_region(BlendDataReader *reader, ARegion *region, int spa
}
}
if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
ED_asset_shelf_region_blend_read_data(reader, region);
blender::ed::asset::shelf::region_blend_read_data(reader, region);
}
}

View File

@@ -282,17 +282,19 @@ static Object *get_poselib_object(bContext *C)
static void poselib_tempload_exit(PoseBlendData *pbd)
{
ED_asset_temp_id_consumer_free(&pbd->temp_id_consumer);
using namespace blender::ed;
asset::temp_id_consumer_free(&pbd->temp_id_consumer);
}
static bAction *poselib_blend_init_get_action(bContext *C, wmOperator *op)
{
using namespace blender::ed;
const AssetRepresentationHandle *asset = CTX_wm_asset(C);
PoseBlendData *pbd = static_cast<PoseBlendData *>(op->customdata);
pbd->temp_id_consumer = ED_asset_temp_id_consumer_create(asset);
return (bAction *)ED_asset_temp_id_consumer_ensure_local_id(
pbd->temp_id_consumer = asset::temp_id_consumer_create(asset);
return (bAction *)asset::temp_id_consumer_ensure_local_id(
pbd->temp_id_consumer, ID_AC, CTX_data_main(C), op->reports);
}

View File

@@ -8,7 +8,7 @@
* UI/Editor level API for catalog operations, creating richer functionality than the asset system
* catalog API provides (which this uses internally).
*
* Functions can be expected to not perform any change when #ED_asset_catalogs_read_only() returns
* Functions can be expected to not perform any change when #catalogs_read_only() returns
* true. Generally UI code should disable such functionality in this case, so these functions are
* not called at all.
*
@@ -25,32 +25,32 @@
struct bScreen;
void ED_asset_catalogs_save_from_main_path(blender::asset_system::AssetLibrary *library,
const Main *bmain);
namespace blender::ed::asset {
void catalogs_save_from_main_path(asset_system::AssetLibrary *library, const 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().
* and as such ignores the per asset library #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);
void catalogs_set_save_catalogs_when_file_is_saved(bool should_save);
bool 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 blender::asset_system::AssetLibrary &library);
[[nodiscard]] bool catalogs_read_only(const asset_system::AssetLibrary &library);
blender::asset_system::AssetCatalog *ED_asset_catalog_add(
blender::asset_system::AssetLibrary *library,
blender::StringRefNull name,
blender::StringRef parent_path = nullptr);
void ED_asset_catalog_remove(blender::asset_system::AssetLibrary *library,
const blender::asset_system::CatalogID &catalog_id);
asset_system::AssetCatalog *catalog_add(asset_system::AssetLibrary *library,
StringRefNull name,
StringRef parent_path = nullptr);
void catalog_remove(asset_system::AssetLibrary *library,
const asset_system::CatalogID &catalog_id);
void ED_asset_catalog_rename(blender::asset_system::AssetLibrary *library,
blender::asset_system::CatalogID catalog_id,
blender::StringRefNull new_name);
void catalog_rename(asset_system::AssetLibrary *library,
asset_system::CatalogID catalog_id,
StringRefNull new_name);
/**
* Reinsert catalog identified by \a src_catalog_id as child to catalog identified by \a
* dst_parent_catalog_id. If \a dst_parent_catalog_id is not set, the catalog is moved to the root
@@ -62,7 +62,8 @@ void ED_asset_catalog_rename(blender::asset_system::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(
blender::asset_system::AssetLibrary *library,
blender::asset_system::CatalogID src_catalog_id,
std::optional<blender::asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);
void catalog_move(asset_system::AssetLibrary *library,
asset_system::CatalogID src_catalog_id,
std::optional<asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);
} // namespace blender::ed::asset

View File

@@ -26,6 +26,8 @@ class AssetLibrary;
class AssetRepresentation;
} // namespace blender::asset_system
namespace blender::ed::asset {
/**
* Compare \a asset against the settings of \a filter.
*
@@ -38,10 +40,8 @@ class AssetRepresentation;
* \returns True if the asset should be visible with these filter settings (parameters match).
* Otherwise returns false (mismatch).
*/
bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
const blender::asset_system::AssetRepresentation &asset);
namespace blender::ed::asset {
bool filter_matches_asset(const AssetFilterSettings *filter,
const blender::asset_system::AssetRepresentation &asset);
struct AssetItemTree {
asset_system::AssetCatalogTree catalogs;

View File

@@ -24,7 +24,10 @@ namespace blender::asset_system {
class AssetRepresentation;
}
blender::asset_system::AssetRepresentation *ED_asset_handle_get_representation(
const AssetHandle *asset);
int ED_asset_handle_get_preview_icon_id(const AssetHandle *asset);
int ED_asset_handle_get_preview_or_type_icon_id(const AssetHandle *asset);
namespace blender::ed::asset {
asset_system::AssetRepresentation *handle_get_representation(const AssetHandle *asset);
int handle_get_preview_icon_id(const AssetHandle *asset);
int handle_get_preview_or_type_icon_id(const AssetHandle *asset);
} // namespace blender::ed::asset

View File

@@ -10,6 +10,8 @@
#include "ED_file_indexer.hh"
namespace blender::ed::asset::index {
/**
* File Indexer Service for indexing asset files.
*
@@ -28,3 +30,5 @@
* additional performance.
*/
extern const FileIndexerType file_indexer_asset;
} // namespace blender::ed::asset::index

View File

@@ -10,19 +10,21 @@
#include "DNA_asset_types.h"
namespace blender::ed::asset {
/**
* Return an index that can be used to uniquely identify \a library, assuming
* that all relevant indices were created with this function.
*/
int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library);
int library_reference_to_enum_value(const AssetLibraryReference *library);
/**
* Return an asset library reference matching the index returned by
* #ED_asset_library_reference_to_enum_value().
* #library_reference_to_enum_value().
*/
AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
AssetLibraryReference library_reference_from_enum_value(int value);
/**
* Translate all available asset libraries to an RNA enum, whereby the enum values match the result
* of #ED_asset_library_reference_to_enum_value() for any given library.
* of #library_reference_to_enum_value() for any given library.
*
* Since this is meant for UI display, skips non-displayable libraries, that is, libraries with an
* empty name or path.
@@ -32,4 +34,6 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
* included, since they are stored on disk with a single root directory,
* thus have a well defined location that can be written to.
*/
const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(bool include_generated);
const EnumPropertyItem *library_reference_to_rna_enum_itemf(bool include_generated);
} // namespace blender::ed::asset

View File

@@ -20,18 +20,15 @@ struct ImBuf;
struct bContext;
struct wmNotifier;
struct wmRegionListenerParams;
namespace blender::asset_system {
class AssetLibrary;
class AssetRepresentation;
} // namespace blender::asset_system
namespace blender::ed::asset {
namespace blender::ed::asset::list {
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.
*
@@ -40,20 +37,19 @@ void asset_reading_region_listen_fn(const wmRegionListenerParams *params);
* ND_ASSET_LIST_READING` notifiers until loading is done, they can be used to continuously
* call this function to retrieve the asset library once available.
*/
blender::asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *library_get_once_available(
const AssetLibraryReference &library_reference);
/* Can return false to stop iterating. */
using AssetListHandleIterFn = blender::FunctionRef<bool(AssetHandle)>;
using AssetListIterFn = blender::FunctionRef<bool(blender::asset_system::AssetRepresentation &)>;
using AssetListHandleIterFn = FunctionRef<bool(AssetHandle)>;
using AssetListIterFn = FunctionRef<bool(asset_system::AssetRepresentation &)>;
/**
* \warning Never keep the asset handle passed to \a fn outside of \a fn's scope. While iterating,
* the file data wrapped by the asset handle can be freed, since the file cache has a maximum size.
*/
void ED_assetlist_iterate(const AssetLibraryReference &library_reference,
AssetListHandleIterFn fn);
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn);
void iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn);
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn);
/**
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
@@ -62,46 +58,47 @@ void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetL
* \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 AssetLibraryReference *library_reference, const bContext *C);
bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference);
void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference,
const bContext *C);
void ED_assetlist_clear(const AssetLibraryReference *library_reference, bContext *C);
bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *library_reference);
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C);
bool is_loaded(const AssetLibraryReference *library_reference);
void ensure_previews_job(const AssetLibraryReference *library_reference, const bContext *C);
void clear(const AssetLibraryReference *library_reference, bContext *C);
bool 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
* for ensuring the necessary redraw. It can use #listen() to check if the asset-list
* needs a redraw for a given notifier.
*/
void ED_assetlist_storage_tag_main_data_dirty();
void storage_tag_main_data_dirty();
/**
* 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(ID *id_old, ID *id_new);
void storage_id_remap(ID *id_old, 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 storage_exit();
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(
AssetHandle asset_handle_get_by_index(const AssetLibraryReference *library_reference,
int asset_index);
blender::asset_system::AssetRepresentation *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);
ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle);
bool asset_image_is_loading(const AssetLibraryReference *library_reference,
const AssetHandle *asset_handle);
ImBuf *asset_image_get(const AssetHandle *asset_handle);
/**
* \return True if the region needs a UI redraw.
*/
bool ED_assetlist_listen(const wmNotifier *notifier);
bool listen(const 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 AssetLibraryReference *library_reference);
int size(const AssetLibraryReference *library_reference);
} // namespace blender::ed::asset::list

View File

@@ -13,6 +13,8 @@ struct ID;
struct Main;
struct bContext;
namespace blender::ed::asset {
/**
* Mark the datablock as asset.
*
@@ -20,14 +22,14 @@ struct bContext;
*
* \return whether the datablock was marked as asset; false when it is not capable of becoming an
* asset, or when it already was an asset. */
bool ED_asset_mark_id(ID *id);
bool mark_id(ID *id);
/**
* Generate preview image for the given datablock.
*
* The preview image might be generated using a background thread.
*/
void ED_asset_generate_preview(const bContext *C, ID *id);
void generate_preview(const bContext *C, ID *id);
/**
* Remove the asset metadata, turning the ID into a "normal" ID.
@@ -37,7 +39,7 @@ void ED_asset_generate_preview(const bContext *C, ID *id);
*
* \return whether the asset metadata was actually removed; false when the ID was not an asset.
*/
bool ED_asset_clear_id(ID *id);
bool clear_id(ID *id);
/**
* Copy the asset metadata to the given destination ID.
@@ -49,8 +51,10 @@ bool ED_asset_clear_id(ID *id);
* \return true when the copy succeeded, false otherwise. The only reason for
* failure is when \a destination is of a type that cannot be an asset.
*/
bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination);
bool copy_to_id(const AssetMetaData *asset_data, ID *destination);
void ED_assets_pre_save(Main *bmain);
void pre_save_assets(Main *bmain);
bool ED_asset_can_mark_single_from_context(const bContext *C);
bool can_mark_single_from_context(const bContext *C);
} // namespace blender::ed::asset

View File

@@ -20,46 +20,50 @@ struct Main;
struct wmWindowManager;
struct RegionPollParams;
namespace blender::ed::asset::shelf {
/* -------------------------------------------------------------------- */
/** \name Asset Shelf Regions
*
* Naming conventions:
* - #ED_asset_shelf_regions_xxx(): Applies to both regions (#RGN_TYPE_ASSET_SHELF and
* - #regions_xxx(): Applies to both regions (#RGN_TYPE_ASSET_SHELF and
* #RGN_TYPE_ASSET_SHELF_HEADER).
* - #ED_asset_shelf_region_xxx(): Applies to the main shelf region (#RGN_TYPE_ASSET_SHELF).
* - #ED_asset_shelf_header_region_xxx(): Applies to the shelf header region
* - #region_xxx(): Applies to the main shelf region (#RGN_TYPE_ASSET_SHELF).
* - #header_region_xxx(): Applies to the shelf header region
* (#RGN_TYPE_ASSET_SHELF_HEADER).
*
* \{ */
bool ED_asset_shelf_regions_poll(const RegionPollParams *params);
bool regions_poll(const RegionPollParams *params);
/** Only needed for #RGN_TYPE_ASSET_SHELF (not #RGN_TYPE_ASSET_SHELF_HEADER). */
void *ED_asset_shelf_region_duplicate(void *regiondata);
void ED_asset_shelf_region_free(ARegion *region);
void ED_asset_shelf_region_init(wmWindowManager *wm, ARegion *region);
int ED_asset_shelf_region_snap(const ARegion *region, int size, int axis);
void ED_asset_shelf_region_on_user_resize(const ARegion *region);
void ED_asset_shelf_region_listen(const wmRegionListenerParams *params);
void ED_asset_shelf_region_layout(const bContext *C, ARegion *region);
void ED_asset_shelf_region_draw(const bContext *C, ARegion *region);
void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, ARegion *region);
void ED_asset_shelf_region_blend_write(BlendWriter *writer, ARegion *region);
int ED_asset_shelf_region_prefsizey(void);
void *region_duplicate(void *regiondata);
void region_free(ARegion *region);
void region_init(wmWindowManager *wm, ARegion *region);
int region_snap(const ARegion *region, int size, int axis);
void region_on_user_resize(const ARegion *region);
void region_listen(const wmRegionListenerParams *params);
void region_layout(const bContext *C, ARegion *region);
void region_draw(const bContext *C, ARegion *region);
void region_blend_read_data(BlendDataReader *reader, ARegion *region);
void region_blend_write(BlendWriter *writer, ARegion *region);
int region_prefsizey(void);
void ED_asset_shelf_header_region_init(wmWindowManager *wm, ARegion *region);
void ED_asset_shelf_header_region(const bContext *C, ARegion *region);
void ED_asset_shelf_header_region_listen(const wmRegionListenerParams *params);
int ED_asset_shelf_header_region_size(void);
void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const int space_type);
void header_region_init(wmWindowManager *wm, ARegion *region);
void header_region(const bContext *C, ARegion *region);
void header_region_listen(const wmRegionListenerParams *params);
int header_region_size(void);
void header_regiontype_register(ARegionType *region_type, const int space_type);
/** \} */
/* -------------------------------------------------------------------- */
void ED_asset_shelf_type_unlink(const Main &bmain, const AssetShelfType &shelf_type);
void type_unlink(const Main &bmain, const AssetShelfType &shelf_type);
int ED_asset_shelf_tile_width(const AssetShelfSettings &settings);
int ED_asset_shelf_tile_height(const AssetShelfSettings &settings);
int tile_width(const AssetShelfSettings &settings);
int tile_height(const AssetShelfSettings &settings);
int ED_asset_shelf_context(const bContext *C, const char *member, bContextDataResult *result);
int context(const bContext *C, const char *member, bContextDataResult *result);
} // namespace blender::ed::asset::shelf

View File

@@ -23,11 +23,15 @@ namespace blender::asset_system {
class AssetRepresentation;
}
AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
namespace blender::ed::asset {
AssetTempIDConsumer *temp_id_consumer_create(
const blender::asset_system::AssetRepresentation *asset);
void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer);
ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
ID_Type id_type,
Main *bmain,
ReportList *reports);
void temp_id_consumer_free(AssetTempIDConsumer **consumer);
ID *temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
ID_Type id_type,
Main *bmain,
ReportList *reports);
} // namespace blender::ed::asset

View File

@@ -12,7 +12,9 @@
struct ID;
bool ED_asset_type_id_is_non_experimental(const ID *id);
namespace blender::ed::asset {
bool id_type_is_non_experimental(const ID *id);
#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS \
(FILTER_ID_MA | FILTER_ID_GR | FILTER_ID_OB | FILTER_ID_AC | FILTER_ID_WO | FILTER_ID_NT)
@@ -20,7 +22,7 @@ bool ED_asset_type_id_is_non_experimental(const ID *id);
* Check if the asset type for \a id (which doesn't need to be an asset right now) can be an asset,
* respecting the "Extended Asset Browser" experimental feature flag.
*/
bool ED_asset_type_is_supported(const ID *id);
bool id_type_is_supported(const ID *id);
/**
* Get the filter flags (subset of #FILTER_ID_ALL) representing the asset ID types that may be
@@ -28,7 +30,7 @@ bool ED_asset_type_is_supported(const ID *id);
* \note Does not check for #BKE_id_can_be_asset(), so may return filter flags for IDs that can
* never be assets.
*/
int64_t ED_asset_types_supported_as_filter_flags();
int64_t types_supported_as_filter_flags();
/**
* Utility: A string enumerating the non-experimental asset types. This is useful info to
@@ -38,3 +40,5 @@ int64_t ED_asset_types_supported_as_filter_flags();
*/
#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING \
"Material, Collection, Object, Pose Action, Node Group or World"
} // namespace blender::ed::asset

View File

@@ -22,10 +22,11 @@
#include "WM_api.hh"
using namespace blender;
namespace blender::ed::asset {
using namespace blender::asset_system;
bool ED_asset_catalogs_read_only(const AssetLibrary &library)
bool catalogs_read_only(const AssetLibrary &library)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
&library);
@@ -57,16 +58,16 @@ static std::string catalog_name_ensure_unique(AssetCatalogService &catalog_servi
return unique_name;
}
asset_system::AssetCatalog *ED_asset_catalog_add(AssetLibrary *library,
StringRefNull name,
StringRef parent_path)
asset_system::AssetCatalog *catalog_add(AssetLibrary *library,
StringRefNull name,
StringRef parent_path)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) {
return nullptr;
}
if (ED_asset_catalogs_read_only(*library)) {
if (catalogs_read_only(*library)) {
return nullptr;
}
@@ -84,7 +85,7 @@ asset_system::AssetCatalog *ED_asset_catalog_add(AssetLibrary *library,
return new_catalog;
}
void ED_asset_catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
void catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
@@ -92,7 +93,7 @@ void ED_asset_catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
BLI_assert_unreachable();
return;
}
if (ED_asset_catalogs_read_only(*library)) {
if (catalogs_read_only(*library)) {
return;
}
@@ -102,9 +103,9 @@ void ED_asset_catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
}
void ED_asset_catalog_rename(AssetLibrary *library,
const CatalogID catalog_id,
const StringRefNull new_name)
void catalog_rename(AssetLibrary *library,
const CatalogID catalog_id,
const StringRefNull new_name)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
@@ -112,7 +113,7 @@ void ED_asset_catalog_rename(AssetLibrary *library,
BLI_assert_unreachable();
return;
}
if (ED_asset_catalogs_read_only(*library)) {
if (catalogs_read_only(*library)) {
return;
}
@@ -132,9 +133,9 @@ void ED_asset_catalog_rename(AssetLibrary *library,
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
}
void ED_asset_catalog_move(AssetLibrary *library,
const CatalogID src_catalog_id,
const std::optional<CatalogID> dst_parent_catalog_id)
void catalog_move(AssetLibrary *library,
const CatalogID src_catalog_id,
const std::optional<CatalogID> dst_parent_catalog_id)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
@@ -142,7 +143,7 @@ void ED_asset_catalog_move(AssetLibrary *library,
BLI_assert_unreachable();
return;
}
if (ED_asset_catalogs_read_only(*library)) {
if (catalogs_read_only(*library)) {
return;
}
@@ -178,7 +179,7 @@ void ED_asset_catalog_move(AssetLibrary *library,
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
}
void ED_asset_catalogs_save_from_main_path(AssetLibrary *library, const Main *bmain)
void catalogs_save_from_main_path(AssetLibrary *library, const Main *bmain)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
@@ -186,7 +187,7 @@ void ED_asset_catalogs_save_from_main_path(AssetLibrary *library, const Main *bm
BLI_assert_unreachable();
return;
}
if (ED_asset_catalogs_read_only(*library)) {
if (catalogs_read_only(*library)) {
return;
}
@@ -196,12 +197,14 @@ void ED_asset_catalogs_save_from_main_path(AssetLibrary *library, const Main *bm
catalog_service->write_to_disk(bmain->filepath);
}
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)
void catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)
{
asset_system::AssetLibrary::save_catalogs_when_file_is_saved = should_save;
}
bool ED_asset_catalogs_get_save_catalogs_when_file_is_saved()
bool catalogs_get_save_catalogs_when_file_is_saved()
{
return asset_system::AssetLibrary::save_catalogs_when_file_is_saved;
}
} // namespace blender::ed::asset

View File

@@ -22,12 +22,11 @@
#include "ED_asset_handle.hh"
#include "ED_asset_library.hh"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
using namespace blender;
namespace blender::ed::asset {
bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
const asset_system::AssetRepresentation &asset)
bool filter_matches_asset(const AssetFilterSettings *filter,
const asset_system::AssetRepresentation &asset)
{
ID_Type asset_type = asset.get_id_type();
uint64_t asset_id_filter = BKE_idtype_idcode_to_idfilter(asset_type);
@@ -50,18 +49,15 @@ bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
return true;
}
namespace blender::ed::asset {
asset_system::AssetCatalogTree build_filtered_catalog_tree(
const asset_system::AssetLibrary &library,
const AssetLibraryReference &library_ref,
const blender::FunctionRef<bool(const asset_system::AssetRepresentation &)>
is_asset_visible_fn)
const FunctionRef<bool(const asset_system::AssetRepresentation &)> is_asset_visible_fn)
{
Set<StringRef> known_paths;
/* Collect paths containing assets. */
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!is_asset_visible_fn(asset)) {
return true;
}
@@ -109,14 +105,14 @@ AssetItemTree build_filtered_all_catalog_tree(
assets_per_path;
Vector<asset_system::AssetRepresentation *> unassigned_assets;
ED_assetlist_storage_fetch(&library_ref, &C);
asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(library_ref);
list::storage_fetch(&library_ref, &C);
asset_system::AssetLibrary *library = list::library_get_once_available(library_ref);
if (!library) {
return {};
}
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!filter_matches_asset(&filter_settings, asset)) {
return true;
}
const AssetMetaData &meta_data = asset.get_metadata();

View File

@@ -24,18 +24,21 @@
#include "ED_asset_handle.hh"
blender::asset_system::AssetRepresentation *ED_asset_handle_get_representation(
const AssetHandle *asset)
namespace blender::ed::asset {
asset_system::AssetRepresentation *handle_get_representation(const AssetHandle *asset)
{
return asset->file_data->asset;
}
int ED_asset_handle_get_preview_icon_id(const AssetHandle *asset)
int handle_get_preview_icon_id(const AssetHandle *asset)
{
return asset->file_data->preview_icon_id;
}
int ED_asset_handle_get_preview_or_type_icon_id(const AssetHandle *asset)
int handle_get_preview_or_type_icon_id(const AssetHandle *asset)
{
return ED_file_icon(asset->file_data);
}
} // namespace blender::ed::asset

View File

@@ -648,7 +648,7 @@ struct AssetIndex {
const int UNKNOWN_VERSION = -1;
/**
* `blender::io::serialize::Value` representing the contents of an index file.
* `io::serialize::Value` representing the contents of an index file.
*
* Value is used over #DictionaryValue as the contents of the index could be corrupted and
* doesn't represent an object. In case corrupted files are detected the `get_version` would
@@ -940,6 +940,6 @@ constexpr FileIndexerType asset_indexer()
return indexer;
}
} // namespace blender::ed::asset::index
const FileIndexerType file_indexer_asset = asset_indexer();
const FileIndexerType file_indexer_asset = blender::ed::asset::index::asset_indexer();
} // namespace blender::ed::asset::index

View File

@@ -25,7 +25,9 @@
#include "ED_asset_library.hh"
int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library)
namespace blender::ed::asset {
int library_reference_to_enum_value(const AssetLibraryReference *library)
{
/* Simple case: Predefined repository, just set the value. */
if (library->type < ASSET_LIBRARY_CUSTOM) {
@@ -43,7 +45,7 @@ int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *librar
return ASSET_LIBRARY_LOCAL;
}
AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
AssetLibraryReference library_reference_from_enum_value(int value)
{
AssetLibraryReference library;
@@ -74,7 +76,7 @@ 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_generated)
const EnumPropertyItem *library_reference_to_rna_enum_itemf(const bool include_generated)
{
EnumPropertyItem *item = nullptr;
int totitem = 0;
@@ -110,7 +112,7 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
library_reference.type = ASSET_LIBRARY_CUSTOM;
library_reference.custom_library_index = i;
const int enum_value = ED_asset_library_reference_to_enum_value(&library_reference);
const int enum_value = library_reference_to_enum_value(&library_reference);
/* Use library path as description, it's a nice hint for users. */
EnumPropertyItem tmp = {
enum_value, user_library->name, ICON_NONE, user_library->name, user_library->dirpath};
@@ -120,3 +122,5 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
RNA_enum_item_end(&item, &totitem);
return item;
}
} // namespace blender::ed::asset

View File

@@ -36,11 +36,10 @@
#include "ED_asset_indexer.hh"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "ED_screen.hh"
#include "asset_library_reference.hh"
namespace blender::ed::asset {
namespace blender::ed::asset::list {
/* -------------------------------------------------------------------- */
/** \name Asset list API
@@ -159,7 +158,7 @@ void AssetList::setup()
"");
const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing);
filelist_setindexer(files, use_asset_indexer ? &file_indexer_asset : &file_indexer_noop);
filelist_setindexer(files, use_asset_indexer ? &index::file_indexer_asset : &file_indexer_noop);
char dirpath[FILE_MAX_LIBEXTRA] = "";
if (!asset_lib_path.empty()) {
@@ -228,9 +227,7 @@ void AssetList::iterate(AssetListHandleIterFn fn) const
void AssetList::iterate(AssetListIterFn fn) const
{
iterate([&fn](AssetHandle handle) {
asset_system::AssetRepresentation &asset =
reinterpret_cast<blender::asset_system::AssetRepresentation &>(*handle.file_data->asset);
auto &asset = reinterpret_cast<asset_system::AssetRepresentation &>(*handle.file_data->asset);
return fn(asset);
});
}
@@ -450,21 +447,16 @@ void asset_reading_region_listen_fn(const wmRegionListenerParams *params)
}
}
} // namespace blender::ed::asset
/* -------------------------------------------------------------------- */
/** \name C-API
* \{ */
using namespace blender;
using namespace blender::ed::asset;
void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
{
AssetListStorage::fetch_library(*library_reference, *C);
}
bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference)
bool is_loaded(const AssetLibraryReference *library_reference)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (!list) {
@@ -476,8 +468,7 @@ bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference)
return list->isLoaded();
}
void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference,
const bContext *C)
void ensure_previews_job(const AssetLibraryReference *library_reference, const bContext *C)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
@@ -486,7 +477,7 @@ void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_refer
}
}
void ED_assetlist_clear(const AssetLibraryReference *library_reference, bContext *C)
void clear(const AssetLibraryReference *library_reference, bContext *C)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (list) {
@@ -494,12 +485,12 @@ void ED_assetlist_clear(const AssetLibraryReference *library_reference, bContext
}
}
bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *library_reference)
bool storage_has_list_for_library(const AssetLibraryReference *library_reference)
{
return AssetListStorage::lookup_list(*library_reference) != nullptr;
}
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn)
void iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn)
{
AssetList *list = AssetListStorage::lookup_list(library_reference);
if (list) {
@@ -507,7 +498,7 @@ void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetL
}
}
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
{
AssetList *list = AssetListStorage::lookup_list(library_reference);
if (list) {
@@ -515,7 +506,7 @@ void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetL
}
}
asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *library_get_once_available(
const AssetLibraryReference &library_reference)
{
const AssetList *list = AssetListStorage::lookup_list(library_reference);
@@ -525,29 +516,28 @@ asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
return list->asset_library();
}
AssetHandle ED_assetlist_asset_handle_get_by_index(const AssetLibraryReference *library_reference,
int asset_index)
AssetHandle asset_handle_get_by_index(const AssetLibraryReference *library_reference,
int asset_index)
{
const AssetList *list = AssetListStorage::lookup_list(*library_reference);
return list->asset_get_by_index(asset_index);
}
asset_system::AssetRepresentation *ED_assetlist_asset_get_by_index(
asset_system::AssetRepresentation *asset_get_by_index(
const AssetLibraryReference &library_reference, int asset_index)
{
AssetHandle asset_handle = ED_assetlist_asset_handle_get_by_index(&library_reference,
asset_index);
AssetHandle asset_handle = asset_handle_get_by_index(&library_reference, asset_index);
return reinterpret_cast<asset_system::AssetRepresentation *>(asset_handle.file_data->asset);
}
bool ED_assetlist_asset_image_is_loading(const AssetLibraryReference *library_reference,
const AssetHandle *asset_handle)
bool asset_image_is_loading(const AssetLibraryReference *library_reference,
const AssetHandle *asset_handle)
{
const AssetList *list = AssetListStorage::lookup_list(*library_reference);
return list->isAssetPreviewLoading(*asset_handle);
}
ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle)
ImBuf *asset_image_get(const AssetHandle *asset_handle)
{
ImBuf *imbuf = filelist_file_getimage(asset_handle->file_data);
if (imbuf) {
@@ -557,12 +547,12 @@ ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle)
return filelist_geticon_image_ex(asset_handle->file_data);
}
bool ED_assetlist_listen(const wmNotifier *notifier)
bool listen(const wmNotifier *notifier)
{
return AssetList::listen(*notifier);
}
int ED_assetlist_size(const AssetLibraryReference *library_reference)
int size(const AssetLibraryReference *library_reference)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (list) {
@@ -571,19 +561,21 @@ int ED_assetlist_size(const AssetLibraryReference *library_reference)
return -1;
}
void ED_assetlist_storage_tag_main_data_dirty()
void storage_tag_main_data_dirty()
{
AssetListStorage::tagMainDataDirty();
}
void ED_assetlist_storage_id_remap(ID *id_old, ID *id_new)
void storage_id_remap(ID *id_old, ID *id_new)
{
AssetListStorage::remapID(id_old, id_new);
}
void ED_assetlist_storage_exit()
void storage_exit()
{
AssetListStorage::destruct();
}
/** \} */
} // namespace blender::ed::asset::list

View File

@@ -30,7 +30,9 @@
#include "WM_api.hh"
#include "WM_types.hh"
bool ED_asset_mark_id(ID *id)
namespace blender::ed::asset {
bool mark_id(ID *id)
{
if (id->asset_data) {
return false;
@@ -49,12 +51,12 @@ bool ED_asset_mark_id(ID *id)
}
/* Important for asset storage to update properly! */
ED_assetlist_storage_tag_main_data_dirty();
list::storage_tag_main_data_dirty();
return true;
}
void ED_asset_generate_preview(const bContext *C, ID *id)
void generate_preview(const bContext *C, ID *id)
{
PreviewImage *preview = BKE_previewimg_id_get(id);
if (preview) {
@@ -64,7 +66,7 @@ void ED_asset_generate_preview(const bContext *C, ID *id)
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, !G.background);
}
bool ED_asset_clear_id(ID *id)
bool clear_id(ID *id)
{
if (!id->asset_data) {
return false;
@@ -73,12 +75,12 @@ bool ED_asset_clear_id(ID *id)
id_fake_user_clear(id);
/* Important for asset storage to update properly! */
ED_assetlist_storage_tag_main_data_dirty();
list::storage_tag_main_data_dirty();
return true;
}
void ED_assets_pre_save(Main *bmain)
void pre_save_assets(Main *bmain)
{
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
@@ -93,7 +95,7 @@ void ED_assets_pre_save(Main *bmain)
FOREACH_MAIN_ID_END;
}
bool ED_asset_can_mark_single_from_context(const bContext *C)
bool can_mark_single_from_context(const bContext *C)
{
/* Context needs a "id" pointer to be set for #ASSET_OT_mark()/#ASSET_OT_mark_single() and
* #ASSET_OT_clear()/#ASSET_OT_clear_single() to use. */
@@ -101,10 +103,10 @@ bool ED_asset_can_mark_single_from_context(const bContext *C)
if (!id) {
return false;
}
return ED_asset_type_is_supported(id);
return id_type_is_supported(id);
}
bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination)
bool copy_to_id(const AssetMetaData *asset_data, ID *destination)
{
if (!BKE_id_can_be_asset(destination)) {
return false;
@@ -116,3 +118,5 @@ bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination)
destination->asset_data = BKE_asset_metadata_copy(asset_data);
return true;
}
} // namespace blender::ed::asset

View File

@@ -25,7 +25,6 @@
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "ED_asset_menu_utils.hh"
@@ -70,10 +69,10 @@ static const asset_system::AssetRepresentation *get_local_asset_from_relative_id
{
AssetLibraryReference library_ref{};
library_ref.type = ASSET_LIBRARY_LOCAL;
ED_assetlist_storage_fetch(&library_ref, &C);
list::storage_fetch(&library_ref, &C);
const asset_system::AssetRepresentation *matching_asset = nullptr;
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (asset.get_identifier().library_relative_identifier() == relative_identifier) {
matching_asset = &asset;
return false;
@@ -82,7 +81,7 @@ static const asset_system::AssetRepresentation *get_local_asset_from_relative_id
});
if (reports && !matching_asset) {
if (ED_assetlist_is_loaded(&library_ref)) {
if (list::is_loaded(&library_ref)) {
BKE_reportf(
reports, RPT_ERROR, "No asset found at path \"%s\"", relative_identifier.c_str());
}
@@ -102,8 +101,8 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
}
const AssetLibraryReference library_ref = asset_system::all_library_reference();
ED_assetlist_storage_fetch(&library_ref, &C);
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
list::storage_fetch(&library_ref, &C);
asset_system::AssetLibrary *all_library = list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
BKE_report(reports, RPT_WARNING, "Asset loading is unfinished");
@@ -112,7 +111,7 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
const std::string full_path = all_library->resolve_asset_weak_reference_to_full_path(weak_ref);
const asset_system::AssetRepresentation *matching_asset = nullptr;
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (asset.get_identifier().full_path() == full_path) {
matching_asset = &asset;
return false;
@@ -121,7 +120,7 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
});
if (reports && !matching_asset) {
if (ED_assetlist_is_loaded(&library_ref)) {
if (list::is_loaded(&library_ref)) {
BKE_reportf(reports, RPT_ERROR, "No asset found at path \"%s\"", full_path.c_str());
}
}

View File

@@ -23,7 +23,6 @@
#include "BLI_set.hh"
#include "ED_asset.hh"
#include "ED_asset_catalog.hh"
#include "ED_screen.hh"
#include "ED_util.hh"
/* XXX needs access to the file list, should all be done via the asset system in future. */
@@ -40,15 +39,12 @@
#include "DNA_space_types.h"
using namespace blender;
namespace blender::ed::asset {
/* -------------------------------------------------------------------- */
using PointerRNAVec = blender::Vector<PointerRNA>;
static PointerRNAVec get_single_id_vec_from_context(const bContext *C)
static Vector<PointerRNA> get_single_id_vec_from_context(const bContext *C)
{
PointerRNAVec ids;
Vector<PointerRNA> ids;
PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID);
if (idptr.data) {
ids.append(idptr);
@@ -61,9 +57,9 @@ static PointerRNAVec get_single_id_vec_from_context(const bContext *C)
* ("selected_ids" context member) over a single active one ("id" context member), since usually
* batch operations are more useful.
*/
static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C)
static Vector<PointerRNA> asset_operation_get_ids_from_context(const bContext *C)
{
PointerRNAVec ids;
Vector<PointerRNA> ids;
/* "selected_ids" context member. */
{
@@ -84,7 +80,7 @@ static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C)
}
/**
* Information about what's contained in a #PointerRNAVec, returned by
* Information about what's contained in a #Vector<PointerRNA>, returned by
* #asset_operation_get_id_vec_stats_from_context().
*/
struct IDVecStats {
@@ -97,7 +93,7 @@ struct IDVecStats {
* Helper to report stats about the IDs in context. Operator polls use this, also to report a
* helpful disabled hint to the user.
*/
static IDVecStats asset_operation_get_id_vec_stats_from_ids(const PointerRNAVec &id_pointers)
static IDVecStats asset_operation_get_id_vec_stats_from_ids(const Vector<PointerRNA> &id_pointers)
{
IDVecStats stats;
@@ -107,7 +103,7 @@ static IDVecStats asset_operation_get_id_vec_stats_from_ids(const PointerRNAVec
BLI_assert(RNA_struct_is_ID(ptr.type));
ID *id = static_cast<ID *>(ptr.data);
if (ED_asset_type_is_supported(id)) {
if (id_type_is_supported(id)) {
stats.has_supported_type = true;
}
if (ID_IS_ASSET(id)) {
@@ -133,7 +129,7 @@ static const char *asset_operation_unsupported_type_msg(const bool is_single)
class AssetMarkHelper {
public:
void operator()(const bContext &C, const PointerRNAVec &ids);
void operator()(const bContext &C, const Vector<PointerRNA> &ids);
void reportResults(ReportList &reports) const;
bool wasSuccessful() const;
@@ -148,7 +144,7 @@ class AssetMarkHelper {
Stats stats;
};
void AssetMarkHelper::operator()(const bContext &C, const PointerRNAVec &ids)
void AssetMarkHelper::operator()(const bContext &C, const Vector<PointerRNA> &ids)
{
for (const PointerRNA &ptr : ids) {
BLI_assert(RNA_struct_is_ID(ptr.type));
@@ -159,8 +155,8 @@ void AssetMarkHelper::operator()(const bContext &C, const PointerRNAVec &ids)
continue;
}
if (ED_asset_mark_id(id)) {
ED_asset_generate_preview(&C, id);
if (mark_id(id)) {
generate_preview(&C, id);
stats.last_id = id;
stats.tot_created++;
@@ -198,7 +194,7 @@ void AssetMarkHelper::reportResults(ReportList &reports) const
}
}
static int asset_mark_exec(const bContext *C, const wmOperator *op, const PointerRNAVec &ids)
static int asset_mark_exec(const bContext *C, const wmOperator *op, const Vector<PointerRNA> &ids)
{
AssetMarkHelper mark_helper;
mark_helper(*C, ids);
@@ -214,7 +210,7 @@ static int asset_mark_exec(const bContext *C, const wmOperator *op, const Pointe
return OPERATOR_FINISHED;
}
static bool asset_mark_poll(bContext *C, const PointerRNAVec &ids)
static bool asset_mark_poll(bContext *C, const Vector<PointerRNA> &ids)
{
IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids);
@@ -273,7 +269,7 @@ class AssetClearHelper {
public:
AssetClearHelper(const bool set_fake_user) : set_fake_user_(set_fake_user) {}
void operator()(const PointerRNAVec &ids);
void operator()(const Vector<PointerRNA> &ids);
void reportResults(const bContext *C, ReportList &reports) const;
bool wasSuccessful() const;
@@ -287,7 +283,7 @@ class AssetClearHelper {
Stats stats;
};
void AssetClearHelper::operator()(const PointerRNAVec &ids)
void AssetClearHelper::operator()(const Vector<PointerRNA> &ids)
{
for (const PointerRNA &ptr : ids) {
BLI_assert(RNA_struct_is_ID(ptr.type));
@@ -297,7 +293,7 @@ void AssetClearHelper::operator()(const PointerRNAVec &ids)
continue;
}
if (!ED_asset_clear_id(id)) {
if (!clear_id(id)) {
continue;
}
@@ -340,7 +336,7 @@ bool AssetClearHelper::wasSuccessful() const
return stats.tot_cleared > 0;
}
static int asset_clear_exec(const bContext *C, const wmOperator *op, const PointerRNAVec &ids)
static int asset_clear_exec(const bContext *C, const wmOperator *op, const Vector<PointerRNA> &ids)
{
const bool set_fake_user = RNA_boolean_get(op->ptr, "set_fake_user");
AssetClearHelper clear_helper(set_fake_user);
@@ -357,7 +353,7 @@ static int asset_clear_exec(const bContext *C, const wmOperator *op, const Point
return OPERATOR_FINISHED;
}
static bool asset_clear_poll(bContext *C, const PointerRNAVec &ids)
static bool asset_clear_poll(bContext *C, const Vector<PointerRNA> &ids)
{
IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids);
@@ -455,7 +451,7 @@ static bool asset_library_refresh_poll(bContext *C)
return false;
}
return ED_assetlist_storage_has_list_for_library(library);
return list::storage_has_list_for_library(library);
}
static int asset_library_refresh_exec(bContext *C, wmOperator * /*unused*/)
@@ -469,7 +465,7 @@ static int asset_library_refresh_exec(bContext *C, wmOperator * /*unused*/)
else {
/* Execution mode #2: Outside the Asset Browser, use the asset list. */
const AssetLibraryReference *library = CTX_wm_asset_library_ref(C);
ED_assetlist_clear(library, C);
list::clear(library, C);
}
return OPERATOR_FINISHED;
@@ -500,12 +496,11 @@ static bool asset_catalog_operator_poll(bContext *C)
if (!sfile) {
return false;
}
const blender::asset_system::AssetLibrary *asset_library =
ED_fileselect_active_asset_library_get(sfile);
const asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
if (!asset_library) {
return false;
}
if (ED_asset_catalogs_read_only(*asset_library)) {
if (catalogs_read_only(*asset_library)) {
CTX_wm_operator_poll_msg_set(C, "Asset catalogs cannot be edited in this asset library");
return false;
}
@@ -515,11 +510,10 @@ static bool asset_catalog_operator_poll(bContext *C)
static int asset_catalog_new_exec(bContext *C, wmOperator *op)
{
SpaceFile *sfile = CTX_wm_space_file(C);
blender::asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(
sfile);
asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
char *parent_path = RNA_string_get_alloc(op->ptr, "parent_path", nullptr, 0, nullptr);
blender::asset_system::AssetCatalog *new_catalog = ED_asset_catalog_add(
asset_system::AssetCatalog *new_catalog = catalog_add(
asset_library, DATA_("Catalog"), parent_path);
if (sfile) {
@@ -556,15 +550,14 @@ static void ASSET_OT_catalog_new(wmOperatorType *ot)
static int asset_catalog_delete_exec(bContext *C, wmOperator *op)
{
SpaceFile *sfile = CTX_wm_space_file(C);
blender::asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(
sfile);
asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
char *catalog_id_str = RNA_string_get_alloc(op->ptr, "catalog_id", nullptr, 0, nullptr);
asset_system::CatalogID catalog_id;
if (!BLI_uuid_parse_string(&catalog_id, catalog_id_str)) {
return OPERATOR_CANCELLED;
}
ED_asset_catalog_remove(asset_library, catalog_id);
catalog_remove(asset_library, catalog_id);
MEM_freeN(catalog_id_str);
@@ -597,7 +590,7 @@ static asset_system::AssetCatalogService *get_catalog_service(bContext *C)
return nullptr;
}
blender::asset_system::AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
asset_system::AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
return AS_asset_library_get_catalog_service(asset_lib);
}
@@ -717,10 +710,9 @@ static bool asset_catalogs_save_poll(bContext *C)
static int asset_catalogs_save_exec(bContext *C, wmOperator * /*op*/)
{
const SpaceFile *sfile = CTX_wm_space_file(C);
blender::asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(
sfile);
asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
ED_asset_catalogs_save_from_main_path(asset_library, CTX_data_main(C));
catalogs_save_from_main_path(asset_library, CTX_data_main(C));
WM_event_add_notifier_ex(
CTX_wm_manager(C), CTX_wm_window(C), NC_ASSET | ND_ASSET_CATALOGS, nullptr);
@@ -852,7 +844,7 @@ static const EnumPropertyItem *rna_asset_library_reference_itemf(bContext * /*C*
PropertyRNA * /*prop*/,
bool *r_free)
{
const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(false);
const EnumPropertyItem *items = library_reference_to_rna_enum_itemf(false);
if (!items) {
*r_free = false;
return nullptr;
@@ -900,7 +892,7 @@ static bool could_be_asset_bundle(const Main *bmain)
static const bUserAssetLibrary *selected_asset_library(wmOperator *op)
{
const int enum_value = RNA_enum_get(op->ptr, "asset_library_reference");
const AssetLibraryReference lib_ref = ED_asset_library_reference_from_enum_value(enum_value);
const AssetLibraryReference lib_ref = library_reference_from_enum_value(enum_value);
const bUserAssetLibrary *lib = BKE_preferences_asset_library_find_index(
&U, lib_ref.custom_library_index);
return lib;
@@ -1011,7 +1003,7 @@ static bool has_external_files(Main *bmain, ReportList *reports)
/* -------------------------------------------------------------------- */
void ED_operatortypes_asset()
void operatortypes_asset()
{
WM_operatortype_append(ASSET_OT_mark);
WM_operatortype_append(ASSET_OT_mark_single);
@@ -1028,3 +1020,5 @@ void ED_operatortypes_asset()
WM_operatortype_append(ASSET_OT_library_refresh);
}
} // namespace blender::ed::asset

View File

@@ -38,20 +38,15 @@
#include "ED_asset_shelf.hh"
#include "asset_shelf.hh"
using namespace blender;
using namespace blender::ed::asset;
namespace blender::ed::asset::shelf {
static int asset_shelf_default_tile_height();
namespace blender::ed::asset::shelf {
void send_redraw_notifier(const bContext &C)
{
WM_event_add_notifier(&C, NC_SPACE | ND_REGIONS_ASSET_SHELF, nullptr);
}
} // namespace blender::ed::asset::shelf
/* -------------------------------------------------------------------- */
/** \name Shelf Type
* \{ */
@@ -188,7 +183,7 @@ static AssetShelf *update_active_shelf(const bContext &C,
/** \name Asset Shelf Regions
* \{ */
void *ED_asset_shelf_region_duplicate(void *regiondata)
void *region_duplicate(void *regiondata)
{
const RegionAssetShelf *shelf_regiondata = static_cast<RegionAssetShelf *>(regiondata);
if (!shelf_regiondata) {
@@ -198,7 +193,7 @@ void *ED_asset_shelf_region_duplicate(void *regiondata)
return shelf::regiondata_duplicate(shelf_regiondata);
}
void ED_asset_shelf_region_free(ARegion *region)
void region_free(ARegion *region)
{
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
if (shelf_regiondata) {
@@ -225,7 +220,7 @@ static bool asset_shelf_space_poll(const bContext *C, const SpaceLink *space_lin
return false;
}
bool ED_asset_shelf_regions_poll(const RegionPollParams *params)
bool regions_poll(const RegionPollParams *params)
{
return asset_shelf_space_poll(params->context,
static_cast<SpaceLink *>(params->area->spacedata.first));
@@ -251,9 +246,9 @@ static void asset_shelf_region_listen(const wmRegionListenerParams *params)
}
}
void ED_asset_shelf_region_listen(const wmRegionListenerParams *params)
void region_listen(const wmRegionListenerParams *params)
{
if (ED_assetlist_listen(params->notifier)) {
if (list::listen(params->notifier)) {
ED_region_tag_redraw_no_rebuild(params->region);
}
/* If the asset list didn't catch the notifier, let the region itself listen. */
@@ -262,7 +257,7 @@ void ED_asset_shelf_region_listen(const wmRegionListenerParams *params)
}
}
void ED_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
void region_init(wmWindowManager *wm, ARegion *region)
{
if (!region->regiondata) {
region->regiondata = MEM_cnew<RegionAssetShelf>("RegionAssetShelf");
@@ -284,7 +279,7 @@ void ED_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.keeptot |= V2D_KEEPTOT_STRICT;
region->v2d.flag |= V2D_SNAP_TO_PAGESIZE_Y;
region->v2d.page_size_y = active_shelf ? ED_asset_shelf_tile_height(active_shelf->settings) :
region->v2d.page_size_y = active_shelf ? tile_height(active_shelf->settings) :
asset_shelf_default_tile_height();
/* Ensure the view is snapped to a page still, especially for DPI changes. */
@@ -313,8 +308,7 @@ static int current_tile_draw_height(const ARegion *region)
/* It can happen that this function is called before the region is actually initialized, when
* user clicks & drags slightly on the 'up arrow' icon of the shelf. */
const AssetShelf *active_shelf = shelf_regiondata ? shelf_regiondata->active_shelf : nullptr;
return (active_shelf ? ED_asset_shelf_tile_height(active_shelf->settings) :
asset_shelf_default_tile_height()) /
return (active_shelf ? tile_height(active_shelf->settings) : asset_shelf_default_tile_height()) /
(IS_EQF(aspect, 0) ? 1.0f : aspect);
}
@@ -333,7 +327,7 @@ static int calculate_scaled_region_height_from_row_count(const int row_count,
return (row_count * tile_draw_height + 2 * main_region_padding_y());
}
int ED_asset_shelf_region_snap(const ARegion *region, const int size, const int axis)
int region_snap(const ARegion *region, const int size, const int axis)
{
/* Only on Y axis. */
if (axis != 1) {
@@ -376,7 +370,7 @@ static void region_resize_to_preferred(ScrArea *area, ARegion *region)
}
}
void ED_asset_shelf_region_on_user_resize(const ARegion *region)
void region_on_user_resize(const ARegion *region)
{
const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
*region);
@@ -390,12 +384,12 @@ void ED_asset_shelf_region_on_user_resize(const ARegion *region)
region->sizey * UI_SCALE_FAC, tile_height);
}
int ED_asset_shelf_tile_width(const AssetShelfSettings &settings)
int tile_width(const AssetShelfSettings &settings)
{
return UI_preview_tile_size_x(settings.preview_size);
}
int ED_asset_shelf_tile_height(const AssetShelfSettings &settings)
int tile_height(const AssetShelfSettings &settings)
{
return (settings.display_flag & ASSETSHELF_SHOW_NAMES) ?
UI_preview_tile_size_y(settings.preview_size) :
@@ -407,20 +401,20 @@ static int asset_shelf_default_tile_height()
return UI_preview_tile_size_x(shelf::DEFAULT_TILE_SIZE);
}
int ED_asset_shelf_region_prefsizey()
int region_prefsizey()
{
/* One row by default (plus padding). */
return asset_shelf_default_tile_height() + 2 * main_region_padding_y();
}
void ED_asset_shelf_region_layout(const bContext *C, ARegion *region)
void region_layout(const bContext *C, ARegion *region)
{
const SpaceLink *space = CTX_wm_space_data(C);
const SpaceType *space_type = BKE_spacetype_from_id(space->spacetype);
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
if (!shelf_regiondata) {
/* Region-data should've been created by a previously called #ED_asset_shelf_region_init(). */
/* Region-data should've been created by a previously called #region_init(). */
BLI_assert_unreachable();
return;
}
@@ -459,7 +453,7 @@ void ED_asset_shelf_region_layout(const bContext *C, ARegion *region)
UI_block_end(C, block);
}
void ED_asset_shelf_region_draw(const bContext *C, ARegion *region)
void region_draw(const bContext *C, ARegion *region)
{
ED_region_clear(C, region, TH_BACK);
@@ -477,19 +471,19 @@ void ED_asset_shelf_region_draw(const bContext *C, ARegion *region)
UI_view2d_scrollers_draw(&region->v2d, nullptr);
}
void ED_asset_shelf_header_region_listen(const wmRegionListenerParams *params)
void header_region_listen(const wmRegionListenerParams *params)
{
asset_shelf_region_listen(params);
}
void ED_asset_shelf_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
void header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
region->alignment |= RGN_SPLIT_SCALE_PREV;
region->flag |= RGN_FLAG_RESIZE_RESPECT_BUTTON_SECTIONS;
}
void ED_asset_shelf_header_region(const bContext *C, ARegion *region)
void header_region(const bContext *C, ARegion *region)
{
const SpaceLink *space = CTX_wm_space_data(C);
const SpaceType *space_type = BKE_spacetype_from_id(space->spacetype);
@@ -503,7 +497,7 @@ void ED_asset_shelf_header_region(const bContext *C, ARegion *region)
ED_region_header_with_button_sections(C, region, uiButtonSectionsAlign::Bottom);
}
int ED_asset_shelf_header_region_size()
int header_region_size()
{
/* Use a height that lets widgets sit just on top of the separator line drawn at the lower edge
* of the region (widgets will be centered).
@@ -513,7 +507,7 @@ int ED_asset_shelf_header_region_size()
return UI_UNIT_Y + (UI_BUTTON_SECTION_SEPERATOR_LINE_WITH * 2);
}
void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, ARegion *region)
void region_blend_read_data(BlendDataReader *reader, ARegion *region)
{
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
if (!shelf_regiondata) {
@@ -523,7 +517,7 @@ void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, ARegion *reg
region->regiondata = shelf_regiondata;
}
void ED_asset_shelf_region_blend_write(BlendWriter *writer, ARegion *region)
void region_blend_write(BlendWriter *writer, ARegion *region)
{
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
if (!shelf_regiondata) {
@@ -561,7 +555,7 @@ static AssetShelf *active_shelf_from_area(const ScrArea *area)
return shelf_regiondata->active_shelf;
}
int ED_asset_shelf_context(const bContext *C, const char *member, bContextDataResult *result)
int context(const bContext *C, const char *member, bContextDataResult *result)
{
static const char *context_dir[] = {
"asset_shelf",
@@ -626,8 +620,6 @@ int ED_asset_shelf_context(const bContext *C, const char *member, bContextDataRe
return CTX_RESULT_MEMBER_NOT_FOUND;
}
namespace blender::ed::asset::shelf {
static PointerRNA active_shelf_ptr_from_context(const bContext *C)
{
return CTX_data_pointer_get_type(C, "asset_shelf", &RNA_AssetShelf);
@@ -639,8 +631,6 @@ AssetShelf *active_shelf_from_context(const bContext *C)
return static_cast<AssetShelf *>(shelf_settings_ptr.data);
}
} // namespace blender::ed::asset::shelf
/** \} */
/* -------------------------------------------------------------------- */
@@ -722,7 +712,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
uiBlock *block = uiLayoutGetBlock(layout);
const AssetLibraryReference *library_ref = CTX_wm_asset_library_ref(C);
ED_assetlist_storage_fetch(library_ref, C);
list::storage_fetch(library_ref, C);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemPopoverPanel(layout, C, "ASSETSHELF_PT_catalog_selector", "", ICON_COLLAPSEMENU);
@@ -730,7 +720,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
uiItemS(layout);
PointerRNA shelf_ptr = shelf::active_shelf_ptr_from_context(C);
PointerRNA shelf_ptr = active_shelf_ptr_from_context(C);
AssetShelf *shelf = static_cast<AssetShelf *>(shelf_ptr.data);
if (shelf) {
add_catalog_tabs(shelf->settings, *layout);
@@ -745,7 +735,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
uiItemR(sub, &shelf_ptr, "search_filter", UI_ITEM_NONE, "", ICON_VIEWZOOM);
}
void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const int space_type)
void header_regiontype_register(ARegionType *region_type, const int space_type)
{
HeaderType *ht = MEM_cnew<HeaderType>(__func__);
STRNCPY(ht->idname, "ASSETSHELF_HT_settings");
@@ -758,7 +748,7 @@ void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const i
BLI_addtail(&region_type->headertypes, ht);
shelf::catalog_selector_panel_register(region_type);
catalog_selector_panel_register(region_type);
}
/** \} */
@@ -767,7 +757,7 @@ void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const i
/** \name Asset Shelf Type (un)registration
* \{ */
void ED_asset_shelf_type_unlink(const Main &bmain, const AssetShelfType &shelf_type)
void type_unlink(const Main &bmain, const AssetShelfType &shelf_type)
{
LISTBASE_FOREACH (bScreen *, screen, &bmain.screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
@@ -798,3 +788,5 @@ void ED_asset_shelf_type_unlink(const Main &bmain, const AssetShelfType &shelf_t
}
/** \} */
} // namespace blender::ed::asset::shelf

View File

@@ -96,15 +96,13 @@ AssetView::AssetView(const AssetLibraryReference &library_ref, const AssetShelf
void AssetView::build_items()
{
const asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(
library_ref_);
const asset_system::AssetLibrary *library = list::library_get_once_available(library_ref_);
if (!library) {
return;
}
ED_assetlist_iterate(library_ref_, [&](AssetHandle asset_handle) {
const asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(
&asset_handle);
list::iterate(library_ref_, [&](AssetHandle asset_handle) {
const asset_system::AssetRepresentation *asset = handle_get_representation(&asset_handle);
if (shelf_.type->asset_poll && !shelf_.type->asset_poll(shelf_.type, asset)) {
return true;
@@ -121,10 +119,10 @@ void AssetView::build_items()
const StringRef identifier = asset->get_identifier().library_relative_identifier();
const int preview_id = [&]() -> int {
if (ED_assetlist_asset_image_is_loading(&library_ref_, &asset_handle)) {
if (list::asset_image_is_loading(&library_ref_, &asset_handle)) {
return ICON_TEMP;
}
return ED_asset_handle_get_preview_or_type_icon_id(&asset_handle);
return handle_get_preview_or_type_icon_id(&asset_handle);
}();
AssetViewItem &item = add_item<AssetViewItem>(
@@ -213,7 +211,7 @@ void AssetViewItem::build_context_menu(bContext &C, uiLayout &column) const
const AssetView &asset_view = dynamic_cast<const AssetView &>(get_view());
const AssetShelfType &shelf_type = *asset_view.shelf_.type;
if (shelf_type.draw_context_menu) {
asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(&asset_);
asset_system::AssetRepresentation *asset = handle_get_representation(&asset_);
shelf_type.draw_context_menu(&C, &shelf_type, asset, &column);
}
}
@@ -225,7 +223,7 @@ bool AssetViewItem::is_filtered_visible() const
return true;
}
const StringRefNull asset_name = ED_asset_handle_get_representation(&asset_)->get_name();
const StringRefNull asset_name = handle_get_representation(&asset_)->get_name();
return fnmatch(asset_view.search_string, asset_name.c_str(), FNM_CASEFOLD) == 0;
}
@@ -234,7 +232,7 @@ std::unique_ptr<ui::AbstractViewItemDragController> AssetViewItem::create_drag_c
if (!allow_asset_drag_) {
return nullptr;
}
asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(&asset_);
asset_system::AssetRepresentation *asset = handle_get_representation(&asset_);
return std::make_unique<AssetDragController>(get_view(), *asset);
}
@@ -246,16 +244,16 @@ void build_asset_view(uiLayout &layout,
const bContext &C,
ARegion &region)
{
ED_assetlist_storage_fetch(&library_ref, &C);
ED_assetlist_ensure_previews_job(&library_ref, &C);
list::storage_fetch(&library_ref, &C);
list::ensure_previews_job(&library_ref, &C);
const asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(library_ref);
const asset_system::AssetLibrary *library = list::library_get_once_available(library_ref);
if (!library) {
return;
}
const float tile_width = ED_asset_shelf_tile_width(shelf.settings);
const float tile_height = ED_asset_shelf_tile_height(shelf.settings);
const float tile_width = shelf::tile_width(shelf.settings);
const float tile_height = shelf::tile_height(shelf.settings);
BLI_assert(tile_width != 0);
BLI_assert(tile_height != 0);

View File

@@ -23,7 +23,6 @@
#include "ED_asset_filter.hh"
#include "ED_asset_list.hh"
#include "ED_asset_list.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.h"
@@ -202,7 +201,7 @@ static void catalog_selector_panel_draw(const bContext *C, Panel *panel)
uiItemO(row, "", ICON_FILE_REFRESH, "ASSET_OT_library_refresh");
}
asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(*library_ref);
asset_system::AssetLibrary *library = list::library_get_once_available(*library_ref);
if (!library) {
return;
}
@@ -230,7 +229,7 @@ void catalog_selector_panel_register(ARegionType *region_type)
pt->description = N_(
"Select the asset library and the contained catalogs to display in the asset shelf");
pt->draw = catalog_selector_panel_draw;
pt->listener = asset::asset_reading_region_listen_fn;
pt->listener = asset::list::asset_reading_region_listen_fn;
BLI_addtail(&region_type->paneltypes, pt);
WM_paneltype_add(pt);
}

View File

@@ -24,16 +24,14 @@
#include "ED_asset_temp_id_consumer.hh"
using namespace blender;
namespace blender::ed::asset {
class AssetTemporaryIDConsumer : NonCopyable, NonMovable {
const blender::asset_system::AssetRepresentation *asset_;
const asset_system::AssetRepresentation *asset_;
TempLibraryContext *temp_lib_context_ = nullptr;
public:
AssetTemporaryIDConsumer(const blender::asset_system::AssetRepresentation *asset) : asset_(asset)
{
}
AssetTemporaryIDConsumer(const asset_system::AssetRepresentation *asset) : asset_(asset) {}
~AssetTemporaryIDConsumer()
{
if (temp_lib_context_) {
@@ -65,8 +63,7 @@ class AssetTemporaryIDConsumer : NonCopyable, NonMovable {
}
};
AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
const asset_system::AssetRepresentation *asset)
AssetTempIDConsumer *temp_id_consumer_create(const asset_system::AssetRepresentation *asset)
{
if (!asset) {
return nullptr;
@@ -75,16 +72,16 @@ AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
MEM_new<AssetTemporaryIDConsumer>(__func__, asset));
}
void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer)
void temp_id_consumer_free(AssetTempIDConsumer **consumer)
{
MEM_delete(reinterpret_cast<AssetTemporaryIDConsumer *>(*consumer));
*consumer = nullptr;
}
ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
ID_Type id_type,
Main *bmain,
ReportList *reports)
ID *temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
ID_Type id_type,
Main *bmain,
ReportList *reports)
{
if (!(consumer_ && bmain && reports)) {
return nullptr;
@@ -96,3 +93,5 @@ ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
}
return consumer->import_id(id_type, *bmain, *reports);
}
} // namespace blender::ed::asset

View File

@@ -14,14 +14,16 @@
#include "ED_asset_type.hh"
bool ED_asset_type_id_is_non_experimental(const ID *id)
namespace blender::ed::asset {
bool id_type_is_non_experimental(const ID *id)
{
/* Remember to update #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING and
* #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS() with this! */
return ELEM(GS(id->name), ID_MA, ID_GR, ID_OB, ID_AC, ID_WO, ID_NT);
}
bool ED_asset_type_is_supported(const ID *id)
bool id_type_is_supported(const ID *id)
{
if (!BKE_id_can_be_asset(id)) {
return false;
@@ -33,10 +35,10 @@ bool ED_asset_type_is_supported(const ID *id)
return true;
}
return ED_asset_type_id_is_non_experimental(id);
return id_type_is_non_experimental(id);
}
int64_t ED_asset_types_supported_as_filter_flags()
int64_t types_supported_as_filter_flags()
{
if (U.experimental.use_extended_asset_browser) {
return FILTER_ID_ALL;
@@ -44,3 +46,5 @@ int64_t ED_asset_types_supported_as_filter_flags()
return ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS;
}
} // namespace blender::ed::asset

View File

@@ -904,7 +904,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu)
const Set<std::string> builtin_menus = get_builtin_menus(ObjectType(active_object->type),
eObjectMode(active_object->mode));
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -929,7 +929,7 @@ MenuType node_group_operator_assets_menu()
STRNCPY(type.idname, "GEO_MT_node_operator_catalog_assets");
type.poll = asset_menu_poll;
type.draw = catalog_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
return type;
}
@@ -1028,7 +1028,7 @@ MenuType node_group_operator_assets_menu_unassigned()
STRNCPY(type.idname, "GEO_MT_node_operator_unassigned");
type.poll = asset_menu_poll;
type.draw = catalog_assets_draw_unassigned;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
type.description = N_(
"Tool node group assets not assigned to a catalog.\n"
@@ -1053,7 +1053,7 @@ void ui_template_node_operator_asset_menu_items(uiLayout &layout,
if (!item) {
return;
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -1082,7 +1082,7 @@ void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext
*tree = build_catalog_tree(C, *active_object);
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;

View File

@@ -14,8 +14,6 @@
/* Barely anything here. Just general editor level functions. Actual asset level code is in
* dedicated headers. */
void ED_operatortypes_asset();
#include "../asset/ED_asset_catalog.hh"
#include "../asset/ED_asset_handle.hh"
#include "../asset/ED_asset_library.hh"
@@ -28,3 +26,9 @@ void ED_operatortypes_asset();
#include "../asset/ED_asset_filter.hh"
#include "../asset/ED_asset_import.hh"
#include "../asset/ED_asset_list.hh"
namespace blender::ed::asset {
void operatortypes_asset();
}

View File

@@ -506,6 +506,7 @@ static void set_layout_context_from_button(bContext *C, uiLayout *layout, uiBut
bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *event)
{
using namespace blender::ed;
/* ui_but_is_interactive() may let some buttons through that should not get a context menu - it
* doesn't make sense for them. */
if (ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_IMAGE)) {
@@ -1023,7 +1024,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
}
/* If the button represents an id, it can set the "id" context pointer. */
if (ED_asset_can_mark_single_from_context(C)) {
if (asset::can_mark_single_from_context(C)) {
const ID *id = static_cast<const ID *>(CTX_data_pointer_get_type(C, "id", &RNA_ID).data);
/* Gray out items depending on if data-block is an asset. Preferably this could be done via

View File

@@ -35,6 +35,7 @@
#include "interface_intern.hh"
using namespace blender;
using namespace blender::ed;
struct AssetViewListData {
AssetLibraryReference asset_library_ref;
@@ -45,7 +46,7 @@ struct AssetViewListData {
static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
{
blender::asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(
blender::asset_system::AssetRepresentation *asset = asset::handle_get_representation(
asset_handle);
UI_but_dragflag_enable(but, UI_BUT_DRAG_FULL_BUT);
@@ -59,9 +60,9 @@ static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
const eAssetImportMethod import_method = asset->get_import_method().value_or(
ASSET_IMPORT_APPEND_REUSE);
ImBuf *imbuf = ED_assetlist_asset_image_get(asset_handle);
ImBuf *imbuf = asset::list::asset_image_get(asset_handle);
UI_but_drag_set_asset(
but, asset, import_method, ED_asset_handle_get_preview_icon_id(asset_handle), imbuf, 1.0f);
but, asset, import_method, asset::handle_get_preview_icon_id(asset_handle), imbuf, 1.0f);
}
static void asset_view_draw_item(uiList *ui_list,
@@ -77,7 +78,7 @@ static void asset_view_draw_item(uiList *ui_list,
{
AssetViewListData *list_data = (AssetViewListData *)ui_list->dyn_data->customdata;
AssetHandle asset_handle = ED_assetlist_asset_handle_get_by_index(&list_data->asset_library_ref,
AssetHandle asset_handle = asset::list::asset_handle_get_by_index(&list_data->asset_library_ref,
index);
PointerRNA file_ptr = RNA_pointer_create(&list_data->screen->id,
@@ -93,8 +94,8 @@ static void asset_view_draw_item(uiList *ui_list,
block,
UI_BTYPE_PREVIEW_TILE,
0,
ED_asset_handle_get_preview_icon_id(&asset_handle),
show_names ? ED_asset_handle_get_representation(&asset_handle)->get_name().c_str() : "",
asset::handle_get_preview_icon_id(&asset_handle),
show_names ? asset::handle_get_representation(&asset_handle)->get_name().c_str() : "",
0,
0,
size_x,
@@ -106,7 +107,7 @@ static void asset_view_draw_item(uiList *ui_list,
0,
"");
ui_def_but_icon(but,
ED_asset_handle_get_preview_icon_id(&asset_handle),
asset::handle_get_preview_icon_id(&asset_handle),
/* NOLINTNEXTLINE: bugprone-suspicious-enum-usage */
UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
but->emboss = UI_EMBOSS_NONE;
@@ -130,10 +131,10 @@ static void asset_view_filter_items(uiList *ui_list,
C,
[&name_filter, list_data, &filter_settings](
const PointerRNA &itemptr, blender::StringRefNull name, int index) {
asset_system::AssetRepresentation *asset = ED_assetlist_asset_get_by_index(
asset_system::AssetRepresentation *asset = asset::list::asset_get_by_index(
list_data->asset_library_ref, index);
if (!ED_asset_filter_matches_asset(&filter_settings, *asset)) {
if (!asset::filter_matches_asset(&filter_settings, *asset)) {
return UI_LIST_ITEM_NEVER_SHOW;
}
return name_filter(itemptr, name, index);
@@ -141,7 +142,7 @@ static void asset_view_filter_items(uiList *ui_list,
dataptr,
propname,
[list_data](const PointerRNA & /*itemptr*/, int index) -> std::string {
asset_system::AssetRepresentation *asset = ED_assetlist_asset_get_by_index(
asset_system::AssetRepresentation *asset = asset::list::asset_get_by_index(
list_data->asset_library_ref, index);
return asset->get_name();
@@ -155,13 +156,13 @@ static void asset_view_listener(uiList * /*ui_list*/, wmRegionListenerParams *pa
switch (notifier->category) {
case NC_ID: {
if (ELEM(notifier->action, NA_RENAME)) {
ED_assetlist_storage_tag_main_data_dirty();
asset::list::storage_tag_main_data_dirty();
}
break;
}
}
if (ED_assetlist_listen(params->notifier)) {
if (asset::list::listen(params->notifier)) {
ED_region_tag_redraw(params->region);
}
}
@@ -199,7 +200,7 @@ static void populate_asset_collection(const AssetLibraryReference &asset_library
RNA_property_collection_clear(&assets_dataptr, assets_prop);
ED_assetlist_iterate(asset_library_ref, [&](AssetHandle /*asset*/) {
asset::list::iterate(asset_library_ref, [&](AssetHandle /*asset*/) {
/* XXX creating a dummy #RNA_AssetHandle collection item. It's #file_data will be null. This is
* because the #FileDirEntry may be freed while iterating, there's a cache for them with a
* maximum size. Further code will query as needed it using the collection index. */
@@ -238,7 +239,7 @@ void uiTemplateAssetView(uiLayout *layout,
PropertyRNA *asset_library_prop = RNA_struct_find_property(asset_library_dataptr,
asset_library_propname);
AssetLibraryReference asset_library_ref = ED_asset_library_reference_from_enum_value(
AssetLibraryReference asset_library_ref = asset::library_reference_from_enum_value(
RNA_property_enum_get(asset_library_dataptr, asset_library_prop));
uiLayout *row = uiLayoutRow(col, true);
@@ -256,9 +257,9 @@ void uiTemplateAssetView(uiLayout *layout,
}
}
ED_assetlist_storage_fetch(&asset_library_ref, C);
ED_assetlist_ensure_previews_job(&asset_library_ref, C);
const int tot_items = ED_assetlist_size(&asset_library_ref);
asset::list::storage_fetch(&asset_library_ref, C);
asset::list::ensure_previews_job(&asset_library_ref, C);
const int tot_items = asset::list::size(&asset_library_ref);
populate_asset_collection(asset_library_ref, *assets_dataptr, assets_propname);

View File

@@ -45,7 +45,7 @@ namespace blender::ed::object {
static bool all_loading_finished()
{
AssetLibraryReference all_library_ref = asset_system::all_library_reference();
return ED_assetlist_is_loaded(&all_library_ref);
return asset::list::is_loaded(&all_library_ref);
}
static asset::AssetItemTree build_catalog_tree(const bContext &C)
@@ -111,7 +111,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu)
asset::operator_asset_reference_props_set(*asset, props_ptr);
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -234,7 +234,7 @@ static void root_catalogs_draw(const bContext *C, Menu *menu)
return menus;
}();
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -358,7 +358,7 @@ static MenuType modifier_add_unassigned_assets_menu_type()
MenuType type{};
STRNCPY(type.idname, "OBJECT_MT_add_modifier_unassigned_assets");
type.draw = unassigned_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.description = N_(
"Modifier node group assets not assigned to a catalog.\n"
"Catalogs can be assigned in the Asset Browser");
@@ -370,7 +370,7 @@ static MenuType modifier_add_catalog_assets_menu_type()
MenuType type{};
STRNCPY(type.idname, "OBJECT_MT_add_modifier_catalog_assets");
type.draw = catalog_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
return type;
}
@@ -380,7 +380,7 @@ static MenuType modifier_add_root_catalogs_menu_type()
MenuType type{};
STRNCPY(type.idname, "OBJECT_MT_modifier_add_root_catalogs");
type.draw = root_catalogs_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
return type;
}
@@ -406,7 +406,7 @@ void ui_template_modifier_asset_menu_items(uiLayout &layout,
if (!item) {
return;
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;

View File

@@ -1348,6 +1348,7 @@ bool ED_region_is_overlap(int spacetype, int regiontype)
static void region_rect_recursive(
ScrArea *area, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad)
{
using namespace blender::ed;
rcti *remainder_prev = remainder;
if (region == nullptr) {
@@ -1409,10 +1410,10 @@ static void region_rect_recursive(
}
else if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
prefsizey = region->sizey > 1 ? (UI_SCALE_FAC * (region->sizey + 0.5f)) :
ED_asset_shelf_region_prefsizey();
asset::shelf::region_prefsizey();
}
else if (region->regiontype == RGN_TYPE_ASSET_SHELF_HEADER) {
prefsizey = ED_asset_shelf_header_region_size();
prefsizey = asset::shelf::header_region_size();
}
else if (ED_area_is_global(area)) {
prefsizey = ED_region_global_size_y();

View File

@@ -61,6 +61,7 @@
void ED_spacetypes_init()
{
using namespace blender::ed;
/* UI unit is a variable, may be used in some space type initialization. */
U.widget_unit = 20;
@@ -92,7 +93,7 @@ void ED_spacetypes_init()
ED_operatortypes_screen();
ED_operatortypes_anim();
ED_operatortypes_animchannels();
ED_operatortypes_asset();
asset::operatortypes_asset();
ED_operatortypes_gpencil_legacy();
ED_operatortypes_grease_pencil();
ED_operatortypes_object();

View File

@@ -330,7 +330,7 @@ bool AssetCatalogTreeViewItem::supports_renaming() const
{
const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
get_tree_view());
return !ED_asset_catalogs_read_only(*tree_view.asset_library_);
return !asset::catalogs_read_only(*tree_view.asset_library_);
}
bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name)
@@ -340,7 +340,7 @@ bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name)
const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
get_tree_view());
ED_asset_catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
return true;
}
@@ -454,7 +454,7 @@ bool AssetCatalogDropTarget::drop_asset_catalog_into_catalog(
{
BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG);
wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
ED_asset_catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
asset::catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
tree_view.activate_catalog_by_id(catalog_drag->drag_catalog_id);
WM_main_add_notifier(NC_ASSET | ND_ASSET_CATALOGS, nullptr);
@@ -529,7 +529,7 @@ bool AssetCatalogDropTarget::has_droppable_asset(const wmDrag &drag, const char
bool AssetCatalogDropTarget::can_modify_catalogs(const asset_system::AssetLibrary &library,
const char **r_disabled_hint)
{
if (ED_asset_catalogs_read_only(library)) {
if (asset::catalogs_read_only(library)) {
*r_disabled_hint = RPT_("Catalogs cannot be edited in this asset library");
return false;
}

View File

@@ -202,6 +202,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
static void file_refresh(const bContext *C, ScrArea *area)
{
using namespace blender::ed;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -231,7 +232,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
if (ED_fileselect_is_asset_browser(sfile)) {
/* Ask the asset code for appropriate ID filter flags for the supported assets, and mask others
* out. */
params->filter_id &= ED_asset_types_supported_as_filter_flags();
params->filter_id &= asset::types_supported_as_filter_flags();
}
filelist_settype(sfile->files, params->type);
@@ -258,8 +259,8 @@ static void file_refresh(const bContext *C, ScrArea *area)
if (ED_fileselect_is_asset_browser(sfile)) {
const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing);
filelist_setindexer(sfile->files,
use_asset_indexer ? &file_indexer_asset : &file_indexer_noop);
filelist_setindexer(
sfile->files, use_asset_indexer ? &asset::index::file_indexer_asset : &file_indexer_noop);
}
/* Update the active indices of bookmarks & co. */

View File

@@ -38,7 +38,7 @@ static bool node_add_menu_poll(const bContext *C, MenuType * /*mt*/)
static bool all_loading_finished()
{
AssetLibraryReference all_library_ref = asset_system::all_library_reference();
return ED_assetlist_is_loaded(&all_library_ref);
return asset::list::is_loaded(&all_library_ref);
}
static asset::AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree &node_tree)
@@ -194,7 +194,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
asset::operator_asset_reference_props_set(*asset, op_ptr);
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -270,7 +270,7 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
const Set<StringRef> all_builtin_menus = get_builtin_menus(edit_tree->type);
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;
@@ -295,7 +295,7 @@ MenuType add_catalog_assets_menu_type()
STRNCPY(type.idname, "NODE_MT_node_add_catalog_assets");
type.poll = node_add_menu_poll;
type.draw = node_add_catalog_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
return type;
}
@@ -306,7 +306,7 @@ MenuType add_unassigned_assets_menu_type()
STRNCPY(type.idname, "NODE_MT_node_add_unassigned_assets");
type.poll = node_add_menu_poll;
type.draw = node_add_unassigned_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
type.flag = MenuTypeFlag::ContextDependent;
type.description = N_(
"Node group assets not assigned to a catalog.\n"
@@ -320,7 +320,7 @@ MenuType add_root_catalogs_menu_type()
STRNCPY(type.idname, "NODE_MT_node_add_root_catalogs");
type.poll = node_add_menu_poll;
type.draw = add_root_catalogs_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.listener = asset::list::asset_reading_region_listen_fn;
return type;
}
@@ -338,7 +338,7 @@ void ui_template_node_asset_menu_items(uiLayout &layout,
if (!item) {
return;
}
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
asset_system::all_library_reference());
if (!all_library) {
return;

View File

@@ -238,9 +238,9 @@ static void gather_search_link_ops_for_asset_library(const bContext &C,
AssetFilterSettings filter_settings{};
filter_settings.id_types = FILTER_ID_NT;
ED_assetlist_storage_fetch(&library_ref, &C);
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
asset::list::storage_fetch(&library_ref, &C);
asset::list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!asset::filter_matches_asset(&filter_settings, asset)) {
return true;
}
if (skip_local && asset.is_local_id()) {

View File

@@ -1937,11 +1937,12 @@ static void view3d_tools_header_region_draw(const bContext *C, ARegion *region)
/* add handlers, stuff you only do once or on area/region changes */
static void view3d_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
{
using namespace blender::ed;
wmKeyMap *keymap = WM_keymap_ensure(
wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler(&region->handlers, keymap);
ED_asset_shelf_region_init(wm, region);
asset::shelf::region_init(wm, region);
}
/* area (not region) level listener */
@@ -2104,6 +2105,7 @@ static void view3d_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_view3d()
{
using namespace blender::ed;
SpaceType *st = MEM_cnew<SpaceType>("spacetype view3d");
ARegionType *art;
@@ -2196,29 +2198,29 @@ void ED_spacetype_view3d()
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf region");
art->regionid = RGN_TYPE_ASSET_SHELF;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES;
art->duplicate = ED_asset_shelf_region_duplicate;
art->free = ED_asset_shelf_region_free;
art->listener = ED_asset_shelf_region_listen;
art->poll = ED_asset_shelf_regions_poll;
art->snap_size = ED_asset_shelf_region_snap;
art->on_user_resize = ED_asset_shelf_region_on_user_resize;
art->context = ED_asset_shelf_context;
art->duplicate = asset::shelf::region_duplicate;
art->free = asset::shelf::region_free;
art->listener = asset::shelf::region_listen;
art->poll = asset::shelf::regions_poll;
art->snap_size = asset::shelf::region_snap;
art->on_user_resize = asset::shelf::region_on_user_resize;
art->context = asset::shelf::context;
art->init = view3d_asset_shelf_region_init;
art->layout = ED_asset_shelf_region_layout;
art->draw = ED_asset_shelf_region_draw;
art->layout = asset::shelf::region_layout;
art->draw = asset::shelf::region_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: asset shelf header */
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf header region");
art->regionid = RGN_TYPE_ASSET_SHELF_HEADER;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
art->init = ED_asset_shelf_header_region_init;
art->poll = ED_asset_shelf_regions_poll;
art->draw = ED_asset_shelf_header_region;
art->listener = ED_asset_shelf_header_region_listen;
art->context = ED_asset_shelf_context;
art->init = asset::shelf::header_region_init;
art->poll = asset::shelf::regions_poll;
art->draw = asset::shelf::header_region;
art->listener = asset::shelf::header_region_listen;
art->context = asset::shelf::context;
BLI_addhead(&st->regiontypes, art);
ED_asset_shelf_header_regiontype_register(art, SPACE_VIEW3D);
asset::shelf::header_regiontype_register(art, SPACE_VIEW3D);
/* regions: hud */
art = ED_area_type_hud(st->spaceid);

View File

@@ -205,6 +205,7 @@ static void ed_undo_step_post(bContext *C,
const enum eUndoStepDir undo_dir,
ReportList *reports)
{
using namespace blender::ed;
BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
Main *bmain = CTX_data_main(C);
@@ -249,7 +250,7 @@ static void ed_undo_step_post(bContext *C,
WM_toolsystem_refresh_active(C);
WM_toolsystem_refresh_screen_all(bmain);
ED_assetlist_storage_tag_main_data_dirty();
asset::list::storage_tag_main_data_dirty();
if (CLOG_CHECK(&LOG, 1)) {
BKE_undosys_print(wm->undo_stack);

View File

@@ -75,6 +75,7 @@ void ED_editors_init_for_undo(Main *bmain)
void ED_editors_init(bContext *C)
{
using namespace blender::ed;
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -205,7 +206,7 @@ void ED_editors_init(bContext *C)
}
}
ED_assetlist_storage_tag_main_data_dirty();
asset::list::storage_tag_main_data_dirty();
SWAP(int, reports->flag, reports_flag_prev);
wm->op_undo_depth--;

View File

@@ -156,6 +156,7 @@ static bool lib_id_generate_preview_poll(bContext *C)
static int lib_id_generate_preview_exec(bContext *C, wmOperator * /*op*/)
{
using namespace blender::ed;
PointerRNA idptr = CTX_data_pointer_get(C, "id");
ID *id = (ID *)idptr.data;
@@ -169,7 +170,7 @@ static int lib_id_generate_preview_exec(bContext *C, wmOperator * /*op*/)
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
WM_event_add_notifier(C, NC_ASSET | NA_EDITED, nullptr);
ED_assetlist_storage_tag_main_data_dirty();
asset::list::storage_tag_main_data_dirty();
return OPERATOR_FINISHED;
}
@@ -201,6 +202,7 @@ static bool lib_id_generate_preview_from_object_poll(bContext *C)
static int lib_id_generate_preview_from_object_exec(bContext *C, wmOperator * /*op*/)
{
using namespace blender::ed;
PointerRNA idptr = CTX_data_pointer_get(C, "id");
ID *id = (ID *)idptr.data;
@@ -213,7 +215,7 @@ static int lib_id_generate_preview_from_object_exec(bContext *C, wmOperator * /*
UI_icon_render_id_ex(C, nullptr, &object_to_render->id, ICON_SIZE_PREVIEW, true, preview_image);
WM_event_add_notifier(C, NC_ASSET | NA_EDITED, nullptr);
ED_assetlist_storage_tag_main_data_dirty();
asset::list::storage_tag_main_data_dirty();
return OPERATOR_FINISHED;
}

View File

@@ -198,9 +198,9 @@ typedef struct AssetWeakReference {
* into a type with PropertyGroup as base, so we can have an RNA collection of #AssetHandle's to
* pass to the UI.
*
* \warning Never store this! When using #ED_assetlist_iterate(), only access it within the
* iterator function. The contained file data can be freed since the file cache has a
* maximum number of items.
* \warning Never store this! When using #blender::ed::asset::list::iterate(), only access it
* within the iterator function. The contained file data can be freed since the file cache has a
* maximum number of items.
*/
#
#

View File

@@ -700,7 +700,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
static void rna_ID_asset_mark(ID *id)
{
if (ED_asset_mark_id(id)) {
if (blender::ed::asset::mark_id(id)) {
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
WM_main_add_notifier(NC_ASSET | NA_ADDED, nullptr);
}
@@ -708,7 +708,7 @@ static void rna_ID_asset_mark(ID *id)
static void rna_ID_asset_generate_preview(ID *id, bContext *C)
{
ED_asset_generate_preview(C, id);
blender::ed::asset::generate_preview(C, id);
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
WM_main_add_notifier(NC_ASSET | NA_EDITED, nullptr);
@@ -716,7 +716,7 @@ static void rna_ID_asset_generate_preview(ID *id, bContext *C)
static void rna_ID_asset_clear(ID *id)
{
if (ED_asset_clear_id(id)) {
if (blender::ed::asset::clear_id(id)) {
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
WM_main_add_notifier(NC_ASSET | NA_REMOVED, nullptr);
}
@@ -743,7 +743,7 @@ static void rna_ID_asset_data_set(PointerRNA *ptr, PointerRNA value, ReportList
return;
}
const bool assigned_ok = ED_asset_copy_to_id(asset_data, destination);
const bool assigned_ok = blender::ed::asset::copy_to_id(asset_data, destination);
if (!assigned_ok) {
BKE_reportf(
reports, RPT_ERROR, "'%s' is of a type that cannot be an asset", destination->name + 2);

View File

@@ -459,7 +459,7 @@ const EnumPropertyItem *rna_asset_library_reference_itemf(bContext * /*C*/,
PropertyRNA * /*prop*/,
bool *r_free)
{
const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(true);
const EnumPropertyItem *items = blender::ed::asset::library_reference_to_rna_enum_itemf(true);
if (!items) {
*r_free = false;
}

View File

@@ -2822,13 +2822,13 @@ static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr)
/* Just an extra sanity check to ensure this isn't somehow called for RNA_FileSelectParams. */
BLI_assert(ptr->type == &RNA_FileAssetSelectParams);
return ED_asset_library_reference_to_enum_value(&params->asset_library_ref);
return blender::ed::asset::library_reference_to_enum_value(&params->asset_library_ref);
}
static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int value)
{
FileAssetSelectParams *params = static_cast<FileAssetSelectParams *>(ptr->data);
params->asset_library_ref = ED_asset_library_reference_from_enum_value(value);
params->asset_library_ref = blender::ed::asset::library_reference_from_enum_value(value);
}
static PointerRNA rna_FileAssetSelectParams_filter_id_get(PointerRNA *ptr)

View File

@@ -1180,7 +1180,7 @@ static bool rna_AssetShelf_unregister(Main *bmain, StructRNA *type)
return false;
}
ED_asset_shelf_type_unlink(*bmain, *shelf_type);
blender::ed::asset::shelf::type_unlink(*bmain, *shelf_type);
RNA_struct_free_extension(type, &shelf_type->rna_ext);
RNA_struct_free(&BLENDER_RNA, type);
@@ -1284,13 +1284,15 @@ static StructRNA *rna_AssetShelf_refine(PointerRNA *shelf_ptr)
static int rna_AssetShelf_asset_library_get(PointerRNA *ptr)
{
AssetShelf *shelf = static_cast<AssetShelf *>(ptr->data);
return ED_asset_library_reference_to_enum_value(&shelf->settings.asset_library_reference);
return blender::ed::asset::library_reference_to_enum_value(
&shelf->settings.asset_library_reference);
}
static void rna_AssetShelf_asset_library_set(PointerRNA *ptr, int value)
{
AssetShelf *shelf = static_cast<AssetShelf *>(ptr->data);
shelf->settings.asset_library_reference = ED_asset_library_reference_from_enum_value(value);
shelf->settings.asset_library_reference = blender::ed::asset::library_reference_from_enum_value(
value);
}
static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)

View File

@@ -99,13 +99,13 @@ static void rna_WorkSpace_owner_ids_clear(WorkSpace *workspace)
static int rna_WorkSpace_asset_library_get(PointerRNA *ptr)
{
const WorkSpace *workspace = static_cast<WorkSpace *>(ptr->data);
return ED_asset_library_reference_to_enum_value(&workspace->asset_library_ref);
return blender::ed::asset::library_reference_to_enum_value(&workspace->asset_library_ref);
}
static void rna_WorkSpace_asset_library_set(PointerRNA *ptr, int value)
{
WorkSpace *workspace = static_cast<WorkSpace *>(ptr->data);
workspace->asset_library_ref = ED_asset_library_reference_from_enum_value(value);
workspace->asset_library_ref = blender::ed::asset::library_reference_from_enum_value(value);
}
static bToolRef *rna_WorkSpace_tools_from_tkey(WorkSpace *workspace,

View File

@@ -397,7 +397,7 @@ void WM_main_remove_notifier_reference(const void *reference)
static void wm_main_remap_assetlist(ID *old_id, ID *new_id, void * /*user_data*/)
{
ED_assetlist_storage_id_remap(old_id, new_id);
blender::ed::asset::list::storage_id_remap(old_id, new_id);
}
static void wm_main_remap_msgbus_notify(ID *old_id, ID *new_id, void *user_data)

View File

@@ -190,6 +190,7 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
Main *bmain,
const bool is_read_homefile)
{
using namespace blender;
BLI_assert(BLI_listbase_count_at_most(&bmain->wm, 2) <= 1);
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
BlendFileReadWMSetupData *wm_setup_data = MEM_cnew<BlendFileReadWMSetupData>(__func__);
@@ -239,7 +240,7 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
/* Asset loading is done by the UI/editors and they keep pointers into it. So make sure to clear
* it after UI/editors. */
ED_assetlist_storage_exit();
ed::asset::list::storage_exit();
AS_asset_libraries_exit();
/* NOTE: `wm_setup_data->old_wm` cannot be set here, as this pointer may be swapped with the
@@ -1952,7 +1953,7 @@ static bool wm_file_write(bContext *C,
return false;
}
ED_assets_pre_save(bmain);
blender::ed::asset::pre_save_assets(bmain);
/* Enforce full override check/generation on file save. */
BKE_lib_override_library_main_operations_create(bmain, true, nullptr);
@@ -2291,7 +2292,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
/* NOTE: either #BKE_CB_EVT_SAVE_POST or #BKE_CB_EVT_SAVE_POST_FAIL must run.
* Runs at the end of this function, don't return beforehand. */
BKE_callback_exec_string(bmain, BKE_CB_EVT_SAVE_PRE, "");
ED_assets_pre_save(bmain);
blender::ed::asset::pre_save_assets(bmain);
/* check current window and close it if temp */
if (win && WM_window_is_temp_screen(win)) {
@@ -4229,11 +4230,13 @@ static const char *close_file_dialog_name = "file_close_popup";
static void save_catalogs_when_file_is_closed_set_fn(bContext * /*C*/, void *arg1, void * /*arg2*/)
{
char *save_catalogs_when_file_is_closed = static_cast<char *>(arg1);
ED_asset_catalogs_set_save_catalogs_when_file_is_saved(*save_catalogs_when_file_is_closed != 0);
blender::ed::asset::catalogs_set_save_catalogs_when_file_is_saved(
*save_catalogs_when_file_is_closed != 0);
}
static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, void *arg1)
{
using namespace blender;
wmGenericCallback *post_action = (wmGenericCallback *)arg1;
Main *bmain = CTX_data_main(C);
@@ -4325,7 +4328,7 @@ static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, vo
if (AS_asset_library_has_any_unsaved_catalogs()) {
static char save_catalogs_when_file_is_closed;
save_catalogs_when_file_is_closed = ED_asset_catalogs_get_save_catalogs_when_file_is_saved();
save_catalogs_when_file_is_closed = ed::asset::catalogs_get_save_catalogs_when_file_is_saved();
/* Only the first checkbox should get extra separation. */
if (!has_extra_checkboxes) {

View File

@@ -461,6 +461,7 @@ void UV_clipboard_free();
void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_actions)
{
using namespace blender;
wmWindowManager *wm = C ? CTX_wm_manager(C) : nullptr;
/* While nothing technically prevents saving user data in background mode,
@@ -577,7 +578,7 @@ void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_
ED_preview_free_dbase(); /* frees a Main dbase, before BKE_blender_free! */
ED_preview_restart_queue_free();
ED_assetlist_storage_exit();
ed::asset::list::storage_exit();
BKE_tracking_clipboard_free();
BKE_mask_clipboard_free();