49class TreeViewItemContainer {
54 TreeViewItemContainer() =
default;
59 TreeViewItemContainer *
root_ =
nullptr;
92 template<
class ItemT,
typename... Args>
inline ItemT &
add_tree_item(Args &&...args);
125 std::shared_ptr<int> custom_height_ =
nullptr;
128 std::shared_ptr<int> scroll_value_ =
nullptr;
132 int last_tot_items_ = 0;
134 bool scroll_active_into_view_on_draw_ =
false;
135 std::shared_ptr<char> show_display_options_ = std::make_shared<char>(0);
138 std::shared_ptr<char[]> search_string_{
new char[256 ]{}};
179 void update_children_from_old(
const AbstractView &old_view)
override;
180 static void update_children_from_old_recursive(
const TreeViewOrItem &new_items,
184 std::optional<int> tot_visible_row_count()
const;
188 void draw_hierarchy_lines(
const ARegion ®ion,
const uiBlock &block)
const;
189 void get_hierarchy_lines(
const ARegion ®ion,
192 Vector<std::pair<int2, int2>> &lines,
193 int &visible_item_index)
const;
196 void scroll_active_into_view();
219 bool is_open_ =
false;
230 std::optional<std::string>
debug_name()
const override;
337 static
void collapse_chevron_click_fn(
bContext *,
void *but_arg1,
void *);
343 bool set_state_active()
final;
345 void add_treerow_button(
uiBlock &block);
346 int indent_width() const;
347 void add_indent(
uiLayout &row) const;
348 void add_collapse_chevron(
uiBlock &block) const;
349 void add_rename_button(
uiLayout &row);
351 bool has_active_child() const;
420 const wmEvent &event)
const override;
424 template<
class ViewType>
inline ViewType &
get_view()
const;
438 bool add_box =
true);
448template<
class ItemT,
typename... Args>
451 static_assert(std::is_base_of_v<AbstractTreeViewItem, ItemT>,
452 "Type must derive from and implement the AbstractTreeViewItem interface");
454 return dynamic_cast<ItemT &
>(
455 add_tree_item(std::make_unique<ItemT>(std::forward<Args>(args)...)));
460 static_assert(std::is_base_of_v<AbstractTreeView, ViewType>,
461 "Type must derive from and implement the ui::AbstractTreeView interface");
462 return dynamic_cast<ViewType &
>(
view_item_.get_tree_view());
#define ENUM_OPERATORS(_type, _max)
Abstract base class for defining a customizable tree-view item.
std::optional< rctf > get_win_rect(const ARegion ®ion) const
void update_from_old(const AbstractViewItem &old) override
bool is_collapsed() const
void change_state_delayed() override
void on_filter_change() override
int count_parents() const
AbstractTreeView & get_tree_view() const
std::unique_ptr< DropTargetInterface > create_item_drop_target() final
bool is_collapsible() const
StringRef get_rename_string() const override
virtual void build_row(uiLayout &row)=0
bool matches(const AbstractViewItem &other) const override
void toggle_collapsed_from_view(bContext &C)
virtual std::unique_ptr< TreeViewItemDropTarget > create_drop_target()
virtual void on_collapse_change(bContext &C, bool is_collapsed)
friend class TreeViewLayoutBuilder
~AbstractTreeViewItem() override=default
virtual std::optional< bool > should_be_collapsed() const
virtual bool set_collapsed(bool collapsed)
virtual bool matches_single(const AbstractTreeViewItem &other) const
std::optional< std::string > debug_name() const override
friend class AbstractTreeView
virtual bool supports_collapsing() const
void uncollapse_by_default()
bool rename(const bContext &C, StringRefNull new_name) override
friend class TreeViewItemAPIWrapper
void ensure_parents_uncollapsed()
AbstractTreeViewItem * find_hovered(const ARegion ®ion, const int2 &xy)
void scroll(ViewScrollDirection direction) override
void foreach_root_item(ItemIterFn iter_fn) const
friend class AbstractTreeViewItem
bool is_fully_visible() const override
friend class TreeViewItemDropTarget
void persistent_state_apply(const uiViewState &state) override
void draw_overlays(const ARegion ®ion, const uiBlock &block) const override
friend class TreeViewLayoutBuilder
~AbstractTreeView() override=default
virtual void build_tree()=0
void foreach_item(ItemIterFn iter_fn, IterOptions options=IterOptions::None) const
std::optional< uiViewState > persistent_state() const override
void set_default_rows(int default_rows)
friend class TreeViewBuilder
virtual void on_activate(bContext &C)
AbstractViewItem()=default
virtual std::optional< bool > should_be_active() const
virtual bool supports_scrolling() const
friend class AbstractViewItem
BasicTreeViewItem(StringRef label, BIFIconID icon=ICON_NONE)
std::function< bool()> IsActiveFn
std::function< void(bContext &C, BasicTreeViewItem &new_active)> ActivateFn
void add_label(uiLayout &layout, StringRefNull label_override="")
void set_is_active_fn(IsActiveFn is_active_fn)
void set_on_activate_fn(ActivateFn fn)
DropTargetInterface()=default
static void build_tree_view(const bContext &C, AbstractTreeView &tree_view, uiLayout &layout, bool add_box=true)
ItemT & add_tree_item(Args &&...args)
friend class AbstractTreeViewItem
AbstractTreeViewItem * parent_
TreeViewItemContainer * root_
void foreach_item_recursive(ItemIterFn iter_fn, IterOptions options=IterOptions::None) const
Vector< std::unique_ptr< AbstractTreeViewItem > > children_
void foreach_parent(ItemIterFn iter_fn) const
friend class AbstractTreeView
FunctionRef< void(AbstractTreeViewItem &)> ItemIterFn
AbstractTreeViewItem & view_item_
TreeViewItemDropTarget(AbstractTreeViewItem &view_item, DropBehavior behavior=DropBehavior::Insert)
const DropBehavior behavior_
std::optional< DropLocation > choose_drop_location(const ARegion ®ion, const wmEvent &event) const override
ViewType & get_view() const
CCL_NAMESPACE_BEGIN struct Options options
TreeViewItemContainer TreeViewOrItem
VecBase< int32_t, 2 > int2