Blender  V3.3
Functions
asset_library_reference_enum.cc File Reference
#include "BLI_listbase.h"
#include "BKE_preferences.h"
#include "DNA_userdef_types.h"
#include "UI_resources.h"
#include "RNA_define.h"
#include "ED_asset_library.h"

Go to the source code of this file.

Functions

int ED_asset_library_reference_to_enum_value (const AssetLibraryReference *library)
 
AssetLibraryReference ED_asset_library_reference_from_enum_value (int value)
 
const EnumPropertyItem * ED_asset_library_reference_to_rna_enum_itemf (const bool include_local_library)
 

Detailed Description

Helpers to convert asset library references from and to enum values and RNA enums. In some cases it's simply not possible to reference an asset library with #AssetLibraryReferences. This API guarantees a safe translation to indices/enum values for as long as there is no change in the order of registered custom asset libraries.

Definition in file asset_library_reference_enum.cc.

Function Documentation

◆ ED_asset_library_reference_from_enum_value()

AssetLibraryReference ED_asset_library_reference_from_enum_value ( int  value)

◆ ED_asset_library_reference_to_enum_value()

int ED_asset_library_reference_to_enum_value ( const AssetLibraryReference *  library)

Return an index that can be used to uniquely identify library, assuming that all relevant indices were created with this function.

Definition at line 24 of file asset_library_reference_enum.cc.

References ASSET_LIBRARY_CUSTOM, ASSET_LIBRARY_LOCAL, BKE_preferences_asset_library_find_from_index(), and library.

Referenced by ED_asset_library_reference_to_rna_enum_itemf().

◆ ED_asset_library_reference_to_rna_enum_itemf()

const EnumPropertyItem* ED_asset_library_reference_to_rna_enum_itemf ( bool  include_local_library)

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.

Since this is meant for UI display, skips non-displayable libraries, that is, libraries with an empty name or path.

Parameters
include_local_libraryWhether to include the "Current File" library or not.

Definition at line 73 of file asset_library_reference_enum.cc.

References ASSET_LIBRARY_CUSTOM, ASSET_LIBRARY_LOCAL, BLI_listbase_is_empty(), AssetLibraryReference::custom_library_index, ED_asset_library_reference_to_enum_value(), is_valid, EnumPropertyItem::name, bUserAssetLibrary::next, RNA_enum_item_add(), RNA_enum_item_add_separator(), RNA_enum_item_end(), RNA_enum_items_add(), and AssetLibraryReference::type.

Referenced by rna_asset_library_reference_itemf().