diff --git a/src/gui/widget/components.cpp b/src/gui/widget/components.cpp index 21f79986c..0609f0207 100644 --- a/src/gui/widget/components.cpp +++ b/src/gui/widget/components.cpp @@ -41,11 +41,15 @@ CComponents::CComponents(const int x_pos, const int y_pos, const int h, const in height = h; width = w; frameBuffer = CFrameBuffer::getInstance(); + bg_buf = NULL; } CComponents::~CComponents() { - + if (bg_buf) { + delete[] bg_buf; + bg_buf = NULL; + } } //------------------------------------------------------------------------------------------------------- @@ -123,3 +127,51 @@ void CComponentsDetailLine::hide() col2 = c_tmp2; } +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsInfoBox +CComponentsInfoBox::CComponentsInfoBox( const int x_pos, const int y_pos, const int width_, const int height_, bool shadow_, + fb_pixel_t color1, fb_pixel_t color2, fb_pixel_t color3) +{ + x = x_pos; + y = y_pos; + width = width_; + height = height_; + rad = RADIUS_LARGE; + shadow = shadow_; + bg_saved = false; + + col_frame = color1; + col_body = color2; + col_shadow = color3; + bg_buf = new fb_pixel_t[(width+SHADOW_OFFSET) * (height+SHADOW_OFFSET)]; +} + +void CComponentsInfoBox::paint(int rad_) +{ + rad = rad_; + if ((bg_buf != NULL) && (!bg_saved)) { + frameBuffer->SaveScreen(x, y, width+SHADOW_OFFSET, height+SHADOW_OFFSET, bg_buf); + bg_saved = true; + } + + /* box shadow */ + if (shadow) + frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y+SHADOW_OFFSET, width, height, col_shadow, rad); + /* box frame */ +// frameBuffer->paintBoxFrame(x, y, width, height, 2, col_frame, rad); + frameBuffer->paintBoxRel(x, y, width, height, col_frame, rad); + /* box fill */ + frameBuffer->paintBoxRel(x+2, y+2, width-4, height-4, col_body, rad); +} + +void CComponentsInfoBox::hide(bool full) +{ + if (full) { + if (bg_buf != NULL) + frameBuffer->RestoreScreen(x, y, width+SHADOW_OFFSET, height+SHADOW_OFFSET, bg_buf); + else + frameBuffer->paintBackgroundBoxRel(x, y, width+SHADOW_OFFSET, height+SHADOW_OFFSET); + } + else + frameBuffer->paintBoxRel(x+2, y+2, width-4, height-4, col_body, rad); +} diff --git a/src/gui/widget/components.h b/src/gui/widget/components.h index d8259ec88..588a0bdde 100644 --- a/src/gui/widget/components.h +++ b/src/gui/widget/components.h @@ -34,6 +34,7 @@ class CComponents { protected: int x, y, height, width; + fb_pixel_t *bg_buf; CFrameBuffer * frameBuffer; @@ -64,4 +65,22 @@ class CComponentsDetailLine : public CComponents void setYPosDown(const int& y_pos_down){y_down = y_pos_down;}; }; +class CComponentsInfoBox : public CComponents +{ + private: + int width, height, rad; + fb_pixel_t col_frame, col_body, col_shadow; + bool shadow, bg_saved; + + public: + CComponentsInfoBox( const int x_pos, const int y_pos, const int width_, const int height_, bool shadow_ = true, + fb_pixel_t color1 = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color2 = COL_MENUCONTENTDARK_PLUS_0, + fb_pixel_t color3 = COL_MENUCONTENTDARK_PLUS_0); + + void paint(int rad_); + void hide(bool full = false); + void setColor(fb_pixel_t color1, fb_pixel_t color2, fb_pixel_t color3){col_frame = color1; col_body = color2; col_shadow = color3;}; +}; + #endif