Blender V5.0
blender::ed::asset::list Namespace Reference

Classes

class  FileListWrapper
class  AssetList
struct  GlobalStorage

Typedefs

using AssetListIterFn = FunctionRef<bool(asset_system::AssetRepresentation &)>

Functions

void asset_reading_region_listen_fn (const wmRegionListenerParams *params)
C-API
asset_system::AssetLibrarylibrary_get_once_available (const AssetLibraryReference &library_reference)
void iterate (const AssetLibraryReference &library_reference, AssetListIterFn fn)
void storage_fetch (const AssetLibraryReference *library_reference, const bContext *C)
void storage_fetch_blocking (const AssetLibraryReference &library_reference, const bContext &C)
bool is_loaded (const AssetLibraryReference *library_reference)
void clear (const AssetLibraryReference *library_reference, const bContext *C)
void clear_all_library (const bContext *C)
bool has_list_storage_for_library (const AssetLibraryReference *library_reference)
bool has_asset_browser_storage_for_library (const AssetLibraryReference *library_reference, const bContext *C)
void storage_exit ()
bool listen (const wmNotifier *notifier)
int size (const AssetLibraryReference *library_reference)
static void foreach_visible_asset_browser_showing_library (const AssetLibraryReference &library_reference, const wmWindowManager *wm, const FunctionRef< void(SpaceFile &sfile)> fn)

Runtime asset list cache

using AssetListMap = Map<AssetLibraryReference, AssetList>
using is_new_t = bool
void storage_tag_main_data_dirty ()
void storage_id_remap (ID *id_old, ID *id_new)
static void clear (const AssetLibraryReference *library_reference, wmWindowManager *wm)
static void on_save_post (Main *main, PointerRNA **pointers, int num_pointers, void *arg)
static AssetListMaplibraries_map ()
static AssetListlookup_list (const AssetLibraryReference &library_ref)
static std::optional< eFileSelectTypeasset_library_reference_to_fileselect_type (const AssetLibraryReference &library_reference)
static std::tuple< AssetList &, is_new_tensure_list_storage (const AssetLibraryReference &library_reference, eFileSelectType filesel_type)

Typedef Documentation

◆ AssetListIterFn

Can return false to stop iterating.

Definition at line 40 of file ED_asset_list.hh.

◆ AssetListMap

A global asset list map, each entry being a list for a specific asset library.

Definition at line 299 of file asset_list.cc.

◆ is_new_t

Definition at line 358 of file asset_list.cc.

Function Documentation

◆ asset_library_reference_to_fileselect_type()

std::optional< eFileSelectType > blender::ed::asset::list::asset_library_reference_to_fileselect_type ( const AssetLibraryReference & library_reference)
static

◆ asset_reading_region_listen_fn()

◆ clear() [1/2]

void blender::ed::asset::list::clear ( const AssetLibraryReference * library_reference,
const bContext * C )

Clears this asset library and the "All" asset library for reload in both the static asset list storage, as well as for all open asset browsers. Call this whenever the content of the given asset library changed in a way that a reload is necessary.

Definition at line 502 of file asset_list.cc.

References C, clear(), and CTX_wm_manager().

Referenced by blender::ed::asset::asset_library_refresh_exec(), clear(), clear_all_library(), on_save_post(), and blender::ed::asset::refresh_asset_library().

◆ clear() [2/2]

◆ clear_all_library()

void blender::ed::asset::list::clear_all_library ( const bContext * C)

Clears the all asset library for reload in both the static asset list storage, as well as for all open asset browsers. Call this whenever any asset library content changed in a way that a reload is necessary.

Definition at line 507 of file asset_list.cc.

References blender::asset_system::all_library_reference(), C, clear(), and CTX_wm_manager().

Referenced by preferences_asset_library_add_exec(), and preferences_asset_library_remove_exec().

◆ ensure_list_storage()

◆ foreach_visible_asset_browser_showing_library()

void blender::ed::asset::list::foreach_visible_asset_browser_showing_library ( const AssetLibraryReference & library_reference,
const wmWindowManager * wm,
const FunctionRef< void(SpaceFile &sfile)> fn )
static

◆ has_asset_browser_storage_for_library()

bool blender::ed::asset::list::has_asset_browser_storage_for_library ( const AssetLibraryReference * library_reference,
const bContext * C )

Returns if any asset browser is visible showing the given asset library. Asset browsers are not really handled by this API, but for convenience of managing clearing it's handled here together with has_list_storage_for_library().

Definition at line 518 of file asset_list.cc.

References C, CTX_wm_manager(), and foreach_visible_asset_browser_showing_library().

Referenced by blender::ed::asset::asset_library_refresh_poll().

◆ has_list_storage_for_library()

bool blender::ed::asset::list::has_list_storage_for_library ( const AssetLibraryReference * library_reference)

Returns if the given asset library in global asset list storage.

