6 |
|
|
7 |
|
#include <foreach.hpp> |
8 |
|
|
9 |
– |
#include <sqlite3.h> |
10 |
– |
|
9 |
|
#include "MenuList.hpp" |
10 |
|
|
11 |
|
MenuList *MenuList::previous; |
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 |
|
|
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'); |
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()) |
89 |
|
if (next == state.bottom) |
90 |
|
++state.top, ++state.bottom; |
91 |
|
else |
92 |
< |
++state.cursor; |
92 |
> |
++cursor; |
93 |
|
|
94 |
|
state.item = next; |
95 |
|
} |
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 |
|
} |
153 |
|
return audacious.IsRunning() ? audacious.IsShuffle() : false; |
154 |
|
} |
155 |
|
|
156 |
< |
TopList::TopList(Audacious::Audacious &audacious, Display &display, bool &append) : MenuList(this, display, 3) |
156 |
> |
TopList::MusicItem::MusicItem(MenuList *list, Audacious::Audacious &audacious) : MenuItem(list), audacious(audacious) |
157 |
> |
{ |
158 |
> |
} |
159 |
> |
|
160 |
> |
MenuList *TopList::MusicItem::Select() |
161 |
> |
{ |
162 |
> |
delete this; |
163 |
> |
|
164 |
> |
return NULL; |
165 |
> |
} |
166 |
> |
|
167 |
> |
TopList::MusicItem::operator std::string() const |
168 |
> |
{ |
169 |
> |
return _B("Music"); |
170 |
> |
} |
171 |
> |
|
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); |
176 |
|
list[1] = new ShuffleItem(this, audacious); |
177 |
+ |
list[2] = new MusicItem(this, audacious); |
178 |
|
} |