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