Author: mordante
Date: Sun May 13 17:46:12 2012
New Revision: 54173

URL: http://svn.gna.org/viewcvs/wesnoth?rev=54173&view=rev
Log:
Fix the formatting for a growing pane.

The code seems to work for this specific case but needs more testing.

This commit finishes the proof-of-concept prototype it seems the big
hurdles in the listbox have been tackled. Now need to focus on getting a
real widget out of this prototype.

The code is used to experiment with a different approach of the
implementation of a listbox.

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

Modified: trunk/src/gui/widgets/pane.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/pane.cpp?rev=54173&r1=54172&r2=54173&view=diff
==============================================================================
--- trunk/src/gui/widgets/pane.cpp (original)
+++ trunk/src/gui/widgets/pane.cpp Sun May 13 17:46:12 2012
@@ -296,6 +296,26 @@
        }
 }
 
+void tpane::place_or_set_origin_children()
+{
+       unsigned y = 0;
+
+       BOOST_FOREACH(titem& item, items_) {
+               if(item.grid->get_visible() == twidget::INVISIBLE) {
+                       continue;
+               }
+
+               DBG_GUI_L << LOG_HEADER << " offset " << y << '\n';
+               if(item.grid->get_size() != item.grid->get_best_size()) {
+                       item.grid->place(tpoint(0, y), 
item.grid->get_best_size());
+               } else {
+                       item.grid->set_origin(tpoint(0, y));
+               }
+               y += item.grid->get_height();
+       }
+
+}
+
 void tpane::signal_handler_request_placement(
                  tdispatcher& dispatcher
                , const event::tevent event
@@ -308,6 +328,15 @@
                BOOST_FOREACH(titem& item, items_) {
                        if(item.grid->has_widget(widget)) {
                                if(item.grid->get_visible() != 
twidget::INVISIBLE) {
+
+                                       /*
+                                        * This time we call init layout but 
also the linked widget
+                                        * update this makes things work 
properly for the
+                                        * addon_list. This code can use some 
more tuning,
+                                        * polishing and testing.
+                                        */
+                                       item.grid->layout_init(false);
+                                       get_window()->layout_linked_widgets();
 
                                        /*
                                         * By not calling init layout it uses 
its previous size
@@ -316,7 +345,7 @@
                                         */
                                        item.grid->place(tpoint(0, 0), 
item.grid->get_best_size());
                                }
-                               set_origin_children();
+                               place_or_set_origin_children();
                                DBG_GUI_E << LOG_HEADER << ' ' << event << " 
handled.\n";
                                handled = true;
                                return;

Modified: trunk/src/gui/widgets/pane.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/pane.hpp?rev=54173&r1=54172&r2=54173&view=diff
==============================================================================
--- trunk/src/gui/widgets/pane.hpp (original)
+++ trunk/src/gui/widgets/pane.hpp Sun May 13 17:46:12 2012
@@ -164,6 +164,17 @@
         */
        void set_origin_children();
 
+       /**
+        * Places or moves the children on the pane.
+        *
+        * If the child has its best size it's move else placed.
+        *
+        * @note It would probably be possible to merge all three placement
+        * routines into one and using a flag for what to do: place, set_origin 
or
+        * place_or_set_origin.
+        */
+       void place_or_set_origin_children();
+
        /***** ***** ***** signal handlers ***** ****** *****/
 
        void signal_handler_request_placement(

Modified: trunk/src/gui/widgets/window.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=54173&r1=54172&r2=54173&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Sun May 13 17:46:12 2012
@@ -39,6 +39,7 @@
 
 class tdialog;
 class tdebug_layout_graph;
+class tpane;
 
 namespace event {
        class tdistributor;
@@ -56,6 +57,7 @@
        friend twindow *build(CVideo &, const twindow_builder::tresolution *);
        friend struct twindow_implementation;
        friend class tinvalidate_layout_blocker;
+       friend class tpane;
 
 public:
 


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

Reply via email to