1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2018 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
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.
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.
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.
20 #ifndef NCMPC_PAGE_HXX
21 #define NCMPC_PAGE_HXX
24 #include "ncmpc_curses.h"
27 #include "util/Compiler.h"
33 enum class Command : unsigned;
40 * The MPD idle event mask pending to be submitted to
43 unsigned pending_events = ~0u;
46 * Does this page need to be repainted?
51 virtual ~Page() = default;
53 bool IsDirty() const {
57 void SetDirty(bool _dirty=true) {
61 void Resize(Size new_size) {
62 if (new_size == last_size)
69 void AddPendingEvents(unsigned events) {
70 pending_events |= events;
73 void Update(struct mpdclient &c) {
74 Update(c, std::exchange(pending_events, 0));
78 const Size &GetLastSize() const {
83 virtual void OnOpen(struct mpdclient &) {}
84 virtual void OnClose() {}
85 virtual void OnResize(Size size) = 0;
86 virtual void Paint() const = 0;
87 virtual void Update(struct mpdclient &, unsigned) {}
92 * @returns true if the command should not be handled by the
95 virtual bool OnCommand(struct mpdclient &c, Command cmd) = 0;
99 * Handle a mouse event.
101 * @return true if the event was handled (and should not be
102 * handled by the ncmpc core)
104 virtual bool OnMouse(gcc_unused struct mpdclient &c,
105 gcc_unused Point position,
106 gcc_unused mmask_t bstate) {
111 virtual const char *GetTitle(char *s, size_t size) const = 0;