Blender
V3.3
|
Abstract base class for defining a customizable tree-view item. More...
#include <UI_tree_view.hh>
Protected Member Functions | |
virtual void | on_activate () |
virtual std::optional< bool > | should_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 () |
uiButViewItem * | view_item_button () |
![]() | |
AbstractViewItem ()=default | |
void | add_rename_button (uiBlock &block) |
![]() | |
void | foreach_item_recursive (ItemIterFn iter_fn, IterOptions options=IterOptions::None) const |
Protected Attributes | |
std::string | label_ {} |
uiButViewItem * | view_item_but_ = nullptr |
![]() | |
AbstractView * | view_ = nullptr |
bool | is_active_ = false |
bool | is_renaming_ = false |
![]() | |
Vector< std::unique_ptr< AbstractTreeViewItem > > | children_ |
TreeViewItemContainer * | root_ = nullptr |
AbstractTreeViewItem * | parent_ = nullptr |
Friends | |
class | AbstractTreeView |
class | TreeViewLayoutBuilder |
class | TreeViewItemAPIWrapper |
Additional Inherited Members | |
![]() | |
enum class | IterOptions { None = 0 , SkipCollapsed = 1 << 0 } |
using | ItemIterFn = FunctionRef< void(AbstractTreeViewItem &)> |
![]() | |
template<typename ToType = AbstractViewItem> | |
static ToType * | from_item_handle (uiViewItemHandle *handle) |
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.
|
virtualdefault |
|
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().
void blender::ui::AbstractTreeViewItem::begin_renaming | ( | ) |
|
protected |
Definition at line 309 of file tree_view.cc.
References blender::ui::AbstractViewItem::is_active_.
|
protected |
Definition at line 354 of file tree_view.cc.
References blender::ui::TreeViewItemContainer::parent_.
Referenced by activate().
|
overrideprotectedvirtual |
See AbstractViewItem::get_rename_string().
Reimplemented from blender::ui::AbstractViewItem.
Definition at line 250 of file tree_view.cc.
References label_.
AbstractTreeView & blender::ui::AbstractTreeViewItem::get_tree_view | ( | ) | const |
Definition at line 276 of file tree_view.cc.
References blender::ui::AbstractViewItem::get_view().
Referenced by activate(), blender::ed::asset_browser::AssetCatalogTreeViewItem::create_drag_controller(), blender::ed::asset_browser::AssetCatalogTreeViewItem::create_drop_controller(), is_collapsed(), is_hovered(), blender::ed::asset_browser::AssetCatalogTreeViewItem::on_activate(), and blender::ed::asset_browser::AssetCatalogTreeViewItem::rename().
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().
|
protected |
Definition at line 346 of file tree_view.cc.
References blender::ui::TreeViewItemContainer::children_, and supports_collapsing().
Referenced by blender::ui::BasicTreeViewItem::add_label(), and is_collapsed().
|
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().
|
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_.
|
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().
|
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().
|
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_.
Definition at line 341 of file tree_view.cc.
Referenced by blender::ed::asset_browser::AssetCatalogTreeView::build_tree(), and blender::ed::spreadsheet::GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem().
|
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.
|
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().
void blender::ui::AbstractTreeViewItem::toggle_collapsed | ( | ) |
Definition at line 336 of file tree_view.cc.
|
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().
|
protected |
Definition at line 383 of file tree_view.cc.
References view_item_but_.
Referenced by blender::ed::asset_browser::AssetCatalogTreeViewItem::build_row(), and blender::ed::spreadsheet::GeometryDataSetTreeViewItem::build_row().
|
friend |
Definition at line 151 of file UI_tree_view.hh.
|
friend |
Definition at line 154 of file UI_tree_view.hh.
|
friend |
Definition at line 152 of file UI_tree_view.hh.
|
protected |
This label is used as the default way to identifying an item within its parent.
Definition at line 161 of file UI_tree_view.hh.
Referenced by blender::ui::BasicTreeViewItem::add_label(), blender::ui::BasicTreeViewItem::BasicTreeViewItem(), blender::ed::asset_browser::AssetCatalogTreeViewItem::build_row(), blender::ed::spreadsheet::GeometryDataSetTreeViewItem::build_row(), blender::ed::spreadsheet::GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem(), get_rename_string(), matches_single(), and rename().
|
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().