Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/tree_view.cc
| Show First 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | bool AbstractTreeViewItem::has_active_child() const | ||||
| return found; | return found; | ||||
| } | } | ||||
| void AbstractTreeViewItem::on_activate() | void AbstractTreeViewItem::on_activate() | ||||
| { | { | ||||
| /* Do nothing by default. */ | /* Do nothing by default. */ | ||||
| } | } | ||||
| void AbstractTreeViewItem::is_active(IsActiveFn is_active_fn) | std::optional<bool> AbstractTreeViewItem::should_be_active() const | ||||
| { | { | ||||
| is_active_fn_ = is_active_fn; | return std::nullopt; | ||||
| } | |||||
| bool AbstractTreeViewItem::supports_collapsing() const | |||||
| { | |||||
| return true; | |||||
Severin: I think in a hierarchical UI it's more common to want collapsing than to not want it. So would… | |||||
Done Inline ActionsGood point. HooglyBoogly: Good point. | |||||
| } | } | ||||
| std::unique_ptr<AbstractTreeViewItemDragController> AbstractTreeViewItem::create_drag_controller() | std::unique_ptr<AbstractTreeViewItemDragController> AbstractTreeViewItem::create_drag_controller() | ||||
| const | const | ||||
| { | { | ||||
| /* There's no drag controller (and hence no drag support) by default. */ | /* There's no drag controller (and hence no drag support) by default. */ | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | |||||
| void AbstractTreeViewItem::set_collapsed(bool collapsed) | void AbstractTreeViewItem::set_collapsed(bool collapsed) | ||||
| { | { | ||||
| is_open_ = !collapsed; | is_open_ = !collapsed; | ||||
| } | } | ||||
| bool AbstractTreeViewItem::is_collapsible() const | bool AbstractTreeViewItem::is_collapsible() const | ||||
| { | { | ||||
| return !children_.is_empty(); | if (children_.is_empty()) { | ||||
| return false; | |||||
| } | |||||
| return this->supports_collapsing(); | |||||
| } | } | ||||
| bool AbstractTreeViewItem::is_renaming() const | bool AbstractTreeViewItem::is_renaming() const | ||||
| { | { | ||||
| return is_renaming_; | return is_renaming_; | ||||
| } | } | ||||
| void AbstractTreeViewItem::ensure_parents_uncollapsed() | void AbstractTreeViewItem::ensure_parents_uncollapsed() | ||||
| Show All 25 Lines | |||||
| uiButTreeRow *AbstractTreeViewItem::tree_row_button() | uiButTreeRow *AbstractTreeViewItem::tree_row_button() | ||||
| { | { | ||||
| return tree_row_but_; | return tree_row_but_; | ||||
| } | } | ||||
| void AbstractTreeViewItem::change_state_delayed() | void AbstractTreeViewItem::change_state_delayed() | ||||
| { | { | ||||
| if (is_active_fn_ && is_active_fn_()) { | const std::optional<bool> should_be_active = this->should_be_active(); | ||||
| if (should_be_active.has_value() && *should_be_active) { | |||||
| activate(); | activate(); | ||||
| } | } | ||||
| } | } | ||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| AbstractTreeViewItemDropController::AbstractTreeViewItemDropController(AbstractTreeView &tree_view) | AbstractTreeViewItemDropController::AbstractTreeViewItemDropController(AbstractTreeView &tree_view) | ||||
| : tree_view_(tree_view) | : tree_view_(tree_view) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
| void BasicTreeViewItem::on_activate() | void BasicTreeViewItem::on_activate() | ||||
| { | { | ||||
| if (activate_fn_) { | if (activate_fn_) { | ||||
| activate_fn_(*this); | activate_fn_(*this); | ||||
| } | } | ||||
| } | } | ||||
| void BasicTreeViewItem::on_activate(ActivateFn fn) | void BasicTreeViewItem::set_on_activate_fn(ActivateFn fn) | ||||
| { | { | ||||
| activate_fn_ = fn; | activate_fn_ = fn; | ||||
| } | } | ||||
| void BasicTreeViewItem::set_is_active_fn(IsActiveFn is_active_fn) | |||||
| { | |||||
| is_active_fn_ = is_active_fn; | |||||
| } | |||||
| std::optional<bool> BasicTreeViewItem::should_be_active() const | |||||
| { | |||||
| if (is_active_fn_) { | |||||
| return is_active_fn_(); | |||||
| } | |||||
| return std::nullopt; | |||||
| } | |||||
| } // namespace blender::ui | } // namespace blender::ui | ||||
| using namespace blender::ui; | using namespace blender::ui; | ||||
| bool UI_tree_view_item_is_active(const uiTreeViewItemHandle *item_handle) | bool UI_tree_view_item_is_active(const uiTreeViewItemHandle *item_handle) | ||||
| { | { | ||||
| const AbstractTreeViewItem &item = reinterpret_cast<const AbstractTreeViewItem &>(*item_handle); | const AbstractTreeViewItem &item = reinterpret_cast<const AbstractTreeViewItem &>(*item_handle); | ||||
| return item.is_active(); | return item.is_active(); | ||||
| ▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines | |||||
I think in a hierarchical UI it's more common to want collapsing than to not want it. So would say this should return true by default.