move code responsible for screen resize to SIGWINCH handler
[ncmpcpp.git] / src / playlist.h
blob79f21d4a2bef3dc7e2e628d2fb4e66cf9a19f60a
1 /***************************************************************************
2 * Copyright (C) 2008-2009 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
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 *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef _PLAYLIST_H
22 #define _PLAYLIST_H
24 #include <sstream>
26 #include "ncmpcpp.h"
27 #include "screen.h"
28 #include "song.h"
30 class Playlist : public Screen<Window>
32 public:
33 Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
34 ~Playlist() { }
36 virtual void SwitchTo();
37 virtual void Resize();
39 virtual std::basic_string<my_char_t> Title();
41 virtual void EnterPressed();
42 virtual void SpacePressed();
43 virtual void MouseButtonPressed(MEVENT);
45 virtual MPD::Song *CurrentSong();
47 virtual bool allowsSelection() { return w == Items; }
48 virtual void ReverseSelection() { Items->ReverseSelection(); }
49 virtual void GetSelectedSongs(MPD::SongList &);
51 virtual void ApplyFilter(const std::string &);
53 virtual List *GetList() { return w == Items ? Items : 0; }
55 bool isPlaying() { return NowPlaying >= 0 && !Items->Empty(); }
56 const MPD::Song *NowPlayingSong();
58 void Sort();
59 void AdjustSortOrder(int key);
60 bool SortingInProgress() { return w == SortDialog; }
61 void FixPositions(size_t = 0);
63 void EnableHighlighting();
64 void UpdateTimer() { time(&itsTimer); }
65 time_t Timer() const { return itsTimer; }
67 bool Add(const MPD::Song &s, bool in_playlist, bool play);
68 bool Add(const MPD::SongList &l, bool play);
70 static std::string SongToString(const MPD::Song &, void *);
71 static std::string SongInColumnsToString(const MPD::Song &, void *);
73 Menu< MPD::Song > *Items;
75 int NowPlaying;
77 static bool ReloadTotalLength;
78 static bool ReloadRemaining;
80 static bool BlockNowPlayingUpdate;
81 static bool BlockUpdate;
83 protected:
84 virtual void Init();
86 private:
87 std::string TotalLength();
89 std::string itsBufferedStats;
91 size_t itsTotalLength;
92 size_t itsRemainingTime;
93 size_t itsScrollBegin;
95 time_t itsTimer;
97 static bool Sorting(MPD::Song *a, MPD::Song *b);
99 static Menu< std::pair<std::string, MPD::Song::GetFunction> > *SortDialog;
100 static const size_t SortOptions;
101 static const size_t SortDialogWidth;
102 static size_t SortDialogHeight;
105 extern Playlist *myPlaylist;
107 #endif