From a9aa78ca3e74fdb403ea51d8cf9011d1ebd8fe87 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 21 Jan 2016 10:56:30 +0100 Subject: [PATCH] text screen save: try to rework screen save behavior for textbox objects Screen save now always disabled by default and can be controlled outside of relevant objects. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9d72b086a2558876f6c0d27eeb1373015dfb5542 Author: Thilo Graf Date: 2016-01-21 (Thu, 21 Jan 2016) ------------------ This commit was generated by Migit --- src/gui/channellist.cpp | 6 ++- src/gui/components/cc_frm_button.cpp | 1 + src/gui/components/cc_frm_button.h | 21 ++++++++++ src/gui/components/cc_frm_clock.cpp | 5 +-- src/gui/components/cc_frm_clock.h | 14 ++++++- src/gui/components/cc_frm_ext_text.cpp | 8 ++-- src/gui/components/cc_frm_ext_text.h | 18 +++++++++ src/gui/components/cc_frm_header.cpp | 2 +- src/gui/components/cc_frm_header.h | 17 ++++++++ src/gui/components/cc_frm_signalbars.cpp | 21 ++++++---- src/gui/components/cc_frm_signalbars.h | 49 ++++++++++++++++++++++-- src/gui/components/cc_item_text.cpp | 4 +- src/gui/components/cc_item_text.h | 16 ++++++-- src/gui/components/cc_text_screen.h | 21 +++++++++- src/gui/infoviewer.cpp | 6 ++- src/gui/widget/textbox.cpp | 4 +- 16 files changed, 177 insertions(+), 36 deletions(-) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index d3b51f91f..17655dc91 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2060,8 +2060,10 @@ void CChannelList::paint() void CChannelList::paintHead() { - if (header == NULL) + if (header == NULL){ header = new CComponentsHeader(); + header->getTextObject()->enableTboxSaveScreen(g_settings.theme.menu_Head_gradient);//enable screen save for title text if color gradient is in use + } header->setDimensionsAll(x, y, full_width, theight); @@ -2098,7 +2100,7 @@ void CChannelList::paintHead() else logo_off = 10; - header->paint(CC_SAVE_SCREEN_NO); + header->paint(CC_SAVE_SCREEN_NO); //TODO: paint title only, currently paint() does paint all enabled header items at once and causes flicker effects in unchanged items (e.g. clock) } CComponentsHeader* CChannelList::getHeaderObject() diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index 38087c79a..403418664 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -174,6 +174,7 @@ void CComponentsButton::initCaption() if (cc_btn_capt_obj == NULL){ cc_btn_capt_obj = new CComponentsLabel(); cc_btn_capt_obj->doPaintBg(false); + cc_btn_capt_obj->doPaintTextBoxBg(false); cc_btn_capt_obj->enableTboxSaveScreen(cc_txt_save_screen); addCCItem(cc_btn_capt_obj); } diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 44a688b32..d665ac6ce 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -135,6 +135,27 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen ///set text color virtual void setButtonTextColor(fb_pixel_t text_color, fb_pixel_t text_color_disabled = COL_MENUCONTENTINACTIVE_TEXT){cc_btn_capt_col = text_color; cc_btn_capt_disable_col = text_color_disabled;} + /**Member to modify background behavior of embeded caption object. + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + virtual void enableTboxSaveScreen(bool mode) + { + if (cc_txt_save_screen == mode) + return; + cc_txt_save_screen = mode; + for(size_t i=0; igetItemType() == CC_ITEMTYPE_LABEL) + static_cast(v_cc_items[i])->enableTboxSaveScreen(cc_txt_save_screen); + } + }; + ///set caption: parameter as string virtual void setCaption(const std::string& text); ///set caption: parameter as locale diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 313b05cc2..e20ef0916 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -402,16 +402,13 @@ void CComponentsFrmClock::kill(const fb_pixel_t& bg_color, bool ignore_parent) CComponentsForm::kill(bg_color, ignore_parent); } -void CComponentsFrmClock::enableSegmentSaveScreen(bool mode) +void CComponentsFrmClock::enableTboxSaveScreen(bool mode) { if (cc_txt_save_screen == mode || v_cc_items.empty()) return; - cc_txt_save_screen = mode; - for (size_t i = 0; i < v_cc_items.size(); i++){ CComponentsLabel *seg = static_cast (v_cc_items[i]); - //seg->clearSavedScreen(); seg->enableTboxSaveScreen(cc_txt_save_screen); } } diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 6b91c836f..8f5fe47b4 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -158,8 +158,18 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen ///reinitialize clock contents virtual void refresh() { initCCLockItems(); } - ///allows to save bg screen behind text within segment objects, see also cl_save_segment_screen - void enableSegmentSaveScreen(bool mode); + + /**Member to modify background behavior of embeded segment objects + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + void enableTboxSaveScreen(bool mode); ///set color gradient on/off, returns true if gradient mode was changed virtual bool enableColBodyGradient(const int& enable_mode, const fb_pixel_t& sec_color = 255 /*=COL_BACKGROUND*/); diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 5d24e7d58..97b798795 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -104,7 +104,8 @@ void CComponentsExtTextForm::initLabel() //initialize label object if (ccx_label_obj == NULL){ ccx_label_obj = new CComponentsLabel(); - ccx_label_obj->doPaintBg(false); + ccx_label_obj->doPaintBg(!cc_txt_save_screen); + ccx_label_obj->doPaintTextBoxBg(false); ccx_label_obj->enableTboxSaveScreen(cc_txt_save_screen); } @@ -117,7 +118,7 @@ void CComponentsExtTextForm::initLabel() ccx_label_width = (ccx_percent_label_w * width/100); ccx_label_obj->setText(ccx_label_text, ccx_label_align, ccx_font); ccx_label_obj->setTextColor(ccx_label_color); - ccx_label_obj->setDimensionsAll(fr_thickness, 0, ccx_label_width-fr_thickness, height-2*fr_thickness); + ccx_label_obj->setDimensionsAll(0, 0, ccx_label_width-2*fr_thickness, height-2*fr_thickness); ccx_label_obj->setCorner(this->corner_rad, CORNER_LEFT); } } @@ -127,7 +128,8 @@ void CComponentsExtTextForm::initText() //initialize text object if (ccx_text_obj == NULL){ ccx_text_obj = new CComponentsText(); - ccx_text_obj->doPaintBg(false); + ccx_text_obj->doPaintBg(!cc_txt_save_screen); + ccx_text_obj->doPaintTextBoxBg(false); ccx_text_obj->enableTboxSaveScreen(cc_txt_save_screen); } diff --git a/src/gui/components/cc_frm_ext_text.h b/src/gui/components/cc_frm_ext_text.h index 007680dea..0bf45f508 100644 --- a/src/gui/components/cc_frm_ext_text.h +++ b/src/gui/components/cc_frm_ext_text.h @@ -110,6 +110,24 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen ///returns a pointer to the internal text object, use this to get access to its most properties CComponentsText*getTextObject(){return ccx_text_obj;}; + /**Member to modify background behavior of embeded label and text objects + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + void enableTboxSaveScreen(bool mode){ + if (cc_txt_save_screen == mode) + return; + cc_txt_save_screen = mode; + for(size_t i=0; i(v_cc_items[i])->enableTboxSaveScreen(cc_txt_save_screen); + }; + ///sets the text modes (mainly text alignment) to the label and text object, see /gui/widget/textbox.h for possible modes void setTextModes(const int& label_mode, const int& text_mode); diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index f26bc4132..4a69827f7 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -86,7 +86,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const fb_pixel_t color_shadow) { cc_item_type = CC_ITEMTYPE_FRM_HEADER; - cc_txt_save_screen = true; + cc_txt_save_screen = false; x = x_old = x_pos; y = y_old = y_pos; diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 56eb3e38d..45354ca2e 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -211,6 +211,23 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen ///returns the text object virtual CComponentsText* getTextObject(){return cch_text_obj;} + /**Member to modify background behavior of embeded title + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + void enableTboxSaveScreen(bool mode) + { + cc_txt_save_screen = mode; + if (cch_text_obj->getCTextBoxObject()) + cch_text_obj->getCTextBoxObject()->enableSaveScreen(cc_txt_save_screen); + } + ///returns the clock object virtual CComponentsFrmClock* getClockObject(){return cch_cl_obj;} diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index 5bea94103..27061c8b8 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -106,7 +106,7 @@ void CSignalBar::initVarSigBar() append_x_offset = 2; append_y_offset = 2; height = SB_MIN_HEIGHT; - + cc_item_type = CC_ITEMTYPE_FRM_SIGNALBAR; sb_scale_height = -1; dy_font = CNeutrinoFonts::getInstance(); @@ -144,12 +144,13 @@ void CSignalBar::initSBarValue() //create value label object with basic properties if (sb_vlbl == NULL){ sb_vlbl = new CComponentsLabel(); - sb_vlbl->doPaintBg(false); - sb_vlbl->doPaintTextBoxBg(false); - sb_vlbl->enableTboxSaveScreen(true); sb_vlbl->setText(REF_PERCENT_TXT, sb_val_mode, sb_font); } + sb_vlbl->doPaintBg(false); + sb_vlbl->doPaintTextBoxBg(!cc_txt_save_screen); + sb_vlbl->enableTboxSaveScreen(cc_txt_save_screen); + //move and set dimensions int vlbl_x = sb_scale->getXPos() + sb_scale_width + append_y_offset; int vlbl_h = sb_scale->getHeight(); @@ -169,12 +170,14 @@ void CSignalBar::initSBarName() //create name label object with basic properties if (sb_lbl == NULL){ sb_lbl = new CComponentsLabel(); - sb_lbl->doPaintBg(false); - sb_lbl->doPaintTextBoxBg(false); - sb_lbl->enableTboxSaveScreen(true); - sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font); } + sb_lbl->doPaintBg(false); + sb_lbl->doPaintTextBoxBg(!cc_txt_save_screen); + sb_lbl->enableTboxSaveScreen(cc_txt_save_screen); + + sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font); + //move and set dimensions int lbl_x = sb_vlbl->getXPos()+ sb_vlbl->getWidth(); int lbl_h = sb_vlbl->getHeight(); @@ -316,11 +319,13 @@ void CSignalBox::initSignalItems() sbar->setFrontEnd(sbx_frontend); sbar->setCorner(0); sbar->setScaleHeight(scale_h); + sbar->enableTboxSaveScreen(cc_txt_save_screen); snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : 1, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setCorner(0); snrbar->setScaleHeight(scale_h); + snrbar->enableTboxSaveScreen(cc_txt_save_screen); } void CSignalBox::paintScale() diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index e78de5353..216b221af 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ CSignalBar() and their sub classes based up CComponentsForm() and are usable lik CSignalBar() is intended to show signal rate. */ -class CSignalBar : public CComponentsForm +class CSignalBar : public CComponentsForm, public CCTextScreen { public: ///refresh current item properties, use this before paintScale(). @@ -141,6 +142,27 @@ class CSignalBar : public CComponentsForm //returns the current signal value uint16_t getValue(void) { return sb_signal; } + + /**Member to modify background behavior of embeded caption objects (value, name) + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + void enableTboxSaveScreen(bool mode) + { + if (cc_txt_save_screen == mode) + return; + cc_txt_save_screen = mode; + for(size_t i=0; igetItemType() == CC_ITEMTYPE_LABEL) + static_cast(v_cc_items[i])->enableTboxSaveScreen(cc_txt_save_screen); + } + } }; /// Sub class of CSignalBar() @@ -237,7 +259,7 @@ void CSampleClass::hide () */ -class CSignalBox : public CComponentsForm +class CSignalBox : public CComponentsForm, public CCTextScreen { private: ///object: current frontend @@ -289,8 +311,27 @@ class CSignalBox : public CComponentsForm ///return current snr value uint16_t getSNRValue(void) { return snrbar->getValue();} - - ///return current snr value + + /**Member to modify background behavior of embeded caption objects (value, name) + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + void enableTboxSaveScreen(bool mode) + { + if (cc_txt_save_screen == mode) + return; + cc_txt_save_screen = mode; + for(size_t i=0; igetItemType() == CC_ITEMTYPE_FRM_SIGNALBAR) + static_cast(v_cc_items[i])->enableTboxSaveScreen(cc_txt_save_screen); + } + }; }; #endif diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 3707dfd85..c554f1123 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -145,13 +145,13 @@ void CComponentsText::initCCText() ct_textbox->setTextMode(ct_text_mode); ct_textbox->setWindowPos(this); ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder); - ct_textbox->enableBackgroundPaint(ct_paint_textbg); + ct_textbox->enableBackgroundPaint(ct_paint_textbg && !cc_txt_save_screen); ct_textbox->setBackGroundColor(col_body); ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type); ct_textbox->setTextColor(ct_col_text); ct_textbox->setWindowMaxDimensions(iWidth, iHeight); ct_textbox->setWindowMinDimensions(iWidth, iHeight); - ct_textbox->enableSaveScreen(cc_txt_save_screen); + ct_textbox->enableSaveScreen(cc_txt_save_screen && !ct_paint_textbg); ct_textbox->enableUTF8(ct_utf8_encoded); //observe behavior of parent form if available diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index af36d128b..5bf297212 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -177,14 +177,22 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox ///returns count of lines from a text box page virtual int getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode); - ///allows to save bg screen behind text within CTextBox object, see also cc_txt_save_screen + + /**Member to modify background behavior of textbox object + * @param[in] mode + * @li bool, default = true + * @return + * void + * @see + * Parent member: CCTextScreen::enableTboxSaveScreen() + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ void enableTboxSaveScreen(bool mode) { - if (cc_txt_save_screen == mode) - return; cc_txt_save_screen = mode; if (ct_textbox) - ct_textbox->enableSaveScreen(mode); + ct_textbox->enableSaveScreen(cc_txt_save_screen); } ///enable/disable utf8 encoding void enableUTF8(bool enable = true){ct_utf8_encoded = enable;} diff --git a/src/gui/components/cc_text_screen.h b/src/gui/components/cc_text_screen.h index afdbe9024..07f7e05e6 100644 --- a/src/gui/components/cc_text_screen.h +++ b/src/gui/components/cc_text_screen.h @@ -24,7 +24,6 @@ #ifndef __CC_TXT_SCREEN__ #define __CC_TXT_SCREEN__ - //! Sub class for CTextBox using CComponent classes. /*! This class contains flags or helpers to control CTextBox screen and paint handling and mostly used by @@ -38,7 +37,25 @@ class CCTextScreen bool cc_txt_save_screen; public: - CCTextScreen(){cc_txt_save_screen = false;}; + CCTextScreen(){cc_txt_save_screen = false;} + + /**Abstract member to modify background behavior of embeded textbox object + * @param[in] mode + * @li bool, default = true, enables backround saving of textbox object. This causes painting of backround from saved screen instead simple backround (if enabled) + * This is usefull if text should be paint on transparent background or background with color gradient. + * @return + * void + * @see + * CTextBox::enableSaveScreen() + * disableTboxSaveScreen() + */ + virtual void enableTboxSaveScreen(bool mode) = 0; + + /**member to disable background behavior of embeded textbox object. + * @see + * disableTboxSaveScreen() + */ + virtual void disableTboxSaveScreen(){enableTboxSaveScreen(false);} }; #endif diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 0b43be313..b326b7dca 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -252,10 +252,10 @@ void CInfoViewer::initClock() InfoClock->getInstance()->disableInfoClock(); clock->enableColBodyGradient(gradient_top, COL_INFOBAR_PLUS_0); - clock->enableSegmentSaveScreen(gradient_top); + clock->doPaintBg(!gradient_top); + clock->enableTboxSaveScreen(gradient_top); clock->setColorBody(COL_INFOBAR_PLUS_0); clock->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); - clock->doPaintBg(!gradient_top); clock->setClockFont(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]); clock->setPos(BoxEndX - 10 - clock->getWidth(), ChanNameY); clock->setTextColor(COL_INFOBAR_TEXT); @@ -1523,7 +1523,9 @@ void CInfoViewer::showSNR () int sigbox_offset = ChanWidth *10/100; sigbox = new CSignalBox(BoxStartX + sigbox_offset, y_numbox+ChanHeight/2, ChanWidth - 2*sigbox_offset, ChanHeight/2, CFEManager::getInstance()->getLiveFE(), true, NULL, "S", "Q"); sigbox->setTextColor(COL_INFOBAR_TEXT); + sigbox->setColorBody(numbox->getColorBody()); sigbox->doPaintBg(false); + sigbox->enableTboxSaveScreen(numbox->getColBodyGradientMode()); } sigbox->paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 18205ea50..5f33a725e 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -588,8 +588,8 @@ void CTextBox::refreshText(void) //save screen only if no paint of background required if (!m_nPaintBackground && m_SaveScreen) { if (m_bgpixbuf == NULL){ - //TRACE("[CTextBox] %s save bg %d\r\n", __FUNCTION__, __LINE__); if ((dx * dy) >0){ +// TRACE("[CTextBox] [%s - %d] save bg for use as transparent background [%s]\n", __func__, __LINE__, m_cText.c_str()); m_bgpixbuf= new fb_pixel_t[dx * dy]; frameBuffer->SaveScreen(ax, ay, dx, dy, m_bgpixbuf); } @@ -598,7 +598,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_nPaintBackground && !m_SaveScreen){ clearScreenBuffer(); if (allow_paint_bg){ //TRACE("[CTextBox] %s paint bg %d\r\n", __FUNCTION__, __LINE__);