settings: make progressbar more customizable (elapsed time part color, boldness)

master
Andrzej Rybczak 14 years ago
parent 27a0dc958f
commit 4475902eb9
  1. 4
      doc/config
  2. 6
      doc/ncmpcpp.1
  3. 4
      src/ncmpcpp.cpp
  4. 12
      src/settings.cpp
  5. 2
      src/settings.h
  6. 16
      src/status.cpp

@ -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"

@ -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

@ -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;

@ -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())

@ -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;

@ -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<my_char_t> 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, ...)

Loading…
Cancel
Save