Blender V4.5
blender::asset_system::AssetRepresentation Class Reference

#include <AS_asset_representation.hh>

Inherits blender::NonCopyable, and blender::NonMovable.

Public Member Functions

 AssetRepresentation (StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata, AssetLibrary &owner_asset_library)
 
 AssetRepresentation (StringRef relative_asset_path, ID &id, AssetLibrary &owner_asset_library)
 
 ~AssetRepresentation ()
 
AssetWeakReference make_weak_reference () const
 
void ensure_previewable ()
 
PreviewImageget_preview () const
 
StringRefNull get_name () const
 
ID_Type get_id_type () const
 
AssetMetaDataget_metadata () const
 
StringRefNull library_relative_identifier () const
 
std::string full_path () const
 
std::string full_library_path () const
 
std::optional< eAssetImportMethodget_import_method () const
 
bool may_override_import_method () const
 
bool get_use_relative_path () const
 
IDlocal_id () const
 
bool is_local_id () const
 
AssetLibraryowner_asset_library () const
 

Friends

class AssetLibrary
 

Detailed Description

Definition at line 35 of file AS_asset_representation.hh.

Constructor & Destructor Documentation

◆ AssetRepresentation() [1/2]

blender::asset_system::AssetRepresentation::AssetRepresentation ( StringRef relative_asset_path,
StringRef name,
int id_type,
std::unique_ptr< AssetMetaData > metadata,
AssetLibrary & owner_asset_library )

Constructs an asset representation for an external ID. The asset will not be editable.

Definition at line 27 of file asset_representation.cc.

◆ AssetRepresentation() [2/2]

blender::asset_system::AssetRepresentation::AssetRepresentation ( StringRef relative_asset_path,
ID & id,
AssetLibrary & owner_asset_library )

Constructs an asset representation for an ID stored in the current file. This makes the asset local and fully editable.

Definition at line 38 of file asset_representation.cc.

◆ ~AssetRepresentation()

blender::asset_system::AssetRepresentation::~AssetRepresentation ( )

Definition at line 50 of file asset_representation.cc.

References BKE_previewimg_cached_release(), and full_path().

Member Function Documentation

◆ ensure_previewable()

void blender::asset_system::AssetRepresentation::ensure_previewable ( )

Makes sure the asset ready to load a preview, if necessary.

For local IDs it calls BKE_previewimg_id_ensure(). For others, this sets loading information to the preview but doesn't actually load it. To load it, attach its #PreviewImageRuntime::icon_id to a UI button (UI loads it asynchronously then) or call BKE_previewimg_ensure() (not asynchronous).

Definition at line 64 of file asset_representation.cc.

References BKE_icon_preview_ensure(), BKE_previewimg_cached_thumbnail_read(), BKE_previewimg_id_ensure(), full_path(), local_id(), and THB_SOURCE_BLEND.

Referenced by asset_view_draw_item(), and blender::ed::asset::shelf::AssetViewItem::build_grid_tile().

◆ full_library_path()

◆ full_path()

std::string blender::asset_system::AssetRepresentation::full_path ( ) const

◆ get_id_type()

◆ get_import_method()

std::optional< eAssetImportMethod > blender::asset_system::AssetRepresentation::get_import_method ( ) const

Get the import method to use for this asset. A different one may be used if may_override_import_method() returns true, otherwise, the returned value must be used. If there is no import method predefined for this asset no value is returned.

Definition at line 143 of file asset_representation.cc.

References blender::asset_system::AssetLibrary::import_method_.

Referenced by blender::ed::asset::asset_local_id_ensure_imported(), asset_view_item_but_drag_set(), and blender::ed::asset::shelf::AssetDragController::create_drag_data().

◆ get_metadata()

◆ get_name()

◆ get_preview()

PreviewImage * blender::asset_system::AssetRepresentation::get_preview ( ) const

Get the preview of this asset.

This will only return a preview for local ID assets or after ensure_previewable() was called.

Definition at line 83 of file asset_representation.cc.

References BKE_previewimg_id_get(), and local_id().

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

◆ get_use_relative_path()

bool blender::asset_system::AssetRepresentation::get_use_relative_path ( ) const

◆ is_local_id()

bool blender::asset_system::AssetRepresentation::is_local_id ( ) const

◆ library_relative_identifier()

StringRefNull blender::asset_system::AssetRepresentation::library_relative_identifier ( ) const

◆ local_id()

ID * blender::asset_system::AssetRepresentation::local_id ( ) const

◆ make_weak_reference()

◆ may_override_import_method()

bool blender::asset_system::AssetRepresentation::may_override_import_method ( ) const

Returns if this asset may be imported with an import method other than the one returned by get_import_method(). Also returns true if there is no predefined import method (when get_import_method() returns no value).

Definition at line 148 of file asset_representation.cc.

References blender::asset_system::AssetLibrary::import_method_, and blender::asset_system::AssetLibrary::may_override_import_method_.

◆ owner_asset_library()

Friends And Related Symbol Documentation

◆ AssetLibrary

friend class AssetLibrary
friend

Definition at line 52 of file AS_asset_representation.hh.


The documentation for this class was generated from the following files: