display selected item/now playing suffix in column view

This commit is contained in:
Andrzej Rybczak
2010-02-05 15:30:20 +01:00
parent 71c81719b5
commit e40ced8daf
3 changed files with 35 additions and 6 deletions

View File

@@ -125,13 +125,14 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
if (Config.columns.empty())
return;
std::vector<Column>::const_iterator next2last, it;
std::vector<Column>::const_iterator next2last, last, it;
size_t where = 0;
int width;
bool last_fixed = Config.columns.back().fixed;
if (Config.columns.size() > 1)
next2last = Config.columns.end()-2;
last = Config.columns.end()-1;
bool discard_colors = Config.discard_colors_if_item_is_selected && menu->isSelected(menu->CurrentlyDrawedPosition());
@@ -211,9 +212,19 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
*menu << it->color;
whline(menu->Raw(), 32, menu->GetWidth()-where);
std::string tag = get ? s.GetTags(get) : "";
// last column might need to be shrinked to make space for np/sel suffixes
if (it == last)
{
if (menu->isSelected(menu->CurrentlyDrawedPosition()))
width -= Config.selected_item_suffix_length;
if (is_now_playing)
width -= Config.now_playing_suffix_length;
}
if (it->right_alignment)
{
if (!tag.empty() || it->display_empty_tag)
if (width > 0 && (!tag.empty() || it->display_empty_tag))
{
int x, y;
menu->GetXY(x, y);
@@ -223,10 +234,25 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
}
else
{
if (!tag.empty())
*menu << tag;
else if (it->display_empty_tag)
*menu << Config.empty_tag;
if (it == last)
{
if (width > 0)
{
std::basic_string<my_char_t> str;
if (!tag.empty())
str = TO_WSTRING(tag).substr(0, width-1);
else if (it->display_empty_tag)
str = TO_WSTRING(Config.empty_tag).substr(0, width-1);
*menu << str;
}
}
else
{
if (!tag.empty())
*menu << tag;
else if (it->display_empty_tag)
*menu << Config.empty_tag;
}
}
where += width;
}

View File

@@ -387,6 +387,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.lines_scrolled = 2;
conf.search_engine_default_search_mode = 0;
conf.selected_item_suffix_length = 0;
conf.now_playing_suffix_length = 0;
# ifdef HAVE_LANGINFO_H
conf.system_encoding = nl_langinfo(CODESET);
if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert
@@ -765,6 +766,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
{
conf.now_playing_suffix.Clear();
String2Buffer(TO_WSTRING(v), conf.now_playing_suffix);
conf.now_playing_suffix_length = Window::Length(conf.now_playing_suffix.Str());
}
}
else if (cl.find("color1") != std::string::npos)

View File

@@ -236,6 +236,7 @@ struct ncmpcpp_config
unsigned search_engine_default_search_mode;
size_t selected_item_suffix_length;
size_t now_playing_suffix_length;
std::list<BasicScreen *> screens_seq;
};