From d12b8301c77bded3a504cc104dce135f571bba5c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 26 Jun 2018 00:02:15 +0200 Subject: [PATCH] channellist: fix display of very long channelnames Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ff1db4da8b26602ab14137e8dba5099f769f223c Author: vanhofen Date: 2018-06-26 (Tue, 26 Jun 2018) Origin message was: ------------------ - channellist: fix display of very long channelnames ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/channellist.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 57259f174..a9f51634b 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2117,14 +2117,20 @@ void CChannelList::paintItem(int pos, const bool firstpaint) pb.setFrameThickness(pb_frame); pb.doPaintBg(false); - if (!(p_event->description.empty())) - { + if (!p_event->description.empty()) snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l, g_settings.channellist_epgtext_align_right ? " " : " - "); - unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription); + unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription); + int max_name_len = width - numwidth - prg_offset - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - offset_right; + if (max_name_len < 0) + max_name_len = 0; + if ((int) ch_name_len > max_name_len) + ch_name_len = max_name_len; + + if (!p_event->description.empty()) + { unsigned int ch_desc_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(p_event->description); - int max_desc_len = width - numwidth - prg_offset - ch_name_len - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - offset_right; - + int max_desc_len = max_name_len - ch_name_len; if (max_desc_len < 0) max_desc_len = 0; if ((int) ch_desc_len > max_desc_len) @@ -2154,7 +2160,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint) } } - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - SCROLLBAR_WIDTH - prg_offset, nameAndDescription, color); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, ch_name_len, nameAndDescription, color); if (g_settings.channellist_epgtext_align_right) { // align right @@ -2174,7 +2180,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint) pb.paint(); } //name - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - SCROLLBAR_WIDTH - prg_offset, nameAndDescription, color); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, ch_name_len, nameAndDescription, color); } if (!firstpaint && curr == selected) updateVfd();