[Scummvm-cvs-logs] CVS: scummvm/gui ScrollBarWidget.cpp,1.3,1.4

Max Horn fingolfin at users.sourceforge.net
Wed Oct 9 12:33:16 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv23607/gui

Modified Files:
	ScrollBarWidget.cpp 
Log Message:
Fix for bug #620854 (launcher crash)

Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ScrollBarWidget.cpp	1 Oct 2002 22:39:55 -0000	1.3
+++ ScrollBarWidget.cpp	9 Oct 2002 19:32:54 -0000	1.4
@@ -75,7 +75,7 @@
 	int old_pos = _currentPos;
 
 	// Do nothing if there are less items than fit on one page
-	if (_numEntries < _entriesPerPage)
+	if (_numEntries <= _entriesPerPage)
 		return;
 
 	if (y <= UP_DOWN_BOX_HEIGHT) {
@@ -107,7 +107,7 @@
 void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
 {
 	// Do nothing if there are less items than fit on one page
-	if (_numEntries < _entriesPerPage)
+	if (_numEntries <= _entriesPerPage)
 		return;
 
 	if (_draggingPart == kSliderPart) {
@@ -165,7 +165,7 @@
 
 void ScrollBarWidget::checkBounds(int old_pos)
 {
-	if (_numEntries < _entriesPerPage || _currentPos < 0)
+	if (_numEntries <= _entriesPerPage || _currentPos < 0)
 		_currentPos = 0;
 	else if (_currentPos > _numEntries - _entriesPerPage)
 		_currentPos = _numEntries - _entriesPerPage;
@@ -179,14 +179,19 @@
 
 void ScrollBarWidget::recalc()
 {
-	_sliderHeight = (_h - 2 * UP_DOWN_BOX_HEIGHT) * _entriesPerPage / _numEntries;
-	if (_sliderHeight < UP_DOWN_BOX_HEIGHT)
-		_sliderHeight = UP_DOWN_BOX_HEIGHT;
+	if (_numEntries > _entriesPerPage) {
+		_sliderHeight = (_h - 2 * UP_DOWN_BOX_HEIGHT) * _entriesPerPage / _numEntries;
+		if (_sliderHeight < UP_DOWN_BOX_HEIGHT)
+			_sliderHeight = UP_DOWN_BOX_HEIGHT;
 
-	_sliderPos =
-		UP_DOWN_BOX_HEIGHT + (_h - 2 * UP_DOWN_BOX_HEIGHT - _sliderHeight) * _currentPos / (_numEntries - _entriesPerPage);
-	if (_sliderPos < 0)
-		_sliderPos = 0;
+		_sliderPos =
+			UP_DOWN_BOX_HEIGHT + (_h - 2 * UP_DOWN_BOX_HEIGHT - _sliderHeight) * _currentPos / (_numEntries - _entriesPerPage);
+		if (_sliderPos < 0)
+			_sliderPos = 0;
+	} else {
+		_sliderHeight = _h - 2 * UP_DOWN_BOX_HEIGHT;
+		_sliderPos = UP_DOWN_BOX_HEIGHT;
+	}
 }
 
 
@@ -194,7 +199,7 @@
 {
 	NewGui *gui = _boss->getGui();
 	int bottomY = _y + _h;
-	bool isSinglePage = (_numEntries < _entriesPerPage);
+	bool isSinglePage = (_numEntries <= _entriesPerPage);
 
 	gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
 





More information about the Scummvm-git-logs mailing list