aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-30 19:43:36 +0000
committerJohannes Schickel2009-07-30 19:43:36 +0000
commitd6d5da0d9f13fdac51bafbe45785c06634b43658 (patch)
tree0e5ad2c4105a72f5890ff384c24e6b86cb82b6ee
parentf5112efa110f736b53409e357504e5a8570b80ca (diff)
downloadscummvm-rg350-d6d5da0d9f13fdac51bafbe45785c06634b43658.tar.gz
scummvm-rg350-d6d5da0d9f13fdac51bafbe45785c06634b43658.tar.bz2
scummvm-rg350-d6d5da0d9f13fdac51bafbe45785c06634b43658.zip
Change code to use our fractional utilities.
svn-id: r42940
-rw-r--r--gui/ListWidget.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 3d4c10859f..7551acac48 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -24,6 +24,8 @@
#include "common/system.h"
#include "common/events.h"
+#include "common/frac.h"
+
#include "gui/ListWidget.h"
#include "gui/ScrollBarWidget.h"
#include "gui/dialog.h"
@@ -538,13 +540,15 @@ void ListWidget::reflowLayout() {
// of the list.
// We do a rough rounding on the decimal places of Entries Per Page,
// to add another entry even if it goes a tad over the padding.
- _entriesPerPage = ((_h - _topPadding - _bottomPadding) << 16) / kLineHeight;
+ frac_t entriesPerPage = intToFrac(_h - _topPadding - _bottomPadding) / kLineHeight;
- if ((uint)(_entriesPerPage & 0xFFFF) >= 0xF000)
- _entriesPerPage += (1 << 16);
+ // Our threshold before we add another entry is 0.9375 (0xF000 with FRAC_BITS being 16).
+ const frac_t threshold = intToFrac(15) / 16;
- _entriesPerPage >>= 16;
+ if ((frac_t)(entriesPerPage & FRAC_LO_MASK) >= threshold)
+ entriesPerPage += FRAC_ONE;
+ _entriesPerPage = fracToInt(entriesPerPage);
assert(_entriesPerPage > 0);
delete[] _textWidth;