Skip to content

Commit

Permalink
add unfolded=yes/no key in gui2 treeview node wml
Browse files Browse the repository at this point in the history
This allows wml to specify whether a node should be unfolded by default.
  • Loading branch information
gfgtdf committed Mar 7, 2016
1 parent 21001bc commit d26c2b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gui/auxiliary/window_builder/tree_view.cpp
Expand Up @@ -79,7 +79,9 @@ twidget* tbuilder_tree_view::build() const
}

tbuilder_tree_view::tnode::tnode(const config& cfg)
: id(cfg["id"]), builder(NULL)
: id(cfg["id"])
, unfolded(cfg["unfolded"].to_bool(false))
, builder(NULL)
{
VALIDATE(!id.empty(), missing_mandatory_wml_key("node", "id"));

Expand Down
1 change: 1 addition & 0 deletions src/gui/auxiliary/window_builder/tree_view.hpp
Expand Up @@ -43,6 +43,7 @@ struct tbuilder_tree_view : public tbuilder_control
explicit tnode(const config& cfg);

std::string id;
bool unfolded;
tbuilder_grid_ptr builder;
};

Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/tree_view_node.cpp
Expand Up @@ -74,6 +74,11 @@ ttree_view_node::ttree_view_node(
&ttree_view_node::signal_handler_left_button_click,
this,
_2), event::tdispatcher::back_post_child);

if(node_definition.unfolded) {
toggle_->set_value(1);
unfolded_ = true;
}
}

if(parent_node_ && parent_node_->toggle_) {
Expand Down

0 comments on commit d26c2b6

Please sign in to comment.