mail[Wesnoth-commits] r33670 - /trunk/src/gui/widgets/


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

Header


Content

Posted by koraq on March 15, 2009 - 13:06:
Author: mordante
Date: Sun Mar 15 13:06:50 2009
New Revision: 33670

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33670&view=rev
Log:
Add a new init routine.

This is the start of a new and better layout algorithm.

These changes are rather late in the 1.6 cycle and will only be used if
the previous routines find no solution. This way the changes can cause
no regressions. In 1.7 these routines will become the default layout
algorithm.

Modified:
    trunk/src/gui/widgets/container.cpp
    trunk/src/gui/widgets/container.hpp
    trunk/src/gui/widgets/control.cpp
    trunk/src/gui/widgets/control.hpp
    trunk/src/gui/widgets/generator.hpp
    trunk/src/gui/widgets/generator_private.hpp
    trunk/src/gui/widgets/grid.cpp
    trunk/src/gui/widgets/grid.hpp
    trunk/src/gui/widgets/scrollbar_container.cpp
    trunk/src/gui/widgets/scrollbar_container.hpp
    trunk/src/gui/widgets/widget.hpp

Modified: trunk/src/gui/widgets/container.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.cpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.cpp (original)
+++ trunk/src/gui/widgets/container.cpp Sun Mar 15 13:06:50 2009
@@ -26,6 +26,14 @@
        grid_.layout_init();
 }
 
+void tcontainer_::layout_init2(const bool full_initialization)
+{
+       // Inherited.
+       tcontrol::layout_init2(full_initialization);
+
+       grid_.layout_init2(full_initialization);
+}
+
 void tcontainer_::layout_wrap(const unsigned maximum_width)
 {
        // Inherited.

Modified: trunk/src/gui/widgets/container.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.hpp (original)
+++ trunk/src/gui/widgets/container.hpp Sun Mar 15 13:06:50 2009
@@ -49,6 +49,7 @@
 
        /** Inherited from tcontrol. */
        void layout_init();
+       void layout_init2(const bool full_initialization);
 
 private:
        /** Inherited from twidget. */

Modified: trunk/src/gui/widgets/control.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.cpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.cpp (original)
+++ trunk/src/gui/widgets/control.cpp Sun Mar 15 13:06:50 2009
@@ -124,6 +124,16 @@
 {
        twidget::layout_init();
        shrunken_ = false;
+}
+
+void tcontrol::layout_init2(const bool full_initialization)
+{
+       // Inherited.
+       twidget::layout_init2(full_initialization);
+
+       if(full_initialization) {
+               shrunken_ = false;
+       }
 }
 
 void tcontrol::layout_wrap(const unsigned maximum_width)

Modified: trunk/src/gui/widgets/control.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.hpp (original)
+++ trunk/src/gui/widgets/control.hpp Sun Mar 15 13:06:50 2009
@@ -151,6 +151,7 @@
        /** @todo Also handle the tooltip state if shrunken_ &&
         * use_tooltip_on_label_overflow_. */
        void layout_init();
+       void layout_init2(const bool full_initialization);
 
        /** Inherited from twidget. */
        void layout_wrap(const unsigned maximum_width);

Modified: trunk/src/gui/widgets/generator.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/generator.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/generator.hpp (original)
+++ trunk/src/gui/widgets/generator.hpp Sun Mar 15 13:06:50 2009
@@ -200,6 +200,7 @@
 
        /** Inherited from twidget. */
        virtual void layout_init() = 0;
+       virtual void layout_init2(const bool /*full_initialization*/) = 0;
 
        /** Inherited from twidget. */
        virtual tpoint calculate_best_size() const = 0;

Modified: trunk/src/gui/widgets/generator_private.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/generator_private.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/generator_private.hpp (original)
+++ trunk/src/gui/widgets/generator_private.hpp Sun Mar 15 13:06:50 2009
@@ -604,6 +604,16 @@
                }
        }
 
