- bouquetlist: rework; ...

* use OFFSET defines
* use CComponentsFooter to paint footer
* use CComponentsScrollBar to paint scrollbar
* use a bit more offset for items
* re-align status icons in items
* use same scambled-icon as used in channellist
This commit is contained in:
svenhoefer
2017-04-13 11:20:10 +02:00
parent cf229bb3af
commit 4ea2f46c7c
2 changed files with 66 additions and 58 deletions

View File

@@ -3,6 +3,7 @@
Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2009,2011,2013,2015-2017 Stefan Seyfried Copyright (C) 2009,2011,2013,2015-2017 Stefan Seyfried
Copyright (C) 2017 Sven Hoefer
License: GPL License: GPL
@@ -67,7 +68,6 @@ CBouquetList::CBouquetList(const char * const Name)
name = g_Locale->getText(LOCALE_BOUQUETLIST_HEAD); name = g_Locale->getText(LOCALE_BOUQUETLIST_HEAD);
else else
name = Name; name = Name;
} }
CBouquetList::~CBouquetList() CBouquetList::~CBouquetList()
@@ -411,7 +411,8 @@ int CBouquetList::show(bool bShowChannelList)
int h_max_icon = 0; int h_max_icon = 0;
favonly = !bShowChannelList; favonly = !bShowChannelList;
for(unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]);count++){ for (unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); count++)
{
int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale)); int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale));
w_max_text = std::max(w_max_text, w_text); w_max_text = std::max(w_max_text, w_text);
frameBuffer->getIconSize(CBouquetListButtons[count].button, &icol_w, &icol_h); frameBuffer->getIconSize(CBouquetListButtons[count].button, &icol_w, &icol_h);
@@ -419,26 +420,32 @@ int CBouquetList::show(bool bShowChannelList)
h_max_icon = std::max(h_max_icon, icol_h); h_max_icon = std::max(h_max_icon, icol_h);
} }
int need_width = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0])*(w_max_icon + w_max_text + 20); item_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "");
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
width = w_max (need_width, 20); /*
height = h_max (16 * fheight, 40); We align width to needed footer space,
but this manual calculation isn't a good idea.
It would be better to get the needed width from
CComponententsFooter class.
*/
width = (sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]))*(w_max_icon + w_max_text + 2*OFFSET_INNER_MID);
height = 16*item_height;
footerHeight = std::max(h_max_icon+8, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight()+8); header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); footer_height = header_height;
listmaxshow = (height - theight - footerHeight)/fheight; listmaxshow = (height - header_height - footer_height)/item_height;
height = theight + footerHeight + listmaxshow * fheight; // recalc height height = header_height + footer_height + listmaxshow*item_height; // recalc height
x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; x = getScreenStartX(width);
y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; y = getScreenStartY(height);
int lmaxpos= 1; int lmaxpos= 1;
int i= Bouquets.size(); int i= Bouquets.size();
while ((i= i/10)!=0) while ((i= i/10)!=0)
lmaxpos++; lmaxpos++;
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "");
COSDFader fader(g_settings.theme.menu_Content_alpha); COSDFader fader(g_settings.theme.menu_Content_alpha);
fader.StartFadeIn(); fader.StartFadeIn();
@@ -471,7 +478,7 @@ int CBouquetList::show(bool bShowChannelList)
{ {
selected = oldselected; selected = oldselected;
if(fader.StartFadeOut()) { if(fader.StartFadeOut()) {
timeoutEnd = CRCInput::calcTimeoutEnd( 1 ); timeoutEnd = CRCInput::calcTimeoutEnd(1);
msg = 0; msg = 0;
} else } else
loop=false; loop=false;
@@ -563,7 +570,7 @@ int CBouquetList::show(bool bShowChannelList)
pos = 1; pos = 1;
} }
} else { } else {
chn = chn * 10 + CRCInput::getNumericValue(msg); chn = chn*10 + CRCInput::getNumericValue(msg);
pos++; pos++;
} }
@@ -591,6 +598,7 @@ int CBouquetList::show(bool bShowChannelList)
fader.StopFade(); fader.StopFade();
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
if (save_bouquets) { if (save_bouquets) {
save_bouquets = false; save_bouquets = false;
#if 0 #if 0
@@ -602,7 +610,8 @@ int CBouquetList::show(bool bShowChannelList)
if (g_settings.epg_scan == CEpgScan::SCAN_SEL) if (g_settings.epg_scan == CEpgScan::SCAN_SEL)
CEpgScan::getInstance()->Start(); CEpgScan::getInstance()->Start();
} }
if(zapOnExit)
if (zapOnExit)
return (selected); return (selected);
return (res); return (res);
@@ -610,13 +619,13 @@ int CBouquetList::show(bool bShowChannelList)
void CBouquetList::hide() void CBouquetList::hide()
{ {
frameBuffer->paintBackgroundBoxRel(x,y, width,height+10); frameBuffer->paintBackgroundBoxRel(x, y, width, height);
CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked()); CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked());
} }
void CBouquetList::paintItem(int pos) void CBouquetList::paintItem(int pos)
{ {
int ypos = y+ theight+0 + pos*fheight; int ypos = y + header_height + pos*item_height;
bool iscurrent = true; bool iscurrent = true;
int npos = liststart + pos; int npos = liststart + pos;
const char * lname = NULL; const char * lname = NULL;
@@ -633,8 +642,8 @@ void CBouquetList::paintItem(int pos)
i_radius = RADIUS_LARGE; i_radius = RADIUS_LARGE;
if (i_radius) if (i_radius)
frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, bgcolor, i_radius); frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius);
if (npos < (int) Bouquets.size()) if (npos < (int) Bouquets.size())
lname = (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bFav) ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : Bouquets[npos]->channelList->getName(); lname = (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bFav) ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : Bouquets[npos]->channelList->getName();
@@ -657,33 +666,33 @@ void CBouquetList::paintItem(int pos)
} }
} }
if(npos < (int) Bouquets.size()) { if (npos < (int) Bouquets.size()) {
char tmp[10]; char num[10];
sprintf((char*) tmp, "%d", npos+ 1); sprintf((char*) num, "%d", npos + 1);
int iw = 0, ih = 0; int iw = 0, ih = 0;
if ((g_settings.epg_scan == CEpgScan::SCAN_SEL) && if ((g_settings.epg_scan == CEpgScan::SCAN_SEL) &&
Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bScanEpg) { Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bScanEpg) {
frameBuffer->getIconSize(NEUTRINO_ICON_EPG, &iw, &ih); frameBuffer->getIconSize(NEUTRINO_ICON_EPG, &iw, &ih);
if (iw && ih) { if (iw && ih) {
int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw; int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw;
frameBuffer->paintIcon(NEUTRINO_ICON_EPG, icon_x - iw, ypos, fheight); frameBuffer->paintIcon(NEUTRINO_ICON_EPG, icon_x, ypos, item_height);
iw = iw + 4 + RADIUS_LARGE/2; iw = iw + OFFSET_INNER_MID;
} }
} }
if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI) { if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI) {
int iw2; int iw2 = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED2, &iw2, &ih); frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &iw2, &ih);
if (iw2 && ih) { if (iw2 && ih) {
int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw - iw2 - 2; int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw - iw2;
frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED2, icon_x - iw2, ypos, fheight); frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, icon_x, ypos, item_height);
iw = iw + iw2 + 4 + RADIUS_LARGE/2; iw = iw + iw2 + OFFSET_INNER_MID;
} }
} }
int numpos = x+5+numwidth- g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); int numpos = x + OFFSET_INNER_MID + numwidth - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(num);
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos,ypos+fheight, numwidth+5, tmp, color, fheight); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos, ypos + item_height, numwidth + OFFSET_INNER_SMALL, num, color, item_height);
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10, ypos+ fheight, width- numwidth- 20- 15 - iw, lname, color); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID, ypos + item_height, width - numwidth - 2*OFFSET_INNER_MID - iw - SCROLLBAR_WIDTH, lname, color);
//CVFD::getInstance()->showMenuText(0, bouq->channelList->getName(), -1, true); //CVFD::getInstance()->showMenuText(0, bouq->channelList->getName(), -1, true);
} }
} }
@@ -691,7 +700,7 @@ void CBouquetList::paintItem(int pos)
void CBouquetList::paintHead() void CBouquetList::paintHead()
{ {
std::string icon(""); std::string icon("");
CComponentsHeader header(x, y, width, theight, name, icon, CComponentsHeader::CC_BTN_LEFT | CComponentsHeader::CC_BTN_RIGHT | CComponentsHeader::CC_BTN_MENU); CComponentsHeader header(x, y, width, header_height, name, icon, CComponentsHeader::CC_BTN_LEFT | CComponentsHeader::CC_BTN_RIGHT | CComponentsHeader::CC_BTN_MENU);
header.paint(CC_SAVE_SCREEN_NO); header.paint(CC_SAVE_SCREEN_NO);
} }
@@ -711,33 +720,32 @@ void CBouquetList::paint()
_lastnum /= 10; _lastnum /= 10;
} }
frameBuffer->paintBoxRel(x, y+theight, width, height - theight - footerHeight, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel(x, y + header_height, width, height - header_height - footer_height, COL_MENUCONTENT_PLUS_0);
int numbuttons = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); int numButtons = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]);
#if 0
if (favonly) /* this actually shows favorites and providers button, but both are active anyway */
numbuttons = 2;
::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight);
#endif
if (favonly) if (favonly)
frameBuffer->paintBoxRel(x, y + (height - footerHeight), width, footerHeight, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); //round
else
::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight);
if(!Bouquets.empty())
{ {
for(unsigned int count=0;count<listmaxshow;count++) { // show an empty footer
frameBuffer->paintBoxRel(x, y + height - footer_height, width, footer_height, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
}
else
{
CComponentsFooter footer;
footer.paintButtons(x, y + height - footer_height, width, footer_height, numButtons, CBouquetListButtons);
}
if (!Bouquets.empty())
{
for (unsigned int count = 0; count < listmaxshow; count++)
{
paintItem(count); paintItem(count);
} }
} }
int ypos = y+ theight; int _listmaxshow = listmaxshow ? listmaxshow : 1; //avoid division by zero
int sb = fheight* listmaxshow; int total_pages = ((bsize - 1) / _listmaxshow) + 1;
frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); int current_page = selected / _listmaxshow;
int listmaxshow_tmp = listmaxshow ? listmaxshow : 1;//avoid division by zero
int sbc= ((bsize - 1)/ listmaxshow_tmp)+ 1; /* bsize is > 0, so sbc is also > 0 */
int sbs= (selected/listmaxshow_tmp);
frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page);
} }

View File

@@ -87,9 +87,9 @@ class CBouquetList : public CListHelpers
unsigned int liststart; unsigned int liststart;
unsigned int listmaxshow; unsigned int listmaxshow;
unsigned int numwidth; unsigned int numwidth;
int fheight; // Fonthoehe Bouquetlist-Inhalt int item_height;
int theight; // Fonthoehe Bouquetlist-Titel int header_height;
int footerHeight; int footer_height;
int width; int width;
int height; int height;