Author: mordante
Date: Sun Jul 13 20:07:58 2008
New Revision: 28018

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28018&view=rev
Log:
Make sure the pixels per step is a floating point number when needed.
Use a better positioner sizing algorithm when not items can be shown.

Modified:
    trunk/src/gui/widgets/scrollbar.cpp

Modified: trunk/src/gui/widgets/scrollbar.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar.cpp?rev=28018&r1=28017&r2=28018&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar.cpp (original)
+++ trunk/src/gui/widgets/scrollbar.cpp Sun Jul 13 20:07:58 2008
@@ -232,7 +232,7 @@
                // We can show them all.
                available_length += minimum_positioner_length();
 
-               pixels_per_step_ = available_length / steps;
+               pixels_per_step_ = available_length / static_cast<float>(steps);
 
                positioner_length_ = static_cast<unsigned>(pixels_per_step_ * 
visible_items_) + available_length % steps;
 
@@ -242,8 +242,14 @@
                WRN_G << "The scrollbar is too small for the"
                        " number of items, movement might seem jerky.\n";
                
-               pixels_per_step_ = available_length / steps;
-               positioner_length_ = minimum_positioner_length();
+               pixels_per_step_ = available_length / static_cast<float>(steps);
+
+               // When a listbox is in 'pixel mode' (not fixed row height) the
+               // positioner might still be rather big so scale it 
proportional but
+               // respect the minimum.
+               positioner_length_ = std::max(
+                       available_length * visible_items_ / item_count_, 
+                       minimum_positioner_length());
        }
 
        set_item_position(item_position_);


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

Reply via email to