[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.61,1.62 ListWidget.h,1.36,1.37

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sat Jan 28 10:22:00 CET 2006


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7097

Modified Files:
	ListWidget.cpp ListWidget.h 
Log Message:
Applied my own patch #1416897, in an attempt to speed up list widget
redrawing. There may be regressions, but none are known at the moment.


Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- ListWidget.cpp	27 Jan 2006 15:43:23 -0000	1.61
+++ ListWidget.cpp	28 Jan 2006 18:21:46 -0000	1.62
@@ -55,9 +55,15 @@
 
 	// FIXME: This flag should come from widget definition
 	_editable = true;
+
+	_textWidth = new int[_entriesPerPage];
+
+	for (int i = 0; i < _entriesPerPage; i++)
+		_textWidth[i] = 0;
 }
 
 ListWidget::~ListWidget() {
+	delete[] _textWidth;
 }
 
 void ListWidget::setSelected(int item) {
@@ -316,30 +322,41 @@
 			if (_hasFocus)
 				inverted = true;
 			else
-				g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y + 1 + kLineHeight * i, _x+_w-1, y+fontHeight-1), _hints, Theme::kWidgetBackgroundBorderSmall);
+				g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y + 1 + kLineHeight * i, _x + _w - 1, y + fontHeight - 1), _hints, Theme::kWidgetBackgroundBorderSmall);
 		}
 
+		Common::Rect r(getEditRect());
+
 		// If in numbering mode, we first print a number prefix
 		if (_numberingMode != kListNumberingOff) {
 			char temp[10];
 			sprintf(temp, "%2d. ", (pos + _numberingMode));
 			buffer = temp;
-			g_gui.theme()->drawText(Common::Rect(_x+2, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
+			g_gui.theme()->drawText(Common::Rect(_x + 2, y, _x + r.left, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
 		}
 
-		Common::Rect r(getEditRect());
-		if (_selectedItem == pos && _editMode) {
+		int width;
 
+		if (_selectedItem == pos && _editMode) {
 			buffer = _editString;
 			adjustOffset();
 			deltax = -_editScrollOffset;
-
-			g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
+			width = _w - r.left + deltax - 2;
+			g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x + r.left - deltax + width, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
 		} else {
+			int maxWidth = _textWidth[i];
 			buffer = _list[pos];
 			deltax = 0;
-			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
+			if (_selectedItem != pos)
+				width = g_gui.getStringWidth(buffer);
+			else
+				width = _w - r.left - 2;
+			if (width > maxWidth)
+				maxWidth = width;
+			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
 		}
+
+		_textWidth[i] = width;
 	}
 }
 

Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- ListWidget.h	18 Jan 2006 17:39:35 -0000	1.36
+++ ListWidget.h	28 Jan 2006 18:21:46 -0000	1.37
@@ -100,6 +100,8 @@
 
 	void lostFocusWidget();
 	void scrollToCurrent();
+
+	int *_textWidth;
 };
 
 } // End of namespace GUI





More information about the Scummvm-git-logs mailing list