components: rework classes

- outsourced some classes cc_item.cpp/h, cc_draw.cpp/h
- added extra methodes for simple use of some basic components extra.cpp/h
- rework clock handling: use timer class, reworked members for
  enable/disable clock with external timer events,
  tryed to fix some display issues related with infoclock and
  time osd clock in moviebrowser, channellist, menuus
- reworked hide/kill handling, removed parameter for hide(), try to use
  cached backgrounds for other constallations, paint cache, image cache (all beta)
- reworked shadow/frame handling, add shadow modes for left/right
  arrangement, TODO: repaint for existant instances required
- reworked color gradient assignment (beta)

... Note: I had a data crash in my local git tree
and i tryed to restore my historie, but most was lost. Therefore here
the commit is large
This commit is contained in:
2015-11-18 18:08:23 +01:00
parent a2171dad4a
commit 0146511f38
68 changed files with 3207 additions and 1682 deletions

View File

@@ -43,21 +43,23 @@ CComponentsText::CComponentsText( CComponentsForm *parent,
std::string text,
const int mode,
Font* font_text,
bool has_shadow,
const int& font_style,
int shadow_mode,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarText(x_pos, y_pos, w, h, text, mode, font_text, parent, has_shadow, color_text, color_frame, color_body, color_shadow);
initVarText(x_pos, y_pos, w, h, text, mode, font_text, font_style, parent, shadow_mode, color_text, color_frame, color_body, color_shadow);
}
CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
std::string text,
const int mode,
Font* font_text,
const int& font_style,
CComponentsForm *parent,
bool has_shadow,
int shadow_mode,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarText(x_pos, y_pos, w, h, text, mode, font_text, parent, has_shadow, color_text, color_frame, color_body, color_shadow);
initVarText(x_pos, y_pos, w, h, text, mode, font_text, font_style, parent, shadow_mode, color_text, color_frame, color_body, color_shadow);
}
CComponentsText::~CComponentsText()
@@ -71,8 +73,9 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
std::string text,
const int mode,
Font* font_text,
const int& font_style,
CComponentsForm *parent,
bool has_shadow,
int shadow_mode,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
cc_item_type = CC_ITEMBOX_TEXT;
@@ -81,10 +84,10 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text = text;
ct_old_text = ct_text;
ct_text_mode = mode;
ct_text_style = FONT_STYLE_REGULAR;
ct_text_style = font_style;
iX = x = x_pos;
iY = y = y_pos;
iX = x = x_old = x_pos; //TODO: equalize inhertited member names
iY = y = y_old = y_pos;
iWidth=width = w;
iHeight=height = h;
@@ -94,13 +97,13 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text_Hborder = 1;
ct_text_Vborder = 0;
shadow = has_shadow;
shadow = shadow_mode;
ct_col_text = color_text;
ct_old_col_text = 0;
ct_old_col_text = ct_col_text;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = 0;
ct_text_sent = false;
ct_paint_textbg = false;
ct_force_text_paint = false;
@@ -148,18 +151,19 @@ void CComponentsText::initCCText()
ct_textbox->setTextColor(ct_col_text);
ct_textbox->setWindowMaxDimensions(iWidth, iHeight);
ct_textbox->setWindowMinDimensions(iWidth, iHeight);
ct_textbox->enableSaveScreen(save_tbox_screen);
ct_textbox->enableSaveScreen(cc_txt_save_screen);
ct_textbox->enableUTF8(ct_utf8_encoded);
//observe behavior of parent form if available
bool force_text_paint = ct_force_text_paint;
#if 0 //FIXME.,
if (cc_parent){
//if any embedded text item was hided because of hided parent form,
//we must ensure repaint of text, otherwise text item is not visible
if (cc_parent->isPainted())
force_text_paint = true;
}
#endif
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
//this is managed by CTextBox object itself
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth, force_text_paint);
@@ -183,37 +187,44 @@ void CComponentsText::clearCCText()
ct_textbox = NULL;
}
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
bool CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
ct_old_text = ct_text;
ct_text = stext;
if (mode != ~CTextBox::AUTO_WIDTH)
ct_text_mode = mode;
if (font_text)
ct_font = font_text;
if (color_text != 0)
setTextColor(color_text);
if (style != FONT_STYLE_REGULAR)
ct_text_style = style;
if (ct_text != stext || ct_text_mode != mode || ct_font != font_text || ct_col_text != color_text || ct_text_style != style ){
if (ct_text != stext){
ct_text = stext;
ct_old_text = ct_text;
}
if (ct_text_mode != mode /*|| mode != ~CTextBox::AUTO_WIDTH*/)
ct_text_mode = mode;
if (font_text)
ct_font = font_text;
if (color_text != 0)
setTextColor(color_text);
if (style != FONT_STYLE_REGULAR)
ct_text_style = style;
dprintf(DEBUG_DEBUG, "[CComponentsText] [%s - %d] ct_text: %s \n", __func__, __LINE__, ct_text.c_str());
dprintf(DEBUG_DEBUG, "[CComponentsText] [%s - %d] ct_text: %s \n", __func__, __LINE__, ct_text.c_str());
return true;
}
return false;
}
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
bool CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
string stext = g_Locale->getText(locale_text);
setText(stext, mode, font_text, color_text, style);
return setText(stext, mode, font_text, color_text, style);
}
void CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
bool CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
setText((string)ctext, mode, font_text, color_text, style);
return setText((string)ctext, mode, font_text, color_text, style);
}
void CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
bool CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
string s_digit = iToString(digit);
setText(s_digit, mode, font_text, color_text, style);
return setText(s_digit, mode, font_text, color_text, style);
}
string CComponentsText::getTextFromFile(const string& path_to_textfile)
@@ -244,15 +255,14 @@ bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int
if (txt.empty())
return false;
setText(txt, mode, font_text, color_text, style);
return true;
return setText(txt, mode, font_text, color_text, style);
}
void CComponentsText::paintText(bool do_save_bg)
{
paintInit(do_save_bg);
initCCText();
if (ct_text_sent && cc_allow_paint)
ct_textbox->paint();
ct_text_sent = false;
@@ -263,12 +273,32 @@ void CComponentsText::paint(bool do_save_bg)
paintText(do_save_bg);
}
void CComponentsText::hide(bool no_restore)
void CComponentsText::hide()
{
if (ct_textbox)
ct_textbox->hide();
ct_old_text = "";
hideCCItem(no_restore);
CComponents::hide();
}
void CComponentsText::setXPos(const int& xpos)
{
iX = x = xpos;
}
void CComponentsText::setYPos(const int& ypos)
{
iY = y = ypos;
}
void CComponentsText::setHeight(const int& h)
{
iHeight = height = h;
}
void CComponentsText::setWidth(const int& w)
{
iWidth = width = w;
}
//small helper to remove excessiv linbreaks
@@ -308,7 +338,33 @@ int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int&
void CComponentsText::setTextColor(const fb_pixel_t& color_text)
{
ct_col_text = color_text;
if (ct_textbox)
ct_textbox->setTextColor(ct_col_text);
if (ct_col_text != color_text){
//ct_textbox->clearScreenBuffer();
ct_col_text = color_text;
if (ct_textbox)
ct_textbox->setTextColor(ct_col_text);
}
}
bool CComponentsText::clearSavedScreen()
{
bool ret0 = CCDraw::clearSavedScreen();
bool ret1 = false;
#if 0
if (ct_textbox)
ret1 = ct_textbox->clearScreenBuffer();
#endif
return max<bool>(ret0, ret1);
}
#if 0
bool CComponentsText::enableColBodyGradient(const int& enable_mode, const fb_pixel_t& sec_color)
{
if (CCDraw::enableColBodyGradient(enable_mode, sec_color)){
if (ct_textbox)
ct_textbox->clearScreenBuffer();
}
return false;
}
#endif