diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index e762f4b47..93b8f348f 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -326,7 +326,7 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg iconfile = Icon; details_line = NULL; info_box = NULL; - + //handle select values if(w_index > MN_WIDGET_ID_MAX){ //error @@ -814,15 +814,15 @@ void CMenuWidget::calcSize() } #endif } - hint_height = 0; + hint_height = 70; //TODO: rework calculation of hint_height if(g_settings.show_menu_hints && has_hints) { int fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - hint_height = 10 + 2*fheight; + int h_tmp = 10 + 2*fheight; /* assuming all hint icons has the same size ! */ int iw, ih; frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &iw, &ih); - if(hint_height < (ih+10)) - hint_height = ih+10; + h_tmp = std::max(h_tmp, ih+10); + hint_height = std::max(h_tmp, hint_height); } /* set the max height to 9/10 of usable screen height debatable, if the callers need a possibility to set this */ @@ -1070,12 +1070,12 @@ void CMenuWidget::paintHint(int pos) { if (!g_settings.show_menu_hints) return; - + if (pos < 0 && !hint_painted) return; - + int rad = RADIUS_LARGE; - + int xpos = x - ConnectLineBox_Width; int ypos2 = y + height + rad + SHADOW_OFFSET + INFO_BOX_Y_OFFSET; int iwidth = width+sb_width; @@ -1111,10 +1111,9 @@ void CMenuWidget::paintHint(int pos) } if (pos < 0) return; - + CMenuItem* item = items[pos]; -//printf("paintHint: icon %s text %s\n", item->hintIcon.c_str(), g_Locale->getText(item->hint)); - + if (item->hintIcon.empty() && item->hint == NONEXISTANT_LOCALE) { #if 0 if (info_box != NULL) { @@ -1130,128 +1129,59 @@ void CMenuWidget::paintHint(int pos) #endif return; } - - hint_painted = true; - + + if (item->hint == NONEXISTANT_LOCALE) + return; + int iheight = item->getHeight(); - - //details line + + //init details line and infobox dimensions int ypos1 = item->getYPosition(); int ypos1a = ypos1 + (iheight/2)-2; int ypos2a = ypos2 + (hint_height/2) - INFO_BOX_Y_OFFSET; int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; int imarkh = iheight/2+1; - if (details_line == NULL){ + //init details line + if (details_line == NULL) details_line = new CComponentsDetailLine(xpos, ypos1a, ypos2a, imarkh, markh); - }else{ + else{ details_line->setXPos(xpos); details_line->setYPos(ypos1a); details_line->setYPosDown(ypos2a); - details_line->setHMarkDown(markh); - details_line->syncSysColors(); + details_line->setHMarkDown(markh); } + details_line->syncSysColors(); #if 0 details_line->paint(savescreen); #endif - details_line->paint(); - - + + //init infobox if (info_box == NULL) - info_box = new CComponentsInfoBox(x, ypos2, iwidth, hint_height); - else { + info_box = new CComponentsInfoBox(x, ypos2, iwidth, hint_height, g_Locale->getText(item->hint), CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH/*, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]*/); + else{ info_box->setXPos(x); info_box->setYPos(ypos2); info_box->setWidth(iwidth); - info_box->setCornerRadius(RADIUS_LARGE); - info_box->syncSysColors(); - info_box->setShadowOnOff(CC_SHADOW_ON); + info_box->setText(g_Locale->getText(item->hint)); + } + info_box->setCornerRadius(RADIUS_LARGE); + info_box->syncSysColors(); + info_box->setShadowOnOff(CC_SHADOW_ON); + info_box->setPicture(item->hintIcon); #if 0 /* force full paint - menu-over i.e. option chooser with pulldown can overwrite */ info_box->paint(savescreen, true); #endif + + + //paint result + details_line->paint(); info_box->paint(); - - - int offset = 10; - if (!item->hintIcon.empty()) { - int iw, ih; - frameBuffer->getIconSize(item->hintIcon.c_str(), &iw, &ih); - if (iw && ih) { - int ix = x + offset; - int iy = ypos2 + (hint_height - ih)/2; - frameBuffer->paintIcon(item->hintIcon.c_str(), ix, iy); - offset += iw + 10; - } - } - if (item->hint == NONEXISTANT_LOCALE) - return; - - int HintFont = SNeutrinoSettings::FONT_TYPE_MENU_HINT; - int fheight = g_Font[HintFont]->getHeight(); - - std::string str1, str2; - std::string str = g_Locale->getText(item->hint); - std::string::size_type spos = str.find_first_of("\n"); - if (spos != std::string::npos) { - str1 = str.substr(0, spos); - str2 = str.substr(spos+1); - } - else - str1 = str; - - if ((!str1.empty()) || (!str1.empty())) { - int wBox = iwidth - 6 - offset; - int wStr1 = 0, wStr2 = 0; - if (!str1.empty()) - wStr1 = g_Font[HintFont]->getRenderWidth(str1); - if (!str2.empty()) - wStr2 = g_Font[HintFont]->getRenderWidth(str2); - if ((wStr1 > wBox) || (wStr2 > wBox)) { - str = g_Locale->getText(item->hint); - // replace "\n" with " " - spos = str.find_first_of("\n"); - if (spos != std::string::npos) - str.replace(spos, 1, " "); - spos = str.length(); - if (spos >= 1) { - std::string BreakChars = "+-/"; - str1 = str; - wStr1 = g_Font[HintFont]->getRenderWidth(str1); - int count = 0; - std::string bChar; - while (wStr1 > wBox) { - spos = str1.find_last_of(BreakChars + " "); - if (spos != std::string::npos) { - str1 = str1.substr(0, spos+1); - // Last delimiter remember if it's not a whitespace - size_t len = str1.length(); - size_t spos2 = str1.find_last_of(BreakChars); - if (len == spos2+1) - bChar = str1.substr(spos2, spos2+1); - else - bChar = ""; - // Remove last delimiter - str1 = str1.substr(0, spos); - } - // Width of string with delimiter - wStr1 = g_Font[HintFont]->getRenderWidth(str1 + bChar); - count++; - if (count > 20) - break; - } - // Last delimiter append again - str1 += bChar; - str2 = str.substr(spos+1); - } - } - ypos2 += (hint_height-fheight*2)/2; - if (!str1.empty()) - g_Font[HintFont]->RenderString(x+offset, ypos2+fheight, wBox, str1, COL_MENUCONTENT, 0, true); // UTF-8 - if (!str2.empty()) - g_Font[HintFont]->RenderString(x+offset, ypos2+fheight*2, wBox, str2, COL_MENUCONTENT, 0, true); // UTF-8 - } + + hint_painted = true; + } //------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index d5d33db33..8e43475f5 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -425,6 +425,7 @@ class CMenuWidget : public CMenuTarget CMenuGlobal *mglobal; CComponentsDetailLine *details_line; CComponentsInfoBox *info_box; + int hint_height; protected: std::string nameString; @@ -448,7 +449,6 @@ class CMenuWidget : public CMenuTarget fb_pixel_t *background; int full_width, full_height; bool savescreen; - int hint_height; bool has_hints; // is any items has hints bool hint_painted; // is hint painted