new feature: separators between albums in playlist

This commit is contained in:
Andrzej Rybczak
2010-05-14 02:24:57 +02:00
parent 8de70f3918
commit 0f230ab7b0
8 changed files with 50 additions and 5 deletions

View File

@@ -125,6 +125,12 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
if (Config.columns.empty())
return;
bool separate_albums = Config.playlist_separate_albums
&& s.GetPosition()+1 < myPlaylist->Items->Size()
&& (*myPlaylist->Items)[s.GetPosition()+1].GetAlbum() != s.GetAlbum();
if (separate_albums)
*menu << fmtUnderline;
std::vector<Column>::const_iterator next2last, last, it;
size_t where = 0;
int width;
@@ -260,6 +266,8 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
*menu << clEnd;
if (is_now_playing)
*menu << Config.now_playing_suffix;
if (separate_albums)
*menu << fmtUnderlineEnd;
}
void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
@@ -271,6 +279,15 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
if (is_now_playing)
*menu << Config.now_playing_prefix;
bool separate_albums = Config.playlist_separate_albums
&& s.GetPosition()+1 < myPlaylist->Items->Size()
&& (*myPlaylist->Items)[s.GetPosition()+1].GetAlbum() != s.GetAlbum();
if (separate_albums)
{
*menu << fmtUnderline;
mvwhline(menu->Raw(), menu->Y(), 0, ' ', menu->GetWidth());
}
bool discard_colors = Config.discard_colors_if_item_is_selected && menu->isSelected(menu->CurrentlyDrawedPosition());
std::string line = s.toString(*static_cast<std::string *>(data), "$");
@@ -298,6 +315,8 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
if (is_now_playing)
buf << Config.now_playing_suffix;
*menu << XY(menu->GetWidth()-buf.Str().length()-(menu->isSelected(menu->CurrentlyDrawedPosition()) ? Config.selected_item_suffix_length : 0), menu->Y()) << buf;
if (separate_albums)
*menu << fmtUnderlineEnd;
return;
}
else // not a color nor right align, just a random character
@@ -315,6 +334,8 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
}
if (is_now_playing)
*menu << Config.now_playing_suffix;
if (separate_albums)
*menu << fmtUnderlineEnd;
}
void Display::Tags(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)

View File

@@ -209,6 +209,7 @@ void Help::GetKeybindings()
# endif // HAVE_TAGLIB_H
*w << DisplayKeys(Key.ToggleDisplayMode) << "Toggle display mode\n";
*w << DisplayKeys(Key.ToggleInterface) << "Toggle user interface\n";
*w << DisplayKeys(Key.ToggleSeparatorsInPlaylist) << "Toggle displaying separators between albums in playlist\n";
*w << DisplayKeys(Key.GoToPosition) << "Go to given position in current song (in % by default)\n";
*w << DisplayKeys(Key.SongInfo) << "Show song info\n";
# ifdef HAVE_CURL_CURL_H

View File

