CEpgData: optimize handling of header and bottom box

Working with existant instances and reduce flicker effects.


Origin commit data
------------------
Branch: ni/coolstream
Commit: fc805049d3
Author: Thilo Graf <dbt@novatux.de>
Date: 2017-05-03 (Wed, 03 May 2017)



------------------
This commit was generated by Migit
This commit is contained in:
2017-05-03 21:29:41 +02:00
parent 93ef2ac356
commit 5dc6e6375f
2 changed files with 111 additions and 60 deletions

View File

@@ -126,12 +126,17 @@ CEpgData::CEpgData()
tmdb_active = false; tmdb_active = false;
mp_movie_info = NULL; mp_movie_info = NULL;
header = NULL; header = NULL;
Bottombox = NULL;
lpic = NULL;
rpic = NULL;
lText = NULL;
rText = NULL;
pb = NULL;
} }
CEpgData::~CEpgData() CEpgData::~CEpgData()
{ {
delete header; ResetModules();
header = NULL;
} }
void CEpgData::start() void CEpgData::start()
@@ -841,40 +846,39 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
// show the epg // show the epg
// header + logo // header + logo
if (header) { if (!header){
header->kill();
delete header;
header = NULL;
}
header = new CComponentsHeader(sx, sy, ox, toph); header = new CComponentsHeader(sx, sy, ox, toph);
header->setCorner(RADIUS_LARGE, CORNER_TOP);
header->setDimensionsAll(sx, sy, ox, toph);
header->setColorBody(COL_MENUHEAD_PLUS_0); header->setColorBody(COL_MENUHEAD_PLUS_0);
header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction); header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction);
header->enableClock(true, "%H:%M", "%H %M", true);
header->enableClock(true, "%H:%M", "%H.%M", true); }else
header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); header->setDimensionsAll(sx, sy, ox, toph);
header->getChannelLogoObject()->hide();
header->setChannelLogo(channel_id, channel_name);
header->setCaption(epgData.title); header->setCaption(epgData.title);
if (header->isPainted())
header->hideCCItems();
// set channel logo
header->setChannelLogo(channel_id, channel_name);
//paint head
header->paint(CC_SAVE_SCREEN_NO); header->paint(CC_SAVE_SCREEN_NO);
int showPos = 0; int showPos = 0;
textCount = epgText.size(); textCount = epgText.size();
showText(showPos, sy + toph); showText(showPos, sy + toph);
// small bottom box // small bottom box with left/right navigation
CComponentsFrmChain *Bottombox = new CComponentsFrmChain(sx, sy+oy-botboxheight, ox, botboxheight); if (!Bottombox){
Bottombox = new CComponentsFrmChain(sx, sy+oy-botboxheight, ox, botboxheight);
Bottombox->setColorBody(COL_MENUFOOT_PLUS_0); Bottombox->setColorBody(COL_MENUFOOT_PLUS_0);
Bottombox->setCornerType(CORNER_NONE);
Bottombox->enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction); Bottombox->enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction);
Bottombox->set2ndColor(COL_MENUCONTENT_PLUS_0); Bottombox->set2ndColor(COL_MENUCONTENT_PLUS_0);
}
if (!mp_info) if (!mp_info){
{
std::string fromto = epg_start + " - " + epg_end; std::string fromto = epg_start + " - " + epg_end;
int x_off = OFFSET_INNER_MID; int x_off = OFFSET_INNER_MID;
int mid_width = ox * 40 / 100; // 40% int mid_width = ox * 40 / 100; // 40%
@@ -882,26 +886,52 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
GetPrevNextEPGData(epgData.eventID, &epgData.epg_times.startzeit); GetPrevNextEPGData(epgData.eventID, &epgData.epg_times.startzeit);
CComponentsPictureScalable *lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT); // init left arrow
CComponentsText *lText = new CComponentsText(x_off + lpic->getWidth() + OFFSET_INNER_MID, CC_CENTERED, side_width, toph, fromto, CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); if (!lpic){
if ((prev_id) && (!call_fromfollowlist)) lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT);
Bottombox->addCCItem(lpic);
lpic->doPaintBg(false); lpic->doPaintBg(false);
lText->doPaintBg(false); Bottombox->addCCItem(lpic);
lpic->enableSaveBg();
}
lpic->allowPaint(prev_id && !call_fromfollowlist);
// init right arrow
if (!rpic){
rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT);
CComponentsPictureScalable *rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT,Bottombox);
int x_pos = ox - rpic->getWidth() - OFFSET_INNER_MID;
if ((next_id) && (!call_fromfollowlist))
Bottombox->addCCItem(rpic);
rpic->setXPos(x_pos);
CComponentsText *rText = new CComponentsText(0, CC_CENTERED, side_width, toph, epg_date, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
rText->setXPos(x_pos - OFFSET_INNER_MID - rText->getWidth());
rpic->doPaintBg(false); rpic->doPaintBg(false);
Bottombox->addCCItem(rpic);
rpic->enableSaveBg();
int x_pos = ox - rpic->getWidth() - x_off;
rpic->setXPos(x_pos);
}
rpic->allowPaint(next_id && !call_fromfollowlist);
// init text left "from to"
if (!lText){
lText = new CComponentsText(x_off + lpic->getWidth() + x_off, CC_CENTERED, side_width, toph, "", CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, NULL, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
lText->doPaintBg(false);
Bottombox->addCCItem(lText);
lText->enableSaveBg();
}
lText->setText(fromto, CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], COL_MENUHEAD_TEXT, CComponentsText::FONT_STYLE_REGULAR);
// init text right "follow"
if (!rText){
rText = new CComponentsText(0, CC_CENTERED, side_width, toph, "", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, Bottombox, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
rText->doPaintBg(false); rText->doPaintBg(false);
rText->enableSaveBg();
}
rText->setText(epg_date, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]);
rText->setXPos(rpic->getXPos() - x_off - rText->getWidth());
} }
Bottombox->paint(false); //ensure clean background
if(Bottombox->isPainted())
Bottombox->hideCCItems();
//paint bottombox contents
Bottombox->paint(false);
showProgressBar(); showProgressBar();
// show Timer Event Buttons // show Timer Event Buttons
@@ -1214,6 +1244,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
} }
case CRCInput::RC_help: case CRCInput::RC_help:
bigFonts = bigFonts ? false : true; bigFonts = bigFonts ? false : true;
ResetModules();
frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy); frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy);
showTimerEventBar (false); showTimerEventBar (false);
start(); start();
@@ -1289,11 +1320,7 @@ void CEpgData::hide()
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() / BIGFONT_FACTOR)); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() / BIGFONT_FACTOR));
} }
if (header) { ResetModules();
header->kill();
delete header;
header = NULL;
}
frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy); frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy);
showTimerEventBar (false); showTimerEventBar (false);
@@ -1436,19 +1463,22 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st
} }
void CEpgData::showProgressBar() void CEpgData::showProgressBar()
{
//show progressbar
if (epg_done != -1)
{ {
int w = 104; int w = 104;
int x = sx + (ox - w)/2; int x = sx + (ox - w)/2;
int h = botboxheight - 12; int h = botboxheight - 12;
int y = sy + oy - botboxheight + (botboxheight - h)/2; int y = sy + oy - botboxheight + (botboxheight - h)/2;
if (!pb){
CProgressBar pb(x, y, w, h); pb = new CProgressBar(x, y, w, h);
pb.setType(CProgressBar::PB_TIMESCALE); pb->setType(CProgressBar::PB_TIMESCALE);
pb.setValues(epg_done, 100); }
pb.paint(false); //show progressbar
if (epg_done != -1)
{
pb->setValues(epg_done, 100);
pb->paint(true);
}else{
pb->hide();
} }
} }
@@ -1523,6 +1553,22 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info)
} }
} }
void CEpgData::ResetModules()
{
if (header){
delete header; header = NULL;
}
if (Bottombox){
delete Bottombox; Bottombox = NULL;
// bottom box items are destroyed but explicit reset of bottom box items here required
lpic = rpic = NULL;
lText = rText = NULL;
}
if (pb){
delete pb; pb = NULL;
}
}
// -- EPG Data Viewer Menu Handler Class // -- EPG Data Viewer Menu Handler Class
// -- to be used for calls from Menue // -- to be used for calls from Menue
// -- (2004-03-06 rasc) // -- (2004-03-06 rasc)

View File

@@ -51,6 +51,10 @@ class CEpgData
CChannelEventList followlist; CChannelEventList followlist;
CEPGData epgData; CEPGData epgData;
CComponentsHeader *header; CComponentsHeader *header;
CComponentsFrmChain *Bottombox;
CComponentsPictureScalable *lpic, *rpic;
CComponentsText *lText, *rText;
CProgressBar *pb;
std::string epg_date; std::string epg_date;
std::string epg_start; std::string epg_start;
std::string epg_end; std::string epg_end;
@@ -100,6 +104,7 @@ class CEpgData
int show(const t_channel_id channel_id, uint64_t id = 0, time_t* startzeit = NULL, bool doLoop = true, bool callFromfollowlist = false, bool mp_info = false ); int show(const t_channel_id channel_id, uint64_t id = 0, time_t* startzeit = NULL, bool doLoop = true, bool callFromfollowlist = false, bool mp_info = false );
int show_mp(MI_MOVIE_INFO *mi, int mp_position = 0, int mp_duration = 0, bool doLoop = true); int show_mp(MI_MOVIE_INFO *mi, int mp_position = 0, int mp_duration = 0, bool doLoop = true);
void hide(); void hide();
void ResetModules();
}; };