- epgplus: smoother aligment for channelnumbers

This commit is contained in:
vanhofen
2017-04-10 21:43:01 +02:00
committed by svenhoefer
parent 46e298823f
commit ab4adc92d0
2 changed files with 33 additions and 11 deletions

View File

@@ -55,6 +55,7 @@
#include <zapit/satconfig.h> #include <zapit/satconfig.h>
#include <zapit/getservices.h> #include <zapit/getservices.h>
#include <eitd/sectionsd.h> #include <eitd/sectionsd.h>
#include <system/helpers.h>
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
@@ -68,6 +69,7 @@ time_t EpgPlus::duration = 0;
int EpgPlus::sliderWidth = 0; int EpgPlus::sliderWidth = 0;
int EpgPlus::channelsTableWidth = 0; int EpgPlus::channelsTableWidth = 0;
int EpgPlus::entryFontSize = 0; int EpgPlus::entryFontSize = 0;
int EpgPlus::channelNumberOffset = 0;
/* negative size means "screen width in percent" */ /* negative size means "screen width in percent" */
static EpgPlus::SizeSetting sizeSettingTable[] = static EpgPlus::SizeSetting sizeSettingTable[] =
@@ -363,16 +365,12 @@ EpgPlus::ChannelEntry::ChannelEntry(const CZapitChannel * pchannel, int pindex,
{ {
this->channel = pchannel; this->channel = pchannel;
this->displayNumber = "";
this->displayName = "";
if (pchannel != NULL) if (pchannel != NULL)
{ {
std::stringstream pdisplayName; this->displayNumber = to_string(pchannel->number);
//pdisplayName << pindex + 1 << " " << pchannel->getName(); this->displayName = pchannel->getName();
if (g_settings.channellist_show_numbers)
pdisplayName << pchannel->number << " " << pchannel->getName();
else
pdisplayName << pchannel->getName();
this->displayName = pdisplayName.str();
} }
this->index = pindex; this->index = pindex;
@@ -423,8 +421,20 @@ void EpgPlus::ChannelEntry::paint(bool isSelected, time_t _selectedTime)
this->frameBuffer->paintBoxRel(this->x, this->y, this->width, this->font->getHeight(), bgcolor, radius, CORNER_LEFT); this->frameBuffer->paintBoxRel(this->x, this->y, this->width, this->font->getHeight(), bgcolor, radius, CORNER_LEFT);
this->font->RenderString(this->x + OFFSET_INNER_MID, this->y + this->font->getHeight(), int xPos = this->x + OFFSET_INNER_MID;
this->width - 2*OFFSET_INNER_MID, this->displayName, color); int numberWidth = 0;
if (g_settings.channellist_show_numbers)
{
// display channelnumber
int xOffset = EpgPlus::channelNumberOffset - this->font->getRenderWidth(this->displayNumber);
this->font->RenderString(xPos + xOffset, this->y + this->font->getHeight(), this->width - 2*OFFSET_INNER_MID, this->displayNumber, color);
numberWidth = EpgPlus::channelNumberOffset + OFFSET_INNER_SMALL;
xPos += numberWidth;
}
// display channelname
this->font->RenderString(xPos, this->y + this->font->getHeight(), this->width - numberWidth - 2*OFFSET_INNER_MID, this->displayName, color);
if (isSelected) if (isSelected)
{ {
@@ -484,7 +494,7 @@ void EpgPlus::ChannelEntry::paint(bool isSelected, time_t _selectedTime)
// paint detailsline // paint detailsline
if (isSelected) if (isSelected)
{ {
int xPos = this->x - DETAILSLINE_WIDTH; xPos = this->x - DETAILSLINE_WIDTH;
int yPosTop = this->y + this->font->getHeight()/2; int yPosTop = this->y + this->font->getHeight()/2;
int yPosBottom = this->footer->y + this->footer->getUsedHeight()/2; int yPosBottom = this->footer->y + this->footer->getUsedHeight()/2;
@@ -725,6 +735,16 @@ void EpgPlus::createChannelEntries(int selectedChannelEntryIndex)
this->selectedChannelEntry = this->displayedChannelEntries[selectedChannelEntryIndex - this->channelListStartIndex]; this->selectedChannelEntry = this->displayedChannelEntries[selectedChannelEntryIndex - this->channelListStartIndex];
} }
// get largest channelnumber
int n = 1;
for (TChannelEntries::iterator It = this->displayedChannelEntries.begin();
It != this->displayedChannelEntries.end();
++It)
{
n = std::max(n, (*It)->channel->number);
}
channelNumberOffset = ChannelEntry::font->getRenderWidth(to_string(n));
} }
void EpgPlus::init() void EpgPlus::init()

View File

@@ -211,6 +211,7 @@ class EpgPlus
//// attributes //// attributes
public: public:
const CZapitChannel * channel; const CZapitChannel * channel;
std::string displayNumber;
std::string displayName; std::string displayName;
int index; int index;
@@ -420,6 +421,7 @@ class EpgPlus
int channelListStartIndex; int channelListStartIndex;
int maxNumberOfDisplayableEntries; // maximal number of displayable entrys int maxNumberOfDisplayableEntries; // maximal number of displayable entrys
static int channelNumberOffset;
time_t startTime; time_t startTime;
time_t firstStartTime; time_t firstStartTime;