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
26 #include "util/Compiler.h"
34 enum class Command : unsigned;
41 * The MPD idle event mask pending to be submitted to
44 unsigned pending_events = ~0u;
47 * Does this page need to be repainted?
52 virtual ~Page() noexcept = default;
54 bool IsDirty() const noexcept {
58 void SetDirty(bool _dirty=true) noexcept {
62 void Resize(Size new_size) noexcept {
63 if (new_size == last_size)
70 void AddPendingEvents(unsigned events) noexcept {
71 pending_events |= events;
74 void Update(struct mpdclient &c) noexcept {
75 Update(c, std::exchange(pending_events, 0));
79 const Size &GetLastSize() const noexcept {
84 virtual void OnOpen(struct mpdclient &) noexcept {}
85 virtual void OnClose() noexcept {}
86 virtual void OnResize(Size size) noexcept = 0;
87 virtual void Paint() const noexcept = 0;
88 virtual void Update(struct mpdclient &, unsigned) noexcept {}
93 * @returns true if the command should not be handled by the
96 virtual bool OnCommand(struct mpdclient &c, Command cmd) = 0;
100 * Handle a mouse event.
102 * @return true if the event was handled (and should not be
103 * handled by the ncmpc core)
105 virtual bool OnMouse(gcc_unused struct mpdclient &c,
106 gcc_unused Point position,
107 gcc_unused mmask_t bstate) {
113 virtual const char *GetTitle(char *s, size_t size) const noexcept = 0;