ncmpc  0.31
ArtistListPage.hxx
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2018 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef NCMPC_ARTIST_LIST_PAGE_HXX
21 #define NCMPC_ARTIST_LIST_PAGE_HXX
22 
23 #include "ListPage.hxx"
24 #include "ListRenderer.hxx"
25 #include "ListText.hxx"
26 
27 #include <vector>
28 #include <string>
29 
30 class ScreenManager;
31 
32 class ArtistListPage final : public ListPage, ListRenderer, ListText {
33  ScreenManager &screen;
34  std::vector<std::string> artist_list;
35 
36 public:
37  ArtistListPage(ScreenManager &_screen, WINDOW *_w, Size _size)
38  :ListPage(_w, _size), screen(_screen) {}
39 
40  const char *GetSelectedValue() const {
41  return lw.selected < artist_list.size()
42  ? artist_list[lw.selected].c_str()
43  : nullptr;
44  }
45 
46 private:
47  void LoadArtistList(struct mpdclient &c);
48  void Reload(struct mpdclient &c);
49 
50  bool OnListCommand(Command cmd);
51 
52 public:
53  /* virtual methods from class Page */
54  void Paint() const override;
55  void Update(struct mpdclient &c, unsigned events) override;
56  bool OnCommand(struct mpdclient &c, Command cmd) override;
57  const char *GetTitle(char *s, size_t size) const override;
58 
59  /* virtual methods from class ListRenderer */
60  void PaintListItem(WINDOW *w, unsigned i, unsigned y, unsigned width,
61  bool selected) const override;
62 
63  /* virtual methods from class ListText */
64  const char *GetListItemText(char *buffer, size_t size,
65  unsigned i) const override;
66 };
67 
68 #endif
void PaintListItem(WINDOW *w, unsigned i, unsigned y, unsigned width, bool selected) const override
Command
Definition: Command.hxx:29
const char * GetListItemText(char *buffer, size_t size, unsigned i) const override
ArtistListPage(ScreenManager &_screen, WINDOW *_w, Size _size)
Definition: ArtistListPage.hxx:37
Definition: screen.hxx:44
Definition: ArtistListPage.hxx:32
Definition: ListPage.hxx:29
bool OnCommand(struct mpdclient &c, Command cmd) override
ListWindow lw
Definition: ListPage.hxx:31
void Paint() const override
Definition: mpdclient.hxx:17
Definition: ListRenderer.hxx:25
Definition: Size.hxx:26
void Update(struct mpdclient &c, unsigned events) override
unsigned selected
Definition: ListWindow.hxx:96
const char * GetTitle(char *s, size_t size) const override
const char * GetSelectedValue() const
Definition: ArtistListPage.hxx:40
Definition: ListText.hxx:25