Blender  V3.3
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
blender::ui::AbstractTreeViewItem Class Referenceabstract

Abstract base class for defining a customizable tree-view item. More...

#include <UI_tree_view.hh>

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

Public Member Functions

virtual ~AbstractTreeViewItem ()=default
 
virtual void build_row (uiLayout &row)=0
 
AbstractTreeViewget_tree_view () const
 
void begin_renaming ()
 
void toggle_collapsed ()
 
void set_collapsed (bool collapsed)
 
bool is_collapsed () const
 
- Public Member Functions inherited from blender::ui::AbstractViewItem
virtual ~AbstractViewItem ()=default
 
virtual void build_context_menu (bContext &C, uiLayout &column) const
 
virtual std::unique_ptr< AbstractViewItemDragControllercreate_drag_controller () const
 
virtual std::unique_ptr< AbstractViewItemDropControllercreate_drop_controller () const
 
AbstractViewget_view () const
 
bool is_active () const
 
virtual bool supports_renaming () const
 
bool is_renaming () const
 
void begin_renaming ()
 
void end_renaming ()
 
void rename_apply ()
 
- Public Member Functions inherited from blender::ui::TreeViewItemContainer
template<class ItemT , typename... Args>
ItemT & add_tree_item (Args &&...args)
 
AbstractTreeViewItemadd_tree_item (std::unique_ptr< AbstractTreeViewItem > item)
 

Protected Member Functions

virtual void on_activate ()
 
virtual std::optional< boolshould_be_active () const
 
virtual StringRef get_rename_string () const override
 
virtual bool rename (StringRefNull new_name) override
 
virtual bool supports_collapsing () const
 
virtual bool matches (const AbstractViewItem &other) const override
 
virtual void update_from_old (const AbstractViewItem &old) override
 
virtual bool matches_single (const AbstractTreeViewItem &other) const
 
void activate ()
 
void deactivate ()
 
bool is_hovered () const
 
bool is_collapsible () const
 
void ensure_parents_uncollapsed ()
 
uiButViewItemview_item_button ()
 
- Protected Member Functions inherited from blender::ui::AbstractViewItem
 AbstractViewItem ()=default
 
void add_rename_button (uiBlock &block)
 
- Protected Member Functions inherited from blender::ui::TreeViewItemContainer
void foreach_item_recursive (ItemIterFn iter_fn, IterOptions options=IterOptions::None) const
 

Protected Attributes

std::string label_ {}
 
uiButViewItemview_item_but_ = nullptr
 
- Protected Attributes inherited from blender::ui::AbstractViewItem
AbstractViewview_ = nullptr
 
bool is_active_ = false
 
bool is_renaming_ = false
 
- Protected Attributes inherited from blender::ui::TreeViewItemContainer
Vector< std::unique_ptr< AbstractTreeViewItem > > children_
 
TreeViewItemContainerroot_ = nullptr
 
AbstractTreeViewItemparent_ = nullptr
 

Friends

class AbstractTreeView
 
class TreeViewLayoutBuilder
 
class TreeViewItemAPIWrapper
 

Additional Inherited Members

- Public Types inherited from blender::ui::TreeViewItemContainer
enum class  IterOptions { None = 0 , SkipCollapsed = 1 << 0 }
 
using ItemIterFn = FunctionRef< void(AbstractTreeViewItem &)>
 
- Static Public Member Functions inherited from blender::ui::AbstractViewItem
template<typename ToType = AbstractViewItem>
static ToType * from_item_handle (uiViewItemHandle *handle)
 

Detailed Description

Abstract base class for defining a customizable tree-view item.

The tree-view item defines how to build its data into a tree-row. There are implementations for common layouts, e.g. #BasicTreeViewItem. It also stores state information that needs to be persistent over redraws, like the collapsed state.

Definition at line 150 of file UI_tree_view.hh.

Constructor & Destructor Documentation

◆ ~AbstractTreeViewItem()

virtual blender::ui::AbstractTreeViewItem::~AbstractTreeViewItem ( )
virtualdefault

Member Function Documentation

◆ activate()

void blender::ui::AbstractTreeViewItem::activate ( )
protected

Activates this item, deactivates other items, calls the #AbstractTreeViewItem::on_activate() function and ensures this item's parents are not collapsed (so the item is visible). Requires the tree to have completed reconstruction, see #is_reconstructed(). Otherwise the actual item state is unknown, possibly calling state-change update functions incorrectly.

Definition at line 290 of file tree_view.cc.

References BLI_assert_msg, ensure_parents_uncollapsed(), blender::ui::AbstractTreeView::foreach_item(), get_tree_view(), blender::ui::AbstractViewItem::is_active(), blender::ui::AbstractViewItem::is_active_, and on_activate().

◆ begin_renaming()

void blender::ui::AbstractTreeViewItem::begin_renaming ( )

◆ build_row()

virtual void blender::ui::AbstractTreeViewItem::build_row ( uiLayout row)
pure virtual

◆ deactivate()

void blender::ui::AbstractTreeViewItem::deactivate ( )
protected

Definition at line 309 of file tree_view.cc.

References blender::ui::AbstractViewItem::is_active_.

◆ ensure_parents_uncollapsed()

void blender::ui::AbstractTreeViewItem::ensure_parents_uncollapsed ( )
protected

Definition at line 354 of file tree_view.cc.

References blender::ui::TreeViewItemContainer::parent_.

Referenced by activate().

◆ get_rename_string()

StringRef blender::ui::AbstractTreeViewItem::get_rename_string ( ) const
overrideprotectedvirtual

