Author: mordante
Date: Sun Jan 17 12:07:58 2010
New Revision: 40721

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40721&view=rev
Log:
Add a function to request a content resize.

This will be used in the MP lobby.

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

Modified: trunk/src/gui/widgets/listbox.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.cpp?rev=40721&r1=40720&r2=40721&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.cpp (original)
+++ trunk/src/gui/widgets/listbox.cpp Sun Jan 17 12:07:58 2010
@@ -205,6 +205,25 @@
                }
        }
        assert(false);
+}
+
+bool tlistbox::update_content_size()
+{
+       if(get_visible() == twidget::INVISIBLE) {
+               return true;
+       }
+
+       if(get_size() == tpoint(0, 0)) {
+               return false;
+       }
+
+       if(content_resize_request(true)) {
+               content_grid_->set_visible_area(content_visible_area());
+               set_dirty();
+               return true;
+       }
+
+       return false;
 }
 
 void tlistbox::set_size(const tpoint& origin, const tpoint& size)

Modified: trunk/src/gui/widgets/listbox.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=40721&r1=40720&r2=40721&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Sun Jan 17 12:07:58 2010
@@ -175,6 +175,23 @@
        void set_self_active(const bool /*active*/)  {}
 //             { state_ = active ? ENABLED : DISABLED; }
 //
+
+       /**
+        * Request to update the size of the content after changing the content.
+        *
+        * When a resize is required the container first can try to handle it
+        * itself. If it can't honour the request the function will call @ref
+        * twindow::invalidate_layout().
+        *
+        * @note Calling this function on a widget with size == (0, 0) results
+        * false but doesn't call invalidate_layout, the engine expects to be in
+        * build up phase with the layout already invalidated.
+        *
+        * @returns                      True if the resizing succeeded, false
+        *                               otherwise.
+        */
+       bool update_content_size();
+
        /***** ***** ***** ***** inherited ***** ***** ****** *****/
 
        /** Inherited from tscrollbar_container. */


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

Reply via email to