Partial implementation of feature request #2834637 "GUI: Allow greying out dummy ListWidget entries", based on a slighly modified version of my latest patch included there.

svn-id: r43551
This commit is contained in:
Johannes Schickel 2009-08-20 09:19:37 +00:00
parent a2a6967a63
commit a8bffbe6a7
8 changed files with 812 additions and 774 deletions

View file

@ -141,7 +141,7 @@ void ListWidget::setSelected(int item) {
}
}
void ListWidget::setList(const StringList &list) {
void ListWidget::setList(const StringList &list, const ColorList *colors) {
if (_editMode && _caretVisible)
drawCaret(true);
@ -150,6 +150,12 @@ void ListWidget::setList(const StringList &list) {
_list = list;
_filter.clear();
_listIndex.clear();
_listColors.clear();
if (colors) {
_listColors = *colors;
assert(_listColors.size() == _dataList.size());
}
int size = list.size();
if (_currentPos >= size)
@ -162,7 +168,19 @@ void ListWidget::setList(const StringList &list) {
scrollBarRecalc();
}
void ListWidget::append(const String &s) {
void ListWidget::append(const String &s, ThemeEngine::FontColor color) {
if (_dataList.size() == _listColors.size()) {
// If the color list has the size of the data list, we append the color.
_listColors.push_back(color);
} else if (!_listColors.size() && color != ThemeEngine::kFontColorNormal) {
// If it's the first entry to use a non default color, we will fill
// up all other entries of the color list with the default color and
// add the requested color for the new entry.
for (uint i = 0; i < _dataList.size(); ++i)
_listColors.push_back(ThemeEngine::kFontColorNormal);
_listColors.push_back(color);
}
_dataList.push_back(s);
_list.push_back(s);
@ -431,17 +449,26 @@ void ListWidget::drawWidget() {
int width;
ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
if (!_listColors.empty()) {
if (_filter.empty() || _selectedItem == -1)
color = _listColors[pos];
else
color = _listColors[_listIndex[pos]];
}
if (_selectedItem == pos && _editMode) {
buffer = _editString;
adjustOffset();
width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW;
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
} else {
buffer = _list[pos];
width = _w - r.left - scrollbarW;
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
}
_textWidth[i] = width;