From 4475902eb9d1140f0e674181dd6884e98b7894ec Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 16 Jul 2012 00:00:20 +0200 Subject: [PATCH] settings: make progressbar more customizable (elapsed time part color, boldness) --- doc/config | 4 ++++ doc/ncmpcpp.1 | 6 ++++++ src/ncmpcpp.cpp | 4 ++-- src/settings.cpp | 12 ++++++++++++ src/settings.h | 2 ++ src/status.cpp | 16 ++++++++++------ 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/doc/config b/doc/config index f966c6f3..c6e7f8b3 100644 --- a/doc/config +++ b/doc/config @@ -308,6 +308,8 @@ ## #progressbar_look = "=>" # +#progressbar_boldness = "yes" +# #default_place_to_search_in = "database" (database/playlist) # #user_interface = "classic" (classic/alternative) @@ -488,6 +490,8 @@ # #progressbar_color = "default" # +#progressbar_elapsed_color = "default" +# #statusbar_color = "default" # #alternative_ui_separator_color = "black" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 9ddf4c22..215fa86f 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -234,6 +234,9 @@ If enabled, currently highlighted position in the list will be always centered. .B progressbar_look = TEXT This variable defines the look of progressbar. Note that it has to be exactly two or three characters long. .TP +.B progressbar_boldness = yes/no +This variable defines whether progressbar should be displayed in bold or not. +.TP .B default_find_mode = wrapped/normal If set to "wrapped", going from last found position to next will take you to the first one (same goes for the first position and going to previous one), otherwise no actions will be performed. .TP @@ -369,6 +372,9 @@ Color of main window's highlight. .B progressbar_color = COLOR Color of progressbar. .TP +.B progressbar_elapsed_color = COLOR +Color of part of progressbar that represents elapsed time. +.TP .B statusbar_color = COLOR Color of statusbar. .TP diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index fd181dd4..4341a45b 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1304,7 +1304,6 @@ int main(int argc, char **argv) wFooter->SetTimeout(ncmpcpp_window_timeout); SeekingInProgress = 1; - *wFooter << fmtBold; while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward)) { TraceMpdStatus(); @@ -1326,6 +1325,7 @@ int main(int argc, char **argv) songpos = 0; } + *wFooter << fmtBold; std::string tracklength; if (Config.new_design) { @@ -1356,10 +1356,10 @@ int main(int argc, char **argv) tracklength += "]"; *wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength; } + *wFooter << fmtBoldEnd; DrawProgressbar(songpos, Mpd.GetTotalTime()); wFooter->Refresh(); } - *wFooter << fmtBoldEnd; SeekingInProgress = 0; Mpd.Seek(songpos); UpdateStatusImmediately = 1; diff --git a/src/settings.cpp b/src/settings.cpp index ba2ddb2c..f82973fe 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -394,6 +394,7 @@ void NcmpcppConfig::SetDefaults() main_color = clYellow; main_highlight_color = main_color; progressbar_color = clDefault; + progressbar_elapsed_color = clDefault; statusbar_color = clDefault; alternative_ui_separator_color = clBlack; active_column_color = clRed; @@ -452,6 +453,7 @@ void NcmpcppConfig::SetDefaults() discard_colors_if_item_is_selected = true; store_lyrics_in_song_dir = false; ask_for_locked_screen_width_part = true; + progressbar_boldness = true; set_window_title = true; mpd_port = 6600; mpd_connection_timeout = 15; @@ -1262,6 +1264,11 @@ void NcmpcppConfig::Read() if (!v.empty()) ask_for_locked_screen_width_part = v == "yes"; } + else if (name == "progressbar_boldness") + { + if (!v.empty()) + progressbar_boldness = v == "yes"; + } else if (name == "song_window_title_format") { if (!v.empty() && MPD::Song::isFormatOk("song_window_title_format", v)) @@ -1315,6 +1322,11 @@ void NcmpcppConfig::Read() if (!v.empty()) progressbar_color = IntoColor(v); } + else if (name == "progressbar_elapsed_color") + { + if (!v.empty()) + progressbar_elapsed_color = IntoColor(v); + } else if (name == "statusbar_color") { if (!v.empty()) diff --git a/src/settings.h b/src/settings.h index 3ae364b3..07114de0 100644 --- a/src/settings.h +++ b/src/settings.h @@ -200,6 +200,7 @@ struct NcmpcppConfig Color main_color; Color main_highlight_color; Color progressbar_color; + Color progressbar_elapsed_color; Color statusbar_color; Color alternative_ui_separator_color; Color active_column_color; @@ -262,6 +263,7 @@ struct NcmpcppConfig bool discard_colors_if_item_is_selected; bool store_lyrics_in_song_dir; bool ask_for_locked_screen_width_part; + bool progressbar_boldness; int mpd_port; int mpd_connection_timeout; diff --git a/src/status.cpp b/src/status.cpp index 6a421f88..4295a226 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -225,7 +225,6 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) static MPD::Song np; int sx, sy; - *wFooter << fmtBold; wFooter->GetXY(sx, sy); if (!Playlist::BlockNowPlayingUpdate) @@ -505,9 +504,9 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) } basic_buffer np_song; String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.song_status_format, "$"))), np_song); - *wFooter << XY(0, 1) << wclrtoeol << player_state << fmtBoldEnd; + *wFooter << XY(0, 1) << wclrtoeol << fmtBold << player_state << fmtBoldEnd; np_song.Write(*wFooter, playing_song_scroll_begin, wFooter->GetWidth()-player_state.length()-tracklength.length(), U(" ** ")); - *wFooter << fmtBold << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength; + *wFooter << fmtBold << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength << fmtBoldEnd; } if (!block_progressbar_update) DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime()); @@ -644,7 +643,6 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) myOutputs->FetchList(); # endif // ENABLE_OUTPUTS } - *wFooter << fmtBoldEnd; wFooter->GotoXY(sx, sy); if (changed.PlayerState || (changed.ElapsedTime && (!Config.new_design || Mpd.GetState() == MPD::psPlay))) wFooter->Refresh(); @@ -662,7 +660,9 @@ void DrawProgressbar(unsigned elapsed, unsigned time) { unsigned pb_width = wFooter->GetWidth(); unsigned howlong = time ? pb_width*elapsed/time : 0; - *wFooter << fmtBold << Config.progressbar_color; + if (Config.progressbar_boldness) + *wFooter << fmtBold; + *wFooter << Config.progressbar_color; if (Config.progressbar[2] != '\0') { wFooter->GotoXY(0, 0); @@ -674,13 +674,17 @@ void DrawProgressbar(unsigned elapsed, unsigned time) mvwhline(wFooter->Raw(), 0, 0, 0, pb_width); if (time) { + *wFooter << Config.progressbar_elapsed_color; pb_width = std::min(size_t(howlong), wFooter->GetWidth()); for (unsigned i = 0; i < pb_width; ++i) *wFooter << Config.progressbar[0]; if (howlong < wFooter->GetWidth()) *wFooter << Config.progressbar[1]; + *wFooter << clEnd; } - *wFooter << clEnd << fmtBoldEnd; + *wFooter << clEnd; + if (Config.progressbar_boldness) + *wFooter << fmtBoldEnd; } void ShowMessage(const char *format, ...)