diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 6880868b7..f905a1ca4 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -307,6 +307,9 @@ CMenuWidget::CMenuWidget() offx = offy = 0; from_wizard = false; fade = true; + sb_width = 0; + savescreen = false; + background = NULL; } CMenuWidget::CMenuWidget(const neutrino_locale_t Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) @@ -368,6 +371,8 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg offx = offy = 0; from_wizard = false; fade = true; + savescreen = false; + background = NULL; } void CMenuWidget::move(int xoff, int yoff) @@ -378,18 +383,6 @@ void CMenuWidget::move(int xoff, int yoff) CMenuWidget::~CMenuWidget() { -#if 0 - for(unsigned int count=0;countinit(-1, 0, 0, 0); -#endif } if (widget_index > -1) @@ -780,18 +769,21 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) void CMenuWidget::hide() { - frameBuffer->paintBackgroundBoxRel(x, y, width+15+SHADOW_OFFSET,height+10+SHADOW_OFFSET); + //frameBuffer->paintBackgroundBoxRel(x, y, width+15+SHADOW_OFFSET,height+10+SHADOW_OFFSET); + if(savescreen && background) + restoreScreen();//FIXME + else + frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height); + /* setActive() paints item for hidden parent menu, if called from child menu */ for (unsigned int count = 0; count < items.size(); count++) items[count]->init(-1, 0, 0, 0); } -void CMenuWidget::paint() +void CMenuWidget::calcSize() { if (name != NONEXISTANT_LOCALE) nameString = g_Locale->getText(name); - - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, nameString.c_str()); /* FIXME why wanted_height needed ? in ::exec it set to height, * here height set to wanted_height ?? */ @@ -821,8 +813,8 @@ void CMenuWidget::paint() if (neededWidth > width-48) { width= neededWidth+ 49; } - int hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getWidth(); + hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + int itemHeightTotal=0; int heightCurrPage=0; page_start.clear(); @@ -868,11 +860,12 @@ void CMenuWidget::paint() x = offx + frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1 ); y = offy + frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >> 1 ); - int sb_width; + sb_width=0; if(total_pages > 1) sb_width=15; - else - sb_width=0; + + full_width = width+sb_width+SHADOW_OFFSET; + full_height = height+RADIUS_LARGE-2+SHADOW_OFFSET; switch(g_settings.menu_pos) { case 0: //DEFAULT_CENTER @@ -894,6 +887,14 @@ void CMenuWidget::paint() x = offx + frameBuffer->getScreenX() + frameBuffer->getScreenWidth() - width - sb_width - 10; break; } +} + +void CMenuWidget::paint() +{ + calcSize(); + saveScreen(); + + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, nameString.c_str()); //paint shadow and backround int rad = RADIUS_LARGE-2; @@ -908,6 +909,7 @@ void CMenuWidget::paint() frameBuffer->getIconSize(iconfile.c_str(), &w, &h); HeadiconOffset = w+6; } + int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getWidth(); g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+(fw/3)+HeadiconOffset,y+hheight+1, width-((fw/3)+HeadiconOffset), nameString.c_str(), COL_MENUHEAD, 0, true); // UTF-8 frameBuffer->paintIcon(iconfile, x + fw/4, y, hheight); @@ -993,6 +995,37 @@ void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_ addItem(GenericMenuSeparatorLine); } +void CMenuWidget::saveScreen() +{ + if(!savescreen) + return; + + delete[] background; + + background = new fb_pixel_t [full_width * full_height]; + if(background) + frameBuffer->SaveScreen(x, y, full_width, full_height, background); +} + +void CMenuWidget::restoreScreen() +{ + if(background) { + if(savescreen) + frameBuffer->RestoreScreen(x, y, full_width, full_height, background); + delete[] background; + background = NULL; + } +} + +void CMenuWidget::enableSaveScreen(bool enable) +{ + savescreen = enable; + if(!enable && background) { + delete[] background; + background = NULL; + } +} + //------------------------------------------------------------------------------------------------------------------------------- CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn) { diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 6562d6c2d..e5950762e 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -402,6 +402,7 @@ class CMenuWidget : public CMenuTarget int min_width; int width; int height; + int hheight; // header int wanted_height; int x; int y; @@ -409,6 +410,10 @@ class CMenuWidget : public CMenuTarget int preselected; int selected; int iconOffset; + int sb_width; + fb_pixel_t *background; + int full_width, full_height; + bool savescreen; unsigned int item_start_y; unsigned int current_page; @@ -419,6 +424,9 @@ class CMenuWidget : public CMenuTarget void Init(const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index); virtual void paintItems(); + void calcSize(); + void saveScreen(); + void restoreScreen(); public: CMenuWidget(); /* mwidth (minimum width) in percent of screen width */ @@ -453,6 +461,7 @@ class CMenuWidget : public CMenuTarget int getSelectedLine(void){return exit_pressed ? -1 : selected;}; void setWizardMode(bool _from_wizard) { from_wizard = _from_wizard;}; void enableFade(bool _enable) { fade = _enable; }; + void enableSaveScreen(bool enable); }; class CPINProtection @@ -519,6 +528,4 @@ extern CMenuSeparator * const GenericMenuSeparatorLine; extern CMenuForwarder * const GenericMenuBack; extern CMenuForwarder * const GenericMenuCancel; - - #endif