From dd2d167dfe311841ef8aa5e5aed36dbdbb38f1ad Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 8 Nov 2013 21:16:42 +0100 Subject: [PATCH] CComponents: add property to allow/disallow paint of items This causes initialization of all properties, but affects the behavior of item paint. This can be understood as a counterpart to isPainted(). Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8ae491a9943e26044bd3fe2dd89847d259c43527 Author: Thilo Graf Date: 2013-11-08 (Fri, 08 Nov 2013) ------------------ This commit was generated by Migit --- src/gui/components/cc_base.cpp | 16 ++++++++++------ src/gui/components/cc_base.h | 7 +++++++ src/gui/components/cc_frm.cpp | 9 +++++++++ src/gui/components/cc_item_infobox.cpp | 15 ++++++++++----- src/gui/components/cc_item_picture.cpp | 2 +- src/gui/components/cc_item_progressbar.cpp | 1 + src/gui/components/cc_item_progressbar.h | 2 +- src/gui/components/cc_item_text.cpp | 2 +- src/gui/components/cc_item_tvpic.cpp | 4 +++- 9 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index b6ce8448d..db8fed84f 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -77,6 +77,7 @@ void CComponents::initVarBasic() firstPaint = true; is_painted = false; paint_bg = true; + cc_allow_paint = true; frameBuffer = CFrameBuffer::getInstance(); v_fbdata.clear(); saved_screen.pixbuf = NULL; @@ -130,7 +131,7 @@ void CComponents::paintFbItems(bool do_save_bg) //paint all fb relevant basic parts (frame and body) with all specified properties, paint_bg must be true if (fbtype != CC_FBDATA_TYPE_BGSCREEN && paint_bg){ if (fbtype == CC_FBDATA_TYPE_FRAME) { - if (v_fbdata[i].frame_thickness > 0) + if (v_fbdata[i].frame_thickness > 0 && cc_allow_paint) frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r, corner_type); } else if (fbtype == CC_FBDATA_TYPE_BACKGROUND) @@ -148,14 +149,17 @@ void CComponents::paintFbItems(bool do_save_bg) //calculate current shadow width depends of current corner_rad sw_cur = max(2*v_fbdata[i].r, sw); } - // shadow right - frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT); - // shadow bottom - frameBuffer->paintBoxRel(v_fbdata[i].x, y_sh, v_fbdata[i].dx, sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_BOTTOM); + if (cc_allow_paint){ + // shadow right + frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT); + // shadow bottom + frameBuffer->paintBoxRel(v_fbdata[i].x, y_sh, v_fbdata[i].dx, sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_BOTTOM); + } } } else - frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type); + if(cc_allow_paint) + frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type); } } diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 32605b04d..0f69bbe40 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -94,6 +94,8 @@ class CComponents bool is_painted; ///mode: true=activate rendering of basic elements (frame, shadow and body) bool paint_bg; + ///mode: true=allows painting of item, see also allowPaint() + bool cc_allow_paint; ///initialize of basic attributes, no parameters required void initVarBasic(); @@ -205,6 +207,11 @@ class CComponents ///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form virtual void doPaintBg(bool do_paint){paint_bg = do_paint;}; + ///allow/disalows paint of item and its contents, but initialize of other properties are not touched + ///this can be understood as a counterpart to isPainted(), but before paint + virtual void allowPaint(bool allow){cc_allow_paint = allow;}; + ///returns visibility mode + virtual bool paintAllowed(){return cc_allow_paint;}; }; class CComponentsItem : public CComponents diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 1d2420a56..27c094170 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -361,8 +361,17 @@ void CComponentsForm::paintCCItems() cc_item->setHeight(new_h); } + //get current visibility mode from item, me must hold it and restore after paint + bool item_visible = cc_item->paintAllowed(); + //set visibility mode + if (!this->cc_allow_paint) + cc_item->allowPaint(false); + //finally paint current item cc_item->paint(CC_SAVE_SCREEN_NO); + + //restore defined old visibility mode of item after paint + cc_item->allowPaint(item_visible); } } diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp index 0ea76cd27..ff1b30bfb 100644 --- a/src/gui/components/cc_item_infobox.cpp +++ b/src/gui/components/cc_item_infobox.cpp @@ -97,16 +97,19 @@ void CComponentsInfoBox::paintPicture() //exit if no image definied if (pic_name == "") return; - + //init pic object and set icon paint position pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, 0, ""); //define icon pic->setPicture(pic_name); - + //fit icon into infobox pic->setHeight(height-2*fr_thickness); pic->setColorBody(col_body); + + //paint, but set visibility mode + pic->allowPaint(cc_allow_paint); pic->paint(CC_SAVE_SCREEN_NO); } @@ -119,7 +122,7 @@ void CComponentsInfoBox::paint(bool do_save_bg) //NOTE: real values are reqiured, if we paint this item within a form as embedded cc-item int x_text = (cc_parent ? cc_xr : x) + fr_thickness; int y_text = (cc_parent ? cc_yr : y) + fr_thickness; - + //set text to the left border if picture is not painted int pic_w = 0; if ((pic) && (pic->isPicPainted())) @@ -141,7 +144,9 @@ void CComponentsInfoBox::paint(bool do_save_bg) int tw = width - x_offset - pic_w - 2*fr_thickness; int th = height-2*fr_thickness; cctext->setDimensionsAll(tx, y_text, tw, th); - - cctext->paint(CC_SAVE_SCREEN_NO); + + //paint, but set visibility mode + cctext->allowPaint(cc_allow_paint); + cctext->paint(CC_SAVE_SCREEN_NO); } } diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 6ccc94de6..6ff199f1d 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -180,7 +180,7 @@ void CComponentsPicture::paintPicture() { pic_painted = false; - if (do_paint){ + if (do_paint && cc_allow_paint){ #ifdef DEBUG_CC printf(" [CComponentsPicture] %s: paint image: %s (do_paint=%d)\n", __FUNCTION__, pic_name.c_str(), do_paint); #endif diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 41bfa2d62..06debd8ae 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -141,6 +141,7 @@ void CProgressBar::paintShapes(int &shx, int ­, int &shw, int &shh, fb_pixel_ { CComponentsShapeSquare shape(shx, shy, shw, shh, false); shape.setColorBody(col); + shape.allowPaint(cc_allow_paint); shape.paint(false); } diff --git a/src/gui/components/cc_item_progressbar.h b/src/gui/components/cc_item_progressbar.h index 90fb2a7a0..ecc074eee 100644 --- a/src/gui/components/cc_item_progressbar.h +++ b/src/gui/components/cc_item_progressbar.h @@ -92,7 +92,7 @@ class CProgressBar : public CComponentsItem ///paint version of progressbar with color and advanced display modifications void paintAdvanced(); ///painting of activ/passive bars via shape object - static void paintShapes(int &shx, int ­, int &shw, int &shh, fb_pixel_t &col); + void paintShapes(int &shx, int ­, int &shw, int &shh, fb_pixel_t &col); void initDimensions(); diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 3a5722353..feb6b3f0e 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -248,7 +248,7 @@ void CComponentsText::paintText(bool do_save_bg) { paintInit(do_save_bg); initCCText(); - if (ct_text_sent) + if (ct_text_sent && cc_allow_paint) ct_textbox->paint(); ct_text_sent = false; } diff --git a/src/gui/components/cc_item_tvpic.cpp b/src/gui/components/cc_item_tvpic.cpp index 9dc397c48..c5aa38117 100644 --- a/src/gui/components/cc_item_tvpic.cpp +++ b/src/gui/components/cc_item_tvpic.cpp @@ -87,6 +87,9 @@ void CComponentsPIP::paint(bool do_save_bg) pig_w -= pig_w*25/100; pig_x += tmpw/2-pig_w/2; } + + if (!cc_allow_paint) + return; if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv){ videoDecoder->Pig(pig_x, pig_y, pig_w, pig_h, screen_w, screen_h); @@ -95,7 +98,6 @@ void CComponentsPIP::paint(bool do_save_bg) CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); pic.paint(CC_SAVE_SCREEN_NO); } - }