Skip to content

Commit

Permalink
Tree View: Allow find_widget to recurse into the nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 21, 2017
1 parent 86d00a4 commit 0a6d6f3
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/gui/widgets/tree_view_node.cpp
Expand Up @@ -352,13 +352,45 @@ const widget* tree_view_node::find_at(const point& coordinate, const bool must_b
widget* tree_view_node::find(const std::string& id, const bool must_be_active)
{
widget* result = widget::find(id, must_be_active);
return result ? result : grid_.find(id, must_be_active);
if(result) {
return result;
}

result = grid_.find(id, must_be_active);
if(result) {
return result;
}

for(tree_view_node& child : children_) {
result = child.find(id, must_be_active);
if(result) {
return result;
}
}

return nullptr;
}

const widget* tree_view_node::find(const std::string& id, const bool must_be_active) const
{
const widget* result = widget::find(id, must_be_active);
return result ? result : grid_.find(id, must_be_active);
if(result) {
return result;
}

result = grid_.find(id, must_be_active);
if(result) {
return result;
}

for(const tree_view_node& child : children_) {
result = child.find(id, must_be_active);
if(result) {
return result;
}
}

return nullptr;
}

void tree_view_node::impl_populate_dirty_list(window& caller, const std::vector<widget*>& call_stack)
Expand Down

0 comments on commit 0a6d6f3

Please sign in to comment.