Fixed display groupname in cChannelGroupGrid::DrawHorizontal

This commit is contained in:
kamel5 2020-07-25 13:35:03 +02:00
parent 5870b1ae4c
commit 52c41ff5af
2 changed files with 8 additions and 10 deletions

View File

@ -68,16 +68,15 @@ void cChannelGroupGrid::Draw(void) {
void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) { void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) {
int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2; int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2;
cString text = CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str(); cString text = cString::sprintf("%s", CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str());
int textWidth = fontManager.FontChannelGroups->Width(*text); int textWidth = fontManager.FontChannelGroups->Width(*text);
int x = (Width() - textWidth) / 2; int x = (Width() - textWidth) / 2;
pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups); pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups);
} }
void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) { void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) {
std::string nameUpper = name; std::string groupName = name;
std::transform(nameUpper.begin(), nameUpper.end(),nameUpper.begin(), ::toupper); int numChars = groupName.length();
int numChars = nameUpper.length();
int charHeight = fontManager.FontChannelGroupsHorizontal->Height(); int charHeight = fontManager.FontChannelGroupsHorizontal->Height();
int textHeight = numChars * charHeight; int textHeight = numChars * charHeight;
int y = 5; int y = 5;
@ -90,7 +89,7 @@ void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) {
pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal);
break; break;
} }
cString currentChar = cString::sprintf("%c", nameUpper.at(i)); cString currentChar = cString::sprintf("%s", utf8_substr(groupName.c_str(), i, 1).c_str());
int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2; int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2;
pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal);
y += fontManager.FontChannelGroupsHorizontal->Height(); y += fontManager.FontChannelGroupsHorizontal->Height();

View File

@ -10,7 +10,6 @@
#include <vdr/plugin.h> #include <vdr/plugin.h>
#include <vdr/skins.h> #include <vdr/skins.h>
#include "services/epgsearch.h" #include "services/epgsearch.h"
#include "tools.h" #include "tools.h"
cPlugin *GetScraperPlugin(void) { cPlugin *GetScraperPlugin(void) {
@ -42,7 +41,7 @@ std::string utf8_substr(const std::string& str, unsigned int start, long unsigne
} }
if (q<=start+leng || leng==std::string::npos){ max=i; } if (q<=start+leng || leng==std::string::npos){ max=i; }
if (min==std::string::npos || max==std::string::npos) { return ""; } if (min==std::string::npos || max==std::string::npos) { return ""; }
return str.substr(min,max); return str.substr(min,max-min);
} }
std::string CutText(std::string text, int width, const cFont *font) { std::string CutText(std::string text, int width, const cFont *font) {