Blender V4.3
asset_catalog_tree_view.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "DNA_space_types.h"
10
11#include "AS_asset_catalog.hh"
13#include "AS_asset_library.hh"
14
15#include "BKE_asset.hh"
16
17#include "BLI_string_ref.hh"
18
19#include "BLT_translation.hh"
20
21#include "ED_asset.hh"
22#include "ED_fileselect.hh"
23#include "ED_undo.hh"
24
25#include "RNA_access.hh"
26
27#include "UI_interface.hh"
28#include "UI_resources.hh"
29#include "UI_tree_view.hh"
30
31#include "WM_api.hh"
32#include "WM_types.hh"
33
34#include "file_intern.hh"
35#include "filelist.hh"
36
37#include <fmt/format.h>
38
39using namespace blender::asset_system;
40
42
44
46 asset_system::AssetLibrary *asset_library_;
48 const asset_system::AssetCatalogTree *catalog_tree_;
49 FileAssetSelectParams *params_;
50 SpaceFile &space_file_;
51
55
56 public:
59 SpaceFile &space_file);
60
61 void build_tree() override;
62
63 void activate_catalog_by_id(CatalogID catalog_id);
64
65 private:
66 ui::BasicTreeViewItem &build_catalog_items_recursive(ui::TreeViewOrItem &view_parent_item,
67 const AssetCatalogTreeItem &catalog);
68
69 AssetCatalogTreeViewAllItem &add_all_item();
70 void add_unassigned_item();
71 bool is_active_catalog(CatalogID catalog_id) const;
72};
73
74/* ---------------------------------------------------------------------- */
75
78 const AssetCatalogTreeItem &catalog_item_;
79
80 public:
82
83 void on_activate(bContext &C) override;
84
85 void build_row(uiLayout &row) override;
86 void build_context_menu(bContext &C, uiLayout &column) const override;
87
88 bool supports_renaming() const override;
89 bool rename(const bContext &C, StringRefNull new_name) override;
90
92 std::unique_ptr<ui::AbstractViewItemDragController> create_drag_controller() const override;
94 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
95};
96
98 const AssetCatalogTreeItem &catalog_item_;
99
100 public:
102 const AssetCatalogTreeItem &catalog_item);
103
104 eWM_DragDataType get_drag_type() const override;
105 void *create_drag_data() const override;
106 void on_drag_start() override;
107};
108
110 const AssetCatalogTreeItem &catalog_item_;
111
112 public:
114
115 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
116 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
117 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
118
120
121 static AssetCatalog *get_drag_catalog(const wmDrag &drag,
122 const asset_system::AssetLibrary &asset_library);
123 static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint);
124 static bool can_modify_catalogs(const asset_system::AssetLibrary &asset_library,
125 const char **r_disabled_hint);
126 static bool drop_assets_into_catalog(bContext *C,
127 const AssetCatalogTreeView &tree_view,
128 const wmDrag &drag,
129 CatalogID catalog_id,
130 StringRefNull simple_name = "");
135 const wmDrag &drag,
136 AssetCatalogTreeView &tree_view,
137 const std::optional<CatalogID> drop_catalog_id = std::nullopt);
138
139 private:
140 std::string drop_tooltip_asset_list(const wmDrag &drag) const;
141 std::string drop_tooltip_asset_catalog(const wmDrag &drag) const;
142};
143
149 using BasicTreeViewItem::BasicTreeViewItem;
150
151 void build_row(uiLayout &row) override;
152
153 struct DropTarget : public ui::TreeViewItemDropTarget {
154 DropTarget(AssetCatalogTreeViewAllItem &item);
155
156 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
157 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
158 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
159 };
160
161 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
162};
163
165 using BasicTreeViewItem::BasicTreeViewItem;
166
167 struct DropTarget : public ui::TreeViewItemDropTarget {
168 DropTarget(AssetCatalogTreeViewUnassignedItem &item);
169
170 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
171 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
172 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
173 };
174
175 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
176};
177
178/* ---------------------------------------------------------------------- */
179
182 SpaceFile &space_file)
183 : asset_library_(library), params_(params), space_file_(space_file)
184{
185 if (library) {
186 catalog_tree_ = &library->catalog_service().catalog_tree();
187 }
188 else {
189 catalog_tree_ = nullptr;
190 }
191}
192
194{
195 AssetCatalogTreeViewAllItem &all_item = add_all_item();
196 all_item.uncollapse_by_default();
197
198 if (catalog_tree_) {
199 /* Pass the "All" item on as parent of the actual catalog items. */
200 catalog_tree_->foreach_root_item([this, &all_item](const AssetCatalogTreeItem &item) {
201 build_catalog_items_recursive(all_item, item);
202 });
203 }
204
205 add_unassigned_item();
206}
207
208ui::BasicTreeViewItem &AssetCatalogTreeView::build_catalog_items_recursive(
209 ui::TreeViewOrItem &view_parent_item, const AssetCatalogTreeItem &catalog)
210{
211 ui::BasicTreeViewItem &view_item = view_parent_item.add_tree_item<AssetCatalogTreeViewItem>(
212 catalog);
213 view_item.set_is_active_fn(
214 [this, &catalog]() { return is_active_catalog(catalog.get_catalog_id()); });
215
216 catalog.foreach_child([&view_item, this](const AssetCatalogTreeItem &child) {
217 build_catalog_items_recursive(view_item, child);
218 });
219 return view_item;
220}
221
222AssetCatalogTreeViewAllItem &AssetCatalogTreeView::add_all_item()
223{
224 FileAssetSelectParams *params = params_;
225
227 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
228 params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
230 });
231 item.set_is_active_fn(
232 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS; });
233 return item;
234}
235
236void AssetCatalogTreeView::add_unassigned_item()
237{
238 FileAssetSelectParams *params = params_;
239
240 AssetCatalogTreeViewUnassignedItem &item = add_tree_item<AssetCatalogTreeViewUnassignedItem>(
241 IFACE_("Unassigned"), ICON_FILE_HIDDEN);
242
243 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
244 params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG;
246 });
247 item.set_is_active_fn(
248 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG; });
249}
250
257
258bool AssetCatalogTreeView::is_active_catalog(CatalogID catalog_id) const
259{
261 (params_->catalog_id == catalog_id);
262}
263
264/* ---------------------------------------------------------------------- */
265
267 : BasicTreeViewItem(catalog_item.get_name()), catalog_item_(catalog_item)
268{
269}
270
272{
273 AssetCatalogTreeView &tree_view = static_cast<AssetCatalogTreeView &>(get_tree_view());
274 tree_view.activate_catalog_by_id(catalog_item_.get_catalog_id());
275}
276
278{
279 const std::string label_override = catalog_item_.has_unsaved_changes() ? (label_ + "*") : label_;
280 this->add_label(row, label_override);
281
282 if (!is_hovered()) {
283 return;
284 }
285
286 uiButViewItem *view_item_but = view_item_button();
287 PointerRNA *props;
288
290 (uiBut *)view_item_but, "ASSET_OT_catalog_new", WM_OP_INVOKE_DEFAULT, ICON_ADD);
291 RNA_string_set(props, "parent_path", catalog_item_.catalog_path().c_str());
292}
293
295{
296 PointerRNA props;
297
298 uiItemFullO(&column,
299 "ASSET_OT_catalog_new",
300 IFACE_("New Catalog"),
301 ICON_NONE,
302 nullptr,
305 &props);
306 RNA_string_set(&props, "parent_path", catalog_item_.catalog_path().c_str());
307
308 uiItemFullO(&column,
309 "ASSET_OT_catalog_delete",
310 IFACE_("Delete Catalog"),
311 ICON_NONE,
312 nullptr,
315 &props);
316 RNA_string_set(&props, "catalog_id", catalog_item_.get_catalog_id().str().c_str());
317 uiItemO(&column, IFACE_("Rename"), ICON_NONE, "UI_OT_view_item_rename");
318
319 /* Doesn't actually exist right now, but could be defined in Python. Reason that this isn't done
320 * in Python yet is that catalogs are not exposed in BPY, and we'd somehow pass the clicked on
321 * catalog to the menu draw callback (via context probably). */
322 MenuType *mt = WM_menutype_find("ASSETBROWSER_MT_catalog_context_menu", true);
323 if (!mt) {
324 return;
325 }
326 UI_menutype_draw(&C, mt, &column);
327}
328
330{
331 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
332 this->get_tree_view());
333 return !asset::catalogs_read_only(*tree_view.asset_library_);
334}
335
337{
338 /* Important to keep state. */
339 BasicTreeViewItem::rename(C, new_name);
340
341 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
342 this->get_tree_view());
343 asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
344 return true;
345}
346
347std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewItem::create_drop_target()
348{
349 return std::make_unique<AssetCatalogDropTarget>(*this, catalog_item_);
350}
351
352std::unique_ptr<ui::AbstractViewItemDragController> AssetCatalogTreeViewItem::
354{
355 return std::make_unique<AssetCatalogDragController>(
356 static_cast<AssetCatalogTreeView &>(this->get_tree_view()), catalog_item_);
357}
358
359/* ---------------------------------------------------------------------- */
360
362 const AssetCatalogTreeItem &catalog_item)
363 : ui::TreeViewItemDropTarget(item), catalog_item_(catalog_item)
364{
365}
366
367bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disabled_hint) const
368{
369 if (drag.type == WM_DRAG_ASSET_CATALOG) {
371 if (!this->can_modify_catalogs(library, r_disabled_hint)) {
372 return false;
373 }
374
375 const AssetCatalog *drag_catalog = this->get_drag_catalog(drag, library);
376 /* NOTE: Technically it's not an issue to allow this (the catalog will just receive a new
377 * path and the catalog system will generate missing parents from the path). But it does
378 * appear broken to users, so disabling entirely. */
379 if (catalog_item_.catalog_path().is_contained_in(drag_catalog->path)) {
380 *r_disabled_hint = RPT_("Catalog cannot be dropped into itself");
381 return false;
382 }
383 if (catalog_item_.catalog_path() == drag_catalog->path.parent()) {
384 *r_disabled_hint = RPT_("Catalog is already placed inside this catalog");
385 return false;
386 }
387 return true;
388 }
389
390 if (drag.type == WM_DRAG_ASSET_LIST && has_droppable_asset(drag, r_disabled_hint)) {
391 return true;
392 }
393 return false;
394}
395
396std::string AssetCatalogDropTarget::drop_tooltip(const ui::DragInfo &drag_info) const
397{
398 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
399 return this->drop_tooltip_asset_catalog(drag_info.drag_data);
400 }
401 return this->drop_tooltip_asset_list(drag_info.drag_data);
402}
403
404std::string AssetCatalogDropTarget::drop_tooltip_asset_catalog(const wmDrag &drag) const
405{
407 const AssetCatalog *src_catalog = this->get_drag_catalog(drag, get_asset_library());
408
409 return fmt::format(
410 TIP_("Move catalog {} into {}"), src_catalog->path.name(), catalog_item_.get_name());
411}
412
413std::string AssetCatalogDropTarget::drop_tooltip_asset_list(const wmDrag &drag) const
414{
416
417 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
418 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
419
420 /* Don't try to be smart by dynamically adding the 's' for the plural. Just makes translation
421 * harder, so use full literals. */
422 std::string basic_tip = is_multiple_assets ? TIP_("Move assets to catalog") :
423 TIP_("Move asset to catalog");
424
425 basic_tip += ": " + catalog_item_.get_name();
426
427 /* Display the full catalog path, but only if it's not exactly the same as the already shown name
428 * (i.e. not a root level catalog with no parent). */
429 if (catalog_item_.get_name() != catalog_item_.catalog_path().str()) {
430 basic_tip += " (" + catalog_item_.catalog_path().str() + ")";
431 }
432
433 return basic_tip;
434}
435
437{
438 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
439 return this->drop_asset_catalog_into_catalog(drag_info.drag_data,
440 this->get_view<AssetCatalogTreeView>(),
441 catalog_item_.get_catalog_id());
442 }
443 return this->drop_assets_into_catalog(C,
445 drag_info.drag_data,
446 catalog_item_.get_catalog_id(),
447 catalog_item_.get_simple_name());
448}
449
451 const wmDrag &drag,
452 AssetCatalogTreeView &tree_view,
453 const std::optional<CatalogID> drop_catalog_id)
454{
457 asset::catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
458 tree_view.activate_catalog_by_id(catalog_drag->drag_catalog_id);
459
461 return true;
462}
463
465 const AssetCatalogTreeView &tree_view,
466 const wmDrag &drag,
467 CatalogID catalog_id,
468 StringRefNull simple_name)
469{
471 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
472 if (!asset_drags) {
473 return false;
474 }
475
476 bool did_update = false;
477 LISTBASE_FOREACH (wmDragAssetListItem *, asset_item, asset_drags) {
478 if (asset_item->is_external) {
479 /* Only internal assets can be modified! */
480 continue;
481 }
482
483 did_update = true;
485 asset_item->asset_data.local_id->asset_data, catalog_id, simple_name.c_str());
486
487 /* Trigger re-run of filtering to update visible assets. */
488 filelist_tag_needs_filtering(tree_view.space_file_.files);
492 }
493
494 if (did_update) {
495 ED_undo_push(C, "Assign Asset Catalog");
496 }
497 return true;
498}
499
501 const wmDrag &drag, const asset_system::AssetLibrary &asset_library)
502{
503 if (drag.type != WM_DRAG_ASSET_CATALOG) {
504 return nullptr;
505 }
506 const AssetCatalogService &catalog_service = asset_library.catalog_service();
507 const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
508
509 return catalog_service.find_catalog(catalog_drag->drag_catalog_id);
510}
511
512bool AssetCatalogDropTarget::has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint)
513{
514 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
515
516 *r_disabled_hint = nullptr;
517 /* There needs to be at least one asset from the current file. */
518 LISTBASE_FOREACH (const wmDragAssetListItem *, asset_item, asset_drags) {
519 if (!asset_item->is_external) {
520 return true;
521 }
522 }
523
524 *r_disabled_hint = RPT_("Only assets from this current file can be moved between catalogs");
525 return false;
526}
527
529 const char **r_disabled_hint)
530{
531 if (asset::catalogs_read_only(library)) {
532 *r_disabled_hint = RPT_("Catalogs cannot be edited in this asset library");
533 return false;
534 }
535 return true;
536}
537
542
543/* ---------------------------------------------------------------------- */
544
546 const AssetCatalogTreeItem &catalog_item)
547 : ui::AbstractViewItemDragController(tree_view), catalog_item_(catalog_item)
548{
549}
550
555
557{
558 wmDragAssetCatalog *drag_catalog = (wmDragAssetCatalog *)MEM_callocN(sizeof(*drag_catalog),
559 __func__);
560 drag_catalog->drag_catalog_id = catalog_item_.get_catalog_id();
561 return drag_catalog;
562}
563
569
570/* ---------------------------------------------------------------------- */
571
572void AssetCatalogTreeViewAllItem::build_row(uiLayout &row)
573{
575
576 PointerRNA *props;
577
578 UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
579 "ASSET_OT_catalogs_save",
581 ICON_FILE_TICK);
582
583 props = UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
584 "ASSET_OT_catalog_new",
586 ICON_ADD);
587 /* No parent path to use the root level. */
588 RNA_string_set(props, "parent_path", nullptr);
589}
590
591std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewAllItem::create_drop_target()
592{
593 return std::make_unique<AssetCatalogTreeViewAllItem::DropTarget>(*this);
594}
595
596AssetCatalogTreeViewAllItem::DropTarget::DropTarget(AssetCatalogTreeViewAllItem &item)
597 : ui::TreeViewItemDropTarget(item)
598{
599}
600
601bool AssetCatalogTreeViewAllItem::DropTarget::can_drop(const wmDrag &drag,
602 const char **r_disabled_hint) const
603{
604 if (drag.type != WM_DRAG_ASSET_CATALOG) {
605 return false;
606 }
607 asset_system::AssetLibrary &library = *this->get_view<AssetCatalogTreeView>().asset_library_;
608 if (!AssetCatalogDropTarget::can_modify_catalogs(library, r_disabled_hint)) {
609 return false;
610 }
611
612 const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(drag, library);
613 if (drag_catalog->path.parent() == "") {
614 *r_disabled_hint = RPT_("Catalog is already placed at the highest level");
615 return false;
616 }
617
618 return true;
619}
620
621std::string AssetCatalogTreeViewAllItem::DropTarget::drop_tooltip(
622 const ui::DragInfo &drag_info) const
623{
626 drag_info.drag_data, *this->get_view<AssetCatalogTreeView>().asset_library_);
627
628 return fmt::format(TIP_("Move catalog {} to the top level of the tree"),
629 drag_catalog->path.name());
630}
631
632bool AssetCatalogTreeViewAllItem::DropTarget::on_drop(bContext * /*C*/,
633 const ui::DragInfo &drag_info) const
634{
637 drag_info.drag_data,
638 this->get_view<AssetCatalogTreeView>(),
639 /* No value to drop into the root level. */
640 std::nullopt);
641}
642
643/* ---------------------------------------------------------------------- */
644
645std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewUnassignedItem::
646 create_drop_target()
647{
648 return std::make_unique<AssetCatalogTreeViewUnassignedItem::DropTarget>(*this);
649}
650
651AssetCatalogTreeViewUnassignedItem::DropTarget::DropTarget(
652 AssetCatalogTreeViewUnassignedItem &item)
653 : ui::TreeViewItemDropTarget(item)
654{
655}
656
657bool AssetCatalogTreeViewUnassignedItem::DropTarget::can_drop(const wmDrag &drag,
658 const char **r_disabled_hint) const
659{
660 if (drag.type != WM_DRAG_ASSET_LIST) {
661 return false;
662 }
663 return AssetCatalogDropTarget::has_droppable_asset(drag, r_disabled_hint);
664}
665
666std::string AssetCatalogTreeViewUnassignedItem::DropTarget::drop_tooltip(
667 const ui::DragInfo &drag_info) const
668{
669 const ListBase *asset_drags = WM_drag_asset_list_get(&drag_info.drag_data);
670 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
671
672 return is_multiple_assets ? TIP_("Move assets out of any catalog") :
673 TIP_("Move asset out of any catalog");
674}
675
676bool AssetCatalogTreeViewUnassignedItem::DropTarget::on_drop(bContext *C,
677 const ui::DragInfo &drag_info) const
678{
679 /* Assign to nil catalog ID. */
681 C, this->get_view<AssetCatalogTreeView>(), drag_info.drag_data, CatalogID{});
682}
683
684/* ---------------------------------------------------------------------- */
685
693
695{
696 return MEM_new<AssetCatalogFilterSettings>(__func__);
697}
698
700{
701 MEM_delete(*filter_settings);
702 *filter_settings = nullptr;
703}
704
706 AssetCatalogFilterSettings *filter_settings,
708 const ::bUUID &catalog_id)
709{
710 bool needs_update = false;
711
712 if (filter_settings->asset_catalog_visibility != catalog_visibility) {
713 filter_settings->asset_catalog_visibility = catalog_visibility;
714 needs_update = true;
715 }
716
718 !BLI_uuid_equal(filter_settings->asset_catalog_id, catalog_id))
719 {
720 filter_settings->asset_catalog_id = catalog_id;
721 needs_update = true;
722 }
723
724 return needs_update;
725}
726
728 const asset_system::AssetLibrary *asset_library)
729{
730 const AssetCatalogService &catalog_service = asset_library->catalog_service();
731
733 filter_settings->catalog_filter = std::make_unique<AssetCatalogFilter>(
734 catalog_service.create_catalog_filter(filter_settings->asset_catalog_id));
735 }
736}
737
739 const AssetCatalogFilterSettings *filter_settings, const AssetMetaData *asset_data)
740{
741 switch (filter_settings->asset_catalog_visibility) {
743 return !filter_settings->catalog_filter->is_known(asset_data->catalog_id);
745 return filter_settings->catalog_filter->contains(asset_data->catalog_id);
747 /* All asset files should be visible. */
748 return true;
749 }
750
752 return false;
753}
754
755/* ---------------------------------------------------------------------- */
756
758 uiLayout *layout,
759 SpaceFile *space_file,
761{
762 uiBlock *block = uiLayoutGetBlock(layout);
763
764 UI_block_layout_set_current(block, layout);
765
767 *block,
768 "asset catalog tree view",
769 std::make_unique<ed::asset_browser::AssetCatalogTreeView>(
770 asset_library, params, *space_file));
771 tree_view->set_context_menu_title("Catalog");
772 ui::TreeViewBuilder::build_tree_view(*tree_view, *layout);
773}
774
775} // namespace blender::ed::asset_browser
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_assert(a)
Definition BLI_assert.h:50
#define LISTBASE_FOREACH(type, var, list)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
bool BLI_uuid_equal(bUUID uuid1, bUUID uuid2)
Definition uuid.cc:84
#define RPT_(msgid)
#define TIP_(msgid)
#define IFACE_(msgid)
eFileSel_Params_AssetCatalogVisibility
@ FILE_SHOW_ASSETS_ALL_CATALOGS
@ FILE_SHOW_ASSETS_WITHOUT_CATALOG
@ FILE_SHOW_ASSETS_FROM_CATALOG
@ FILE_SEL_HIGHLIGHTED
@ FILE_SEL_SELECTED
void ED_undo_push(bContext *C, const char *str)
Definition ed_undo.cc:104
blender::ui::AbstractGridView * UI_block_add_view(uiBlock &block, blender::StringRef idname, std::unique_ptr< blender::ui::AbstractGridView > grid_view)
void uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, wmOperatorCallContext context, eUI_Item_Flag flag, PointerRNA *r_opptr)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
PointerRNA * UI_but_extra_operator_icon_add(uiBut *but, const char *opname, wmOperatorCallContext opcontext, int icon)
#define UI_ITEM_NONE
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
#define ND_SPACE_ASSET_PARAMS
Definition WM_types.hh:491
#define NC_ASSET
Definition WM_types.hh:371
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:218
#define ND_ASSET_CATALOGS
Definition WM_types.hh:520
eWM_DragDataType
Definition WM_types.hh:1152
@ WM_DRAG_ASSET_LIST
Definition WM_types.hh:1158
@ WM_DRAG_ASSET_CATALOG
Definition WM_types.hh:1172
#define NC_SPACE
Definition WM_types.hh:359
#define ND_SPACE_FILE_LIST
Definition WM_types.hh:490
constexpr const char * c_str() const
bool is_contained_in(const AssetCatalogPath &other_path) const
AssetCatalogFilter create_catalog_filter(CatalogID active_catalog_id) const
AssetCatalog * find_catalog(CatalogID catalog_id) const
void foreach_child(ItemIterFn callback) const
void foreach_root_item(ItemIterFn callback) const
AssetCatalogService & catalog_service() const
AssetCatalogDragController(AssetCatalogTreeView &tree_view, const AssetCatalogTreeItem &catalog_item)
bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override
static bool drop_asset_catalog_into_catalog(const wmDrag &drag, AssetCatalogTreeView &tree_view, const std::optional< CatalogID > drop_catalog_id=std::nullopt)
static AssetCatalog * get_drag_catalog(const wmDrag &drag, const asset_system::AssetLibrary &asset_library)
static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint)
static bool drop_assets_into_catalog(bContext *C, const AssetCatalogTreeView &tree_view, const wmDrag &drag, CatalogID catalog_id, StringRefNull simple_name="")
std::string drop_tooltip(const ui::DragInfo &drag_info) const override
static bool can_modify_catalogs(const asset_system::AssetLibrary &asset_library, const char **r_disabled_hint)
bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override
AssetCatalogDropTarget(AssetCatalogTreeViewItem &item, const AssetCatalogTreeItem &catalog_item)
eFileSel_Params_AssetCatalogVisibility asset_catalog_visibility
void build_context_menu(bContext &C, uiLayout &column) const override
AssetCatalogTreeViewItem(const AssetCatalogTreeItem &catalog_item)
bool rename(const bContext &C, StringRefNull new_name) override
std::unique_ptr< ui::AbstractViewItemDragController > create_drag_controller() const override
std::unique_ptr< ui::TreeViewItemDropTarget > create_drop_target() override
AssetCatalogTreeView(asset_system::AssetLibrary *library, FileAssetSelectParams *params, SpaceFile &space_file)
AbstractTreeView & get_tree_view() const
Definition tree_view.cc:565
uiButViewItem * view_item_button() const
void set_context_menu_title(const std::string &title)
void build_row(uiLayout &row) override
Definition tree_view.cc:947
void add_label(uiLayout &layout, StringRefNull label_override="")
Definition tree_view.cc:952
void set_is_active_fn(IsActiveFn is_active_fn)
Definition tree_view.cc:970
static void build_tree_view(AbstractTreeView &tree_view, uiLayout &layout, std::optional< StringRef > search_string={}, bool add_box=true)
Definition tree_view.cc:918
ItemT & add_tree_item(Args &&...args)
void file_select_deselect_all(SpaceFile *sfile, eDirEntry_SelectFlag flag)
Definition filesel.cc:1187
void filelist_tag_needs_filtering(FileList *filelist)
Definition filelist.cc:947
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
void file_ensure_updated_catalog_filter_data(AssetCatalogFilterSettings *filter_settings, const asset_system::AssetLibrary *asset_library)
AssetCatalogFilterSettings * file_create_asset_catalog_filter_settings()
bool file_is_asset_visible_in_catalog_filter_settings(const AssetCatalogFilterSettings *filter_settings, const AssetMetaData *asset_data)
void file_delete_asset_catalog_filter_settings(AssetCatalogFilterSettings **filter_settings)
void file_create_asset_catalog_tree_view_in_layout(asset_system::AssetLibrary *asset_library, uiLayout *layout, SpaceFile *space_file, FileAssetSelectParams *params)
bool file_set_asset_catalog_filter_settings(AssetCatalogFilterSettings *filter_settings, eFileSel_Params_AssetCatalogVisibility catalog_visibility, const ::bUUID &catalog_id)
bool catalogs_read_only(const asset_system::AssetLibrary &library)
void catalog_move(asset_system::AssetLibrary *library, asset_system::CatalogID src_catalog_id, std::optional< asset_system::CatalogID > dst_parent_catalog_id=std::nullopt)
void catalog_rename(asset_system::AssetLibrary *library, asset_system::CatalogID catalog_id, StringRefNull new_name)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct bUUID catalog_id
struct FileList * files
Universally Unique Identifier according to RFC4122.
const wmDrag & drag_data
eWM_DragDataType type
Definition WM_types.hh:1282
wmDragAssetCatalog * WM_drag_get_asset_catalog_data(const wmDrag *drag)
const ListBase * WM_drag_asset_list_get(const wmDrag *drag)
void WM_main_add_notifier(uint type, void *reference)
MenuType * WM_menutype_find(const char *idname, bool quiet)