Author: mordante
Date: Fri May  1 21:42:11 2009
New Revision: 35395

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35395&view=rev
Log:
Add linked widgets in the new layout algorithm.

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

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=35395&r1=35394&r2=35395&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Fri May  1 21:42:11 2009
@@ -891,7 +891,7 @@
        const int maximum_height = automatic_placement_ ?
                        settings::screen_height : h_(variables);
 
-       /** @todo Handle linked widgets. */
+       NEW_layout_linked_widgets();
 
        try {
                twindow_implementation::NEW_layout(*this, maximum_width, 
maximum_height);
@@ -965,6 +965,44 @@
 
        // The widgets might have moved so set the mouse location properly.
        init_mouse_location();
+}
+
+void twindow::NEW_layout_linked_widgets()
+{
+       // evaluate the group sizes
+       typedef std::pair<const std::string, tlinked_size> hack;
+       foreach(hack& linked_size, linked_size_) {
+
+               tpoint max_size(0, 0);
+
+               // Determine the maximum size.
+               foreach(twidget* widget, linked_size.second.widgets) {
+
+                       const tpoint size = widget->get_best_size();
+
+                       if(size.x > max_size.x) {
+                               max_size.x = size.x;
+                       }
+                       if(size.y > max_size.y) {
+                               max_size.y = size.y;
+                       }
+               }
+
+               // Set the maximum size.
+               foreach(twidget* widget, linked_size.second.widgets) {
+
+                       tpoint size = widget->get_best_size();
+
+                       if(linked_size.second.width) {
+                               size.x = max_size.x;
+                       }
+                       if(linked_size.second.height) {
+                               size.y = max_size.y;
+                       }
+
+                       widget->set_layout_size(size);
+               }
+       }
 }
 
 void twindow::do_show_tooltip(const tpoint& location, const t_string& tooltip)
@@ -1155,6 +1193,7 @@
        } catch (tlayout_exception_width_modified&) {
                DBG_GUI_L << "Status: Width has been modified, rerun.\n";
                window.NEW_layout_init(false);
+               window.NEW_layout_linked_widgets();
                NEW_layout(window, maximum_width, maximum_height);
                return;
        }
@@ -1321,6 +1360,7 @@
  * - Relayout:
  *   - Initialize all widgets
  *     (@ref gui2::twidget::NEW_layout_init (full_initialization = false))
+ *   - Handle shared sizes, since the reinitialization resets that state.
  *   - Goto start layout loop.
  *
  * @section grid Grid

Modified: trunk/src/gui/widgets/window.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=35395&r1=35394&r2=35395&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Fri May  1 21:42:11 2009
@@ -484,6 +484,13 @@
         */
        void NEW_layout();
 
+       /**
+        * Layouts the linked widgets.
+        *
+        * @see layout_algorihm for more information.
+        */
+       void NEW_layout_linked_widgets();
+
        /** Inherited from tevent_handler. */
        void do_show_tooltip(const tpoint& location, const t_string& tooltip);
 


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

Reply via email to