ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/MenuList.cpp
(Generate patch)

Comparing DashInterface/MenuList.cpp (file contents):
Revision 43 by douglas, 2008-03-06T13:34:03-08:00 vs.
Revision 45 by douglas, 2008-03-06T18:12:54-08:00

# Line 6 | Line 6
6  
7   #include <foreach.hpp>
8  
9 #include <sqlite3.h>
10
9   #include "MenuList.hpp"
10  
11   MenuList *MenuList::previous;
# Line 16 | Line 14 | MenuList::MenuItem::MenuItem(MenuList *l
14   {
15   }
16  
17 < MenuList::MenuList(MenuList *parent, Display &display, size_t size) : parent(parent), display(display), list(size)
17 > MenuList::MenuList(MenuList *parent, Display &display, size_t size) : parent(parent), display(display), cursor(0), list(size)
18   {
19   }
20  
# Line 48 | Line 46 | MenuList *MenuList::Left()
46  
47   void MenuList::Render()
48   {
49 +        display.SetCursorPosition(19, cursor);
50 +
51          if (this != previous || state != old)
52          {
53 < #               define Cursor(index) (state.cursor == index ? _B("\x1f") : _B(" "))
54 <
55 <                display.Set(0, 0, (state.bottom != 0 ? '\x1a' : ' ') + Cursor(0));
56 <                display.Set(0, 1, '\x12' + Cursor(1));
57 <                display.Set(0, 2, '\x13' + Cursor(2));
58 <                display.Set(0, 3, (state.top < list.size() ? '\x1b' : ' ') + Cursor(3));
59 <
60 < #               undef Cursor
53 >                display.Set(0, 0, (state.bottom != 0 ? '\x1a' : ' '));
54 >                display.Set(0, 1, '\x12');
55 >                display.Set(0, 2, '\x13');
56 >                display.Set(0, 3, (state.top < list.size() ? '\x1b' : ' '));
57  
58                  _forall (size_t, index, state.bottom, state.top)
59                  {
60                          MenuItem *item(list[index]);
61                          std::string value(*item);
62  
63 <                        value.resize(17, ' ');
63 >                        value.resize(18, ' ');
64  
65                          if (BoolItem *item_ = dynamic_cast<BoolItem *>(item))
66                                  value += (*item_ ? '\x94' : '\xcf');
# Line 73 | Line 69 | void MenuList::Render()
69                          else
70                                  value += ' ';
71  
72 <                        display.Set(2, _index, value);
72 >                        display.Set(1, _index, value);
73                  }
74          }
75          else
80        {
81                if (state.cursor != old.cursor)
82                {
83                        display.Set(1, old.cursor, _B(" "));
84                        display.Set(1, state.cursor, _B("\x1f"));
85                }
86
76                  _forall (size_t, index, state.bottom, state.top)
77                          if (BoolItem *item = dynamic_cast<BoolItem *>(list[index]))
78                                  display.Set(19, _index, (*item ? _B("\x94") : _B("\xcf")));
90        }
79   }
80  
81   MenuList &MenuList::operator ++()
82   {
83 +        old = state;
84 +
85          size_t next(state.item + 1);
86  
87          if (next != list.size())
# Line 99 | Line 89 | MenuList &MenuList::operator ++()
89                  if (next == state.bottom)
90                          ++state.top, ++state.bottom;
91                  else
92 <                        ++state.cursor;
92 >                        ++cursor;
93  
94                  state.item = next;
95          }
# Line 109 | Line 99 | MenuList &MenuList::operator ++()
99  
100   MenuList &MenuList::operator --()
101   {
102 +        old = state;
103 +
104          if (state.item != 0)
105                  if (state.item-- == state.top)
106                          --state.top, --state.bottom;
107                  else
108 <                        --state.cursor;
108 >                        --cursor;
109  
110          return *this;
111   }
# Line 167 | Line 159 | TopList::MusicItem::MusicItem(MenuList *
159  
160   MenuList *TopList::MusicItem::Select()
161   {
162 +        delete this;
163 +
164          return NULL;
165   }
166  
# Line 175 | Line 169 | TopList::MusicItem::operator std::string
169          return _B("Music");
170   }
171  
172 < TopList::TopList(Audacious::Audacious &audacious, Display &display, bool &append) : MenuList(this, display, 3)
172 > TopList::TopList(Display &display, Audacious::Audacious &audacious, bool &append) : MenuList(this, display, 3)
173   {
174          previous = NULL;
175          list[0] = new AppendItem(this, append);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines