Blender V4.5
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_fileselect.hh"
24#include "ED_undo.hh"
25
26#include "RNA_access.hh"
27
28#include "UI_interface.hh"
29#include "UI_resources.hh"
30#include "UI_tree_view.hh"
31
32#include "WM_api.hh"
33#include "WM_types.hh"
34
35#include "file_intern.hh"
36#include "filelist.hh"
37
38#include <fmt/format.h>
39
40using namespace blender::asset_system;
41
43
45
47 asset_system::AssetLibrary *asset_library_;
49 const asset_system::AssetCatalogTree *catalog_tree_;
50 FileAssetSelectParams *params_;
51 SpaceFile &space_file_;
52
56
57 public:
60 SpaceFile &space_file);
61
62 void build_tree() override;
63
64 void activate_catalog_by_id(CatalogID catalog_id);
65
66 private:
67 ui::BasicTreeViewItem &build_catalog_items_recursive(ui::TreeViewOrItem &view_parent_item,
68 const AssetCatalogTreeItem &catalog);
69
70 AssetCatalogTreeViewAllItem &add_all_item();
71 void add_unassigned_item();
72 bool is_active_catalog(CatalogID catalog_id) const;
73};
74
75/* ---------------------------------------------------------------------- */
76
79 const AssetCatalogTreeItem &catalog_item_;
80
81 public:
83
84 void on_activate(bContext &C) override;
85
86 void build_row(uiLayout &row) override;
87 void build_context_menu(bContext &C, uiLayout &column) const override;
88
89 bool supports_renaming() const override;
90 bool rename(const bContext &C, StringRefNull new_name) override;
91
93 std::unique_ptr<ui::AbstractViewItemDragController> create_drag_controller() const override;
95 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
96};
97
99 const AssetCatalogTreeItem &catalog_item_;
100
101 public:
103 const AssetCatalogTreeItem &catalog_item);
104
105 eWM_DragDataType get_drag_type() const override;
106 void *create_drag_data() const override;
107 void on_drag_start() override;
108};
109
111 const AssetCatalogTreeItem &catalog_item_;
112
113 public:
115
116 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
117 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
118 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
119
121
122 static AssetCatalog *get_drag_catalog(const wmDrag &drag,
123 const asset_system::AssetLibrary &asset_library);
124 static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint);
125 static bool can_modify_catalogs(const asset_system::AssetLibrary &asset_library,
126 const char **r_disabled_hint);
127 static bool drop_assets_into_catalog(bContext *C,
128 const AssetCatalogTreeView &tree_view,
129 const wmDrag &drag,
130 CatalogID catalog_id,
131 StringRefNull simple_name = "");
136 const wmDrag &drag,
137 AssetCatalogTreeView &tree_view,
138 const std::optional<CatalogID> drop_catalog_id = std::nullopt);
139
140 private:
141 std::string drop_tooltip_asset_list(const wmDrag &drag) const;
142 std::string drop_tooltip_asset_catalog(const wmDrag &drag) const;
143};
144
150 using BasicTreeViewItem::BasicTreeViewItem;
151
152 void build_row(uiLayout &row) override;
153
154 struct DropTarget : public ui::TreeViewItemDropTarget {
155 DropTarget(AssetCatalogTreeViewAllItem &item);
156
157 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
158 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
159 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
160 };
161
162 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
163};
164
166 using BasicTreeViewItem::BasicTreeViewItem;
167
168 struct DropTarget : public ui::TreeViewItemDropTarget {
169 DropTarget(AssetCatalogTreeViewUnassignedItem &item);
170
171 bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
172 std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
173 bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
174 };
175
176 std::unique_ptr<ui::TreeViewItemDropTarget> create_drop_target() override;
177};
178
179/* ---------------------------------------------------------------------- */
180
183 SpaceFile &space_file)
184 : asset_library_(library), params_(params), space_file_(space_file)
185{
186 if (library) {
187 catalog_tree_ = &library->catalog_service().catalog_tree();
188 }
189 else {
190 catalog_tree_ = nullptr;
191 }
192}
193
195{
196 AssetCatalogTreeViewAllItem &all_item = add_all_item();
197 all_item.uncollapse_by_default();
198
199 if (catalog_tree_) {
200 /* Pass the "All" item on as parent of the actual catalog items. */
201 catalog_tree_->foreach_root_item([this, &all_item](const AssetCatalogTreeItem &item) {
202 build_catalog_items_recursive(all_item, item);
203 });
204 }
205
206 add_unassigned_item();
207}
208
209ui::BasicTreeViewItem &AssetCatalogTreeView::build_catalog_items_recursive(
210 ui::TreeViewOrItem &view_parent_item, const AssetCatalogTreeItem &catalog)
211{
212 ui::BasicTreeViewItem &view_item = view_parent_item.add_tree_item<AssetCatalogTreeViewItem>(
213 catalog);
214 view_item.set_is_active_fn(
215 [this, &catalog]() { return is_active_catalog(catalog.get_catalog_id()); });
216
217 catalog.foreach_child([&view_item, this](const AssetCatalogTreeItem &child) {
218 build_catalog_items_recursive(view_item, child);
219 });
220 return view_item;
221}
222
223AssetCatalogTreeViewAllItem &AssetCatalogTreeView::add_all_item()
224{
225 FileAssetSelectParams *params = params_;
226
228 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
229 params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
231 });
232 item.set_is_active_fn(
233 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS; });
234 return item;
235}
236
237void AssetCatalogTreeView::add_unassigned_item()
238{
239 FileAssetSelectParams *params = params_;
240
241 AssetCatalogTreeViewUnassignedItem &item = add_tree_item<AssetCatalogTreeViewUnassignedItem>(
242 IFACE_("Unassigned"), ICON_FILE_HIDDEN);
243
244 item.set_on_activate_fn([params](bContext & /*C*/, ui::BasicTreeViewItem & /*item*/) {
245 params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG;
247 });
248 item.set_is_active_fn(
249 [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG; });
250}
251
253{
254 params_->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
255 params_->catalog_id = catalog_id;
257}
258
259bool AssetCatalogTreeView::is_active_catalog(CatalogID catalog_id) const
260{
262 (params_->catalog_id == catalog_id);
263}
264
265/* ---------------------------------------------------------------------- */
266
268 : BasicTreeViewItem(catalog_item.get_name()), catalog_item_(catalog_item)
269{
270}
271
273{
274 AssetCatalogTreeView &tree_view = static_cast<AssetCatalogTreeView &>(get_tree_view());
275 tree_view.activate_catalog_by_id(catalog_item_.get_catalog_id());
276}
277
279{
280 const std::string label_override = catalog_item_.has_unsaved_changes() ? (label_ + "*") : label_;
281 this->add_label(row, label_override);
282
283 if (!is_hovered()) {
284 return;
285 }
286
287 uiButViewItem *view_item_but = view_item_button();
288 PointerRNA *props;
289
291 (uiBut *)view_item_but, "ASSET_OT_catalog_new", WM_OP_INVOKE_DEFAULT, ICON_ADD);
292 RNA_string_set(props, "parent_path", catalog_item_.catalog_path().c_str());
293}
294
296{
297 PointerRNA props;
298
299 props = column.op("ASSET_OT_catalog_new",
300 IFACE_("New Catalog"),
301 ICON_NONE,
304 RNA_string_set(&props, "parent_path", catalog_item_.catalog_path().c_str());
305
306 props = column.op("ASSET_OT_catalog_delete",
307 IFACE_("Delete Catalog"),
308 ICON_NONE,
311 RNA_string_set(&props, "catalog_id", catalog_item_.get_catalog_id().str().c_str());
312 column.op("UI_OT_view_item_rename", IFACE_("Rename"), ICON_NONE);
313
314 /* Doesn't actually exist right now, but could be defined in Python. Reason that this isn't done
315 * in Python yet is that catalogs are not exposed in BPY, and we'd somehow pass the clicked on
316 * catalog to the menu draw callback (via context probably). */
317 MenuType *mt = WM_menutype_find("ASSETBROWSER_MT_catalog_context_menu", true);
318 if (!mt) {
319 return;
320 }
321 UI_menutype_draw(&C, mt, &column);
322}
323
325{
326 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
327 this->get_tree_view());
328 return !asset::catalogs_read_only(*tree_view.asset_library_);
329}
330
332{
333 /* Important to keep state. */
334 BasicTreeViewItem::rename(C, new_name);
335
336 const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
337 this->get_tree_view());
338 asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
339 return true;
340}
341
342std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewItem::create_drop_target()
343{
344 return std::make_unique<AssetCatalogDropTarget>(*this, catalog_item_);
345}
346
347std::unique_ptr<ui::AbstractViewItemDragController> AssetCatalogTreeViewItem::
349{
350 return std::make_unique<AssetCatalogDragController>(
351 static_cast<AssetCatalogTreeView &>(this->get_tree_view()), catalog_item_);
352}
353
354/* ---------------------------------------------------------------------- */
355
357 const AssetCatalogTreeItem &catalog_item)
358 : ui::TreeViewItemDropTarget(item), catalog_item_(catalog_item)
359{
360}
361
362bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disabled_hint) const
363{
364 if (drag.type == WM_DRAG_ASSET_CATALOG) {
366 if (!can_modify_catalogs(library, r_disabled_hint)) {
367 return false;
368 }
369
370 const AssetCatalog *drag_catalog = get_drag_catalog(drag, library);
371 /* NOTE: Technically it's not an issue to allow this (the catalog will just receive a new
372 * path and the catalog system will generate missing parents from the path). But it does
373 * appear broken to users, so disabling entirely. */
374 if (catalog_item_.catalog_path().is_contained_in(drag_catalog->path)) {
375 *r_disabled_hint = RPT_("Catalog cannot be dropped into itself");
376 return false;
377 }
378 if (catalog_item_.catalog_path() == drag_catalog->path.parent()) {
379 *r_disabled_hint = RPT_("Catalog is already placed inside this catalog");
380 return false;
381 }
382 return true;
383 }
384
385 if (drag.type == WM_DRAG_ASSET_LIST && has_droppable_asset(drag, r_disabled_hint)) {
386 return true;
387 }
388 return false;
389}
390
391std::string AssetCatalogDropTarget::drop_tooltip(const ui::DragInfo &drag_info) const
392{
393 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
394 return this->drop_tooltip_asset_catalog(drag_info.drag_data);
395 }
396 return this->drop_tooltip_asset_list(drag_info.drag_data);
397}
398
399std::string AssetCatalogDropTarget::drop_tooltip_asset_catalog(const wmDrag &drag) const
400{
402 const AssetCatalog *src_catalog = get_drag_catalog(drag, get_asset_library());
403
404 return fmt::format(fmt::runtime(TIP_("Move catalog {} into {}")),
405 src_catalog->path.name(),
406 catalog_item_.get_name());
407}
408
409std::string AssetCatalogDropTarget::drop_tooltip_asset_list(const wmDrag &drag) const
410{
412
413 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
414 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
415
416 /* Don't try to be smart by dynamically adding the 's' for the plural. Just makes translation
417 * harder, so use full literals. */
418 std::string basic_tip = is_multiple_assets ? TIP_("Move assets to catalog") :
419 TIP_("Move asset to catalog");
420
421 basic_tip += ": " + catalog_item_.get_name();
422
423 /* Display the full catalog path, but only if it's not exactly the same as the already shown name
424 * (i.e. not a root level catalog with no parent). */
425 if (catalog_item_.get_name() != catalog_item_.catalog_path().str()) {
426 basic_tip += " (" + catalog_item_.catalog_path().str() + ")";
427 }
428
429 return basic_tip;
430}
431
433{
434 if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) {
436 this->get_view<AssetCatalogTreeView>(),
437 catalog_item_.get_catalog_id());
438 }
441 drag_info.drag_data,
442 catalog_item_.get_catalog_id(),
443 catalog_item_.get_simple_name());
444}
445
447 const wmDrag &drag,
448 AssetCatalogTreeView &tree_view,
449 const std::optional<CatalogID> drop_catalog_id)
450{
453 asset::catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
454 tree_view.activate_catalog_by_id(catalog_drag->drag_catalog_id);
455
457 return true;
458}
459
461 const AssetCatalogTreeView &tree_view,
462 const wmDrag &drag,
463 CatalogID catalog_id,
464 StringRefNull simple_name)
465{
467 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
468 if (!asset_drags) {
469 return false;
470 }
471
472 bool did_update = false;
473 LISTBASE_FOREACH (wmDragAssetListItem *, asset_item, asset_drags) {
474 if (asset_item->is_external) {
475 /* Only internal assets can be modified! */
476 continue;
477 }
478
479 did_update = true;
481 asset_item->asset_data.local_id->asset_data, catalog_id, simple_name.c_str());
482
483 /* Trigger re-run of filtering to update visible assets. */
484 filelist_tag_needs_filtering(tree_view.space_file_.files);
488 }
489
490 if (did_update) {
491 ED_undo_push(C, "Assign Asset Catalog");
492 }
493 return true;
494}
495
497 const wmDrag &drag, const asset_system::AssetLibrary &asset_library)
498{
499 if (drag.type != WM_DRAG_ASSET_CATALOG) {
500 return nullptr;
501 }
502 const AssetCatalogService &catalog_service = asset_library.catalog_service();
503 const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
504
505 return catalog_service.find_catalog(catalog_drag->drag_catalog_id);
506}
507
508bool AssetCatalogDropTarget::has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint)
509{
510 const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
511
512 *r_disabled_hint = nullptr;
513 /* There needs to be at least one asset from the current file. */
514 LISTBASE_FOREACH (const wmDragAssetListItem *, asset_item, asset_drags) {
515 if (!asset_item->is_external) {
516 return true;
517 }
518 }
519
520 *r_disabled_hint = RPT_("Only assets from this current file can be moved between catalogs");
521 return false;
522}
523
525 const char **r_disabled_hint)
526{
527 if (asset::catalogs_read_only(library)) {
528 *r_disabled_hint = RPT_("Catalogs cannot be edited in this asset library");
529 return false;
530 }
531 return true;
532}
533
538
539/* ---------------------------------------------------------------------- */
540
542 const AssetCatalogTreeItem &catalog_item)
543 : ui::AbstractViewItemDragController(tree_view), catalog_item_(catalog_item)
544{
545}
546
551
553{
554 wmDragAssetCatalog *drag_catalog = (wmDragAssetCatalog *)MEM_callocN(sizeof(*drag_catalog),
555 __func__);
556 drag_catalog->drag_catalog_id = catalog_item_.get_catalog_id();
557 return drag_catalog;
558}
559
561{
563 tree_view_.activate_catalog_by_id(catalog_item_.get_catalog_id());
564}
565
566/* ---------------------------------------------------------------------- */
567
568void AssetCatalogTreeViewAllItem::build_row(uiLayout &row)
569{
571
572 PointerRNA *props;
573
574 UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
575 "ASSET_OT_catalogs_save",
577 ICON_FILE_TICK);
578
579 props = UI_but_extra_operator_icon_add(reinterpret_cast<uiBut *>(this->view_item_button()),
580 "ASSET_OT_catalog_new",
582 ICON_ADD);
583 /* No parent path to use the root level. */
584 RNA_string_set(props, "parent_path", nullptr);
585}
586
587std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewAllItem::create_drop_target()
588{
589 return std::make_unique<AssetCatalogTreeViewAllItem::DropTarget>(*this);
590}
591
592AssetCatalogTreeViewAllItem::DropTarget::DropTarget(AssetCatalogTreeViewAllItem &item)
593 : ui::TreeViewItemDropTarget(item)
594{
595}
596
597bool AssetCatalogTreeViewAllItem::DropTarget::can_drop(const wmDrag &drag,
598 const char **r_disabled_hint) const
599{
600 if (drag.type != WM_DRAG_ASSET_CATALOG) {
601 return false;
602 }
603 asset_system::AssetLibrary &library = *this->get_view<AssetCatalogTreeView>().asset_library_;
604 if (!AssetCatalogDropTarget::can_modify_catalogs(library, r_disabled_hint)) {
605 return false;
606 }
607
608 const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(drag, library);
609 if (drag_catalog->path.parent() == "") {
610 *r_disabled_hint = RPT_("Catalog is already placed at the highest level");
611 return false;
612 }
613
614 return true;
615}
616
617std::string AssetCatalogTreeViewAllItem::DropTarget::drop_tooltip(
618 const ui::DragInfo &drag_info) const
619{
621 const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(
622 drag_info.drag_data, *this->get_view<AssetCatalogTreeView>().asset_library_);
623
624 return fmt::format(fmt::runtime(TIP_("Move catalog {} to the top level of the tree")),
625 drag_catalog->path.name());
626}
627
628bool AssetCatalogTreeViewAllItem::DropTarget::on_drop(bContext * /*C*/,
629 const ui::DragInfo &drag_info) const
630{
633 drag_info.drag_data,
634 this->get_view<AssetCatalogTreeView>(),
635 /* No value to drop into the root level. */
636 std::nullopt);
637}
638
639/* ---------------------------------------------------------------------- */
640
641std::unique_ptr<ui::TreeViewItemDropTarget> AssetCatalogTreeViewUnassignedItem::
643{
644 return std::make_unique<AssetCatalogTreeViewUnassignedItem::DropTarget>(*this);
645}
646
647AssetCatalogTreeViewUnassignedItem::DropTarget::DropTarget(
648 AssetCatalogTreeViewUnassignedItem &item)
649 : ui::TreeViewItemDropTarget(item)
650{
651}
652
653bool AssetCatalogTreeViewUnassignedItem::DropTarget::can_drop(const wmDrag &drag,
654 const char **r_disabled_hint) const
655{
656 if (drag.type != WM_DRAG_ASSET_LIST) {
657 return false;
658 }
659 return AssetCatalogDropTarget::has_droppable_asset(drag, r_disabled_hint);
660}
661
662std::string AssetCatalogTreeViewUnassignedItem::DropTarget::drop_tooltip(
663 const ui::DragInfo &drag_info) const
664{
665 const ListBase *asset_drags = WM_drag_asset_list_get(&drag_info.drag_data);
666 const bool is_multiple_assets = !BLI_listbase_is_single(asset_drags);
667
668 return is_multiple_assets ? TIP_("Move assets out of any catalog") :
669 TIP_("Move asset out of any catalog");
670}
671
672bool AssetCatalogTreeViewUnassignedItem::DropTarget::on_drop(bContext *C,
673 const ui::DragInfo &drag_info) const
674{
675 /* Assign to nil catalog ID. */
677 C, this->get_view<AssetCatalogTreeView>(), drag_info.drag_data, CatalogID{});
678}
679
680/* ---------------------------------------------------------------------- */
681
689
691{
692 return MEM_new<AssetCatalogFilterSettings>(__func__);
693}
694
696{
697 MEM_delete(*filter_settings);
698 *filter_settings = nullptr;
699}
700
702 AssetCatalogFilterSettings *filter_settings,
704 const ::bUUID &catalog_id)
705{
706 bool needs_update = false;
707
708 if (filter_settings->asset_catalog_visibility != catalog_visibility) {
709 filter_settings->asset_catalog_visibility = catalog_visibility;
710 needs_update = true;
711 }
712
714 !BLI_uuid_equal(filter_settings->asset_catalog_id, catalog_id))
715 {
716 filter_settings->asset_catalog_id = catalog_id;
717 needs_update = true;
718 }
719
720 return needs_update;
721}
722
724 const asset_system::AssetLibrary *asset_library)
725{
726 const AssetCatalogService &catalog_service = asset_library->catalog_service();
727
729 filter_settings->catalog_filter = std::make_unique<AssetCatalogFilter>(
730 catalog_service.create_catalog_filter(filter_settings->asset_catalog_id));
731 }
732}
733
735 const AssetCatalogFilterSettings *filter_settings, const AssetMetaData *asset_data)
736{
737 switch (filter_settings->asset_catalog_visibility) {
739 return !filter_settings->catalog_filter->is_known(asset_data->catalog_id);
741 return filter_settings->catalog_filter->contains(asset_data->catalog_id);
743 /* All asset files should be visible. */
744 return true;
745 }
746
748 return false;
749}
750
751/* ---------------------------------------------------------------------- */
752
754 asset_system::AssetLibrary *asset_library,
755 uiLayout *layout,
756 SpaceFile *space_file,
758{
759 uiBlock *block = uiLayoutGetBlock(layout);
760
761 UI_block_layout_set_current(block, layout);
762
764 *block,
765 "asset catalog tree view",
766 std::make_unique<ed::asset_browser::AssetCatalogTreeView>(
767 asset_library, params, *space_file));
768 tree_view->set_context_menu_title("Catalog");
769 ui::TreeViewBuilder::build_tree_view(*C, *tree_view, *layout);
770}
771
772} // 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:99
#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, wmOperatorCallContext opcontext, int icon)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
#define UI_ITEM_NONE
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
#define ND_SPACE_ASSET_PARAMS
Definition WM_types.hh:522
#define NC_ASSET
Definition WM_types.hh:401
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:238
#define ND_ASSET_CATALOGS
Definition WM_types.hh:551
eWM_DragDataType
Definition WM_types.hh:1197
@ WM_DRAG_ASSET_LIST
Definition WM_types.hh:1203
@ WM_DRAG_ASSET_CATALOG
Definition WM_types.hh:1217
#define NC_SPACE
Definition WM_types.hh:389
#define ND_SPACE_FILE_LIST
Definition WM_types.hh:521
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
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:620
virtual std::unique_ptr< TreeViewItemDropTarget > create_drop_target()
Definition tree_view.cc:610
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, std::optional< StringRef > search_string={}, bool add_box=true)
Definition tree_view.cc:980
ItemT & add_tree_item(Args &&...args)
TreeViewItemDropTarget(AbstractTreeViewItem &view_item, DropBehavior behavior=DropBehavior::Insert)
Definition tree_view.cc:394
void file_select_deselect_all(SpaceFile *sfile, eDirEntry_SelectFlag flag)
Definition filesel.cc:1196
void filelist_tag_needs_filtering(FileList *filelist)
Definition filelist.cc:945
#define this
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)
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 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
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
eWM_DragDataType type
Definition WM_types.hh:1327
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)