From 485dca43e2e25b54ea8507344b12cd8b62692c9b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 3 Aug 2012 23:33:00 +0200 Subject: [PATCH] CComponents: add more basic members and sub classes - change default colors for info box - add member methode to synchronize system colors - add class CComponentsShapeCircle - add class CComponentsShapeSquare - add sub class CComponentsPIP --- src/gui/components/cc.h | 101 +++++++++--- src/gui/components/components.cpp | 254 +++++++++++++++++++++++++----- src/gui/widget/menue.cpp | 9 +- 3 files changed, 301 insertions(+), 63 deletions(-) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index e88b0e655..0b9baf7e8 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -54,10 +54,31 @@ typedef enum CC_FBDATA_TYPE_SHADOW, CC_FBDATA_TYPE_BOX, CC_FBDATA_TYPE_FRAME, - CC_FBDATA_TYPE_LINE + CC_FBDATA_TYPE_LINE, + CC_FBDATA_TYPE_BACKGROUND, + + CC_FBDATA_TYPES } FBDATA_TYPES; +typedef struct comp_screen_data_t +{ + int x; + int y; + int dx; + int dy; + fb_pixel_t* pixbuf; +} comp_screen_data_struct_t; + +typedef enum +{ + CC_BGMODE_STANDARD, + CC_BGMODE_PERMANENT, + + CC_BGMODE_TYPES +} +BGMODE_TYPES; + #define CC_WIDTH_MIN 16 #define CC_HEIGHT_MIN 16 #define CC_SHADOW_ON true @@ -65,6 +86,7 @@ FBDATA_TYPES; #define CC_SAVE_SCREEN_YES true #define CC_SAVE_SCREEN_NO false + class CComponents { protected: @@ -73,26 +95,34 @@ class CComponents std::vector v_fbdata; fb_pixel_t col_body, col_shadow, col_frame; bool firstPaint, shadow; + BGMODE_TYPES bgMode; void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true); fb_pixel_t* getScreen(int ax, int ay, int dx, int dy); - fb_pixel_t* saved_screen; - void clear(); + comp_screen_data_t saved_screen; + void clear(); public: CComponents(); virtual~CComponents(); - virtual void setXPos(const int& xpos){x = xpos;}; - virtual void setYPos(const int& ypos){y = ypos;}; - virtual void setHeight(const int& h){height = h;}; - virtual void setWidth(const int& w){width = w;}; + inline virtual void setXPos(const int& xpos){x = xpos;}; + inline virtual void setYPos(const int& ypos){y = ypos;}; + inline virtual void setHeight(const int& h){height = h;}; + inline virtual void setWidth(const int& w){width = w;}; + inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;}; + + inline virtual int getXPos(){return x;}; + inline virtual int getYPos(){return y;}; + inline virtual int getHeight(){return height;}; + inline virtual int getWidth(){return width;}; /// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h" - virtual void setColorFrame(fb_pixel_t color){col_frame = color;}; - virtual void setColorBody(fb_pixel_t color){col_body = color;}; - virtual void setColorShadow(fb_pixel_t color){col_shadow = color;}; - virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;}; + inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;}; + inline virtual void setColorBody(fb_pixel_t color){col_body = color;}; + inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;}; + inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;}; + inline virtual void setBgMode(BGMODE_TYPES mode) {bgMode = mode;}; virtual void hide(); }; @@ -101,20 +131,24 @@ class CComponentsContainer : public CComponents { protected: int corner_rad, fr_thickness; + void hideContainer(bool no_restore = false); + void paintInit(bool do_save_bg); public: CComponentsContainer(); /// set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h). - virtual void setCornerType(const int& type){corner_type = type;}; - virtual void setCornerRadius(const int& radius){corner_rad = radius;}; + inline virtual void setCornerType(const int& type){corner_type = type;}; + inline virtual void setCornerRadius(const int& radius){corner_rad = radius;}; - virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;}; - virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;}; + inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;}; + inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;}; virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); virtual void hide(bool no_restore = false); - virtual void paintBackground(); + virtual void kill(); + + virtual void syncSysColors(); }; @@ -123,9 +157,39 @@ class CComponentsInfoBox : public CComponentsContainer { public: CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENTDARK_PLUS_0,fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); }; +class CComponentsShapeCircle : public CComponentsContainer +{ + private: + int d; + public: + CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;}; + int getDiam(){return d;}; +}; + +class CComponentsShapeSquare : public CComponentsContainer +{ + public: + CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); +}; + +class CComponentsPIP : public CComponentsContainer +{ + private: + int screen_w, screen_h; + public: + CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow = CC_SHADOW_OFF); + ~CComponentsPIP(); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void hide(bool no_restore = false); +}; class CComponentsDetailLine : public CComponents { @@ -139,8 +203,9 @@ class CComponentsDetailLine : public CComponents ~CComponentsDetailLine(); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - void paintBackground(); + void kill(); void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;}; + void syncSysColors(); void setYPosDown(const int& y_pos_down){y_down = y_pos_down;}; void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;}; }; diff --git a/src/gui/components/components.cpp b/src/gui/components/components.cpp index 3529664a0..a93dd1e6b 100644 --- a/src/gui/components/components.cpp +++ b/src/gui/components/components.cpp @@ -32,6 +32,9 @@ #include #include "cc.h" +#include + +extern cVideo * videoDecoder; using namespace std; @@ -39,37 +42,65 @@ using namespace std; CComponents::CComponents() { //basic CComponents - x = 0; - y = 0; - height = CC_HEIGHT_MIN; - width = CC_WIDTH_MIN; - col_body = COL_MENUCONTENT; - col_shadow = COL_MENUCONTENTDARK_PLUS_0; - col_frame = COL_MENUCONTENT_PLUS_6; - corner_type = CORNER_ALL; - shadow = CC_SHADOW_OFF; - shadow_w = SHADOW_OFFSET; - firstPaint = true; - frameBuffer = CFrameBuffer::getInstance(); + x = saved_screen.x = 0; + y = saved_screen.y = 0; + height = saved_screen.dy = CC_HEIGHT_MIN; + width = saved_screen.dx = CC_WIDTH_MIN; + + col_body = COL_MENUCONTENT_PLUS_0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + col_frame = COL_MENUCONTENT_PLUS_6; + corner_type = CORNER_ALL; + shadow = CC_SHADOW_OFF; + shadow_w = SHADOW_OFFSET; + + firstPaint = true; + frameBuffer = CFrameBuffer::getInstance(); v_fbdata.clear(); - saved_screen = NULL; + bgMode = CC_BGMODE_STANDARD; + saved_screen.pixbuf = NULL; } CComponents::~CComponents() { + hide(); + if (saved_screen.pixbuf) + delete[] saved_screen.pixbuf; clear(); } //paint framebuffer stuff and fill buffer void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg) { + if (firstPaint && do_save_bg) { + for(int i=0; i 0) frameBuffer->paintBoxFrame(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].frame_thickness, fbdata[i].color, fbdata[i].r); + else if (fbtype == CC_FBDATA_TYPE_BACKGROUND) + frameBuffer->paintBackgroundBoxRel(x, y, fbdata[i].dx, fbdata[i].dy); else frameBuffer->paintBoxRel(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].color, fbdata[i].r, corner_type); } @@ -135,10 +168,9 @@ CComponentsContainer::CComponentsContainer() // +--------width---------+ -void CComponentsContainer::paint(bool do_save_bg) +void CComponentsContainer::paintInit(bool do_save_bg) { - int items_cnt = 0; - clear(); + clear(); int sw = shadow ? shadow_w : 0; int th = fr_thickness; @@ -151,39 +183,53 @@ void CComponentsContainer::paint(bool do_save_bg) {CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, corner_rad-th, 0, NULL, NULL}, }; - items_cnt = sizeof(fbdata) / sizeof(fbdata[0]); - - if (firstPaint && do_save_bg) { - for(int i=0; iRestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf); - delete[] v_fbdata[i].pixbuf; + if (bgMode == CC_BGMODE_PERMANENT) { + if (saved_screen.pixbuf) { + frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf); + if (no_restore) { + delete[] saved_screen.pixbuf; + saved_screen.pixbuf = NULL; + firstPaint = true; + } + } + } + else { + if (no_restore) + return; + + for(size_t i =0; i< v_fbdata.size() ;i++) { + if (v_fbdata[i].pixbuf != NULL && v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN) + frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf); + delete[] v_fbdata[i].pixbuf; + } + v_fbdata.clear(); + firstPaint = true; } - v_fbdata.clear(); - firstPaint = true; } +void CComponentsContainer::hide(bool no_restore) +{ + hideContainer(no_restore); +} + + //hide rendered objects -void CComponentsContainer::paintBackground() +void CComponentsContainer::kill() { //save current colors fb_pixel_t c_tmp1, c_tmp2, c_tmp3; @@ -202,6 +248,16 @@ void CComponentsContainer::paintBackground() firstPaint = true; } +//synchronize colors for forms +//This is usefull if the system colors are changed during runtime +//so you can ensure correct applied system colors in relevant objects with unchanged instances. +void CComponentsContainer::syncSysColors() +{ + col_body = COL_MENUCONTENT_PLUS_0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + col_frame = COL_MENUCONTENT_PLUS_6; +} + //------------------------------------------------------------------------------------------------------- //sub class CComponentsInfoBox from CComponentsContainer CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) @@ -218,12 +274,74 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i col_shadow = color_shadow; firstPaint = true; v_fbdata.clear(); + bgMode = CC_BGMODE_PERMANENT; //CComponentsContainer corner_rad = RADIUS_LARGE; fr_thickness = 2; } +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsShapeSquare from CComponentsContainer +CComponentsShapeSquare::CComponentsShapeSquare(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponents + x = x_pos; + y = y_pos; + width = w; + height = h; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + firstPaint = true; + v_fbdata.clear(); + bgMode = CC_BGMODE_PERMANENT; + + //CComponentsContainer + corner_rad = 0; + fr_thickness = 0; +} + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsShapeCircle from CComponentsContainer +CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsShapeCircle + d = diam; + + //CComponents + x = x_pos; + y = y_pos; + width = d; + height = d; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + firstPaint = true; + v_fbdata.clear(); + bgMode = CC_BGMODE_PERMANENT; + + //CComponentsContainer + corner_rad = d/2; + fr_thickness = 0; +} + +// y +// x+ - + +// +// +// +// |----d-i-a-m----| +// +// +// +// + - + + //------------------------------------------------------------------------------------------------------- //sub class CComponentsDetailLine from CComponents @@ -250,6 +368,7 @@ CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_to CComponentsDetailLine::~CComponentsDetailLine() { + hide(); //restore background clear(); } @@ -311,7 +430,7 @@ void CComponentsDetailLine::paint(bool do_save_bg) } //remove painted fb items from screen -void CComponentsDetailLine::paintBackground() +void CComponentsDetailLine::kill() { //save current colors fb_pixel_t c_tmp1, c_tmp2; @@ -328,5 +447,62 @@ void CComponentsDetailLine::paintBackground() firstPaint = true; } +//synchronize colors for details line +//This is usefull if the system colors are changed during runtime +//so you can ensure correct applied system colors in relevant objects with unchanged instances. +void CComponentsDetailLine::syncSysColors() +{ + col_body = COL_MENUCONTENT_PLUS_6; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; +} +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsPIP from CComponentsContainer +CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow) +{ + //CComponentsPIP + screen_w = frameBuffer->getScreenWidth(true); + screen_h = frameBuffer->getScreenHeight(true); + + //CComponents + x = x_pos; + y = y_pos; + width = percent*screen_w/100; + height = percent*screen_h/100; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = COL_BACKGROUND; + col_body = COL_BACKGROUND; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + firstPaint = true; + v_fbdata.clear(); + bgMode = CC_BGMODE_PERMANENT; + + //CComponentsContainer + corner_rad = 0; + fr_thickness = 0; +} + +CComponentsPIP::~CComponentsPIP() +{ + hide(); +// if (saved_screen.pixbuf) +// delete[] saved_screen.pixbuf; + clear(); + videoDecoder->Pig(-1, -1, -1, -1); +} + +void CComponentsPIP::paint(bool do_save_bg) +{ + paintInit(do_save_bg); + videoDecoder->Pig(x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness, screen_w, screen_h); +} + + +void CComponentsPIP::hide(bool no_restore) +{ + hideContainer(no_restore); + videoDecoder->Pig(-1, -1, -1, -1); +} + diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index ee2e4375c..86feceebe 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1105,13 +1105,10 @@ void CMenuWidget::paintHint(int pos) if (details_line) details_line->hide(); /* clear info box */ - if (info_box) - info_box->hide(hint_painted); + if ((info_box) && (pos == -1)) + info_box->hide(true); hint_painted = false; } - else if (info_box){ - info_box->hide(hint_painted); - } if (pos < 0) return; @@ -1124,7 +1121,7 @@ void CMenuWidget::paintHint(int pos) if (savescreen) #endif if (info_box) - info_box->hide(); + info_box->hide(false); #if 0 info_box->restore(); else