32#include "RNA_prototypes.hh"
43 std::optional<AssetWeakReference> active_asset_;
44 std::optional<asset_system::AssetCatalogFilter> catalog_filter_ = std::nullopt;
55 void set_catalog_filter(
const std::optional<asset_system::AssetCatalogFilter> &catalog_filter);
60 bool allow_asset_drag_ =
true;
81 std::optional<eWM_DragDataType>
get_drag_type()
const override;
87 : library_ref_(library_ref), shelf_(
shelf)
89 if (
shelf.type->get_active_asset) {
90 if (const AssetWeakReference *weak_ref = shelf.type->get_active_asset(shelf.type)) {
91 active_asset_ = *weak_ref;
94 active_asset_.reset();
107 if (shelf_.type->asset_poll && !shelf_.type->asset_poll(shelf_.type, &
asset)) {
112 if (catalog_filter_ && !catalog_filter_->contains(asset_data.
catalog_id)) {
127 if (!shelf_.type->drag_operator.empty()) {
159 const std::optional<asset_system::AssetCatalogFilter> &catalog_filter)
161 if (catalog_filter) {
162 catalog_filter_.emplace(*catalog_filter);
165 catalog_filter_ = std::nullopt;
178 if (!active_catalog) {
196 allow_asset_drag_ =
false;
214 PointerRNA *op_props = MEM_new<PointerRNA>(__func__);
238 MEM_delete(activate_op->opptr);
259 asset_.ensure_previewable();
261 const int preview_id = [&]() ->
int {
267 return ICON_PREVIEW_LOADING;
291 if (!asset_view.active_asset_) {
295 const bool matches = *asset_view.active_asset_ == weak_ref;
309 &
C, activate_op->optype, activate_op->opcontext, activate_op->opptr,
nullptr);
311 MEM_delete(activate_op->opptr);
318 return fnmatch(filter_string.
c_str(), asset_name.
c_str(), FNM_CASEFOLD) == 0;
326 if (!allow_asset_drag_ && shelf_type.
drag_operator.empty()) {
329 return std::make_unique<AssetDragController>(this->
get_view(), asset_);
340 return search_string;
360 std::unique_ptr asset_view = std::make_unique<AssetView>(library_ref,
shelf);
366 *block,
"asset shelf asset view", std::move(asset_view));
404 MEM_delete(drag_op->opptr);
410 ID *local_id = asset_.local_id();
412 return static_cast<void *
>(local_id);
421 import_settings.
method = import_method;
Main runtime representation of an asset.
ScrArea * CTX_wm_area(const bContext *C)
@ ASSET_SHELF_TYPE_FLAG_ACTIVATE_FOR_CONTEXT_MENU
@ 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_custom_set(uiBut *but, uiButToolTipCustomFunc func, void *arg, uiFreeArgFunc free_arg)
void UI_but_context_ptr_set(uiBlock *block, uiBut *but, blender::StringRef name, const PointerRNA *ptr)
void UI_but_operator_set_never_call(uiBut *but)
void UI_but_operator_set(uiBut *but, wmOperatorType *optype, blender::wm::OpCallContext opcontext, const PointerRNA *opptr=nullptr)
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)
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
std::optional< eWM_DragDataType > get_drag_type() const override
AssetDragController(ui::AbstractGridView &view, asset_system::AssetRepresentation &asset)
void on_drag_start(bContext &C) override
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
void on_activate(bContext &C) override
void disable_asset_drag()
AssetViewItem(asset_system::AssetRepresentation &asset_, StringRef identifier, StringRef label)
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
friend class AssetDragController
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
friend class AssetViewItem
AbstractGridView & get_view() const
bool matches(const AbstractViewItem &other) const override
ItemT & add_item(Args &&...args)
const GridViewStyle & get_style() const
ViewType & get_view() const
AbstractViewItemDragController(AbstractView &view)
uiButViewItem * view_item_but_
uiButViewItem * view_item_button() const
void always_reactivate_on_click()
void select_on_click_set()
void activate_for_context_menu_set()
void set_context_menu_title(const std::string &title)
void build_grid_view(const bContext &C, AbstractGridView &grid_view, uiLayout &layout, std::optional< StringRef > search_string={})
PreviewGridItem(StringRef identifier, StringRef label, int preview_icon_id)
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 iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
asset_system::AssetLibrary * library_get_once_available(const AssetLibraryReference &library_reference)
bool is_loaded(const AssetLibraryReference *library_reference)
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)
static std::optional< wmOperatorCallParams > create_asset_operator_params(const StringRefNull op_name, const asset_system::AssetRepresentation &asset)
void build_asset_view(uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C)
void asset_tooltip(const asset_system::AssetRepresentation &asset, uiTooltipData &tip, const bool include_name)
void operator_asset_reference_props_set(const asset_system::AssetRepresentation &asset, PointerRNA &ptr)
BIFIconID asset_preview_or_icon(const asset_system::AssetRepresentation &asset)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool use_instance_collections
eAssetImportMethod method
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)
std::string drag_operator
const AssetWeakReference *(* get_active_asset)(const AssetShelfType *shelf_type)
struct AssetShelfType * type
wmDragAsset * WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset, const AssetImportSettings &import_settings)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, blender::wm::OpCallContext 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)