@@ -542,7 +542,7 @@ int main(int argc, char *argv[])
else if (mouse_event.bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED))
myScreen->MouseButtonPressed(mouse_event);
}
if (Keypressed(input, Key.ToggleInterface))
else if (Keypressed(input, Key.ToggleInterface))
{
Config.new_design = !Config.new_design;
Config.statusbar_visibility = Config.new_design ? 0 : real_statusbar_visibility;
@@ -940,8 +940,8 @@ int main(int argc, char *argv[])
if (modify_now_playing)
--myPlaylist->NowPlaying;
--to;
myPlaylist->Items->at(from).SetPosition(to);
myPlaylist->Items->at(to).SetPosition(from);
myPlaylist->Items->at(to+1).SetPosition(to);
myPlaylist->Items->at(to).SetPosition(to+1);
myPlaylist->Items->Swap(to, to+1);
myPlaylist->Items->Scroll(wUp);
myPlaylist->Items->Refresh();
@@ -1066,8 +1066,8 @@ int main(int argc, char *argv[])
if (modify_now_playing)
++myPlaylist->NowPlaying;
++to;
myPlaylist->Items->at(from).SetPosition(to);
myPlaylist->Items->at(to).SetPosition(from);
myPlaylist->Items->at(to-1).SetPosition(to);
myPlaylist->Items->at(to).SetPosition(to-1);
myPlaylist->Items->Swap(to, to-1);
myPlaylist->Items->Scroll(wDown);
myPlaylist->Items->Refresh();
@@ -1315,6 +1315,11 @@ int main(int argc, char *argv[])
mySearcher->Main()->SetTitle(Config.columns_in_search_engine ? Display::Columns() : "");
}
}
else if (Keypressed(input, Key.ToggleSeparatorsInPlaylist))
{
Config.playlist_separate_albums = !Config.playlist_separate_albums;
ShowMessage("Separators between albums in playlist: %s", Config.playlist_separate_albums ? "On" : "Off");
}
# ifdef HAVE_CURL_CURL_H
else if (Keypressed(input, Key.ToggleLyricsDB))
{

View File

@@ -228,6 +228,7 @@ void NcmpcppKeys::SetDefaults()
ToggleAutoCenter[0] = 'U';
ToggleDisplayMode[0] = 'p';
ToggleInterface[0] = '\\';
ToggleSeparatorsInPlaylist[0] = '!';
ToggleLyricsDB[0] = 'L';
GoToParentDir[0] = KEY_BACKSPACE;
SwitchTagTypeList[0] = '`';
@@ -308,6 +309,7 @@ void NcmpcppKeys::SetDefaults()
ToggleAutoCenter[1] = NullKey;
ToggleDisplayMode[1] = NullKey;
ToggleInterface[1] = NullKey;
ToggleSeparatorsInPlaylist[1] = NullKey;
ToggleLyricsDB[1] = NullKey;
GoToParentDir[1] = 127;
SwitchTagTypeList[1] = NullKey;
@@ -354,6 +356,7 @@ void NcmpcppConfig::SetDefaults()
colors_enabled = true;
fancy_scrolling = true;
playlist_show_remaining_time = false;
playlist_separate_albums = false;
columns_in_playlist = false;
columns_in_browser = false;
columns_in_search_engine = false;
@@ -571,6 +574,8 @@ void NcmpcppKeys::Read()
GetKeys(key, ToggleAutoCenter);
else if (key.find("key_toggle_display_mode ") != std::string::npos)
GetKeys(key, ToggleDisplayMode);
else if (key.find("key_toggle_separators_in_playlist ") != std::string::npos)
GetKeys(key, ToggleSeparatorsInPlaylist);
else if (key.find("key_toggle_lyrics_db ") != std::string::npos)
GetKeys(key, ToggleLyricsDB);
else if (key.find("key_go_to_containing_directory ") != std::string::npos)
@@ -826,6 +831,10 @@ void NcmpcppConfig::Read()
{
playlist_show_remaining_time = v == "yes";
}
else if (cl.find("playlist_separate_albums") != std::string::npos)
{
playlist_separate_albums = v == "yes";
}
else if (cl.find("playlist_display_mode") != std::string::npos)
{
columns_in_playlist = v == "columns";

View File

@@ -132,6 +132,7 @@ struct NcmpcppKeys
int ToggleAutoCenter[2];
int ToggleDisplayMode[2];
int ToggleInterface[2];
int ToggleSeparatorsInPlaylist[2];
int ToggleLyricsDB[2];
int GoToParentDir[2];
int SwitchTagTypeList[2];
@@ -195,6 +196,7 @@ struct NcmpcppConfig
bool colors_enabled;
bool fancy_scrolling;
bool playlist_show_remaining_time;
bool playlist_separate_albums;
bool columns_in_playlist;
bool columns_in_browser;
bool columns_in_search_engine;