mail[Wesnoth-commits] r40412 - in /trunk/src/gui/widgets: generator.cpp generator_private.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on December 26, 2009 - 18:05:
Author: mordante
Date: Sat Dec 26 18:05:09 2009
New Revision: 40412

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40412&view=rev
Log:
Improve show and hiding of rows.

Some glitches existed where items were incorrectly placed after an
update. Now the items are recalculated and replaced correctly.

Modified:
    trunk/src/gui/widgets/generator.cpp
    trunk/src/gui/widgets/generator_private.hpp

Modified: trunk/src/gui/widgets/generator.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/generator.cpp?rev=40412&r1=40411&r2=40412&view=diff
==============================================================================
--- trunk/src/gui/widgets/generator.cpp (original)
+++ trunk/src/gui/widgets/generator.cpp Sat Dec 26 18:05:09 2009
@@ -103,7 +103,6 @@
 
 void thorizontal_list::set_item_shown(const unsigned index, const bool show)
 {
-       // Adjust the size.
        tpoint best_size = this->get_best_size();
        const int item_width = show
                        ?  get_item(index).get_best_size().x
@@ -111,13 +110,6 @@
 
        best_size.x += item_width;
        this->set_layout_size(best_size);
-
-       // Adjust the placement.
-       for(unsigned i = index + 1; i < get_item_count(); ++i) {
-               tpoint origin = get_item(i).get_origin();
-               origin.x += item_width;
-               get_item(i).set_origin(origin);
-       }
 }
 
 void thorizontal_list::create_item(const unsigned /*index*/)
@@ -317,7 +309,6 @@
 
 void tvertical_list::set_item_shown(const unsigned index, const bool show)
 {
-       // Adjust the size.
        tpoint best_size = this->get_best_size();
        const int item_height = show
                        ?  get_item(index).get_best_size().y
@@ -325,13 +316,6 @@
 
        best_size.y += item_height;
        this->set_layout_size(best_size);
-
-       // Adjust the placement.
-       for(unsigned i = index + 1; i < get_item_count(); ++i) {
-               tpoint origin = get_item(i).get_origin();
-               origin.y += item_height;
-               get_item(i).set_origin(origin);
-       }
 }
 
 void tvertical_list::create_item(const unsigned /*index*/)

Modified: trunk/src/gui/widgets/generator_private.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/generator_private.hpp?rev=40412&r1=40411&r2=40412&view=diff
==============================================================================
--- trunk/src/gui/widgets/generator_private.hpp (original)
+++ trunk/src/gui/widgets/generator_private.hpp Sat Dec 26 18:05:09 2009
@@ -167,6 +167,9 @@
 
        /**
         * Called when an item is shown or hidden.
+        *
+        * This function is responsible to calculate the new best size, the
+        * generator will call @ref set_size later.
         *
         * @param index               The item to show or hide.
         * @param show                If true shows the item, else hides it.
@@ -649,13 +652,19 @@
                                
items_[index]->grid.set_visible(twidget::VISIBLE);
                        }
 
+                       /*** Calculate the new best size. ***/
                        placement::set_item_shown(index, show);
 
+                       /*** Set the proper visible state. ***/
                        items_[index]->shown = show;
                        if(!show) {
                                
items_[index]->grid.set_visible(twidget::INVISIBLE);
                        }
 
+                       /*** Put the items at their new places. ***/
+                       placement::set_size(this->get_origin(), 
this->get_best_size());
+
+                       /*** Update the selection. ***/
                        minimum_selection::set_item_shown(index, show);
                }
        }




Related Messages


Powered by MHonArc, Updated Sat Dec 26 18:20:12 2009