- timerlist: rework gui stuff

* add shadow
* change some calculations to be more equal to other windows
* get footerheight from paintButtons methode
* change ok button to blue button in footer
* blue button has same function as ok button
* init members in contructor
* remove unused code
* change rotating colors because COL_MENUCONTENTDARK_PLUS_0
  is used for shadow
* replace info button with dummy if timer is not type REC or ZAP
* sort member variables in header
This commit is contained in:
svenhoefer
2013-05-27 12:03:08 +02:00
parent 8e46f63900
commit c557c03695
2 changed files with 70 additions and 61 deletions

View File

@@ -76,8 +76,6 @@ extern CBouquetManager *g_bouquetManager;
#include <string.h>
#define info_height 60
class CTimerListNewNotifier : public CChangeObserver
{
private:
@@ -247,19 +245,16 @@ CTimerList::CTimerList()
{
frameBuffer = CFrameBuffer::getInstance();
visible = false;
x = y = 0;
width = height = 0;
fheight = theight = 0;
footerHeight = 0;
selected = 0;
liststart = 0;
listmaxshow = 0;
Timer = new CTimerdClient();
skipEventID=0;
/* assuming all color icons must have same size */
int icol_w, icol_h, ih2;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h);
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_OKAY, &icol_w, &ih2);
icol_h = std::max(icol_h, ih2);
//buttonHeight = 7 + std::max(icol_h+2, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight());
buttonHeight = std::max(icol_h+4, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight());
/* most probable default */
saved_dispmode = (int)CVFD::MODE_TVRADIO;
}
@@ -414,6 +409,16 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
}*/
}
#define TimerListButtonsCount 5
struct button_label TimerListButtons[TimerListButtonsCount] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_TIMERLIST_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_TIMERLIST_NEW },
{ NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_TIMERLIST_RELOAD },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_TIMERLIST_MODIFY },
{ NEUTRINO_ICON_BUTTON_INFO_SMALL, NONEXISTANT_LOCALE }
};
void CTimerList::updateEvents(void)
{
timerlist.clear();
@@ -429,35 +434,32 @@ void CTimerList::updateEvents(void)
}
}
sort(timerlist.begin(), timerlist.end());
width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20);
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
int icol_w, icol_h;
frameBuffer->getIconSize(NEUTRINO_ICON_TIMER, &icol_w, &icol_h);
if(theight < icol_h)
theight = icol_h;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_INFO, &icol_w, &icol_h);
if(theight < icol_h)
theight = icol_h;
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
//get footerHeight from paintButtons
footerHeight = ::paintButtons(0, 0, 0, TimerListButtonsCount, TimerListButtons, 0, 0, "", false, COL_INFOBAR_SHADOW, NULL, 0, false);
height = frameBuffer->getScreenHeight() - (info_height+50);
width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20);
height = frameBuffer->getScreenHeight() - (2*theight); // max height
listmaxshow = (height-theight)/(fheight*2);
height = theight+listmaxshow*fheight*2+footerHeight; // recalc height
listmaxshow = (height-theight-0)/(fheight*2);
height = theight+0+listmaxshow*fheight*2; // recalc height
if (timerlist.size() < listmaxshow)
{
listmaxshow=timerlist.size();
height = theight+0+listmaxshow*fheight*2; // recalc height
height = theight+listmaxshow*fheight*2+footerHeight; // recalc height
}
if (selected==timerlist.size() && !(timerlist.empty()))
{
selected=timerlist.size()-1;
liststart = (selected/listmaxshow)*listmaxshow;
}
x=getScreenStartX( width );
y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2;
x = getScreenStartX(width);
y = getScreenStartY(height);
}
@@ -532,6 +534,8 @@ int CTimerList::show()
{
paintItem(selected - liststart);
}
paintFoot();
}
else if ((msg == CRCInput::RC_down || msg == (unsigned int)g_settings.key_channelList_pagedown) && !(timerlist.empty()))
{
@@ -560,8 +564,10 @@ int CTimerList::show()
{
paintItem(selected - liststart);
}
paintFoot();
}
else if ((msg == CRCInput::RC_right || msg == CRCInput::RC_ok) && !(timerlist.empty()))
else if ((msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg==CRCInput::RC_blue) && !(timerlist.empty()))
{
if (modifyTimer()==menu_return::RETURN_EXIT_ALL)
{
@@ -669,14 +675,14 @@ void CTimerList::hide()
{
if (visible)
{
frameBuffer->paintBackgroundBoxRel(x, y, width, height+ info_height+ 5);
frameBuffer->paintBackgroundBoxRel(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET);
visible = false;
}
}
void CTimerList::paintItem(int pos)
{
int ypos = y+ theight+0 + pos*fheight*2;
int ypos = y+ theight+ pos*fheight*2;
uint8_t color;
fb_pixel_t bgcolor;
@@ -687,16 +693,14 @@ void CTimerList::paintItem(int pos)
real_width-=15; //scrollbar
}
color = COL_MENUCONTENT;
if (pos & 1)
{
color = COL_MENUCONTENTDARK;
bgcolor = COL_MENUCONTENTDARK_PLUS_0;
}
bgcolor = COL_MENUCONTENT_PLUS_1;
else
{
color = COL_MENUCONTENT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
//shadow
frameBuffer->paintBoxRel(x + width, ypos, SHADOW_OFFSET, 2*fheight, COL_MENUCONTENTDARK_PLUS_0);
//item
frameBuffer->paintBoxRel(x, ypos, real_width, 2*fheight, bgcolor);
if (liststart + pos == selected)
@@ -704,8 +708,9 @@ void CTimerList::paintItem(int pos)
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
//selected item
frameBuffer->paintBoxRel(x,ypos, real_width, 2*fheight, bgcolor, RADIUS_MID);
if (liststart+pos<timerlist.size())
{
CTimerd::responseGetTimer & timer = timerlist[liststart+pos];
@@ -858,24 +863,29 @@ void CTimerList::paintItem(int pos)
void CTimerList::paintHead()
{
CComponentsHeader header(x, y, width, theight, LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER);
header.setShadowOnOff(CC_SHADOW_ON);
header.paint();
}
const struct button_label TimerListButtons[5] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_TIMERLIST_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_TIMERLIST_NEW },
{ NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_TIMERLIST_RELOAD },
{ NEUTRINO_ICON_BUTTON_OKAY , LOCALE_TIMERLIST_MODIFY },
{ NEUTRINO_ICON_BUTTON_INFO_SMALL, NONEXISTANT_LOCALE }
};
void CTimerList::paintFoot()
{
CTimerd::responseGetTimer* timer=&timerlist[selected];
if (timer != NULL)
{
//replace info button with dummy if timer is not type REC or ZAP
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO)
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_INFO_SMALL;
else
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL;
}
//shadow
frameBuffer->paintBoxRel(x + SHADOW_OFFSET, y + height - footerHeight, width, footerHeight + SHADOW_OFFSET, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
if (timerlist.empty())
::paintButtons(x, y + height, width, 2, &(TimerListButtons[1]), width);
::paintButtons(x, y + height - footerHeight, width, 2, &(TimerListButtons[1]), width);
else
::paintButtons(x, y + height, width, 5, TimerListButtons, width);
::paintButtons(x, y + height - footerHeight, width, TimerListButtonsCount, TimerListButtons, width);
}
void CTimerList::paint()