Blender V5.0
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
8
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_listbase.h"
18#include "BLI_string_ref.hh"
19
20#include "BLT_translation.hh"
21
22#include "ED_asset.hh"
23#include "ED_asset_catalog.hh"
24#include "ED_fileselect.hh"
25#include "ED_undo.hh"
26
27#include "RNA_access.hh"
28
30#include "UI_resources.hh"
31#include "UI_tree_view.hh"
32
33#include "WM_api.hh"
34#include "WM_types.hh"
35
36#include "file_intern.hh"
37#include "filelist.hh"
38
39#include <fmt/format.h>
40
41using namespace blender::asset_system;
42
44
46
48 asset_system::AssetLibrary *asset_library_;
50 const asset_system::AssetCatalogTree *catalog_tree_;
51 FileAssetSelectParams *params_;
52 SpaceFile &space_file_;
53
57
58 public:
61 SpaceFile &space_file);
62
63 void build_tree() override;
64
65 void activate_catalog_by_id(CatalogID catalog_id);
66
67 private:
68 ui::BasicTreeViewItem &build_catalog_items_recursive(ui::TreeViewOrItem &view_parent_item,
69 const AssetCatalogTreeItem &catalog);
70
71 AssetCatalogTreeViewAllItem &add_all_item();
72 void add_unassigned_item();
73 bool is_active_catalog(CatalogID catalog_id) const;
74};
75
76/* ---------------------------------------------------------------------- */
77
80 const AssetCatalogTreeItem &catalog_item_;
81
82 public:
84
85 void on_activate(bContext &C) override;
86
87 void build_row(uiLayout &row) override;
88 void build_context_menu(bContext &C, uiLayout &column) const override;
89
90 bool supports_renaming() const override;
91 bool rename(const bContext &C, StringRefNull new_name) override;
92 void delete_item(bContext *C) override;
93
95 std::unique_ptr<ui::AbstractViewItemDragController> create_drag_controller() const override;
97 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
98};
99
101 const AssetCatalogTreeItem &catalog_item_;
102
103 public:
105 const AssetCatalogTreeItem &catalog_item);
106
107 std::optional<eWM_DragDataType> get_drag_type() const override;
108 void *create_drag_data() const override;
109 void on_drag_start(bContext &C) override;
110};
111
113 const AssetCatalogTreeItem &catalog_item_;
114
115 public:
117
118 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
119 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
120 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
121
123
124 static AssetCatalog *get_drag_catalog(const wmDrag &drag,
125 const asset_system::AssetLibrary &asset_library);
126 static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint);
127 static bool can_modify_catalogs(const asset_system::AssetLibrary &asset_library,
128 const char **r_disabled_hint);
129 static bool drop_assets_into_catalog(bContext *C,
130 const AssetCatalogTreeView &tree_view,
131 const wmDrag &drag,
132 CatalogID catalog_id,
133 StringRefNull simple_name = "");
138 const wmDrag &drag,
139 AssetCatalogTreeView &tree_view,
140 const std::optional<CatalogID> drop_catalog_id = std::nullopt);
141
142 private:
143 std::string drop_tooltip_asset_list(const wmDrag &drag) const;
144 std::string drop_tooltip_asset_catalog(const wmDrag &drag) const;
145};
146
152 using BasicTreeViewItem::BasicTreeViewItem;
153
154 void build_row(uiLayout &row) override;
155
156 struct DropTarget : public ui::TreeViewItemDropTarget {
157 DropTarget(AssetCatalogTreeViewAllItem &item);
158
159 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
160 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
161 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
162 };
163
164 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
165};
166
168 using BasicTreeViewItem::BasicTreeViewItem;
169
170 struct DropTarget : public ui::TreeViewItemDropTarget {
171 DropTarget(AssetCatalogTreeViewUnassignedItem &item);
172
173 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
174 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
175 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
176 };
177
178 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
179};
180
181/* ---------------------------------------------------------------------- */
182
185 SpaceFile &space_file)
186 : asset_library_(library), params_(params), space_file_(space_file)
187{
188 if (library) {
189 catalog_tree_ = &library->catalog_service().catalog_tree();
190 }
191 else {
192 catalog_tree_ = nullptr;
193 }
194}
195
197{
198 AssetCatalogTreeViewAllItem &all_item = add_all_item();
199 all_item.uncollapse_by_default();
200
201 if (catalog_tree_) {
202 /* Pass the "All" item on as parent of the actual catalog items. */
203 catalog_tree_->foreach_root_item([this, &all_item](const AssetCatalogTreeItem &item) {
204 build_catalog_items_recursive(all_item, item);
205 });
206 }
207
208 add_unassigned_item();
209}
210
211ui::BasicTreeViewItem &AssetCatalogTreeView::build_catalog_items_recursive(
212 ui::TreeViewOrItem &view_parent_item, const AssetCatalogTreeItem &catalog)
213{
214 ui::BasicTreeViewItem &view_item = view_parent_item.add_tree_item<AssetCatalogTreeViewItem>(
215 catalog);
216 view_item.set_is_active_fn(
217 [this, &catalog]() { return is_active_catalog(catalog.get_catalog_id()); });
218
219 catalog.foreach_child([&view_item, this](const AssetCatalogTreeItem &child) {
220 build_catalog_items_recursive(view_item, child);
221 });
222 return view_item;
223}
224
225AssetCatalogTreeViewAllItem &AssetCatalogTreeView::add_all_item()
226{
227 FileAssetSelectParams *params = params_;
228
230 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
231 params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
233 });
234 item.set_is_active_fn(
235 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS; });
236 return item;
237}
238
239void AssetCatalogTreeView::add_unassigned_item()
240{
241 FileAssetSelectParams *params = params_;
242
243 AssetCatalogTreeViewUnassignedItem &item = add_tree_item<AssetCatalogTreeViewUnassignedItem>(
244 IFACE_("Unassigned"), ICON_FILE_HIDDEN);
245
246 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
247 params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG;
249 });
250 item.set_is_active_fn(
251 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG; });
252}
253
255{
256 params_->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
257 params_->catalog_id = catalog_id;
259}
260
261bool AssetCatalogTreeView::is_active_catalog(CatalogID catalog_id) const
262{
264 (params_->catalog_id == catalog_id);
265}
266
267/* ---------------------------------------------------------------------- */
268
270 : BasicTreeViewItem(catalog_item.get_name()), catalog_item_(catalog_item)
271{
272}
273
275{
276 AssetCatalogTreeView &tree_view = static_cast<AssetCatalogTreeView &>(get_tree_view());
277 tree_view.activate_catalog_by_id(catalog_item_.get_catalog_id());
278}
279
281{
282 const std::string label_override = catalog_item_.has_unsaved_changes() ? (label_ + "*") : label_;
283 this->add_label(row, label_override);
284
285 if (!is_hovered()) {
286 return;
287 }
288
289 uiButViewItem *view_item_but = view_item_button();
290 PointerRNA *props;
291
293 (uiBut *)view_item_but, "ASSET_OT_catalog_new", wm::OpCallContext::InvokeDefault, ICON_ADD);
294 RNA_string_set(props, "parent_path", catalog_item_.catalog_path().c_str());
295}
296
298{
299 PointerRNA props;
300
301 props = column.op("ASSET_OT_catalog_new",
302 IFACE_("New Catalog"),
303 ICON_NONE,
306 RNA_string_set(&props, "parent_path", catalog_item_.catalog_path().c_str());
307
308 props = column.op("ASSET_OT_catalog_delete",
309 IFACE_("Delete Catalog"),
310 ICON_NONE,
313 RNA_string_set(&props, "catalog_id", catalog_item_.get_catalog_id().str().c_str());
314 column.op("UI_OT_view_item_rename", IFACE_("Rename"), ICON_NONE);
315
316 /* Doesn't actually exist right now, but could be defined in Python. Reason that this isn't done
317 * in Python yet is that catalogs are not exposed in BPY, and we'd somehow pass the clicked on
318 * catalog to the menu draw callback (via context probably). */
319 MenuType *mt = WM_menutype_find("ASSETBROWSER_MT_catalog_context_menu", true);
320 if (!mt) {
321 return;
322 }
323 UI_menutype_draw(&C, mt, &column);
324}
325
327{
328 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
329 this->get_tree_view());
330 return !asset::catalogs_read_only(*tree_view.asset_library_);
331}
332
334{
335 /* Important to keep state. */
336 BasicTreeViewItem::rename(C, new_name);
337
338 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
339 this->get_tree_view());
340 asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
341 return true;
342}
343
345{
346 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
347 this->get_tree_view());
348 ed::asset::catalog_remove(tree_view.asset_library_, catalog_item_.get_catalog_id());
349}
350
351std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewItem::create_drop_target()
352{
353 return std::make_unique<AssetCatalogDropTarget>(*this, catalog_item_);
354}
355
356std::unique_ptr<ui::AbstractViewItemDragController> AssetCatalogTreeViewItem::
358{
359 return std::make_unique<AssetCatalogDragController>(
360 static_cast<AssetCatalogTreeView &>(this->get_tree_view()), catalog_item_);
361}
362
363/* ---------------------------------------------------------------------- */
364
366 const AssetCatalogTreeItem &catalog_item)
367 : ui::TreeViewItemDropTarget(item), catalog_item_(catalog_item)
368{
369}
370
371bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disabled_hint) const
372{
373 if (drag.type == WM_DRAG_ASSET_CATALOG) {
375 if (!can_modify_catalogs(library, r_disabled_hint)) {
376 return false;
377 }
378
379 const AssetCatalog *drag_catalog = get_drag_catalog(drag, library);
380 /* NOTE: Technically it's not an issue to allow this (the catalog will just receive a new
381 * path and the catalog system will generate missing parents from the path). But it does
382 * appear broken to users, so disabling entirely. */
383 if (catalog_item_.catalog_path().is_contained_in(drag_catalog->path)) {
384 *r_disabled_hint = RPT_("Catalog cannot be dropped into itself");
385 return false;
386 }
387 if (catalog_item_.catalog_path() == drag_catalog->path.parent()) {
388 *r_disabled_hint = RPT_("Catalog is already placed inside this catalog");
389 return false;
390 }
391 return true;
392 }
393
394 if (drag.type == WM_DRAG_ASSET_LIST && has_droppable_asset(drag, r_disabled_hint)) {
395 return true;
396 }
397 return false;
398}
399
400std::string AssetCatalogDropTarget::drop_tooltip(const ui::DragInfo &drag_info) const
401{
402 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
403 return this->drop_tooltip_asset_catalog(drag_info.drag_data);
404 }
405 return this->drop_tooltip_asset_list(drag_info.drag_data);
406}
407
408std::string AssetCatalogDropTarget::drop_tooltip_asset_catalog(const wmDrag &drag) const
409{
411 const AssetCatalog *src_catalog = get_drag_catalog(drag, get_asset_library());
412
413 return fmt::format(fmt::runtime(TIP_("Move catalog {} into {}")),
414 src_catalog->path.name(),
415 catalog_item_.get_name());
416}
417
418std::string AssetCatalogDropTarget::drop_tooltip_asset_list(const wmDrag &drag) const
419{
421
422 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
423 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
424
425 /* Don't try to be smart by dynamically adding the 's' for the plural. Just makes translation
426 * harder, so use full literals. */
427 std::string basic_tip = is_multiple_assets ? TIP_("Move assets to catalog") :
428 TIP_("Move asset to catalog");
429
430 basic_tip += ": " + catalog_item_.get_name();
431
432 /* Display the full catalog path, but only if it's not exactly the same as the already shown name
433 * (i.e. not a root level catalog with no parent). */
434 if (catalog_item_.get_name() != catalog_item_.catalog_path().str()) {
435 basic_tip += " (" + catalog_item_.catalog_path().str() + ")";
436 }
437
438 return basic_tip;
439}
440
442{
443 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
445 this->get_view<AssetCatalogTreeView>(),
446 catalog_item_.get_catalog_id());
447 }
450 drag_info.drag_data,
451 catalog_item_.get_catalog_id(),
452 catalog_item_.get_simple_name());
453}
454
456 const wmDrag &drag,
457 AssetCatalogTreeView &tree_view,
458 const std::optional<CatalogID> drop_catalog_id)
459{
462 asset::catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
463 tree_view.activate_catalog_by_id(catalog_drag->drag_catalog_id);
464
466 return true;
467}
468
470 const AssetCatalogTreeView &tree_view,
471 const wmDrag &drag,
472 CatalogID catalog_id,
473 StringRefNull simple_name)
474{
476 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
477 if (!asset_drags) {
478 return false;
479 }
480
481 bool did_update = false;
482 LISTBASE_FOREACH (wmDragAssetListItem *, asset_item, asset_drags) {
483 if (asset_item->is_external) {
484 /* Only internal assets can be modified! */
485 continue;
486 }
487
488 did_update = true;
490 asset_item->asset_data.local_id->asset_data, catalog_id, simple_name.c_str());
491
492 /* Trigger re-run of filtering to update visible assets. */
493 filelist_tag_needs_filtering(tree_view.space_file_.files);
497 }
498
499 if (did_update) {
500 ED_undo_push(C, "Assign Asset Catalog");
501 }
502 return true;
503}
504
506 const wmDrag &drag, const asset_system::AssetLibrary &asset_library)
507{
508 if (drag.type != WM_DRAG_ASSET_CATALOG) {
509 return nullptr;
510 }
511 const AssetCatalogService &catalog_service = asset_library.catalog_service();
512 const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
513
514 return catalog_service.find_catalog(catalog_drag->drag_catalog_id);
515}
516
517bool AssetCatalogDropTarget::has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint)
518{
519 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
520
521 *r_disabled_hint = nullptr;
522 /* There needs to be at least one asset from the current file. */
523 LISTBASE_FOREACH (const wmDragAssetListItem *, asset_item, asset_drags) {
524 if (!asset_item->is_external) {
525 return true;
526 }
527 }
528
529 *r_disabled_hint = RPT_("Only assets from this current file can be moved between catalogs");
530 return false;
531}
532
534 const char **r_disabled_hint)
535{
536 if (asset::catalogs_read_only(library)) {
537 *r_disabled_hint = RPT_("Catalogs cannot be edited in this asset library");
538 return false;
539 }
540 return true;
541}
542
547
548/* ---------------------------------------------------------------------- */
549
551 const AssetCatalogTreeItem &catalog_item)
552 : ui::AbstractViewItemDragController(tree_view), catalog_item_(catalog_item)
553{
554}
555
556std::optional<eWM_DragDataType> AssetCatalogDragController::get_drag_type() const
557{
559}
560
562{
563 wmDragAssetCatalog *drag_catalog = (wmDragAssetCatalog *)MEM_callocN(sizeof(*drag_catalog),
564 __func__);
565 drag_catalog->drag_catalog_id = catalog_item_.get_catalog_id();
566 return drag_catalog;
567}
568
570{
572 tree_view_.activate_catalog_by_id(catalog_item_.get_catalog_id());
573}
574
575/* ---------------------------------------------------------------------- */
576
577void AssetCatalogTreeViewAllItem::build_row(uiLayout &row)
578{
580
581 PointerRNA *props;
582
583 UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
584 "ASSET_OT_catalogs_save",
586 ICON_FILE_TICK);
587
588 props = UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
589 "ASSET_OT_catalog_new",
591 ICON_ADD);
592 /* No parent path to use the root level. */
593 RNA_string_set(props, "parent_path", nullptr);
594}
595
596std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewAllItem::create_drop_target()
597{
598 return std::make_unique<AssetCatalogTreeViewAllItem::DropTarget>(*this);
599}
600
601AssetCatalogTreeViewAllItem::DropTarget::DropTarget(AssetCatalogTreeViewAllItem &item)
602 : ui::TreeViewItemDropTarget(item)
603{
604}
605
606bool AssetCatalogTreeViewAllItem::DropTarget::can_drop(const wmDrag &drag,
607 const char **r_disabled_hint) const
608{
609 if (drag.type != WM_DRAG_ASSET_CATALOG) {
610 return false;
611 }
612 asset_system::AssetLibrary &library = *this->get_view<AssetCatalogTreeView>().asset_library_;
613 if (!AssetCatalogDropTarget::can_modify_catalogs(library, r_disabled_hint)) {
614 return false;
615 }
616
617 const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(drag, library);
618 if (drag_catalog->path.parent() == "") {
619 *r_disabled_hint = RPT_("Catalog is already placed at the highest level");
620 return false;
621 }
622
623 return true;
624}
625
626std::string AssetCatalogTreeViewAllItem::DropTarget::drop_tooltip(
627 const ui::DragInfo &drag_info) const
628{
630 const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(
631 drag_info.drag_data, *this->get_view<AssetCatalogTreeView>().asset_library_);
632
633 return fmt::format(fmt::runtime(TIP_("Move catalog {} to the top level of the tree")),
634 drag_catalog->path.name());
635}
636
637bool AssetCatalogTreeViewAllItem::DropTarget::on_drop(bContext * /*C*/,
638 const ui::DragInfo &drag_info) const
639{
642 drag_info.drag_data,
643 this->get_view<AssetCatalogTreeView>(),
644 /* No value to drop into the root level. */
645 std::nullopt);
646}
647
648/* ---------------------------------------------------------------------- */
649
650std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewUnassignedItem::
652{
653 return std::make_unique<AssetCatalogTreeViewUnassignedItem::DropTarget>(*this);
654}
655
656AssetCatalogTreeViewUnassignedItem::DropTarget::DropTarget(
657 AssetCatalogTreeViewUnassignedItem &item)
658 : ui::TreeViewItemDropTarget(item)
659{
660}
661
662bool AssetCatalogTreeViewUnassignedItem::DropTarget::can_drop(const wmDrag &drag,
663 const char **r_disabled_hint) const
664{
665 if (drag.type != WM_DRAG_ASSET_LIST) {
666 return false;
667 }
668 return AssetCatalogDropTarget::has_droppable_asset(drag, r_disabled_hint);
669}
670
671std::string AssetCatalogTreeViewUnassignedItem::DropTarget::drop_tooltip(
672 const ui::DragInfo &drag_info) const
673{
674 const ListBase *asset_drags = WM_drag_asset_list_get(&drag_info.drag_data);
675 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
676
677 return is_multiple_assets ? TIP_("Move assets out of any catalog") :
678 TIP_("Move asset out of any catalog");
679}
680
681bool AssetCatalogTreeViewUnassignedItem::DropTarget::on_drop(bContext *C,
682 const ui::DragInfo &drag_info) const
683{
684 /* Assign to nil catalog ID. */
686 C, this->get_view<AssetCatalogTreeView>(), drag_info.drag_data, CatalogID{});
687}
688
689/* ---------------------------------------------------------------------- */
690
698
700{
701 return MEM_new<AssetCatalogFilterSettings>(__func__);
702}
703
705{
706 MEM_delete(*filter_settings);
707 *filter_settings = nullptr;
708}
709
711 AssetCatalogFilterSettings *filter_settings,
713 const ::bUUID &catalog_id)
714{
715 bool needs_update = false;
716
717 if (filter_settings->asset_catalog_visibility != catalog_visibility) {
718 filter_settings->asset_catalog_visibility = catalog_visibility;
719 needs_update = true;
720 }
721
723 !BLI_uuid_equal(filter_settings->asset_catalog_id, catalog_id))
724 {
725 filter_settings->asset_catalog_id = catalog_id;
726 needs_update = true;
727 }
728
729 return needs_update;
730}
731
733 const asset_system::AssetLibrary *asset_library)
734{
735 const AssetCatalogService &catalog_service = asset_library->catalog_service();
736
738 filter_settings->catalog_filter = std::make_unique<AssetCatalogFilter>(
739 catalog_service.create_catalog_filter(filter_settings->asset_catalog_id));
740 }
741}
742
744 const AssetCatalogFilterSettings *filter_settings, const AssetMetaData *asset_data)
745{
746 switch (filter_settings->asset_catalog_visibility) {
748 return !filter_settings->catalog_filter->is_known(asset_data->catalog_id);
750 return filter_settings->catalog_filter->contains(asset_data->catalog_id);
752 /* All asset files should be visible. */
753 return true;
754 }
755
757 return false;
758}
759
760/* ---------------------------------------------------------------------- */
761
763 asset_system::AssetLibrary *asset_library,
764 uiLayout *layout,
765 SpaceFile *space_file,
767{
768 uiBlock *block = layout->block();
769
770 ui::block_layout_set_current(block, layout);
771
773 *block,
774 "asset catalog tree view",
775 std::make_unique<ed::asset_browser::AssetCatalogTreeView>(
776 asset_library, params, *space_file));
777 tree_view->set_context_menu_title("Catalog");
778 ui::TreeViewBuilder::build_tree_view(*C, *tree_view, *layout);
779}
780
781} // 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:93
#define BLI_assert(a)
Definition BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
void void BLI_INLINE bool BLI_listbase_is_single(const ListBase *lb)
bool BLI_uuid_equal(bUUID uuid1, bUUID uuid2)
Definition uuid.cc:84
#define RPT_(msgid)
#define TIP_(msgid)
#define IFACE_(msgid)
struct ListBase ListBase
eFileSel_Params_AssetCatalogVisibility
@ FILE_SHOW_ASSETS_ALL_CATALOGS
@ FILE_SHOW_ASSETS_WITHOUT_CATALOG
@ FILE_SHOW_ASSETS_FROM_CATALOG
@ FILE_SEL_HIGHLIGHTED
@ FILE_SEL_SELECTED
struct FileAssetSelectParams FileAssetSelectParams
void ED_undo_push(bContext *C, const char *str)
Definition ed_undo.cc:98
#define C
Definition RandGen.cpp:29
blender::ui::AbstractGridView * UI_block_add_view(uiBlock &block, blender::StringRef idname, std::unique_ptr< blender::ui::AbstractGridView > grid_view)
PointerRNA * UI_but_extra_operator_icon_add(uiBut *but, blender::StringRefNull opname, blender::wm::OpCallContext opcontext, int icon)
#define UI_ITEM_NONE
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
#define ND_SPACE_ASSET_PARAMS
Definition WM_types.hh:525
@ WM_DRAG_ASSET_LIST
Definition WM_types.hh:1206
@ WM_DRAG_ASSET_CATALOG
Definition WM_types.hh:1220
#define NC_ASSET
Definition WM_types.hh:404
#define ND_ASSET_CATALOGS
Definition WM_types.hh:554
#define NC_SPACE
Definition WM_types.hh:392
#define ND_SPACE_FILE_LIST
Definition WM_types.hh:524
constexpr const char * c_str() const
AssetCatalogFilter create_catalog_filter(CatalogID active_catalog_id) const
AssetCatalog * find_catalog(CatalogID catalog_id) const
void foreach_child(ItemIterFn callback) const
AssetCatalogService & catalog_service() const
std::optional< eWM_DragDataType > get_drag_type() const override
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:644
virtual std::unique_ptr< TreeViewItemDropTarget > create_drop_target()
Definition tree_view.cc:634
uiButViewItem * view_item_button() const
void set_context_menu_title(const std::string &title)
BasicTreeViewItem(StringRef label, BIFIconID icon=ICON_NONE)
void build_row(uiLayout &row) override
void add_label(uiLayout &layout, StringRefNull label_override="")
void set_is_active_fn(IsActiveFn is_active_fn)
static void build_tree_view(const bContext &C, AbstractTreeView &tree_view, uiLayout &layout, bool add_box=true)
ItemT & add_tree_item(Args &&...args)
TreeViewItemDropTarget(AbstractTreeViewItem &view_item, DropBehavior behavior=DropBehavior::Insert)
Definition tree_view.cc:437
void file_select_deselect_all(SpaceFile *sfile, eDirEntry_SelectFlag flag)
Definition filesel.cc:1188
void filelist_tag_needs_filtering(FileList *filelist)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
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)
bool file_set_asset_catalog_filter_settings(AssetCatalogFilterSettings *filter_settings, eFileSel_Params_AssetCatalogVisibility catalog_visibility, const ::bUUID &catalog_id)
void file_create_asset_catalog_tree_view_in_layout(const bContext *C, asset_system::AssetLibrary *asset_library, uiLayout *layout, SpaceFile *space_file, FileAssetSelectParams *params)
void catalog_remove(asset_system::AssetLibrary *library, const asset_system::CatalogID &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)
TreeViewItemContainer TreeViewOrItem
void block_layout_set_current(uiBlock *block, uiLayout *layout)
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
const wmDrag & drag_data
uiBlock * block() const
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext context, eUI_Item_Flag flag)
eWM_DragDataType type
Definition WM_types.hh:1331
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 StringRef idname, bool quiet)