mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
CTextBox: add/modify methodes for screen handlings
- split hasChanged() into hasChangedPos(), hasChangedDim()
- add return value bool to enableBackgroundPaint(), enableSaveScreen()
- add clearScreenBuffer(), for unified usage in destructor and functions
- add OnAfterRefresh() as a signal/slot handler, this allows to use
external methodes as callbacks after painted text
Origin commit data
------------------
Commit: a2171dad4a
Author: Thilo Graf <dbt@novatux.de>
Date: 2015-11-18 (Wed, 18 Nov 2015)
Origin message was:
------------------
CTextBox: add/modify methodes for screen handlings
- split hasChanged() into hasChangedPos(), hasChangedDim()
- add return value bool to enableBackgroundPaint(), enableSaveScreen()
- add clearScreenBuffer(), for unified usage in destructor and functions
- add OnAfterRefresh() as a signal/slot handler, this allows to use
external methodes as callbacks after painted text
This commit is contained in:
@@ -135,7 +135,7 @@ CTextBox::~CTextBox()
|
||||
//TRACE("[CTextBox] del\r\n");
|
||||
m_cLineArray.clear();
|
||||
//hide();
|
||||
delete[] m_bgpixbuf;
|
||||
clearScreenBuffer();
|
||||
}
|
||||
|
||||
void CTextBox::initVar(void)
|
||||
@@ -515,10 +515,8 @@ void CTextBox::refreshScroll(void)
|
||||
//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
|
||||
if ( hasChangedPos(x, y)
|
||||
|| hasChangedDim(dx, dy)
|
||||
|| m_old_textBackgroundColor != m_textBackgroundColor
|
||||
|| m_old_textColor != m_textColor
|
||||
|| m_old_nBgRadius != m_nBgRadius
|
||||
@@ -528,6 +526,17 @@ bool CTextBox::hasChanged(int* x, int* y, int* dx, int* dy)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTextBox::hasChangedPos(int* x, int* y)
|
||||
{
|
||||
return (m_old_x != *x || m_old_y != *y);
|
||||
}
|
||||
|
||||
bool CTextBox::hasChangedDim(int* dx, int* dy)
|
||||
{
|
||||
return (m_old_dx != *dx || m_old_dy != *dy);
|
||||
}
|
||||
|
||||
void CTextBox::reInitToCompareVar(int* x, int* y, int* dx, int* dy)
|
||||
{
|
||||
m_old_x = *x;
|
||||
@@ -560,13 +569,14 @@ void CTextBox::refreshText(void)
|
||||
//find changes
|
||||
bool has_changed = hasChanged(&ax, &ay, &dx, &dy);
|
||||
|
||||
//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;
|
||||
}
|
||||
//clean up possible screen on any changes
|
||||
if (has_changed && m_bgpixbuf){
|
||||
/*TODO/FIXME: in some cases could be required, that we must restore old saved screen. eg. if a text without bg was painted
|
||||
* and another text should be painted as next on the same position like current text, but new text will be overpaint and is
|
||||
* not visible. It's currently solvable only with appropriate order of text items
|
||||
*/
|
||||
frameBuffer->RestoreScreen(m_old_x, m_old_y, m_old_dx, m_old_dy, m_bgpixbuf);
|
||||
clearScreenBuffer();
|
||||
}
|
||||
|
||||
//detect corrupt position values
|
||||
@@ -589,11 +599,7 @@ void CTextBox::refreshText(void)
|
||||
//Paint Text Background
|
||||
bool allow_paint_bg = (m_old_cText != m_cText || has_changed || m_has_scrolled);
|
||||
if (m_nPaintBackground){
|
||||
if (m_bgpixbuf){
|
||||
//TRACE("[CTextBox] %s destroy bg %d\r\n", __FUNCTION__, __LINE__);
|
||||
delete[] m_bgpixbuf;
|
||||
m_bgpixbuf = NULL;
|
||||
}
|
||||
clearScreenBuffer();
|
||||
if (allow_paint_bg){
|
||||
//TRACE("[CTextBox] %s paint bg %d\r\n", __FUNCTION__, __LINE__);
|
||||
frameBuffer->paintBoxRel(ax, ay, dx, dy, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType);
|
||||
@@ -713,6 +719,7 @@ void CTextBox::refresh(void)
|
||||
//Paint text
|
||||
refreshScroll();
|
||||
refreshText();
|
||||
OnAfterRefresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -772,3 +779,28 @@ void CTextBox::hide (void)
|
||||
|
||||
frameBuffer = NULL;
|
||||
}
|
||||
|
||||
bool CTextBox::clearScreenBuffer()
|
||||
{
|
||||
if(m_bgpixbuf){
|
||||
//TRACE("[CTextBox] %s destroy bg %d\r\n", __FUNCTION__, __LINE__);
|
||||
delete[] m_bgpixbuf;
|
||||
m_bgpixbuf = NULL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTextBox::enableSaveScreen(bool mode)
|
||||
{
|
||||
if (m_SaveScreen == mode)
|
||||
return false;
|
||||
|
||||
if (!m_SaveScreen || m_SaveScreen != mode)
|
||||
clearScreenBuffer();
|
||||
|
||||
m_SaveScreen = mode;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,7 @@
|
||||
#include <driver/fb_window.h>
|
||||
#include <gui/color.h>
|
||||
#include <gui/customcolor.h>
|
||||
|
||||
#include <sigc++/signal.h>
|
||||
#define TRACE printf
|
||||
#define TRACE_1 printf
|
||||
|
||||
@@ -81,7 +81,7 @@ class CBox
|
||||
int iHeight;
|
||||
};
|
||||
|
||||
class CTextBox
|
||||
class CTextBox : public sigc::trackable
|
||||
{
|
||||
public:
|
||||
/* Variables */
|
||||
@@ -110,6 +110,8 @@ class CTextBox
|
||||
void reSizeMainFrameHeight(int maxTextHeight);
|
||||
|
||||
bool hasChanged(int* x, int* y, int* dx, int* dy);
|
||||
bool hasChangedPos(int* x, int* y);
|
||||
bool hasChangedDim(int* dx, int* dy);
|
||||
void reInitToCompareVar(int* x, int* y, int* dx, int* dy);
|
||||
|
||||
/* Variables */
|
||||
@@ -179,8 +181,9 @@ class CTextBox
|
||||
void refresh(void);
|
||||
void scrollPageDown(const int pages);
|
||||
void scrollPageUp(const int pages);
|
||||
void enableBackgroundPaint(bool mode = true){m_nPaintBackground = mode;};
|
||||
void enableSaveScreen(bool mode = true){m_SaveScreen = mode;};
|
||||
void enableBackgroundPaint(bool mode = true){m_nPaintBackground = mode;}
|
||||
//enable screen saving behind chars, is required for transparent text paint, returns true if mode was changed
|
||||
bool enableSaveScreen(bool mode = true);
|
||||
bool setText(const std::string* newText, int max_width = 0, bool force_repaint = true);
|
||||
void setTextColor(fb_pixel_t color_text){ m_textColor = color_text;};
|
||||
void setBackGroundRadius(const int radius, const int type = CORNER_ALL){m_nBgRadius = radius; m_nBgRadiusType = type;};
|
||||
@@ -207,6 +210,8 @@ class CTextBox
|
||||
inline int getTextMode() {return m_nMode;};
|
||||
void paint (void);
|
||||
void hide (void);
|
||||
bool clearScreenBuffer();
|
||||
sigc::signal<void> OnAfterRefresh;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_TEXTBOX_H__208DED01_ABEC_491C_A632_5B21057DC5D8__INCLUDED_)
|
||||
|
Reference in New Issue
Block a user