Definition at line 513 of file asset_list.cc.

References lookup_list().

Referenced by blender::ed::asset::asset_library_refresh_poll().

◆ is_loaded()

◆ iterate()

◆ libraries_map()

AssetListMap & blender::ed::asset::list::libraries_map ( )
static

Wrapper for Construct on First Use idiom, to avoid the Static Initialization Fiasco.

Definition at line 317 of file asset_list.cc.

References blender::ed::asset::list::GlobalStorage::list_map.

Referenced by ensure_list_storage(), lookup_list(), storage_exit(), storage_id_remap(), and storage_tag_main_data_dirty().

◆ library_get_once_available()

asset_system::AssetLibrary * blender::ed::asset::list::library_get_once_available ( const AssetLibraryReference & library_reference)

Get the asset library being read into an asset-list and identified using library_reference.

Note
The asset library may be allocated and loaded asynchronously, so it's not available right after fetching, and this function will return null. The asset list code sends NC_ASSET | 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.

Definition at line 538 of file asset_list.cc.

References lookup_list().

Referenced by blender::ed::asset::shelf::build_asset_view(), blender::ed::asset::build_filtered_all_catalog_tree(), blender::ed::asset::shelf::AssetView::build_items(), blender::ed::geometry::catalog_assets_draw(), blender::ed::asset::shelf::catalog_selector_panel_draw(), blender::ed::asset::shelf::catalog_tree_draw(), blender::ed::asset::find_asset_from_weak_ref(), blender::ed::object::ui_template_modifier_asset_menu_items(), and blender::ed::geometry::ui_template_node_operator_asset_menu_items().

◆ listen()

bool blender::ed::asset::list::listen ( const wmNotifier * notifier)
Returns
True if the region needs a UI redraw.

Definition at line 548 of file asset_list.cc.

References blender::ed::asset::list::AssetList::listen().

Referenced by blender::ed::asset::shelf::region_listen().

◆ lookup_list()

◆ on_save_post()

void blender::ed::asset::list::on_save_post ( Main * main,
PointerRNA ** pointers,
int num_pointers,
void * arg )
static

◆ size()

int blender::ed::asset::list::size ( const AssetLibraryReference * library_reference)
Returns
The number of assets stored in the asset list for library_reference, or -1 if there is no list fetched for it.

Definition at line 553 of file asset_list.cc.

References lookup_list().

◆ storage_exit()

void blender::ed::asset::list::storage_exit ( )

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.

Definition at line 562 of file asset_list.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::clear(), and libraries_map().

Referenced by WM_exit_ex(), and wm_file_read_setup_wm_init().

◆ storage_fetch()

void blender::ed::asset::list::storage_fetch ( const AssetLibraryReference * library_reference,
const bContext * C )

Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done, and may return earlier.

See also
: storage_fetch_blocking for a blocking version.
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.

Definition at line 402 of file asset_list.cc.

References asset_library_reference_to_fileselect_type(), C, and ensure_list_storage().

Referenced by blender::ed::asset::shelf::asset_shelf_header_draw(), blender::ed::asset::shelf::build_asset_view(), blender::ed::asset::build_filtered_all_catalog_tree(), blender::ed::asset::shelf::ensure_asset_library_fetched(), blender::ed::asset::find_asset_from_weak_ref(), blender::ed::space_node::gather_search_link_ops_for_all_assets(), and blender::ed::asset::get_local_asset_from_relative_identifier().

◆ storage_fetch_blocking()

void blender::ed::asset::list::storage_fetch_blocking ( const AssetLibraryReference & library_reference,
const bContext & C )

Invoke asset list reading, guaranteed to execute on the same thread.

See also
storage_fetch for an asynchronous version.

Definition at line 416 of file asset_list.cc.

References asset_library_reference_to_fileselect_type(), C, and ensure_list_storage().

Referenced by blender::ed::sculpt_paint::brush_asset_activate_exec(), and blender::ed::object::shade_auto_smooth_exec().

◆ storage_id_remap()

void blender::ed::asset::list::storage_id_remap ( ID * id_old,
ID * id_new )

Remapping of ID pointers within the asset lists. Typically called when an ID is deleted to clear all references to it (id_new is null then).

Definition at line 335 of file asset_list.cc.

References libraries_map().

Referenced by WM_main_remap_editor_id_reference().

◆ storage_tag_main_data_dirty()

void blender::ed::asset::list::storage_tag_main_data_dirty ( )

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 listen() to check if the asset-list needs a redraw for a given notifier.

Definition at line 328 of file asset_list.cc.

References libraries_map().

Referenced by blender::ed::asset::clear_id(), ED_editors_init(), ed_undo_step_post(), lib_id_generate_preview_exec(), lib_id_generate_preview_from_object_exec(), blender::ed::asset::mark_id(), and blender::ed::asset::screenshot_preview_exec().