|
|
|
|
@@ -88,18 +88,18 @@ void TreeViewItemContainer::foreach_item_recursive(ItemIterFn iter_fn, IterOptio
|
|
|
|
|
/* Implementation for the base class virtual function. More specialized iterators below. */
|
|
|
|
|
void AbstractTreeView::foreach_view_item(FunctionRef<void(AbstractViewItem &)> iter_fn) const
|
|
|
|
|
{
|
|
|
|
|
foreach_item_recursive(iter_fn);
|
|
|
|
|
this->foreach_item_recursive(iter_fn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractTreeView::foreach_item(ItemIterFn iter_fn, IterOptions options) const
|
|
|
|
|
{
|
|
|
|
|
foreach_item_recursive(iter_fn, options);
|
|
|
|
|
this->foreach_item_recursive(iter_fn, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbstractTreeViewItem *AbstractTreeView::find_hovered(const ARegion ®ion, const int2 &xy)
|
|
|
|
|
{
|
|
|
|
|
AbstractTreeViewItem *hovered_item = nullptr;
|
|
|
|
|
foreach_item_recursive(
|
|
|
|
|
this->foreach_item_recursive(
|
|
|
|
|
[&](AbstractTreeViewItem &item) {
|
|
|
|
|
if (hovered_item) {
|
|
|
|
|
return;
|
|
|
|
|
@@ -145,7 +145,7 @@ void AbstractTreeView::draw_hierarchy_lines_recursive(const ARegion ®ion,
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draw_hierarchy_lines_recursive(region, *item, pos, aspect);
|
|
|
|
|
this->draw_hierarchy_lines_recursive(region, *item, pos, aspect);
|
|
|
|
|
|
|
|
|
|
const AbstractTreeViewItem *first_descendant = item->children_.first().get();
|
|
|
|
|
const AbstractTreeViewItem *last_descendant = find_last_visible_descendant(*item);
|
|
|
|
|
@@ -198,14 +198,14 @@ void AbstractTreeView::draw_hierarchy_lines(const ARegion ®ion) const
|
|
|
|
|
|
|
|
|
|
void AbstractTreeView::draw_overlays(const ARegion ®ion) const
|
|
|
|
|
{
|
|
|
|
|
draw_hierarchy_lines(region);
|
|
|
|
|
this->draw_hierarchy_lines(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractTreeView::update_children_from_old(const AbstractView &old_view)
|
|
|
|
|
{
|
|
|
|
|
const AbstractTreeView &old_tree_view = dynamic_cast<const AbstractTreeView &>(old_view);
|
|
|
|
|
|
|
|
|
|
update_children_from_old_recursive(*this, old_tree_view);
|
|
|
|
|
this->update_children_from_old_recursive(*this, old_tree_view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractTreeView::update_children_from_old_recursive(const TreeViewOrItem &new_items,
|
|
|
|
|
@@ -310,7 +310,7 @@ void AbstractTreeViewItem::add_treerow_button(uiBlock &block)
|
|
|
|
|
|
|
|
|
|
int AbstractTreeViewItem::indent_width() const
|
|
|
|
|
{
|
|
|
|
|
return count_parents() * UI_TREEVIEW_INDENT;
|
|
|
|
|
return this->count_parents() * UI_TREEVIEW_INDENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractTreeViewItem::add_indent(uiLayout &row) const
|
|
|
|
|
@@ -319,11 +319,11 @@ void AbstractTreeViewItem::add_indent(uiLayout &row) const
|
|
|
|
|
uiLayout *subrow = uiLayoutRow(&row, true);
|
|
|
|
|
uiLayoutSetFixedSize(subrow, true);
|
|
|
|
|
|
|
|
|
|
uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, indent_width(), 0, nullptr, 0.0, 0.0, "");
|
|
|
|
|
uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, this->indent_width(), 0, nullptr, 0.0, 0.0, "");
|
|
|
|
|
|
|
|
|
|
/* Indent items without collapsing icon some more within their parent. Makes it clear that they
|
|
|
|
|
* are actually nested and not just a row at the same level without a chevron. */
|
|
|
|
|
if (!is_collapsible()) {
|
|
|
|
|
if (!this->is_collapsible()) {
|
|
|
|
|
uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, UI_TREEVIEW_INDENT, 0, nullptr, 0.0, 0.0, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -357,11 +357,11 @@ void AbstractTreeViewItem::collapse_chevron_click_fn(bContext *C,
|
|
|
|
|
|
|
|
|
|
void AbstractTreeViewItem::add_collapse_chevron(uiBlock &block) const
|
|
|
|
|
{
|
|
|
|
|
if (!is_collapsible()) {
|
|
|
|
|
if (!this->is_collapsible()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BIFIconID icon = is_collapsed() ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT;
|
|
|
|
|
const BIFIconID icon = this->is_collapsed() ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT;
|
|
|
|
|
uiBut *but = uiDefIconBut(&block,
|
|
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
|
0,
|
|
|
|
|
@@ -438,7 +438,7 @@ bool AbstractTreeViewItem::matches_single(const AbstractTreeViewItem &other) con
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<DropTargetInterface> AbstractTreeViewItem::create_item_drop_target()
|
|
|
|
|
{
|
|
|
|
|
return create_drop_target();
|
|
|
|
|
return this->create_drop_target();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<TreeViewItemDropTarget> AbstractTreeViewItem::create_drop_target()
|
|
|
|
|
@@ -503,17 +503,17 @@ bool AbstractTreeViewItem::is_collapsed() const
|
|
|
|
|
{
|
|
|
|
|
BLI_assert_msg(get_tree_view().is_reconstructed(),
|
|
|
|
|
"State can't be queried until reconstruction is completed");
|
|
|
|
|
return is_collapsible() && !is_open_;
|
|
|
|
|
return this->is_collapsible() && !is_open_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AbstractTreeViewItem::toggle_collapsed()
|
|
|
|
|
{
|
|
|
|
|
return set_collapsed(is_open_);
|
|
|
|
|
return this->set_collapsed(is_open_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AbstractTreeViewItem::set_collapsed(const bool collapsed)
|
|
|
|
|
{
|
|
|
|
|
if (!is_collapsible()) {
|
|
|
|
|
if (!this->is_collapsible()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (collapsed == !is_open_) {
|
|
|
|
|
@@ -546,8 +546,8 @@ std::optional<bool> AbstractTreeViewItem::should_be_collapsed() const
|
|
|
|
|
|
|
|
|
|
void AbstractTreeViewItem::toggle_collapsed_from_view(bContext &C)
|
|
|
|
|
{
|
|
|
|
|
if (toggle_collapsed()) {
|
|
|
|
|
on_collapse_change(C, is_collapsed());
|
|
|
|
|
if (this->toggle_collapsed()) {
|
|
|
|
|
this->on_collapse_change(C, this->is_collapsed());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -559,7 +559,7 @@ void AbstractTreeViewItem::change_state_delayed()
|
|
|
|
|
if (should_be_collapsed.has_value()) {
|
|
|
|
|
/* This reflects an external state change and therefore shouldn't call #on_collapse_change().
|
|
|
|
|
*/
|
|
|
|
|
set_collapsed(*should_be_collapsed);
|
|
|
|
|
this->set_collapsed(*should_be_collapsed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -574,10 +574,10 @@ bool AbstractTreeViewItem::matches(const AbstractViewItem &other) const
|
|
|
|
|
{
|
|
|
|
|
const AbstractTreeViewItem &other_tree_item = dynamic_cast<const AbstractTreeViewItem &>(other);
|
|
|
|
|
|
|
|
|
|
if (!matches_single(other_tree_item)) {
|
|
|
|
|
if (!this->matches_single(other_tree_item)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (count_parents() != other_tree_item.count_parents()) {
|
|
|
|
|
if (this->count_parents() != other_tree_item.count_parents()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -618,7 +618,7 @@ TreeViewLayoutBuilder::TreeViewLayoutBuilder(uiLayout &layout) : block_(*uiLayou
|
|
|
|
|
|
|
|
|
|
void TreeViewLayoutBuilder::build_from_tree(const AbstractTreeView &tree_view)
|
|
|
|
|
{
|
|
|
|
|
uiLayout &parent_layout = current_layout();
|
|
|
|
|
uiLayout &parent_layout = this->current_layout();
|
|
|
|
|
|
|
|
|
|
uiLayout *box = uiLayoutBox(&parent_layout);
|
|
|
|
|
uiLayoutColumn(box, true);
|
|
|
|
|
@@ -724,7 +724,7 @@ BasicTreeViewItem::BasicTreeViewItem(StringRef label, BIFIconID icon_) : icon(ic
|
|
|
|
|
|
|
|
|
|
void BasicTreeViewItem::build_row(uiLayout &row)
|
|
|
|
|
{
|
|
|
|
|
add_label(row);
|
|
|
|
|
this->add_label(row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BasicTreeViewItem::add_label(uiLayout &layout, StringRefNull label_override)
|
|
|
|
|
|