1 /* 2 Vimpc 3 Copyright (C) 2010 - 2012 Nathan Sweetman 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 3 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, see <http://www.gnu.org/licenses/>. 17 18 directorywindow.hpp - navigate the mpd directory 19 */ 20 21 #ifndef __UI__DIRECTORYWINDOW 22 #define __UI__DIRECTORYWINDOW 23 24 #include "song.hpp" 25 #include "buffer/directory.hpp" 26 #include "window/selectwindow.hpp" 27 28 #include <map> 29 #include <stack> 30 31 namespace Main { class Settings; } 32 namespace Mpc { class Client; class ClientState; } 33 34 namespace Ui 35 { 36 class Search; 37 38 class DirectoryWindow : public Ui::SelectWindow 39 { 40 private: 41 typedef void (Mpc::Directory::*DirectoryFunction)(Mpc::Song::SongCollection Collection, Mpc::Client & client, Mpc::ClientState & clientState, uint32_t position); 42 43 public: 44 DirectoryWindow(Main::Settings const & settings, Ui::Screen & screen, Mpc::Directory & directory, Mpc::Client & client, Mpc::ClientState & clientState, Ui::Search const & search); 45 ~DirectoryWindow(); 46 47 private: 48 DirectoryWindow(DirectoryWindow & library); 49 DirectoryWindow & operator=(DirectoryWindow & library); 50 51 private: 52 void Print(uint32_t line) const; 53 54 public: 55 void Left(Ui::Player & player, uint32_t count); 56 void Right(Ui::Player & player, uint32_t count); 57 void Click(); 58 void Confirm(); 59 void Redraw(); 60 void SoftRedraw(); 61 uint32_t Current() const; 62 63 public: 64 std::string SearchPattern(uint32_t id) const; 65 66 public: 67 void AddLine(uint32_t line, uint32_t count = 1, bool scroll = true); 68 void AddAllLines(); 69 void CropLine(uint32_t line, uint32_t count = 1, bool scroll = true); 70 void CropAllLines(); 71 void DeleteLine(uint32_t line, uint32_t count = 1, bool scroll = true); 72 void DeleteAllLines(); 73 void Edit(); 74 #ifdef LYRICS_SUPPORT 75 void Lyrics(); 76 #endif 77 void ScrollToFirstMatch(std::string const & input); 78 void ScrollToCurrent(); 79 void Scroll(int32_t scrollCount); 80 void ScrollTo(uint32_t scrollLine); 81 uint32_t BufferSize() const; 82 83 protected: 84 void LimitCurrentSelection(); WindowBuffer() const85 Main::WindowBuffer const & WindowBuffer() const { return directory_; } 86 87 private: 88 std::vector<uint32_t> PositionVector(uint32_t & line, uint32_t count, bool visual); 89 90 template <typename T> 91 void ForPositions(T start, T end, DirectoryFunction function); 92 93 private: 94 void Clear(); 95 int32_t DetermineSongColour(Mpc::DirectoryEntry const * const entry) const; 96 97 private: 98 Main::Settings const & settings_; 99 Mpc::Client & client_; 100 Mpc::ClientState & clientState_; 101 Ui::Search const & search_; 102 Mpc::Directory & directory_; 103 uint32_t selectedDirectory_; 104 std::stack<uint32_t> selection_; 105 }; 106 } 107 #endif 108 /* vim: set sw=3 ts=3: */ 109