aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-01-28 18:21:46 +0000
committerTorbjörn Andersson2006-01-28 18:21:46 +0000
commit91d253c5b142b751fea3596b519d0eb0efb0c6a0 (patch)
tree67bd6fffc27aa972768869dbfab51309f8f9b2eb
parentdd02251cb30221a9b3e55602afff364b76dd9b3c (diff)
downloadscummvm-rg350-91d253c5b142b751fea3596b519d0eb0efb0c6a0.tar.gz
scummvm-rg350-91d253c5b142b751fea3596b519d0eb0efb0c6a0.tar.bz2
scummvm-rg350-91d253c5b142b751fea3596b519d0eb0efb0c6a0.zip
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. svn-id: r20271
-rw-r--r--gui/ListWidget.cpp31
-rw-r--r--gui/ListWidget.h2
2 files changed, 26 insertions, 7 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 9f3797af15..82f92d81a5 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -55,9 +55,15 @@ ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize w
// 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 @@ void ListWidget::drawWidget(bool hilite) {
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;
}
}
diff --git a/gui/ListWidget.h b/gui/ListWidget.h
index 0156733226..e5e217c9b8 100644
--- a/gui/ListWidget.h
+++ b/gui/ListWidget.h
@@ -100,6 +100,8 @@ protected:
void lostFocusWidget();
void scrollToCurrent();
+
+ int *_textWidth;
};
} // End of namespace GUI