libsaria: Return nth renderer

Useful for switching to a specific list in the UI

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-03-26 20:01:58 -04:00
parent c953ce6fd4
commit 691f74ee10
4 changed files with 21 additions and 0 deletions

View File

@ -55,6 +55,7 @@ namespace libsaria
Playlist(string, unsigned int, PlaylistType);
~Playlist();
void set_renderer(PlaylistRenderer *);
PlaylistRenderer *get_renderer();
bool is_static();
void prepare_for_removal();

View File

@ -17,6 +17,7 @@ namespace libsaria
void prev();
void init();
Playlist *get_recent_plist();
PlaylistRenderer *get_nth_renderer(unsigned int);
};

View File

@ -66,6 +66,11 @@ namespace libsaria
renderer = r;
}
PlaylistRenderer *Playlist::get_renderer()
{
return renderer;
}
void Playlist::reset_iterator()
{
cur = plist.begin();

View File

@ -127,4 +127,18 @@ namespace libsaria
return &recent_plist;
}
PlaylistRenderer *stack::get_nth_renderer(unsigned int n)
{
list<Playlist *>::iterator it = playlist_stack.begin();
unsigned int max = (playlist_stack.size() - num_static);
println("n: %u, max: %u", n, max);
if (n >= max)
return NULL;
for (unsigned int i = 0; i < n; i++)
it++;
return (*it)->get_renderer();
}
}; /* Namespace: libsaria */