add playlist mode switcher (and some clean-ups ofc)
This commit is contained in:
@@ -115,6 +115,8 @@
|
|||||||
#
|
#
|
||||||
#key_toggle_auto_center = 'U'
|
#key_toggle_auto_center = 'U'
|
||||||
#
|
#
|
||||||
|
#key_toggle_playlist_display_mode = 'p'
|
||||||
|
#
|
||||||
#key_go_to_containing_directory = 'G'
|
#key_go_to_containing_directory = 'G'
|
||||||
#
|
#
|
||||||
#key_start_searching = 'y'
|
#key_start_searching = 'y'
|
||||||
|
|||||||
@@ -863,9 +863,9 @@ void Search(SongList &result, Song &s)
|
|||||||
if (found && !s.GetAlbum().empty())
|
if (found && !s.GetAlbum().empty())
|
||||||
found = copy.GetAlbum().find(s.GetAlbum()) != string::npos;
|
found = copy.GetAlbum().find(s.GetAlbum()) != string::npos;
|
||||||
if (found && !s.GetYear().empty())
|
if (found && !s.GetYear().empty())
|
||||||
found = atoi(copy.GetYear().c_str()) == atoi(s.GetYear().c_str()) && atoi(s.GetYear().c_str());
|
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear());
|
||||||
if (found && !s.GetTrack().empty())
|
if (found && !s.GetTrack().empty())
|
||||||
found = atoi(copy.GetTrack().c_str()) == atoi(s.GetTrack().c_str()) && atoi(s.GetTrack().c_str());
|
found = StrToInt(copy.GetTrack()) == StrToInt(s.GetTrack()) && StrToInt(s.GetTrack());
|
||||||
if (found && !s.GetGenre().empty())
|
if (found && !s.GetGenre().empty())
|
||||||
found = copy.GetGenre().find(s.GetGenre()) != string::npos;
|
found = copy.GetGenre().find(s.GetGenre()) != string::npos;
|
||||||
if (found && !s.GetComment().empty())
|
if (found && !s.GetComment().empty())
|
||||||
@@ -882,9 +882,9 @@ void Search(SongList &result, Song &s)
|
|||||||
if (found && !s.GetAlbum().empty())
|
if (found && !s.GetAlbum().empty())
|
||||||
found = copy.GetAlbum() == s.GetAlbum();
|
found = copy.GetAlbum() == s.GetAlbum();
|
||||||
if (found && !s.GetYear().empty())
|
if (found && !s.GetYear().empty())
|
||||||
found = atoi(copy.GetYear().c_str()) == atoi(s.GetYear().c_str()) && atoi(s.GetYear().c_str());
|
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear());
|
||||||
if (found && !s.GetTrack().empty())
|
if (found && !s.GetTrack().empty())
|
||||||
found = atoi(copy.GetTrack().c_str()) == atoi(s.GetTrack().c_str()) && atoi(s.GetTrack().c_str());
|
found = StrToInt(copy.GetTrack()) == StrToInt(s.GetTrack()) && StrToInt(s.GetTrack());
|
||||||
if (found && !s.GetGenre().empty())
|
if (found && !s.GetGenre().empty())
|
||||||
found = copy.GetGenre() == s.GetGenre();
|
found = copy.GetGenre() == s.GetGenre();
|
||||||
if (found && !s.GetComment().empty())
|
if (found && !s.GetComment().empty())
|
||||||
|
|||||||
@@ -415,6 +415,9 @@ void Menu<T>::Refresh(bool redraw_whole_window)
|
|||||||
if (itsHighlight >= itsOptions.size()-1)
|
if (itsHighlight >= itsOptions.size()-1)
|
||||||
Highlight(itsOptions.size());
|
Highlight(itsOptions.size());
|
||||||
|
|
||||||
|
while (itsHighlight-itsBeginning > itsHeight-1)
|
||||||
|
itsBeginning++;
|
||||||
|
|
||||||
if (redraw_whole_window)
|
if (redraw_whole_window)
|
||||||
{
|
{
|
||||||
Window::Clear();
|
Window::Clear();
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ int main(int argc, char *argv[])
|
|||||||
sHelp->Add(DisplayKeys(Key.Add) + "Add url/file/directory to playlist\n");
|
sHelp->Add(DisplayKeys(Key.Add) + "Add url/file/directory to playlist\n");
|
||||||
sHelp->Add(DisplayKeys(Key.SavePlaylist) + "Save playlist\n");
|
sHelp->Add(DisplayKeys(Key.SavePlaylist) + "Save playlist\n");
|
||||||
sHelp->Add(DisplayKeys(Key.GoToNowPlaying) + "Go to currently playing position\n");
|
sHelp->Add(DisplayKeys(Key.GoToNowPlaying) + "Go to currently playing position\n");
|
||||||
|
sHelp->Add(DisplayKeys(Key.TogglePlaylistDisplayMode) + "Toggle playlist display mode\n");
|
||||||
sHelp->Add(DisplayKeys(Key.ToggleAutoCenter) + "Toggle auto center mode\n\n\n");
|
sHelp->Add(DisplayKeys(Key.ToggleAutoCenter) + "Toggle auto center mode\n\n\n");
|
||||||
|
|
||||||
sHelp->Add(" [.b]Keys - Browse screen\n -----------------------------------------[/b]\n");
|
sHelp->Add(" [.b]Keys - Browse screen\n -----------------------------------------[/b]\n");
|
||||||
@@ -342,18 +343,18 @@ int main(int argc, char *argv[])
|
|||||||
int input;
|
int input;
|
||||||
timer = time(NULL);
|
timer = time(NULL);
|
||||||
|
|
||||||
sHelp->Timeout(ncmpcpp_window_timeout);
|
sHelp->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mPlaylist->Timeout(ncmpcpp_window_timeout);
|
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mBrowser->Timeout(ncmpcpp_window_timeout);
|
mBrowser->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mTagEditor->Timeout(ncmpcpp_window_timeout);
|
mTagEditor->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mSearcher->Timeout(ncmpcpp_window_timeout);
|
mSearcher->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mLibArtists->Timeout(ncmpcpp_window_timeout);
|
mLibArtists->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mLibAlbums->Timeout(ncmpcpp_window_timeout);
|
mLibAlbums->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mLibSongs->Timeout(ncmpcpp_window_timeout);
|
mLibSongs->SetTimeout(ncmpcpp_window_timeout);
|
||||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
sLyrics->SetTimeout(ncmpcpp_window_timeout);
|
||||||
wFooter->Timeout(ncmpcpp_window_timeout);
|
wFooter->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mPlaylistList->Timeout(ncmpcpp_window_timeout);
|
mPlaylistList->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mPlaylistEditor->Timeout(ncmpcpp_window_timeout);
|
mPlaylistEditor->SetTimeout(ncmpcpp_window_timeout);
|
||||||
|
|
||||||
mPlaylist->HighlightColor(Config.main_highlight_color);
|
mPlaylist->HighlightColor(Config.main_highlight_color);
|
||||||
mBrowser->HighlightColor(Config.main_highlight_color);
|
mBrowser->HighlightColor(Config.main_highlight_color);
|
||||||
@@ -721,14 +722,12 @@ int main(int argc, char *argv[])
|
|||||||
main_height++;
|
main_height++;
|
||||||
|
|
||||||
sHelp->Resize(COLS, main_height);
|
sHelp->Resize(COLS, main_height);
|
||||||
sHelp->Timeout(ncmpcpp_window_timeout);
|
|
||||||
mPlaylist->Resize(COLS, main_height);
|
mPlaylist->Resize(COLS, main_height);
|
||||||
mPlaylist->SetTitle(Config.columns_in_playlist ? DisplayColumns(Config.song_columns_list_format) : "");
|
mPlaylist->SetTitle(Config.columns_in_playlist ? DisplayColumns(Config.song_columns_list_format) : "");
|
||||||
mBrowser->Resize(COLS, main_height);
|
mBrowser->Resize(COLS, main_height);
|
||||||
mTagEditor->Resize(COLS, main_height);
|
mTagEditor->Resize(COLS, main_height);
|
||||||
mSearcher->Resize(COLS, main_height);
|
mSearcher->Resize(COLS, main_height);
|
||||||
sLyrics->Resize(COLS, main_height);
|
sLyrics->Resize(COLS, main_height);
|
||||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
|
||||||
|
|
||||||
lib_artist_width = COLS/3-1;
|
lib_artist_width = COLS/3-1;
|
||||||
lib_albums_start_x = lib_artist_width+1;
|
lib_albums_start_x = lib_artist_width+1;
|
||||||
@@ -1412,7 +1411,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
block_playlist_update = 1;
|
block_playlist_update = 1;
|
||||||
dont_change_now_playing = 1;
|
dont_change_now_playing = 1;
|
||||||
mPlaylist->Timeout(50);
|
mPlaylist->SetTimeout(50);
|
||||||
while (!mPlaylist->Empty() && Keypressed(input, Key.Delete))
|
while (!mPlaylist->Empty() && Keypressed(input, Key.Delete))
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
@@ -1421,7 +1420,7 @@ int main(int argc, char *argv[])
|
|||||||
mPlaylist->Refresh();
|
mPlaylist->Refresh();
|
||||||
mPlaylist->ReadKey(input);
|
mPlaylist->ReadKey(input);
|
||||||
}
|
}
|
||||||
mPlaylist->Timeout(ncmpcpp_window_timeout);
|
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||||
dont_change_now_playing = 0;
|
dont_change_now_playing = 0;
|
||||||
}
|
}
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
@@ -1468,7 +1467,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mPlaylistEditor->Timeout(50);
|
mPlaylistEditor->SetTimeout(50);
|
||||||
while (!mPlaylistEditor->Empty() && Keypressed(input, Key.Delete))
|
while (!mPlaylistEditor->Empty() && Keypressed(input, Key.Delete))
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
@@ -1477,7 +1476,7 @@ int main(int argc, char *argv[])
|
|||||||
mPlaylistEditor->Refresh();
|
mPlaylistEditor->Refresh();
|
||||||
mPlaylistEditor->ReadKey(input);
|
mPlaylistEditor->ReadKey(input);
|
||||||
}
|
}
|
||||||
mPlaylistEditor->Timeout(ncmpcpp_window_timeout);
|
mPlaylistEditor->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
}
|
}
|
||||||
@@ -1711,6 +1710,15 @@ int main(int argc, char *argv[])
|
|||||||
block_progressbar_update = 0;
|
block_progressbar_update = 0;
|
||||||
UNLOCK_STATUSBAR;
|
UNLOCK_STATUSBAR;
|
||||||
}
|
}
|
||||||
|
else if (Keypressed(input, Key.TogglePlaylistDisplayMode) && wCurrent == mPlaylist)
|
||||||
|
{
|
||||||
|
Config.columns_in_playlist = !Config.columns_in_playlist;
|
||||||
|
ShowMessage("Playlist display mode: " + string(Config.columns_in_playlist ? "Columns" : "Classic"));
|
||||||
|
mPlaylist->SetItemDisplayer(Config.columns_in_playlist ? DisplaySongInColumns : DisplaySong);
|
||||||
|
mPlaylist->SetItemDisplayerUserData(Config.columns_in_playlist ? &Config.song_columns_list_format : &Config.song_list_format);
|
||||||
|
mPlaylist->SetTitle(Config.columns_in_playlist ? DisplayColumns(Config.song_columns_list_format) : "");
|
||||||
|
redraw_me = 1;
|
||||||
|
}
|
||||||
else if (Keypressed(input, Key.ToggleAutoCenter))
|
else if (Keypressed(input, Key.ToggleAutoCenter))
|
||||||
{
|
{
|
||||||
Config.autocenter_mode = !Config.autocenter_mode;
|
Config.autocenter_mode = !Config.autocenter_mode;
|
||||||
@@ -1970,7 +1978,7 @@ int main(int argc, char *argv[])
|
|||||||
const int dialog_width = COLS*0.8;
|
const int dialog_width = COLS*0.8;
|
||||||
const int dialog_height = LINES*0.6;
|
const int dialog_height = LINES*0.6;
|
||||||
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", clYellow, brGreen);
|
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", clYellow, brGreen);
|
||||||
mDialog->Timeout(ncmpcpp_window_timeout);
|
mDialog->SetTimeout(ncmpcpp_window_timeout);
|
||||||
|
|
||||||
mDialog->AddOption("Current MPD playlist");
|
mDialog->AddOption("Current MPD playlist");
|
||||||
mDialog->AddOption("Create new playlist (m3u file)");
|
mDialog->AddOption("Create new playlist (m3u file)");
|
||||||
@@ -2250,7 +2258,6 @@ int main(int argc, char *argv[])
|
|||||||
sLyrics->WriteXY(0, 0, "Fetching lyrics...");
|
sLyrics->WriteXY(0, 0, "Fetching lyrics...");
|
||||||
sLyrics->Refresh();
|
sLyrics->Refresh();
|
||||||
sLyrics->Add(GetLyrics(s->GetArtist(), s->GetTitle()));
|
sLyrics->Add(GetLyrics(s->GetArtist(), s->GetTitle()));
|
||||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ void Scrollpad::recreate_win()
|
|||||||
{
|
{
|
||||||
delwin(itsWindow);
|
delwin(itsWindow);
|
||||||
itsWindow = newpad(itsRealHeight, itsWidth);
|
itsWindow = newpad(itsRealHeight, itsWidth);
|
||||||
|
SetTimeout(itsWindowTimeout);
|
||||||
SetColor(itsBaseColor, itsBgColor);
|
SetColor(itsBaseColor, itsBgColor);
|
||||||
Write(itsContent.c_str());
|
Write(itsContent.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
|||||||
keys.GoToContainingDir[0] = 'G';
|
keys.GoToContainingDir[0] = 'G';
|
||||||
keys.StartSearching[0] = 'y';
|
keys.StartSearching[0] = 'y';
|
||||||
keys.ToggleAutoCenter[0] = 'U';
|
keys.ToggleAutoCenter[0] = 'U';
|
||||||
|
keys.TogglePlaylistDisplayMode[0] = 'p';
|
||||||
keys.GoToParentDir[0] = 263;
|
keys.GoToParentDir[0] = 263;
|
||||||
keys.Quit[0] = 'q';
|
keys.Quit[0] = 'q';
|
||||||
|
|
||||||
@@ -136,6 +137,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
|||||||
keys.GoToContainingDir[1] = null_key;
|
keys.GoToContainingDir[1] = null_key;
|
||||||
keys.StartSearching[1] = null_key;
|
keys.StartSearching[1] = null_key;
|
||||||
keys.ToggleAutoCenter[1] = null_key;
|
keys.ToggleAutoCenter[1] = null_key;
|
||||||
|
keys.TogglePlaylistDisplayMode[1] = null_key;
|
||||||
keys.GoToParentDir[1] = 127;
|
keys.GoToParentDir[1] = 127;
|
||||||
keys.Quit[1] = 'Q';
|
keys.Quit[1] = 'Q';
|
||||||
}
|
}
|
||||||
@@ -386,6 +388,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
|||||||
GetKeys(*it, keys.GoToNowPlaying);
|
GetKeys(*it, keys.GoToNowPlaying);
|
||||||
else if (it->find("key_toggle_auto_center ") != string::npos)
|
else if (it->find("key_toggle_auto_center ") != string::npos)
|
||||||
GetKeys(*it, keys.ToggleAutoCenter);
|
GetKeys(*it, keys.ToggleAutoCenter);
|
||||||
|
else if (it->find("key_toggle_playlist_display_mode ") != string::npos)
|
||||||
|
GetKeys(*it, keys.TogglePlaylistDisplayMode);
|
||||||
else if (it->find("key_go_to_containing_directory ") != string::npos)
|
else if (it->find("key_go_to_containing_directory ") != string::npos)
|
||||||
GetKeys(*it, keys.GoToContainingDir);
|
GetKeys(*it, keys.GoToContainingDir);
|
||||||
else if (it->find("key_start_searching ") != string::npos)
|
else if (it->find("key_start_searching ") != string::npos)
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ struct ncmpcpp_keys
|
|||||||
int GoToContainingDir[2];
|
int GoToContainingDir[2];
|
||||||
int StartSearching[2];
|
int StartSearching[2];
|
||||||
int ToggleAutoCenter[2];
|
int ToggleAutoCenter[2];
|
||||||
|
int TogglePlaylistDisplayMode[2];
|
||||||
int GoToParentDir[2];
|
int GoToParentDir[2];
|
||||||
int Quit[2];
|
int Quit[2];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
Window::Window(int startx, int starty, int width, int height, string title, Color color, Border border) : itsWindow(0), itsWinBorder(0), itsGetStringHelper(0), itsStartX(startx), itsStartY(starty), itsWidth(width), itsHeight(height), BBEnabled(1), AutoRefreshEnabled(1), itsTitle(title), itsColor(color), itsBaseColor(color), itsBgColor(clDefault), itsBaseBgColor(clDefault), itsBorder(border)
|
Window::Window(int startx, int starty, int width, int height, string title, Color color, Border border) : itsWindow(0), itsWinBorder(0), itsGetStringHelper(0), itsStartX(startx), itsStartY(starty), itsWidth(width), itsHeight(height), itsWindowTimeout(-1), BBEnabled(1), AutoRefreshEnabled(1), itsTitle(title), itsColor(color), itsBaseColor(color), itsBgColor(clDefault), itsBaseBgColor(clDefault), itsBorder(border)
|
||||||
{
|
{
|
||||||
if (itsStartX < 0) itsStartX = 0;
|
if (itsStartX < 0) itsStartX = 0;
|
||||||
if (itsStartY < 0) itsStartY = 0;
|
if (itsStartY < 0) itsStartY = 0;
|
||||||
@@ -153,7 +153,8 @@ void Window::recreate_win()
|
|||||||
{
|
{
|
||||||
delwin(itsWindow);
|
delwin(itsWindow);
|
||||||
itsWindow = newwin(itsHeight, itsWidth, itsStartY, itsStartX);
|
itsWindow = newwin(itsHeight, itsWidth, itsStartY, itsStartX);
|
||||||
SetColor(itsColor);
|
SetTimeout(itsWindowTimeout);
|
||||||
|
SetColor(itsColor, itsBgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::reallocate_win(int newx, int newy)
|
bool Window::reallocate_win(int newx, int newy)
|
||||||
@@ -265,8 +266,9 @@ void Window::Delay(bool delay) const
|
|||||||
nodelay(itsWindow, !delay);
|
nodelay(itsWindow, !delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Timeout(int timeout) const
|
void Window::SetTimeout(int timeout)
|
||||||
{
|
{
|
||||||
|
itsWindowTimeout = timeout;
|
||||||
wtimeout(itsWindow, timeout);
|
wtimeout(itsWindow, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class Window
|
|||||||
virtual void Reverse(bool) const;
|
virtual void Reverse(bool) const;
|
||||||
virtual void AltCharset(bool) const;
|
virtual void AltCharset(bool) const;
|
||||||
virtual void Delay(bool) const;
|
virtual void Delay(bool) const;
|
||||||
virtual void Timeout(int) const;
|
virtual void SetTimeout(int);
|
||||||
virtual void AutoRefresh(bool val) { AutoRefreshEnabled = val; }
|
virtual void AutoRefresh(bool val) { AutoRefreshEnabled = val; }
|
||||||
virtual void ReadKey(int &) const;
|
virtual void ReadKey(int &) const;
|
||||||
virtual void ReadKey() const;
|
virtual void ReadKey() const;
|
||||||
@@ -142,6 +142,7 @@ class Window
|
|||||||
int itsStartY;
|
int itsStartY;
|
||||||
int itsWidth;
|
int itsWidth;
|
||||||
int itsHeight;
|
int itsHeight;
|
||||||
|
int itsWindowTimeout;
|
||||||
bool BBEnabled;
|
bool BBEnabled;
|
||||||
bool AutoRefreshEnabled;
|
bool AutoRefreshEnabled;
|
||||||
string itsTitle;
|
string itsTitle;
|
||||||
|
|||||||
Reference in New Issue
Block a user