ncmpc  0.31
FileListPage.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 FILE_LIST_PAGE_HXX
21 #define FILE_LIST_PAGE_HXX
22 
23 #include "config.h"
24 #include "ncmpc_curses.h"
25 #include "ListPage.hxx"
26 #include "ListRenderer.hxx"
27 #include "ListText.hxx"
28 
29 struct mpdclient;
30 struct MpdQueue;
31 class ScreenManager;
32 class FileList;
33 struct FileListEntry;
34 
36 protected:
38 
39  FileList *filelist = nullptr;
40  const char *const song_format;
41 
42 public:
43  FileListPage(ScreenManager &_screen, WINDOW *_w,
44  Size size,
45  const char *_song_format)
46  :ListPage(_w, size),
47  screen(_screen),
48  song_format(_song_format) {}
49 
50  ~FileListPage() override;
51 
52 protected:
53  gcc_pure
55 
56  gcc_pure
57  const struct mpd_entity *GetSelectedEntity() const;
58 
59  gcc_pure
60  const struct mpd_song *GetSelectedSong() const;
61 
62  FileListEntry *GetIndex(unsigned i) const;
63 
64 private:
65  bool HandleEnter(struct mpdclient &c);
66  bool HandleSelect(struct mpdclient &c);
67  bool HandleAdd(struct mpdclient &c);
68 
69  void HandleSelectAll(struct mpdclient &c);
70 
71  static void PaintRow(WINDOW *w, unsigned i,
72  unsigned y, unsigned width,
73  bool selected, const void *data);
74 
75  /* virtual methods from class ListRenderer */
76  void PaintListItem(WINDOW *w, unsigned i,
77  unsigned y, unsigned width,
78  bool selected) const final;
79 
80  /* virtual methods from class ListText */
81  const char *GetListItemText(char *buffer, size_t size,
82  unsigned i) const override;
83 
84 public:
85  /* virtual methods from class Page */
86  void Paint() const override;
87  bool OnCommand(struct mpdclient &c, Command cmd) override;
88 
89 #ifdef HAVE_GETMOUSE
90  bool OnMouse(struct mpdclient &c, Point p,
91  mmask_t bstate) override;
92 #endif
93 };
94 
95 #ifndef NCMPC_MINI
96 
97 void
99  const MpdQueue *playlist);
100 
101 #else
102 
103 static inline void
105  gcc_unused const MpdQueue *playlist)
106 {
107 }
108 
109 #endif
110 
111 void
112 screen_browser_paint_directory(WINDOW *w, unsigned width,
113  bool selected, const char *name);
114 
115 #endif
Command
Definition: Command.hxx:29
gcc_pure FileListEntry * GetSelectedEntry() const
Definition: filelist.hxx:31
void screen_browser_paint_directory(WINDOW *w, unsigned width, bool selected, const char *name)
Definition: screen.hxx:44
Definition: ListPage.hxx:29
Definition: FileListPage.hxx:35
const char *const song_format
Definition: FileListPage.hxx:40
bool OnCommand(struct mpdclient &c, Command cmd) override
void screen_browser_sync_highlights(FileList *fl, const MpdQueue *playlist)
ScreenManager & screen
Definition: FileListPage.hxx:37
Definition: mpdclient.hxx:17
gcc_pure const struct mpd_entity * GetSelectedEntity() const
FileListEntry * GetIndex(unsigned i) const
Definition: ListRenderer.hxx:25
Definition: Size.hxx:26
FileList * filelist
Definition: FileListPage.hxx:39
void Paint() const override
Definition: filelist.hxx:54
Definition: ListText.hxx:25
Definition: Point.hxx:28
gcc_pure const struct mpd_song * GetSelectedSong() const
FileListPage(ScreenManager &_screen, WINDOW *_w, Size size, const char *_song_format)
Definition: FileListPage.hxx:43
~FileListPage() override
Definition: Queue.hxx:38