Ticket #7733: alt_list_color_v2.patch

File alt_list_color_v2.patch, 7.6 KB (added by lordhoto, 15 years ago)

Patch against r43438 (trunk).

  • gui/ListWidget.cpp

    diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
    index 7551aca..6f4fd25 100644
    a b void ListWidget::setSelected(int item) {  
    141141        }
    142142}
    143143
    144 void ListWidget::setList(const StringList &list) {
     144void ListWidget::setList(const StringList &list, const ColorList *colors) {
    145145        if (_editMode && _caretVisible)
    146146                drawCaret(true);
    147147
    void ListWidget::setList(const StringList &list) {  
    150150        _list = list;
    151151        _filter.clear();
    152152        _listIndex.clear();
     153        _listColors.clear();
     154
     155        if (colors) {
     156                _listColors = *colors;
     157                assert(_listColors.size() == _dataList.size());
     158        }
    153159
    154160        int size = list.size();
    155161        if (_currentPos >= size)
    void ListWidget::setList(const StringList &list) {  
    162168        scrollBarRecalc();
    163169}
    164170
    165 void ListWidget::append(const String &s) {
     171void ListWidget::append(const String &s, ThemeEngine::FontColor color) {
     172        if (_dataList.size() == _listColors.size()) {
     173                // If the color list has the size of the data list, we append the color.
     174                _listColors.push_back(color);
     175        } else if (!_listColors.size() && color != ThemeEngine::kFontColorNormal) {
     176                // If it's the first entry to use a non default color, we will fill
     177                // up all other entries of the color list with the default color and
     178                // add the requested color for the new entry.
     179                for (uint i = 0; i < _dataList.size(); ++i)
     180                        _listColors.push_back(ThemeEngine::kFontColorNormal);
     181                _listColors.push_back(color);
     182        }
     183
    166184        _dataList.push_back(s);
    167185        _list.push_back(s);
    168186
    void ListWidget::drawWidget() {  
    431449
    432450                int width;
    433451
     452                ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
     453
     454                if (!_listColors.empty()) {
     455                        if (_filter.empty() || _selectedItem == -1)
     456                                color = _listColors[pos];
     457                        else
     458                                color = _listColors[_listIndex[pos]];
     459                }
     460
    434461                if (_selectedItem == pos && _editMode) {
    435462                        buffer = _editString;
    436463                        adjustOffset();
    437464                        width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW;
    438                         g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
    439                                                                         buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
     465                        g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
     466                                                                        Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
    440467                } else {
    441468                        buffer = _list[pos];
    442469                        width = _w - r.left - scrollbarW;
    443                         g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
    444                                                                         buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
     470                        g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
     471                                                                        Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
    445472                }
    446473
    447474                _textWidth[i] = width;
  • gui/ListWidget.h

    diff --git a/gui/ListWidget.h b/gui/ListWidget.h
    index 203cd88..1ee6a94 100644
    a b  
    2828#include "gui/editable.h"
    2929#include "common/str.h"
    3030
     31#include "gui/ThemeEngine.h"
     32
    3133namespace GUI {
    3234
    3335class ScrollBarWidget;
    class ListWidget : public EditableWidget {  
    5153public:
    5254        typedef Common::String String;
    5355        typedef Common::StringList StringList;
     56        typedef Common::Array<ThemeEngine::FontColor> ColorList;
    5457protected:
    5558        StringList              _list;
    5659        StringList              _dataList;
     60        ColorList               _listColors;
    5761        Common::Array<int>              _listIndex;
    5862        bool                    _editable;
    5963        bool                    _editMode;
    public:  
    8791
    8892        virtual Widget *findWidget(int x, int y);
    8993
    90         void setList(const StringList &list);
    91         void append(const String &s);
     94        void setList(const StringList &list, const ColorList *colors = 0);
     95        void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
    9296        const StringList &getList()     const                   { return _dataList; }
    9397        int getSelected() const                                         { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
    9498        void setSelected(int item);
  • gui/saveload.cpp

    diff --git a/gui/saveload.cpp b/gui/saveload.cpp
    index ce700c1..dc1b1b4 100644
    a b void SaveLoadChooser::updateSaveList() {  
    316316        int curSlot = 0;
    317317        int saveSlot = 0;
    318318        StringList saveNames;
     319        ListWidget::ColorList colors;
    319320        for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) {
    320321                // Handle gaps in the list of save games
    321322                saveSlot = atoi(x->save_slot().c_str());
    void SaveLoadChooser::updateSaveList() {  
    324325                                SaveStateDescriptor dummySave(curSlot, "");
    325326                                _saveList.insert_at(curSlot, dummySave);
    326327                                saveNames.push_back(dummySave.description());
     328                                colors.push_back(ThemeEngine::kFontColorNormal);
    327329                                curSlot++;
    328330                        }
    329331
    void SaveLoadChooser::updateSaveList() {  
    338340                Common::String description = x->description();
    339341                Common::String trimmedDescription = description;
    340342                trimmedDescription.trim();
    341                 if (trimmedDescription.empty())
     343                if (trimmedDescription.empty()) {
    342344                        description = "Untitled savestate";
     345                        colors.push_back(ThemeEngine::kFontColorAlternate);
     346                } else {
     347                        colors.push_back(ThemeEngine::kFontColorNormal);
     348                }
    343349
    344350                saveNames.push_back(description);
    345351                curSlot++;
    void SaveLoadChooser::updateSaveList() {  
    351357                saveNames.push_back(emptyDesc);
    352358                SaveStateDescriptor dummySave(i, "");
    353359                _saveList.push_back(dummySave);
     360                colors.push_back(ThemeEngine::kFontColorNormal);
    354361        }
    355362
    356         _list->setList(saveNames);
     363        _list->setList(saveNames, &colors);
    357364}
    358365
    359366} // End of namespace GUI
  • gui/themes/default.inc

    diff --git a/gui/themes/default.inc b/gui/themes/default.inc
    index 88ef801..d9298ff 100644
    a b  
    15501550"color='lightgrey' "
    15511551"/> "
    15521552"<text_color id='color_alternative' "
    1553 "color='green' "
     1553"color='lightgrey' "
    15541554"/> "
    15551555"<text_color id='color_alternative_inverted' "
    1556 "color='black' "
     1556"color='255,255,255' "
    15571557"/> "
    15581558"<text_color id='color_alternative_hover' "
    1559 "color='green2' "
     1559"color='lightgrey' "
    15601560"/> "
    15611561"<text_color id='color_alternative_disabled' "
    15621562"color='lightgrey' "
  • gui/themes/scummclassic/classic_gfx.stx

    diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
    index c295002..60a3e0d 100644
    Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
    diff --git a/gui/themes/scummclassic/classic_gfx.stx b/gui/themes/scummclassic/classic_gfx.stx
    index ff2fadc..3c552ac 100644
    a b  
    7070                />
    7171
    7272                <text_color     id = 'color_alternative'
    73                                 color = 'green'
     73                                color = 'lightgrey'
    7474                />
    7575
    7676                <text_color     id = 'color_alternative_inverted'
    77                                 color = 'black'
     77                                color = '255, 255, 255'
    7878                />
    7979
    8080                <text_color     id = 'color_alternative_hover'
    81                                 color = 'green2'
     81                                color = 'lightgrey'
    8282                />
    8383
    8484                <text_color     id = 'color_alternative_disabled'
  • gui/themes/scummmodern/scummmodern_gfx.stx

    diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
    index 7e693c3..1426bf1 100644
    Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
    diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx
    index 6a3ab0c..05a4599 100644
    a b  
    130130                />
    131131
    132132                <text_color     id = 'color_alternative'
    133                                 color = 'black'
     133                                color = 'darkgray'
    134134                />
    135135
    136136                <text_color     id = 'color_alternative_inverted'
    137                                 color = 'black'
     137                                color = 'white'
    138138                />
    139139
    140140                <text_color     id = 'color_alternative_hover'
    141                                 color = 'bgreen'
     141                                color = 'darkgray'
    142142                />
    143143
    144144                <text_color     id = 'color_alternative_disabled'
    145                                 color = '192, 192, 192'
     145                                color = 'darkgray'
    146146                />
    147147
    148148                <text_color     id = 'color_button'