Blender V5.3
ED_asset_library_ui.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "UI_tree_view.hh"
12
13namespace blender {
14
16
31
41
49
54template<typename AssetLibraryListItemType,
55 typename AssetLibraryRepoItemType = AssetLibraryListItemType>
58
60
61 void build_tree() override
62 {
63 /* Group the libraries of an extension repository under its row. */
64 AssetLibraryRepoItemType *repo_parent = nullptr;
65 AssetLibraryProjectHeading *project_group = nullptr;
66
67 int i = 0;
69 if (library.is_extension_repo()) {
71 repo_parent->disable_activatable();
72 continue;
73 }
74 ui::TreeViewOrItem *parent = this;
75 if (repo_parent && library.extension_repo == repo_parent->library.extension_repo) {
76 parent = repo_parent;
77 }
78 if constexpr (std::is_same_v<AssetLibraryListItemType, AssetLibraryListItem>) {
79 const bool project_library = library.user_library &&
80 (library.user_library->flag & ASSET_LIBRARY_PROJECT_DEFINED);
81 if (project_library) {
82 if (!project_group) {
84 }
85 parent = project_group;
86 }
87 }
88 parent->add_tree_item<AssetLibraryListItemType>(library, i++);
89 }
90 this->is_flat_ = (!repo_parent && !project_group);
91 }
92};
93
94template<typename AssetLibraryListItemType,
95 typename AssetLibraryRepoItemType = AssetLibraryListItemType>
97 ui::Layout &layout,
99 StringRef view_description)
100{
101 ui::Block *block = layout.block();
102
104 *block,
105 view_description,
107 libraries));
108 tree_view->set_default_rows(5);
109
110 ui::TreeViewBuilder::build_tree_view(C, *tree_view, layout);
111}
112
113void draw_active_library_settings(const bContext *C,
114 ui::Layout &layout,
115 const AnyAssetLibraryDefinition &library);
116
117} // namespace blender
#define C
Definition RandGen.cpp:29
Abstract base class for defining a customizable tree-view item.
void set_default_rows(int default_rows)
Definition tree_view.cc:234
static void build_tree_view(const bContext &C, AbstractTreeView &tree_view, Layout &layout, bool add_box=true)
ItemT & add_tree_item(Args &&...args)
AbstractGridView * block_add_view(Block &block, StringRef idname, std::unique_ptr< AbstractGridView > grid_view)
TreeViewItemContainer TreeViewOrItem
BMesh Iterators.
void draw_library_list(const bContext &C, ui::Layout &layout, Vector< AnyAssetLibraryDefinition > &libraries, StringRef view_description)
@ ASSET_LIBRARY_PROJECT_DEFINED
void draw_active_library_settings(const bContext *C, ui::Layout &layout, const AnyAssetLibraryDefinition &library)
bool rename(const bContext &C, StringRefNull new_name) override
AssetLibraryListItemCommon(const AnyAssetLibraryDefinition &library, const int index_in_list)
AssetLibraryList(const Vector< AnyAssetLibraryDefinition > libraries)
Vector< AnyAssetLibraryDefinition > libraries