From c557c036954471cf70d365c31e19befb9638220e Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 27 May 2013 12:03:08 +0200 Subject: [PATCH] - 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 --- src/gui/timerlist.cpp | 106 +++++++++++++++++++++++------------------- src/gui/timerlist.h | 25 +++++----- 2 files changed, 70 insertions(+), 61 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 2c9e0276e..f4ae3fb2f 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -76,8 +76,6 @@ extern CBouquetManager *g_bouquetManager; #include -#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+poseventType == 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() diff --git a/src/gui/timerlist.h b/src/gui/timerlist.h index 3645a7483..8b74bc278 100644 --- a/src/gui/timerlist.h +++ b/src/gui/timerlist.h @@ -45,14 +45,18 @@ class CTimerList : public CMenuTarget { private: - CFrameBuffer *frameBuffer; - unsigned int selected; - unsigned int liststart; - unsigned int listmaxshow; - int fheight; // Fonthoehe Timerlist-Inhalt - int theight; // Fonthoehe Timerlist-Titel - int buttonHeight; - bool visible; + CFrameBuffer *frameBuffer; + int x; + int y; + int width; + int height; + int fheight; // fontheight content + int theight; // fontheight titel + int footerHeight; + unsigned int selected; + unsigned int liststart; + unsigned int listmaxshow; + bool visible; CTimerdClient *Timer; CTimerd::TimerList timerlist; // List of timers @@ -66,11 +70,6 @@ class CTimerList : public CMenuTarget int timer_apids_ac3; int timer_apids_alt; - int width; - int height; - int x; - int y; - int skipEventID; void paintItem(int pos);