CInfoViewer: add member killInfobarText()

Ensure that no unnecessary instance of Components infobox is generated
and paint only changed text.
This commit is contained in:
2013-04-26 16:48:45 +02:00
parent dfc6e2069e
commit 54d0f8b42b
2 changed files with 22 additions and 11 deletions

View File

@@ -1811,6 +1811,17 @@ void CInfoViewer::show_Data (bool calledFromEvent)
#endif #endif
} }
void CInfoViewer::killInfobarText()
{
if (infobar_txt){
if (infobar_txt->isPainted())
infobar_txt->hide();
delete infobar_txt;
}
infobar_txt = NULL;
}
void CInfoViewer::showInfoFile() void CInfoViewer::showInfoFile()
{ {
//read textcontent from this file //read textcontent from this file
@@ -1818,16 +1829,11 @@ void CInfoViewer::showInfoFile()
//exit if file not found, don't create an info object, delete old instance if required //exit if file not found, don't create an info object, delete old instance if required
if (!file_size(infobar_file.c_str())) { if (!file_size(infobar_file.c_str())) {
if (infobar_txt){ killInfobarText();
if (infobar_txt->isPainted())
infobar_txt->hide();
delete infobar_txt;
}
infobar_txt = NULL;
return; return;
} }
//get position of info area //set position of info area
const int oOffset = 140; // outer left/right offset const int oOffset = 140; // outer left/right offset
const int pb_w = 112; // same value as int pb_w in display_Info() const int pb_w = 112; // same value as int pb_w in display_Info()
const int xStart = BoxStartX + ChanWidth + oOffset; const int xStart = BoxStartX + ChanWidth + oOffset;
@@ -1841,8 +1847,7 @@ void CInfoViewer::showInfoFile()
//get text from file and set it to info object, exit and delete object if failed //get text from file and set it to info object, exit and delete object if failed
if (!infobar_txt->setTextFromFile(infobar_file, CTextBox::CENTER, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO])){ if (!infobar_txt->setTextFromFile(infobar_file, CTextBox::CENTER, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO])){
delete infobar_txt; killInfobarText();
infobar_txt = NULL;
return; return;
} }
@@ -1853,9 +1858,10 @@ void CInfoViewer::showInfoFile()
infobar_txt->setColorBody(COL_INFOBAR_PLUS_0); infobar_txt->setColorBody(COL_INFOBAR_PLUS_0);
infobar_txt->doPaintTextBoxBg(false); infobar_txt->doPaintTextBoxBg(false);
//paint info, don't save backscreen, if already painted, global hide is done by killTitle() //paint info, don't save background, if already painted, global hide is also done by killTitle()
bool save_bg = !infobar_txt->isPainted(); bool save_bg = !infobar_txt->isPainted();
infobar_txt->paint(save_bg); if (infobar_txt->textChanged())
infobar_txt->paint(save_bg);
} }
@@ -1874,6 +1880,8 @@ void CInfoViewer::killTitle()
g_Radiotext->S_RtOsd = g_Radiotext->haveRadiotext() ? 1 : 0; g_Radiotext->S_RtOsd = g_Radiotext->haveRadiotext() ? 1 : 0;
killRadiotext(); killRadiotext();
} }
killInfobarText();
} }
showButtonBar = false; showButtonBar = false;
} }

View File

@@ -128,8 +128,11 @@ class CInfoViewer
void showRadiotext(); void showRadiotext();
void killRadiotext(); void killRadiotext();
//small infobox, shows a small textbox with a short message text,
//text must be located in a file named /tmp/infobar.txt
CComponentsInfoBox *infobar_txt; CComponentsInfoBox *infobar_txt;
void showInfoFile(); void showInfoFile();
void killInfobarText();
//void loop(int fadeValue, bool show_dot ,bool fadeIn); //void loop(int fadeValue, bool show_dot ,bool fadeIn);
void loop(bool show_dot); void loop(bool show_dot);