mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 00:41:17 +02:00
CTextBox: ensure paint of text and background only if required
It's not new, but this involves also other properties, like color or position... It's possible that more properties are required, maybe needs to be watched and evaluation of comparison might require further revisions.
This commit is contained in:
@@ -77,7 +77,7 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode,
|
|||||||
initVar();
|
initVar();
|
||||||
|
|
||||||
if(text != NULL)
|
if(text != NULL)
|
||||||
m_cText = text;
|
m_cText = m_old_cText = text;
|
||||||
|
|
||||||
if(font_text != NULL)
|
if(font_text != NULL)
|
||||||
m_pcFontText = font_text;
|
m_pcFontText = font_text;
|
||||||
@@ -113,7 +113,7 @@ CTextBox::CTextBox(const char * text)
|
|||||||
initVar();
|
initVar();
|
||||||
|
|
||||||
if(text != NULL)
|
if(text != NULL)
|
||||||
m_cText = *text;
|
m_cText = m_old_cText = *text;
|
||||||
|
|
||||||
//TRACE_1("[CTextBox] %s Line %d text: %s\r\n", __FUNCTION__, __LINE__, text);
|
//TRACE_1("[CTextBox] %s Line %d text: %s\r\n", __FUNCTION__, __LINE__, text);
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ void CTextBox::initVar(void)
|
|||||||
m_nMaxLineWidth = 0;
|
m_nMaxLineWidth = 0;
|
||||||
|
|
||||||
m_cText = "";
|
m_cText = "";
|
||||||
m_nMode = SCROLL;
|
m_nMode = m_old_nMode = SCROLL;
|
||||||
|
|
||||||
m_FontUseDigitHeight = false;
|
m_FontUseDigitHeight = false;
|
||||||
m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1];
|
m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1];
|
||||||
@@ -164,21 +164,21 @@ void CTextBox::initVar(void)
|
|||||||
text_Hborder_width = 8; //border left and right
|
text_Hborder_width = 8; //border left and right
|
||||||
text_Vborder_width = 8; //border top and buttom
|
text_Vborder_width = 8; //border top and buttom
|
||||||
|
|
||||||
m_cFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1);
|
m_cFrame.iX = m_old_x = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1);
|
||||||
m_cFrame.iWidth = MIN_WINDOW_WIDTH;
|
m_cFrame.iWidth = m_old_dx = MIN_WINDOW_WIDTH;
|
||||||
m_cFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>1);
|
m_cFrame.iY = m_old_y = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>1);
|
||||||
m_cFrame.iHeight = MIN_WINDOW_HEIGHT;
|
m_cFrame.iHeight = m_old_dy = MIN_WINDOW_HEIGHT;
|
||||||
|
|
||||||
m_nMaxHeight = MAX_WINDOW_HEIGHT;
|
m_nMaxHeight = MAX_WINDOW_HEIGHT;
|
||||||
m_nMaxWidth = MAX_WINDOW_WIDTH;
|
m_nMaxWidth = MAX_WINDOW_WIDTH;
|
||||||
m_nMinHeight = MIN_WINDOW_HEIGHT;
|
m_nMinHeight = MIN_WINDOW_HEIGHT;
|
||||||
m_nMinWidth = MIN_WINDOW_WIDTH;
|
m_nMinWidth = MIN_WINDOW_WIDTH;
|
||||||
|
|
||||||
m_textBackgroundColor = COL_MENUCONTENT_PLUS_0;
|
m_textBackgroundColor = m_old_textBackgroundColor = COL_MENUCONTENT_PLUS_0;
|
||||||
m_textColor = COL_MENUCONTENT_TEXT;
|
m_textColor = COL_MENUCONTENT_TEXT;
|
||||||
m_nPaintBackground = true;
|
m_nPaintBackground = true;
|
||||||
m_nBgRadius = 0;
|
m_nBgRadius = m_old_nBgRadius = 0;
|
||||||
m_nBgRadiusType = CORNER_ALL;
|
m_nBgRadiusType = m_old_nBgRadiusType = CORNER_ALL;
|
||||||
|
|
||||||
m_cLineArray.clear();
|
m_cLineArray.clear();
|
||||||
|
|
||||||
@@ -516,25 +516,68 @@ void CTextBox::refreshText(void)
|
|||||||
int ay = /*m_cFrameTextRel.iY+*/m_cFrame.iY;
|
int ay = /*m_cFrameTextRel.iY+*/m_cFrame.iY;
|
||||||
int dx = m_cFrameTextRel.iWidth;
|
int dx = m_cFrameTextRel.iWidth;
|
||||||
int dy = m_cFrameTextRel.iHeight;
|
int dy = m_cFrameTextRel.iHeight;
|
||||||
|
bool has_changed = false;
|
||||||
|
|
||||||
//save screen
|
//evaluate comparsion properties
|
||||||
|
if (m_old_x != ax || m_old_y != ay || m_old_dx != dx || m_old_dy != dy ||
|
||||||
|
m_old_textBackgroundColor != m_textBackgroundColor ||
|
||||||
|
m_old_nBgRadius != m_nBgRadius ||m_old_nBgRadiusType != m_nBgRadiusType ||
|
||||||
|
m_nNrOfPages > 1 ||
|
||||||
|
m_old_nMode != m_nMode){
|
||||||
|
has_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//destroy pixel buffer on changed property values
|
||||||
|
if (has_changed){
|
||||||
|
if (m_bgpixbuf){
|
||||||
|
//TRACE("[CTextBox] %s destroy ol pixel buffer, has changes%d\r\n", __FUNCTION__, __LINE__);
|
||||||
|
delete[] m_bgpixbuf;
|
||||||
|
m_bgpixbuf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//save screen only if no paint of background required
|
||||||
|
if (!m_nPaintBackground){
|
||||||
if (m_bgpixbuf == NULL){
|
if (m_bgpixbuf == NULL){
|
||||||
|
//TRACE("[CTextBox] %s save bg %d\r\n", __FUNCTION__, __LINE__);
|
||||||
m_bgpixbuf= new fb_pixel_t[dx * dy];
|
m_bgpixbuf= new fb_pixel_t[dx * dy];
|
||||||
frameBuffer->SaveScreen(ax, ay, dx, dy, m_bgpixbuf);
|
frameBuffer->SaveScreen(ax, ay, dx, dy, m_bgpixbuf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Paint Text Background
|
//Paint Text Background
|
||||||
if (m_nPaintBackground){
|
if (m_nPaintBackground){
|
||||||
if (m_bgpixbuf){
|
if (m_bgpixbuf){
|
||||||
|
//TRACE("[CTextBox] %s destroy bg %d\r\n", __FUNCTION__, __LINE__);
|
||||||
delete[] m_bgpixbuf;
|
delete[] m_bgpixbuf;
|
||||||
m_bgpixbuf = NULL;
|
m_bgpixbuf = NULL;
|
||||||
}
|
}
|
||||||
|
if (has_changed){
|
||||||
|
//TRACE("[CTextBox] %s paint bg %d\r\n", __FUNCTION__, __LINE__);
|
||||||
frameBuffer->paintBoxRel(ax, ay, dx, dy, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType);
|
frameBuffer->paintBoxRel(ax, ay, dx, dy, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
if (m_bgpixbuf)
|
if (m_bgpixbuf){
|
||||||
|
if (m_old_cText != m_cText || has_changed){
|
||||||
|
//TRACE("[CTextBox] %s restore bg %d\r\n", __FUNCTION__, __LINE__);
|
||||||
frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf);
|
frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//save current comparsion properties
|
||||||
|
if (has_changed){
|
||||||
|
//TRACE("[CTextBox] %s set current values %d\r\n", __FUNCTION__, __LINE__);
|
||||||
|
m_old_x = ax;
|
||||||
|
m_old_y = ay;
|
||||||
|
m_old_dx = dx;
|
||||||
|
m_old_dy = dy;
|
||||||
|
m_old_textBackgroundColor = m_textBackgroundColor;
|
||||||
|
m_old_nBgRadius = m_nBgRadius;
|
||||||
|
m_old_nBgRadiusType = m_nBgRadiusType;
|
||||||
|
m_old_nMode = m_nMode;
|
||||||
|
}
|
||||||
|
|
||||||
if( m_nNrOfLines <= 0)
|
if( m_nNrOfLines <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -571,6 +614,7 @@ void CTextBox::refreshText(void)
|
|||||||
m_pcFontText->RenderString(m_cFrame.iX + m_cFrameTextRel.iX + text_Hborder_width + x_center,
|
m_pcFontText->RenderString(m_cFrame.iX + m_cFrameTextRel.iX + text_Hborder_width + x_center,
|
||||||
y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(),
|
y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(),
|
||||||
m_textColor, 0, true); // UTF-8
|
m_textColor, 0, true); // UTF-8
|
||||||
|
m_old_cText = m_cText;
|
||||||
y += m_nFontTextHeight;
|
y += m_nFontTextHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -116,9 +116,12 @@ class CTextBox
|
|||||||
int getFontTextHeight();
|
int getFontTextHeight();
|
||||||
|
|
||||||
/* Variables */
|
/* Variables */
|
||||||
std::string m_cText;
|
std::string m_cText, m_old_cText;
|
||||||
std::vector<std::string> m_cLineArray;
|
std::vector<std::string> m_cLineArray;
|
||||||
|
|
||||||
|
int m_old_x, m_old_y, m_old_dx, m_old_dy, m_old_nBgRadius, m_old_nBgRadiusType, m_old_nMode;
|
||||||
|
fb_pixel_t m_old_textBackgroundColor;
|
||||||
|
|
||||||
bool m_showTextFrame;
|
bool m_showTextFrame;
|
||||||
|
|
||||||
CBox m_cFrame;
|
CBox m_cFrame;
|
||||||
|
Reference in New Issue
Block a user