mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 23:33:17 +00:00
Add a layout function to a tree view.
This allows the content to request redraws and notify the parent container that it should (re)layout the contents.
This commit is contained in:
parent
76f25a7f68
commit
9d792f79a3
@ -31,6 +31,7 @@ ttree_view::ttree_view(const std::vector<tnode_definition>& node_definitions)
|
||||
: tscrollbar_container(2)
|
||||
, node_definitions_(node_definitions)
|
||||
, indention_step_size_(0)
|
||||
, need_layout_(false)
|
||||
, root_node_(new ttree_view_node(
|
||||
"root"
|
||||
, node_definitions_
|
||||
@ -85,6 +86,8 @@ void ttree_view::child_populate_dirty_list(twindow& caller
|
||||
// Inherited.
|
||||
tscrollbar_container::child_populate_dirty_list(caller, call_stack);
|
||||
|
||||
layout();
|
||||
|
||||
assert(root_node_);
|
||||
root_node_->impl_populate_dirty_list(caller, call_stack);
|
||||
}
|
||||
@ -94,6 +97,18 @@ bool ttree_view::empty() const
|
||||
return root_node_->empty();
|
||||
}
|
||||
|
||||
void ttree_view::layout()
|
||||
{
|
||||
if(need_layout_) {
|
||||
root_node_->set_size(indention_step_size_
|
||||
, get_origin()
|
||||
, root_node_->get_size().x);
|
||||
root_node_->set_visible_area(content_visible_area_);
|
||||
|
||||
need_layout_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
|
@ -107,12 +107,17 @@ private:
|
||||
|
||||
unsigned indention_step_size_;
|
||||
|
||||
bool need_layout_;
|
||||
|
||||
ttree_view_node* root_node_;
|
||||
|
||||
ttree_view_node* selected_item_;
|
||||
|
||||
boost::function<void ()> selection_change_callback_;
|
||||
|
||||
/** Layouts the children if needed. */
|
||||
void layout();
|
||||
|
||||
/** Inherited from tcontainer_. */
|
||||
virtual void finalize_setup();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user