See AbstractViewItem::get_rename_string().

Reimplemented from blender::ui::AbstractViewItem.

Definition at line 250 of file tree_view.cc.

References label_.

◆ get_tree_view()

AbstractTreeView & blender::ui::AbstractTreeViewItem::get_tree_view ( ) const

◆ is_collapsed()

bool blender::ui::AbstractTreeViewItem::is_collapsed ( ) const

Requires the tree to have completed reconstruction, see #is_reconstructed(). Otherwise we can't be sure about the item state.

Definition at line 329 of file tree_view.cc.

References BLI_assert_msg, get_tree_view(), and is_collapsible().

◆ is_collapsible()

bool blender::ui::AbstractTreeViewItem::is_collapsible ( ) const
protected

◆ is_hovered()

bool blender::ui::AbstractTreeViewItem::is_hovered ( ) const
protected

Can be called from the #AbstractTreeViewItem::build_row() implementation, but not earlier. The hovered state can't be queried reliably otherwise. Note that this does a linear lookup in the old block, so isn't too great performance-wise.

Definition at line 314 of file tree_view.cc.

References BLI_assert_msg, uiBut::block, uiButViewItem::but, uiBut::flag, get_tree_view(), UI_ACTIVE, ui_block_view_find_matching_view_item_but_in_old_block(), and view_item_but_.

Referenced by blender::ed::asset_browser::AssetCatalogTreeViewItem::build_row().

◆ matches()

bool blender::ui::AbstractTreeViewItem::matches ( const AbstractViewItem other) const
overrideprotectedvirtual

See #AbstractViewItem::matches().

Implements blender::ui::AbstractViewItem.

Definition at line 361 of file tree_view.cc.

References matches_single(), and blender::ui::TreeViewItemContainer::parent_.

◆ matches_single()

bool blender::ui::AbstractTreeViewItem::matches_single ( const AbstractTreeViewItem other) const
protectedvirtual

Compare this item to other to check if they represent the same data. Used to recognize an item from a previous redraw, to be able to keep its state (e.g. open/closed, active, etc.). Items are only matched if their parents also match. By default this just matches the item's label (if the parents match!). If that isn't good enough for a sub-class, that can override it.

TODO matches_single() is a rather temporary name, used to indicate that this only compares the item itself, not the parents. Item matching is expected to change quite a bit anyway.

Definition at line 271 of file tree_view.cc.

References label_.

Referenced by matches().

◆ on_activate()

void blender::ui::AbstractTreeViewItem::on_activate ( )
protectedvirtual

Called when the items state changes from inactive to active.

Reimplemented in blender::ed::spreadsheet::GeometryDataSetTreeViewItem, and blender::ed::asset_browser::AssetCatalogTreeViewItem.

Definition at line 235 of file tree_view.cc.

Referenced by activate().

◆ rename()

bool blender::ui::AbstractTreeViewItem::rename ( StringRefNull  new_name)
overrideprotectedvirtual

See AbstractViewItem::rename().

Reimplemented from blender::ui::AbstractViewItem.

Reimplemented in blender::ed::asset_browser::AssetCatalogTreeViewItem.

Definition at line 255 of file tree_view.cc.

References label_.

◆ set_collapsed()

void blender::ui::AbstractTreeViewItem::set_collapsed ( bool  collapsed)

◆ should_be_active()

std::optional< bool > blender::ui::AbstractTreeViewItem::should_be_active ( ) const
protectedvirtual

If the result is not empty, it controls whether the item should be active or not, usually depending on the data that the view represents.

Reimplemented in blender::ed::spreadsheet::GeometryDataSetTreeViewItem.

Definition at line 240 of file tree_view.cc.

◆ supports_collapsing()

bool blender::ui::AbstractTreeViewItem::supports_collapsing ( ) const
protectedvirtual

Return whether the item can be collapsed. Used to disable collapsing for items with children.

Reimplemented in blender::ed::spreadsheet::GeometryDataSetTreeViewItem.

Definition at line 245 of file tree_view.cc.

Referenced by is_collapsible().

◆ toggle_collapsed()

void blender::ui::AbstractTreeViewItem::toggle_collapsed ( )

Definition at line 336 of file tree_view.cc.

◆ update_from_old()

void blender::ui::AbstractTreeViewItem::update_from_old ( const AbstractViewItem old)
overrideprotectedvirtual

See #AbstractViewItem::update_from_old().

Reimplemented from blender::ui::AbstractViewItem.

Definition at line 263 of file tree_view.cc.

References blender::ui::AbstractViewItem::update_from_old().

◆ view_item_button()

uiButViewItem * blender::ui::AbstractTreeViewItem::view_item_button ( )
protected

Friends And Related Function Documentation

◆ AbstractTreeView

friend class AbstractTreeView
friend

Definition at line 151 of file UI_tree_view.hh.

◆ TreeViewItemAPIWrapper

friend class TreeViewItemAPIWrapper
friend

Definition at line 154 of file UI_tree_view.hh.

◆ TreeViewLayoutBuilder

friend class TreeViewLayoutBuilder
friend

Definition at line 152 of file UI_tree_view.hh.

Member Data Documentation

◆ label_

std::string blender::ui::AbstractTreeViewItem::label_ {}
protected

◆ view_item_but_

uiButViewItem* blender::ui::AbstractTreeViewItem::view_item_but_ = nullptr
protected

Every visible item gets a button of type UI_BTYPE_VIEW_ITEM during the layout building.

Definition at line 163 of file UI_tree_view.hh.

Referenced by is_hovered(), and view_item_button().


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