libsaria: Tell playlist renderers to goto a specific index

I want to use this to scroll the library list when a new song is picked.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-03-26 07:58:26 -04:00
parent 5f7e5890c8
commit acef058afa
5 changed files with 23 additions and 6 deletions

View File

@ -36,6 +36,7 @@ namespace libsaria
void incr_iter();
Track *picked_next();
unsigned int find_cur_index();
protected:
string name;

View File

@ -20,6 +20,8 @@ namespace libsaria
bool is_static();
virtual void prepare_for_removal();
virtual void goto_index(unsigned int);
virtual void insert_prepare();
virtual void insert(Track *, unsigned int);
virtual void insert_done();

View File

@ -20,14 +20,14 @@ namespace libsaria
Track *Playlist::picked_next()
{
Track *res = (*cur);
unsigned int index = 0;
list<Track *>::iterator it;
unsigned int index;
if (flags & PL_NO_DRAIN)
index = find_cur_index();
if (flags & PL_NO_DRAIN) {
RENDER(goto_index(index));
return res;
for (it = plist.begin(); it != cur; it++)
index++;
}
cur = plist.erase(cur);
if (cur == plist.end())

View File

@ -59,4 +59,14 @@ namespace libsaria
cur = plist.begin();
}
unsigned int Playlist::find_cur_index()
{
list<Track *>::iterator it;
unsigned int index = 0;
for (it = plist.begin(); it != cur; it++)
index++;
return index;
}
}

View File

@ -45,4 +45,8 @@ namespace libsaria
{
}
void PlaylistRenderer::goto_index(unsigned int index)
{
}
}; /* Namespace: libsaria */