CTextBox: fix repaint of background of textbox on scroll and changed text

suplement to ca22cb9241
This commit is contained in:
2013-10-27 14:43:19 +01:00
parent 6dd1da0628
commit 5c7e926a86
2 changed files with 45 additions and 22 deletions

View File

@@ -168,6 +168,8 @@ void CTextBox::initVar(void)
m_cFrame.iWidth = m_old_dx = MIN_WINDOW_WIDTH; m_cFrame.iWidth = m_old_dx = MIN_WINDOW_WIDTH;
m_cFrame.iY = m_old_y = 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 = m_old_dy = MIN_WINDOW_HEIGHT; m_cFrame.iHeight = m_old_dy = MIN_WINDOW_HEIGHT;
m_has_scrolled = false;
m_nMaxHeight = MAX_WINDOW_HEIGHT; m_nMaxHeight = MAX_WINDOW_HEIGHT;
m_nMaxWidth = MAX_WINDOW_WIDTH; m_nMaxWidth = MAX_WINDOW_WIDTH;
@@ -495,15 +497,45 @@ void CTextBox::refreshScroll(void)
m_cFrameScrollRel.iY + m_nCurrentPage * marker_size+m_cFrame.iY, m_cFrameScrollRel.iY + m_nCurrentPage * marker_size+m_cFrame.iY,
m_cFrameScrollRel.iWidth - 2*SCROLL_MARKER_BORDER, m_cFrameScrollRel.iWidth - 2*SCROLL_MARKER_BORDER,
marker_size, COL_MENUCONTENT_PLUS_3); marker_size, COL_MENUCONTENT_PLUS_3);
m_has_scrolled = true;
} }
else else
{ {
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY,
m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight,
m_textBackgroundColor); m_textBackgroundColor);
m_has_scrolled = false;
} }
} }
//evaluate comparsion between old and current properties WITHOUT text contents, return true if found changes
//first init is done in initVar() and reinit done in reInitToCompareVar()
bool CTextBox::hasChanged(int* x, int* y, int* dx, int* dy)
{
if ( m_old_x != *x
|| m_old_y != *y
|| 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){
return true;
}
return false;
}
void CTextBox::reInitToCompareVar(int* x, int* y, int* dx, int* dy)
{
m_old_x = *x;
m_old_y = *y;
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;
}
void CTextBox::refreshText(void) void CTextBox::refreshText(void)
{ {
//TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__);
@@ -518,17 +550,10 @@ 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;
//find changes
//evaluate comparsion properties bool has_changed = hasChanged(&ax, &ay, &dx, &dy);
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 //destroy pixel buffer on changed property values
if (has_changed){ if (has_changed){
if (m_bgpixbuf){ if (m_bgpixbuf){
@@ -548,38 +573,33 @@ void CTextBox::refreshText(void)
} }
//Paint Text Background //Paint Text Background
bool allow_paint_bg = (m_old_cText != m_cText || has_changed || m_has_scrolled);
if (m_nPaintBackground){ if (m_nPaintBackground){
if (m_bgpixbuf){ if (m_bgpixbuf){
//TRACE("[CTextBox] %s destroy bg %d\r\n", __FUNCTION__, __LINE__); //TRACE("[CTextBox] %s destroy bg %d\r\n", __FUNCTION__, __LINE__);
delete[] m_bgpixbuf; delete[] m_bgpixbuf;
m_bgpixbuf = NULL; m_bgpixbuf = NULL;
} }
if (m_old_cText != m_cText || has_changed){ if (allow_paint_bg){
//TRACE("[CTextBox] %s paint bg %d\r\n", __FUNCTION__, __LINE__); //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){ if (allow_paint_bg){
//TRACE("[CTextBox] %s restore bg %d\r\n", __FUNCTION__, __LINE__); //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 //save and reinit current comparsion properties
if (has_changed){ if (has_changed){
//TRACE("[CTextBox] %s set current values %d\r\n", __FUNCTION__, __LINE__); //TRACE("[CTextBox] %s set current values %d\r\n", __FUNCTION__, __LINE__);
m_old_x = ax; reInitToCompareVar(&ax, &ay, &dx, &dy);
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;
} }
m_has_scrolled = false;
if( m_nNrOfLines <= 0) if( m_nNrOfLines <= 0)
return; return;

View File

@@ -115,12 +115,15 @@ class CTextBox
void reSizeMainFrameWidth(int maxTextWidth); void reSizeMainFrameWidth(int maxTextWidth);
void reSizeMainFrameHeight(int maxTextHeight); void reSizeMainFrameHeight(int maxTextHeight);
int getFontTextHeight(); int getFontTextHeight();
bool hasChanged(int* x, int* y, int* dx, int* dy);
void reInitToCompareVar(int* x, int* y, int* dx, int* dy);
/* Variables */ /* Variables */
std::string m_cText, m_old_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; int m_old_x, m_old_y, m_old_dx, m_old_dy, m_old_nBgRadius, m_old_nBgRadiusType, m_old_nMode;
bool m_has_scrolled;
fb_pixel_t m_old_textBackgroundColor; fb_pixel_t m_old_textBackgroundColor;
bool m_showTextFrame; bool m_showTextFrame;