[Scummvm-cvs-logs] SF.net SVN: scummvm:[42940] scummvm/trunk/gui/ListWidget.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jul 30 21:43:37 CEST 2009


Revision: 42940
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42940&view=rev
Author:   lordhoto
Date:     2009-07-30 19:43:36 +0000 (Thu, 30 Jul 2009)

Log Message:
-----------
Change code to use our fractional utilities.

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2009-07-30 18:27:50 UTC (rev 42939)
+++ scummvm/trunk/gui/ListWidget.cpp	2009-07-30 19:43:36 UTC (rev 42940)
@@ -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 @@
 	// 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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list