+       void layout_init2(const bool full_initialization)
+       {
+               foreach(titem* item, items_) {
+                       if(item->grid.get_visible() != twidget::INVISIBLE) {
+                               item->grid.layout_init2(full_initialization);
+                       }
+               }
+       }
+
+
        /** Inherited from tgenerator_. */
        tpoint calculate_best_size() const
        {

Modified: trunk/src/gui/widgets/grid.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Sun Mar 15 13:06:50 2009
@@ -194,6 +194,21 @@
                twidget* widget = child.widget();
                if(widget) {
                        widget->layout_init();
+               }
+       }
+}
+
+void tgrid::layout_init2(const bool full_initialization)
+{
+       // Inherited.
+       twidget::layout_init2(full_initialization);
+
+       // Clear child caches.
+       foreach(tchild& child, children_) {
+
+               twidget* widget = child.widget();
+               if(widget && widget->get_visible() != twidget::INVISIBLE) {
+                       widget->layout_init2(full_initialization);
                }
        }
 }

Modified: trunk/src/gui/widgets/grid.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Sun Mar 15 13:06:50 2009
@@ -181,6 +181,7 @@
 
        /** Inherited from twidget. */
        void layout_init();
+       void layout_init2(const bool full_initialization);
 
 private:
 

Modified: trunk/src/gui/widgets/scrollbar_container.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.cpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.cpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.cpp Sun Mar 15 13:06:50 2009
@@ -112,6 +112,36 @@
        content_grid_->layout_init();
 }
 
+void tscrollbar_container::layout_init2(const bool full_initialization)
+{
+       // Inherited.
+       tcontainer_::layout_init2(full_initialization);
+
+       if(full_initialization) {
+               /*
+                * When the scrollbars should be shown when needed, assume 
they're not
+                * needed and unhide them when needed.
+                */
+               if(initial_vertical_scrollbar_mode_ == SHOW_WHEN_NEEDED) {
+                       vertical_scrollbar_mode_ = HIDE;
+               } else {
+                       vertical_scrollbar_mode_ = 
initial_vertical_scrollbar_mode_;
+               }
+               show_vertical_scrollbar();
+
+               if(initial_vertical_scrollbar_mode_ == SHOW_WHEN_NEEDED) {
+                       horizontal_scrollbar_mode_ = HIDE;
+               } else {
+                       horizontal_scrollbar_mode_ = 
initial_horizontal_scrollbar_mode_;
+               }
+               show_horizontal_scrollbar();
+       }
+
+       assert(content_grid_);
+       content_grid_->layout_init2(full_initialization);
+
+}
+
 void tscrollbar_container::layout_wrap(const unsigned maximum_width)
 {
        // Inherited.

Modified: trunk/src/gui/widgets/scrollbar_container.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.hpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.hpp Sun Mar 15 13:06:50 2009
@@ -68,6 +68,7 @@
 
        /** Inherited from tcontainer_. */
        void layout_init();
+       void layout_init2(const bool full_initialization);
 
        /** Inherited from tcontainer_. */
        bool can_wrap() const

Modified: trunk/src/gui/widgets/widget.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=33670&r1=33669&r2=33670&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Sun Mar 15 13:06:50 2009
@@ -146,6 +146,17 @@
        /** Initializes the layout phase. */
        virtual void layout_init() { layout_size_ = tpoint(0,0); }
 
+       /** 
+        * Initializes the layout phase.
+        *
+        * @param full_initialization Reset the widget to its initial state. 
This
+        *                            flag is used to change the status in the
+        *                            first layout run, but keep the status 
when a
+        *                            relayout phase happens.
+        */
+       virtual void layout_init2(const bool /*full_initialization*/)
+               { layout_size_ = tpoint(0,0); }
+
        /**
         * Gets the best size for the widget.
         *




Related Messages


Powered by MHonArc, Updated Sun Mar 15 13:20:16 2009