From db6fd8480d4a051af48edd75fc12f7e4cdd95509 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 20 Sep 2014 21:34:07 +0200 Subject: [PATCH] CComponents: Add color gradient for CC_FBDATA_TYPE_BOX --- src/gui/components/cc_base.cpp | 27 +++++++++++++++++++++++---- src/gui/components/cc_base.h | 2 ++ src/gui/components/cc_item.cpp | 6 +++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index 11c08b014..603e272a1 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -31,6 +31,7 @@ #include #include #include "cc_base.h" +#include #include using namespace std; @@ -197,9 +198,20 @@ void CComponents::paintFbItems(bool do_save_bg) } } } - else - 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); + else { + if(cc_allow_paint) { + if ((v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX) && (v_fbdata[i].data != NULL)) { + // color gradient + gradientData_t *gradientData = static_cast (v_fbdata[i].data); + if (gradientData->boxBuf == NULL) + gradientData->boxBuf = frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, 0, gradientData, v_fbdata[i].r, corner_type); + else +// frameBuffer->blit2FB(gradientData->boxBuf, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].x, v_fbdata[i].y); + frameBuffer->blitBox2FB(gradientData->boxBuf, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].x, v_fbdata[i].y); + } 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); + } + } } } @@ -272,9 +284,16 @@ void CComponents::kill(const fb_pixel_t& bg_color, const int& corner_radius) //clean old screen buffer void CComponents::clearFbData() { - for(size_t i =0; i< v_fbdata.size() ;i++) + for(size_t i =0; i< v_fbdata.size() ;i++) { if (v_fbdata[i].pixbuf) delete[] v_fbdata[i].pixbuf; + + if (v_fbdata[i].data && (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX)) { + gradientData_t *gradientData = static_cast (v_fbdata[i].data); + if (gradientData->boxBuf) + cs_free_uncached(gradientData->boxBuf); + } + } v_fbdata.clear(); } diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index fa984baf9..5ce448cb7 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -249,6 +249,8 @@ class CComponentsItem : public CComponents ///Is typically the type CComponentsForm or derived classes, default intialized with NULL CComponentsForm *cc_parent; + gradientData_t cc_gradientData; + ///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required void hideCCItem(bool no_restore = false); diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 4f0874897..03a6a5132 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -51,6 +51,7 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent) cc_item_selected = false; cc_page_number = 0; cc_has_focus = true; + cc_gradientData.gradientBuf = NULL; initParent(parent); } @@ -88,12 +89,15 @@ void CComponentsItem::paintInit(bool do_save_bg) iy = cc_yr; } + cc_gradientData.boxBuf = NULL; + cc_gradientData.mode = CFrameBuffer::pbrg_noFree; + void* gradientData = (cc_gradientData.gradientBuf == NULL) ? NULL : &cc_gradientData; comp_fbdata_t fbdata[] = { {CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+sw, height+sw, 0, 0, 0, NULL, NULL}, {CC_FBDATA_TYPE_SHADOW_BOX, ix+sw, iy+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},//shadow {CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, th, NULL, NULL},//frame - {CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, 0, NULL, NULL},//body + {CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, 0, NULL, gradientData},//body }; for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {