Blender  V3.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
blender::ui::TreeViewItemContainer Class Reference

#include <UI_tree_view.hh>

Inheritance diagram for blender::ui::TreeViewItemContainer:
blender::ui::AbstractTreeView blender::ui::AbstractTreeViewItem blender::ed::asset_browser::AssetCatalogTreeView blender::ed::spreadsheet::GeometryDataSetTreeView blender::ed::spreadsheet::GeometryDataSetTreeViewItem blender::ui::BasicTreeViewItem blender::ed::asset_browser::AssetCatalogTreeViewAllItem blender::ed::asset_browser::AssetCatalogTreeViewItem blender::ed::asset_browser::AssetCatalogTreeViewUnassignedItem

Public Types

enum class  IterOptions { None = 0 , SkipCollapsed = 1 << 0 }
 
using ItemIterFn = FunctionRef< void(AbstractTreeViewItem &)>
 

Public Member Functions

template<class ItemT , typename... Args>
ItemT & add_tree_item (Args &&...args)
 
AbstractTreeViewItemadd_tree_item (std::unique_ptr< AbstractTreeViewItem > item)
 

Protected Member Functions

void foreach_item_recursive (ItemIterFn iter_fn, IterOptions options=IterOptions::None) const
 

Protected Attributes

Vector< std::unique_ptr< AbstractTreeViewItem > > children_
 
TreeViewItemContainerroot_ = nullptr
 
AbstractTreeViewItemparent_ = nullptr
 

Friends

class AbstractTreeView
 
class AbstractTreeViewItem
 

Detailed Description

Both the tree-view (as the root of the tree) and the items can have children. This is the base class for both, to store and manage child items. Children are owned by their parent container (tree-view or item).

That means this type can be used whenever either an AbstractTreeView or an AbstractTreeViewItem is needed, but the TreeViewOrItem alias is a better name to use then.

Definition at line 49 of file UI_tree_view.hh.

Member Typedef Documentation

◆ ItemIterFn

Definition at line 70 of file UI_tree_view.hh.

Member Enumeration Documentation

◆ IterOptions

Enumerator
None 
SkipCollapsed 

Definition at line 64 of file UI_tree_view.hh.

Member Function Documentation

◆ add_tree_item() [1/2]

template<class ItemT , typename... Args>
ItemT & blender::ui::TreeViewItemContainer::add_tree_item ( Args &&...  args)
inline

Convenience wrapper constructing the item by forwarding given arguments to the constructor of the type (ItemT).

E.g. if your tree-item type has the following constructor:

MyTreeItem(std::string str, int i);
#define str(s)

You can add an item like this:

add_tree_item<MyTreeItem>("blabla", 42);

Definition at line 322 of file UI_tree_view.hh.

◆ add_tree_item() [2/2]

AbstractTreeViewItem & blender::ui::TreeViewItemContainer::add_tree_item ( std::unique_ptr< AbstractTreeViewItem item)

Add an already constructed tree item to this parent. Ownership is moved to it. All tree items must be added through this, it handles important invariants!

Add a tree-item to the container. This is the only place where items should be added, it handles important invariants!

Definition at line 31 of file tree_view.cc.

References children_, parent_, blender::ui::AbstractView::register_item(), and root_.

◆ foreach_item_recursive()

void blender::ui::TreeViewItemContainer::foreach_item_recursive ( ItemIterFn  iter_fn,
IterOptions  options = IterOptions::None 
) const
protected

Definition at line 54 of file tree_view.cc.

References children_, options, and SkipCollapsed.

Referenced by blender::ui::AbstractTreeView::foreach_item().

Friends And Related Function Documentation

◆ AbstractTreeView

friend class AbstractTreeView
friend

Definition at line 50 of file UI_tree_view.hh.

◆ AbstractTreeViewItem

friend class AbstractTreeViewItem
friend

Definition at line 51 of file UI_tree_view.hh.

Member Data Documentation

◆ children_

Vector<std::unique_ptr<AbstractTreeViewItem> > blender::ui::TreeViewItemContainer::children_
protected

◆ parent_

AbstractTreeViewItem* blender::ui::TreeViewItemContainer::parent_ = nullptr
protected

◆ root_

TreeViewItemContainer* blender::ui::TreeViewItemContainer::root_ = nullptr
protected

Adding the first item to the root will set this, then it's passed on to all children.

Definition at line 59 of file UI_tree_view.hh.

Referenced by add_tree_item().


The documentation for this class was generated from the following files: