From 511486c404d79d1517232664fd5ed2e59ad25ec3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 1/8] CComponentsFrmClock: add members to control segment refreshing on interval Refreshing of segments is now enabled on default. In certain conditions this should be better. --- src/gui/components/cc_frm_clock.cpp | 5 ++++- src/gui/components/cc_frm_clock.h | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 0f4329ea3..a13193e09 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -87,6 +87,9 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, //set default text background behavior cc_txt_save_screen = false; + //enable refresh of all segments on each interval as default + cl_force_repaint = true; + //set default running clock properties cl_interval = interval_seconds; cl_timer = NULL; @@ -255,7 +258,7 @@ void CComponentsFrmClock::initCCLockItems() //set size, text, color of current item lbl->setDimensionsAll(x_tmp, y_tmp, w_tmp, h_tmp); lbl->setColorAll(col_frame, col_body, col_shadow); - lbl->forceTextPaint(false); + lbl->forceTextPaint(cl_force_repaint); lbl->setText(stmp, CTextBox::CENTER, cl_font, cl_col_text, cl_font_style); //init background behavior of segment diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 23eb726ce..4595edd58 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -70,6 +70,9 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen ///text color int cl_col_text; + ///refresh mode + bool cl_force_repaint; + ///current time format std::string cl_format; ///primary time format @@ -151,7 +154,7 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen ///returns true, if clock is running virtual bool isRun() const {return cl_timer ? true : false;}; ///set refresh interval in seconds, default value=1 (=1 sec) - virtual void setClockInterval(const int& seconds){cl_interval = seconds;}; + virtual void setClockInterval(const int& seconds){cl_interval = seconds;} ///show clock on screen virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); @@ -163,6 +166,11 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen ///reinitialize clock contents virtual void refresh() { initCCLockItems(); } + ///enables force to repaint of all segments on each interval, Note: repaint of all segemts is default enabled. + void enableForceSegmentPaint(bool enable = true){cl_force_repaint = enable;} + ///disables repaint of all segments on each interval, repaint happens only on changed segment value + void disableForceSegmentPaint(){enableForceSegmentPaint(false);} + /**Member to modify background behavior of embeded segment objects * @param[in] mode * @li bool, default = true From 6d45fbb4eb103e30ed516682d4d8b753d056e196 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 2/8] CCDraw: fix wrong intit values for corners and position --- src/gui/components/cc_draw.cpp | 4 ++-- src/gui/components/cc_item_shapes.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 5c4d8448b..dff34aad1 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -49,7 +49,7 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha) fr_thickness = fr_thickness_old = 0; - corner_type = corner_type_old = CORNER_ALL; + corner_type = corner_type_old = CORNER_NONE; corner_rad = corner_rad_old = 0; shadow = CC_SHADOW_OFF; @@ -552,7 +552,7 @@ void CCDraw::paintFbItems(bool do_save_bg) } if (paint_bg){ if (fbtype == CC_FBDATA_TYPE_BACKGROUND){ - frameBuffer->paintBackgroundBoxRel(x, y, fbdata.dx, fbdata.dy); + frameBuffer->paintBackgroundBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy); v_fbdata[i].is_painted = true; } } diff --git a/src/gui/components/cc_item_shapes.cpp b/src/gui/components/cc_item_shapes.cpp index dffaca928..9b55d0580 100644 --- a/src/gui/components/cc_item_shapes.cpp +++ b/src/gui/components/cc_item_shapes.cpp @@ -74,6 +74,9 @@ CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam, //CComponents x = x_pos; y = y_pos; + + corner_type = corner_type_old = CORNER_ALL; + //width = height = d = diam; shadow = shadow_mode; shadow_w = OFFSET_SHADOW; From c9152beada992e2a2ea977f57de6edf77a088398 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 3/8] CComponentsButton: remove unused member --- src/gui/components/cc_frm_button.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 92bf474f8..1e36bd826 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -72,8 +72,6 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen ///property: container for all assigned event message values, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKey(), hasButtonDirectKey() std::vectorcc_directKeys; - ///property: assigned an alternate event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKeyAlt(), hasButtonDirectKeyAlt() - neutrino_msg_t cc_directKeyAlt; ///property: assigned return value, see also setButtonResult(), getButtonResult(), default value = -1 (not defined) int cc_btn_result; ///property: assigned alias value, see also setButtonAlias(), getButtonAlias(), default value = -1 (not defined) From bad5f02c06ed04ea41a94abe466f8de5698b1b9c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 4/8] CComponentsItem: fix possible artefacts if fb box is smaller the radius If box height/2 is smaller than corner radius it is possible we have artefacts after killed or hided fb box. This effect only I have seen with full hd resolution, in hd ready mode it was ok. Sideeffects with this changes I have not seen, but I can't exclude. Must be watched. --- src/gui/components/cc_item.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 4a6f49faf..a0f914f0a 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -89,11 +89,16 @@ void CComponentsItem::paintInit(bool do_save_bg) //set current needed corner main box radius int box_rad = corner_type ? corner_rad : 0; - //and ensure max main box radius < dimensions - if (2*box_rad > dy) - box_rad -= max(0, 2*box_rad-dy); - if (2*box_rad > dx) - box_rad -= max(0, 2*box_rad-dy); + //and ensure max main box radius < dimensions, avoids possible fb artefacts on screen + int box_rad2 = box_rad/2; + if(box_rad2 > dy || box_rad2 > dx){ + int tmp_rad = box_rad; + if (box_rad2 > dx) + tmp_rad = (box_rad2-dx)*2; + if (box_rad2 > dy) + tmp_rad = (box_rad2-dy)*2; + box_rad = tmp_rad; + } //Workaround: ensure radius values >= 0, framebuffer methode paintBoxRel() gets confused box_rad = max(box_rad, 0); @@ -113,13 +118,12 @@ void CComponentsItem::paintInit(bool do_save_bg) int sh_cdy = box_rad+sw+th; //height //adapt shadow corner dimensions if body dimensions are too small, use an offset if required - int /*sh_cdx_size_offset,*/ sh_cdy_size_offset = 0; + int sh_cdx_size_offset, sh_cdy_size_offset = 0; if (sh_cdy*2 > dy) sh_cdy_size_offset = sh_cdy*2-dy; -#if 0 if (sh_cdx*2 > dx) sh_cdx_size_offset = sh_cdx*2-dx; -#endif + //handle shadow positions //...corner bottom right int sh_cbr_x = ix+dx-sh_cdx+sw; From 62a2a29a123c07357e550c4fdf8b12fa3a1d325b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 5/8] CCDraw: remove some debug lines, and override comparisons This should reduce some effort in this method. --- src/gui/components/cc_draw.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index dff34aad1..dbca41d93 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -497,16 +497,6 @@ void CCDraw::paintFbItems(bool do_save_bg) break; } - dprintf(DEBUG_DEBUG, "[CCDraw]\n\t[%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n", - __func__, - __LINE__, - firstPaint, - v_fbdata[i].fbdata_type, - v_fbdata[i].x, - v_fbdata[i].y, - v_fbdata[i].dx, - v_fbdata[i].dy); - /* Here we save the background of current box before paint. * Only the reserved fbdata type CC_FBDATA_TYPE_BGSCREEN is here required and is used for this. * This pixel buffer is required for the hide() method that will @@ -524,20 +514,15 @@ void CCDraw::paintFbItems(bool do_save_bg) for(size_t i=0; i< v_fbdata.size(); i++){ cc_fbdata_t& fbdata = v_fbdata[i]; - // Don't paint on dimension or position error dx or dy are 0. - if (!CheckFbData(fbdata, __func__, __LINE__)){ - continue; - } int fbtype = fbdata.fbdata_type; - dprintf(DEBUG_DEBUG, "[CCDraw]\n\t[%s - %d], fbdata_[%d]\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n", - __func__, - __LINE__, - (int)i, - fbdata.x, - fbdata.y, - fbdata.dx, - fbdata.dy); + //ignore bg screen layer + if (fbtype == CC_FBDATA_TYPE_BGSCREEN) + continue; + + // Don't paint on dimension or position error dx or dy are 0. + if (!CheckFbData(fbdata, __func__, __LINE__)) + continue; /* Paint all fb relevant basic parts (shadow, frame and body) * with all specified properties, paint_bg must be enabled. @@ -548,12 +533,14 @@ void CCDraw::paintFbItems(bool do_save_bg) frameBuffer->paintBoxFrame(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.frame_thickness, fbdata.color, fbdata.r, fbdata.rtype); v_fbdata[i].is_painted = true; } + continue; } } if (paint_bg){ if (fbtype == CC_FBDATA_TYPE_BACKGROUND){ frameBuffer->paintBackgroundBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy); v_fbdata[i].is_painted = true; + continue; } } if (fbtype == CC_FBDATA_TYPE_SHADOW_BOX && ((!is_painted || !fbdata.is_painted)|| shadow_force || force_paint_bg)) { @@ -575,6 +562,7 @@ void CCDraw::paintFbItems(bool do_save_bg) fbdata.pixbuf = getScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy); fbdata.is_painted = true; } + continue; } } if (paint_bg){ From 3e342a7661562312fb4677a35268f4f7190913ed Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 6/8] CComponentsHeader: add methode initRepaintSlot() and considered parent Required in sub classes. Considering of parent ensures usage of required background color in sub classes. --- src/gui/components/cc_frm_header.cpp | 12 ++++++++---- src/gui/components/cc_frm_header.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index f66b7a387..acdee9363 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -136,13 +136,17 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_cl_sec_format = cch_cl_format; cch_cl_enable_run = false; - //init slot before re paint of header, paint() is already done - sl_form_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::kill), col_body, -1, CC_FBDATA_TYPES, false); - OnBeforeRePaint.connect(sl_form_repaint); - addContextButton(buttons); initCCItems(); initParent(parent); + + //init repaint slot before re paint of body, if paint() is already done + initRepaintSlot(); +} + +void CComponentsHeader::initRepaintSlot(){ + sl_form_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::kill), cc_parent ? col_body : 0, -1, CC_FBDATA_TYPES, false); + OnBeforeRePaint.connect(sl_form_repaint); } CComponentsHeader::~CComponentsHeader() diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 7f75f2fd7..eb4a6d607 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -112,6 +112,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen void initButtons(); ///sub: init clock object void initClock(); + ///int repaint slot + void initRepaintSlot(); public: enum From 47fceca1886e907382e0279f3f3c2778426ee6b7 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH 7/8] CComponentsFooter: add missing member inits --- src/gui/components/cc_frm_footer.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 63c9f4cf9..853b4465a 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -63,11 +63,11 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const { cc_item_type = CC_ITEMTYPE_FOOTER; - x = x_pos; - y = y_pos; + x = x_old = x_pos; + y = y_old = y_pos; //init footer width - width = w == 0 ? frameBuffer->getScreenWidth(true) : w; + width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w; //init default fonts initDefaultFonts(); @@ -77,15 +77,15 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const //init footer height initCaptionFont(); - height = max(h, cch_font->getHeight()); + height = height_old = max(h, cch_font->getHeight()); shadow = shadow_mode; ccf_enable_button_shadow = false ; ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0; ccf_button_shadow_force_paint = false; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; + col_frame = col_frame_old = color_frame; + col_body = col_body_old = color_body; + col_shadow = col_shadow_old = color_shadow; cc_body_gradient_enable = cc_body_gradient_enable_old = CC_COLGRAD_OFF/*g_settings.theme.menu_ButtonBar_gradient*/; //TODO: not complete implemented at the moment cc_body_gradient_direction = CFrameBuffer::gradientVertical; cc_body_gradient_mode = CColorGradient::gradientDark2Light; @@ -100,6 +100,9 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const addContextButton(buttons); initCCItems(); initParent(parent); + + //init repaint slot before re paint of body, if paint() is already done + initRepaintSlot(); } void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width) From 6135a827da54b5a8d2c470b2122ef8de44c8d755 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 8 Apr 2017 08:24:41 +0200 Subject: [PATCH 8/8] CComponentsItem: disable unused variable --- src/gui/components/cc_item.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index a0f914f0a..b783f82d8 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -118,11 +118,11 @@ void CComponentsItem::paintInit(bool do_save_bg) int sh_cdy = box_rad+sw+th; //height //adapt shadow corner dimensions if body dimensions are too small, use an offset if required - int sh_cdx_size_offset, sh_cdy_size_offset = 0; + int /*sh_cdx_size_offset = 0,*/ sh_cdy_size_offset = 0; if (sh_cdy*2 > dy) sh_cdy_size_offset = sh_cdy*2-dy; - if (sh_cdx*2 > dx) - sh_cdx_size_offset = sh_cdx*2-dx; +// if (sh_cdx*2 > dx) +// sh_cdx_size_offset = sh_cdx*2-dx; //handle shadow positions //...corner bottom right