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 42 by douglas, 2008-03-06T13:04:20-08:00 vs.
Revision 46 by douglas, 2008-03-06T19:47:57-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #include <foreach.hpp>
7 > #include <iostream>
8  
9 < #include <sqlite3.h>
9 > #include <foreach.hpp>
10  
11   #include "MenuList.hpp"
12  
# Line 16 | Line 16 | MenuList::MenuItem::MenuItem(MenuList *l
16   {
17   }
18  
19 < MenuList::MenuList(MenuList *parent, Display &display, size_t size) : parent(parent), display(display), list(size)
19 > MenuList::MenuList(MenuList *parent, Display &display, size_t size) : parent(parent), display(display), cursor(0), list(size)
20   {
21   }
22  
# Line 48 | Line 48 | MenuList *MenuList::Left()
48  
49   void MenuList::Render()
50   {
51 +        display.SetCursorPosition(19, cursor);
52 +
53 +        size_t size(list.size());
54 +
55          if (this != previous || state != old)
56          {
57 < #               define Cursor(index) (state.cursor == index ? _B("\x1f") : _B(" "))
57 >                display.Set(0, 0, (state.top != 0 ? '\x1a' : ' '));
58 >                display.Set(0, 1, '\x12');
59 >                display.Set(0, 2, '\x13');
60 >                display.Set(0, 3, (state.bottom < size ? '\x1b' : ' '));
61 >
62 >                _forall (size_t, index, state.top, state.bottom)
63 >                        if (index < size)
64 >                        {
65 >                                MenuItem *item(list[index]);
66 >                                std::string value(*item);
67 >
68 >                                value.resize(18, ' ');
69 >
70 >                                if (BoolItem *item_ = dynamic_cast<BoolItem *>(item))
71 >                                        value += (*item_ ? '\x94' : '\xcf');
72 >                                else if (dynamic_cast<SubItem *>(item))
73 >                                        value += '\x10';
74 >                                else
75 >                                        value += ' ';
76  
77 <                display.Set(0, 0, (state.bottom != 0 ? '\x1a' : ' ') + Cursor(0));
78 <                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
61 <
62 <                _forall (size_t, index, state.bottom, state.top)
63 <                {
64 <                        MenuItem *item(list[index]);
65 <                        std::string value(*item);
66 <
67 <                        value.resize(17, ' ');
68 <
69 <                        if (BoolItem *item_ = dynamic_cast<BoolItem *>(item))
70 <                                value += (*item_ ? '\x94' : '\xcf');
71 <                        else if (dynamic_cast<SubItem *>(item))
72 <                                value += '\x10';
77 >                                display.Set(1, _index, value);
78 >                        }
79                          else
80 <                                value += ' ';
75 <
76 <                        display.Set(2, _index, value);
77 <                }
80 >                                display.Set(1, _index, std::string(18, ' '));
81          }
82          else
83 <        {
81 <                if (state.cursor != old.cursor)
82 <                {
83 <                        display.Set(1, old.cursor, _B(" "));
84 <                        display.Set(1, state.cursor, _B("\x1f"));
85 <                }
86 <
87 <                _forall (size_t, index, state.bottom, state.top)
83 >                _forall (size_t, index, state.top, size < state.bottom ? size : state.bottom)
84                          if (BoolItem *item = dynamic_cast<BoolItem *>(list[index]))
85                                  display.Set(19, _index, (*item ? _B("\x94") : _B("\xcf")));
90        }
86   }
87  
88   MenuList &MenuList::operator ++()
89   {
90 +        old = state;
91 +
92          size_t next(state.item + 1);
93  
94          if (next != list.size())
# Line 99 | Line 96 | MenuList &MenuList::operator ++()
96                  if (next == state.bottom)
97                          ++state.top, ++state.bottom;
98                  else
99 <                        ++state.cursor;
99 >                        ++cursor;
100  
101                  state.item = next;
102          }
103  
104 +        std::cerr << state.item << ' ' << state.top << ' ' << state.bottom << ' ' << cursor << std::endl;
105 +
106          return *this;
107   }
108  
109   MenuList &MenuList::operator --()
110   {
111 +        old = state;
112 +
113          if (state.item != 0)
114                  if (state.item-- == state.top)
115                          --state.top, --state.bottom;
116                  else
117 <                        --state.cursor;
117 >                        --cursor;
118 >
119 >        std::cerr << state.item << ' ' << state.top << ' ' << state.bottom << ' ' << cursor << std::endl;
120  
121          return *this;
122   }
# Line 131 | Line 134 | MenuList *TopList::AppendItem::Select()
134  
135   TopList::AppendItem::operator std::string() const
136   {
137 <        return _B("Append");
137 >        return _B("Playlist Append");
138   }
139  
140   TopList::AppendItem::operator bool() const
# Line 161 | Line 164 | TopList::ShuffleItem::operator bool() co
164          return audacious.IsRunning() ? audacious.IsShuffle() : false;
165   }
166  
167 < TopList::TopList(Audacious::Audacious &audacious, Display &display, bool &append) : MenuList(this, display, 3)
167 > TopList::MusicItem::MusicItem(MenuList *list, Audacious::Audacious &audacious) : MenuItem(list), audacious(audacious)
168 > {
169 > }
170 >
171 > MenuList *TopList::MusicItem::Select()
172 > {
173 >        delete this;
174 >
175 >        return NULL;
176 > }
177 >
178 > TopList::MusicItem::operator std::string() const
179 > {
180 >        return _B("Music");
181 > }
182 >
183 > TopList::TopList(Display &display, Audacious::Audacious &audacious, bool &append) : MenuList(this, display, 3)
184   {
185          previous = NULL;
186          list[0] = new AppendItem(this, append);
187          list[1] = new ShuffleItem(this, audacious);
188 +        list[2] = new MusicItem(this, audacious);
189   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines