31#include "RNA_prototypes.hh"
42 std::optional<AssetWeakReference> active_asset_;
43 std::optional<asset_system::AssetCatalogFilter> catalog_filter_ = std::nullopt;
54 void set_catalog_filter(
const std::optional<asset_system::AssetCatalogFilter> &catalog_filter);
59 bool allow_asset_drag_ =
true;
88 : library_ref_(library_ref), shelf_(shelf)
92 active_asset_ = *weak_ref;
95 active_asset_.reset();
117 asset_handle, identifier, asset->
get_name(), preview_id);
135 if (catalog_filter_ && !catalog_filter_->contains(asset_data.
catalog_id)) {
156 const std::optional<asset_system::AssetCatalogFilter> &catalog_filter)
158 if (catalog_filter) {
159 catalog_filter_.emplace(*catalog_filter);
162 catalog_filter_ = std::nullopt;
175 if (!active_catalog) {
188 : ui::PreviewGridItem(identifier,
label, preview_icon_id), asset_(asset)
194 allow_asset_drag_ =
false;
212 PointerRNA *op_props = MEM_new<PointerRNA>(__func__);
226 &RNA_FileSelectEntry,
243 MEM_delete(activate_op->opptr);
253 [](
bContext * ,
void *argN,
const char * ) {
265 C, &asset_view.library_ref_,
const_cast<AssetHandle *
>(&asset_));
267 const int preview_id = [&]() ->
int {
294 if (!asset_view.active_asset_) {
299 const bool matches = *asset_view.active_asset_ == weak_ref;
313 &C, activate_op->optype, activate_op->opcontext, activate_op->opptr,
nullptr);
315 MEM_delete(activate_op->opptr);
322 return fnmatch(filter_string.
c_str(), asset_name.
c_str(), FNM_CASEFOLD) == 0;
327 if (!allow_asset_drag_) {
331 return std::make_unique<AssetDragController>(this->
get_view(), *asset);
342 return search_string;
364 std::unique_ptr asset_view = std::make_unique<AssetView>(library_ref, shelf);
370 *block,
"asset shelf asset view", std::move(asset_view));
382 : ui::AbstractViewItemDragController(view), asset_(asset)
395 return static_cast<void *
>(local_id);
Main runtime representation of an asset.
ScrArea * CTX_wm_area(const bContext *C)
@ ASSET_SHELF_TYPE_FLAG_NO_ASSET_DRAG
#define LISTBASE_FOREACH(type, var, list)
char char * BLI_strncpy_ensure_pad(char *__restrict dst, const char *__restrict src, char pad, size_t dst_maxncpy) ATTR_NONNULL(1
@ ASSET_IMPORT_APPEND_REUSE
blender::ui::AbstractGridView * UI_block_add_view(uiBlock &block, blender::StringRef idname, std::unique_ptr< blender::ui::AbstractGridView > grid_view)
bool UI_textbutton_activate_rna(const bContext *C, ARegion *region, const void *rna_poin_data, const char *rna_prop_id)
void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *arg, uiFreeArgFunc free_arg)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
void UI_but_operator_set(uiBut *but, wmOperatorType *optype, wmOperatorCallContext opcontext, const PointerRNA *opptr=nullptr)
void UI_but_context_ptr_set(uiBlock *block, uiBut *but, const char *name, const PointerRNA *ptr)
void UI_but_operator_set_never_call(uiBut *but)
void UI_but_view_item_draw_size_set(uiBut *but, const std::optional< int > draw_width=std::nullopt, const std::optional< int > draw_height=std::nullopt)
@ WM_OP_INVOKE_REGION_WIN
constexpr bool is_empty() const
constexpr const char * c_str() const
AssetCatalogFilter create_catalog_filter(CatalogID active_catalog_id) const
AssetCatalog * find_catalog_by_path(const AssetCatalogPath &path) const
const CatalogID catalog_id
AssetCatalogService & catalog_service() const
StringRefNull library_relative_identifier() const
AssetWeakReference make_weak_reference() const
std::optional< eAssetImportMethod > get_import_method() const
StringRefNull get_name() const
eWM_DragDataType get_drag_type() const override
AssetDragController(ui::AbstractGridView &view, asset_system::AssetRepresentation &asset)
void * create_drag_data() const override
void build_grid_tile(const bContext &C, uiLayout &layout) const override
bool should_be_filtered_visible(StringRefNull filter_string) const override
AssetViewItem(const AssetHandle &asset, StringRef identifier, StringRef label, int preview_icon_id)
void on_activate(bContext &C) override
void disable_asset_drag()
void build_context_menu(bContext &C, uiLayout &column) const override
std::unique_ptr< ui::AbstractViewItemDragController > create_drag_controller() const override
std::optional< bool > should_be_active() const override
bool begin_filtering(const bContext &C) const override
AssetView(const AssetLibraryReference &library_ref, const AssetShelf &shelf)
void set_catalog_filter(const std::optional< asset_system::AssetCatalogFilter > &catalog_filter)
void build_items() override
AbstractGridView & get_view() const
bool matches(const AbstractViewItem &other) const override
ItemT & add_item(Args &&...args)
const GridViewStyle & get_style() const
uiButViewItem * view_item_but_
uiButViewItem * view_item_button() const
void set_context_menu_title(const std::string &title)
void build_grid_view(const bContext &C, AbstractGridView &grid_view, const View2D &v2d, uiLayout &layout, std::optional< StringRef > search_string={})
void build_grid_tile_button(uiLayout &layout, BIFIconID override_preview_icon_id=ICON_NONE) const
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void asset_preview_ensure_requested(const bContext &C, const AssetLibraryReference *library_reference, AssetHandle *asset_handle)
bool asset_image_is_loading(const AssetLibraryReference *library_reference, const AssetHandle *asset_handle)
asset_system::AssetLibrary * library_get_once_available(const AssetLibraryReference &library_reference)
void iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn, FunctionRef< bool(asset_system::AssetRepresentation &)> prefilter_fn=nullptr)
void previews_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void build_asset_view(uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C, const ARegion ®ion)
static std::optional< wmOperatorCallParams > create_activate_operator_params(const StringRefNull op_name, const asset_system::AssetRepresentation &asset)
static std::optional< asset_system::AssetCatalogFilter > catalog_filter_from_shelf_settings(const AssetShelfSettings &shelf_settings, const asset_system::AssetLibrary &library)
int tile_height(const AssetShelfSettings &settings)
int tile_width(const AssetShelfSettings &settings)
static std::string filter_string_get(const AssetShelf &shelf)
std::string asset_tooltip(const asset_system::AssetRepresentation &asset, const bool include_name)
asset_system::AssetRepresentation * handle_get_representation(const AssetHandle *asset)
int handle_get_preview_or_type_icon_id(const AssetHandle *asset)
void operator_asset_reference_props_set(const asset_system::AssetRepresentation &asset, PointerRNA &ptr)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
const struct FileDirEntry * file_data
const char * active_catalog_path
std::string activate_operator
void(* draw_context_menu)(const bContext *C, const AssetShelfType *shelf_type, const blender::asset_system::AssetRepresentation *asset, uiLayout *layout)
bool(* asset_poll)(const AssetShelfType *shelf_type, const blender::asset_system::AssetRepresentation *asset)
const AssetWeakReference *(* get_active_asset)(const AssetShelfType *shelf_type)
struct AssetShelfType * type
AssetShelfSettings settings
wmDragAsset * WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset, int import_method)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)