diff --git a/src/gui/widget/components.cpp b/src/gui/widget/components.cpp index eddfe8af6..fb82880f2 100644 --- a/src/gui/widget/components.cpp +++ b/src/gui/widget/components.cpp @@ -52,17 +52,17 @@ CComponents::~CComponents() clear(); } - //paint framebuffer stuff and fill buffer void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg) { - for(int i=0; i< items_count ;i++){ - if (do_save_bg){ - fbdata[i].pixbuf = new fb_pixel_t[fbdata[i].dx * fbdata[i].dy]; - frameBuffer->SaveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].pixbuf); - } + int i; + for(i=0; i< items_count ;i++){ + if (do_save_bg) + fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy); v_screen_val.push_back(fbdata[i]); + } + for(i=0; i< items_count ;i++){ if (fbdata[i].is_frame) 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 @@ -70,6 +70,14 @@ void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_co } } +//screen area save +inline fb_pixel_t* CComponents::saveScreen(int ax, int ay, int dx, int dy) +{ + fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; + frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); + return pixbuf; +} + //restore screen inline void CComponents::restore() { @@ -184,7 +192,7 @@ void CComponentsDetailLine::hide() //------------------------------------------------------------------------------------------------------- //sub class CComponentsInfoBox -CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int h, const int w, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow, bool has_shadow) +CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int h, const int w, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { x = x_pos; y = y_pos; @@ -196,6 +204,8 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i col_body = color_body; col_shadow = color_shadow; fr_thickness = 2; + bg_saved = false; + v_infobox_val.clear(); } #define INFOBOX_ITEMS_COUNT 3 @@ -207,11 +217,40 @@ void CComponentsInfoBox::paint(bool do_save_bg) comp_fbdata_t fbdata[INFOBOX_ITEMS_COUNT] = { {x+SHADOW_OFFSET, y+SHADOW_OFFSET, width, height, col_shadow, rad, NULL, NULL, false, 0}, - {x, y, width, height, col_frame, rad, NULL, NULL, true, fr_thickness}, + {x, y, width, height, col_frame, rad, NULL, NULL, false, 0}, {x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness, col_body, rad, NULL, NULL, false, 0}, }; - paintFbItems(fbdata, INFOBOX_ITEMS_COUNT, do_save_bg); + int start = (shadow) ? 0 : 1; + if (do_save_bg) { + if (!bg_saved) { + v_infobox_val.clear(); + for(int i = start; i < INFOBOX_ITEMS_COUNT; i++) { + fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy); + v_infobox_val.push_back(fbdata[i]); + fbdata[i].pixbuf = NULL; + } + bg_saved = true; + } + } + + paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false); +} + +//restore infobox +void CComponentsInfoBox::restore(bool clear_) +{ + if (!v_infobox_val.empty()) { + for(size_t i =0; i< v_infobox_val.size() ;i++) { + if (v_infobox_val[i].pixbuf != NULL) { + frameBuffer->RestoreScreen(v_infobox_val[i].x, v_infobox_val[i].y, v_infobox_val[i].dx, v_infobox_val[i].dy, v_infobox_val[i].pixbuf); + if (clear_) + delete[] v_infobox_val[i].pixbuf; + } + } + if (clear_) + v_infobox_val.clear(); + } } void CComponentsInfoBox::hide() @@ -231,4 +270,3 @@ void CComponentsInfoBox::hide() col_shadow = c_tmp2; col_frame = c_tmp3; } - diff --git a/src/gui/widget/components.h b/src/gui/widget/components.h index b639519f0..902b48a4f 100644 --- a/src/gui/widget/components.h +++ b/src/gui/widget/components.h @@ -54,6 +54,7 @@ class CComponents std::vector v_screen_val; void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true); + fb_pixel_t* saveScreen(int ax, int ay, int dx, int dy); void clear(); public: @@ -92,14 +93,16 @@ class CComponentsInfoBox : public CComponents int rad,fr_thickness; bool shadow; fb_pixel_t col_frame, col_body, col_shadow; + bool bg_saved; + std::vector v_infobox_val; public: - CComponentsInfoBox( const int x_pos, const int y_pos, const int h, const int w, - 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, - bool has_shadow = true); + CComponentsInfoBox( const int x_pos, const int y_pos, const int h, const int w, bool has_shadow = true, + 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); void paint(bool do_save_bg = true); void hide(); + void restore(bool clear_); void setColor(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;}; }; diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 8858605d9..46bb726fd 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1049,7 +1049,7 @@ void CMenuWidget::paintHint(int pos) int rad = RADIUS_LARGE; int xpos = x - ConnectLineBox_Width; - int ypos2 = y + height + rad + SHADOW_OFFSET; + int ypos2 = y + height + rad + SHADOW_OFFSET + 2; int iwidth = width+sb_width; if (hint_painted) { @@ -1058,7 +1058,8 @@ void CMenuWidget::paintHint(int pos) details_line->restore(); /* clear info box */ if (info_box != NULL) - pos == -1 ? info_box->hide() : info_box->restore(); + if (pos == -1) + info_box->restore(true); hint_painted = false; } if (pos < 0) @@ -1069,7 +1070,7 @@ printf("paintHint: icon %s text %s\n", item->hintIcon.c_str(), g_Locale->getText if (item->hintIcon.empty() && item->hint == NONEXISTANT_LOCALE) { if (info_box != NULL) - info_box->hide(); + info_box->restore(false); return; } @@ -1080,7 +1081,7 @@ printf("paintHint: icon %s text %s\n", item->hintIcon.c_str(), g_Locale->getText //details line int ypos1 = item->getYPosition(); int ypos1a = ypos1 + (iheight/2)-2; - int ypos2a = ypos2 + (hint_height/2); + int ypos2a = ypos2 + (hint_height/2)-2; int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; int imarkh = iheight/2+1;