Author: mordante
Date: Sun Feb 14 20:36:32 2010
New Revision: 41215

URL: http://svn.gna.org/viewcvs/wesnoth?rev=41215&view=rev
Log:
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.

Modified:
    trunk/src/gui/widgets/tree_view.cpp
    trunk/src/gui/widgets/tree_view.hpp

Modified: trunk/src/gui/widgets/tree_view.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/tree_view.cpp?rev=41215&r1=41214&r2=41215&view=diff
==============================================================================
--- trunk/src/gui/widgets/tree_view.cpp (original)
+++ trunk/src/gui/widgets/tree_view.cpp Sun Feb 14 20:36:32 2010
@@ -31,6 +31,7 @@
        : 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 @@
        // Inherited.
        tscrollbar_container::child_populate_dirty_list(caller, call_stack);
 
+       layout();
+
        assert(root_node_);
        root_node_->impl_populate_dirty_list(caller, call_stack);
 }
@@ -92,6 +95,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 {

Modified: trunk/src/gui/widgets/tree_view.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/tree_view.hpp?rev=41215&r1=41214&r2=41215&view=diff
==============================================================================
--- trunk/src/gui/widgets/tree_view.hpp (original)
+++ trunk/src/gui/widgets/tree_view.hpp Sun Feb 14 20:36:32 2010
@@ -107,11 +107,16 @@
 
        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();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to