diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 34f892240..0e5ed1e0c 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -655,6 +655,21 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) } return res; } + else if (actionKey == "footer_key"){ + neutrino_msg_t msg; + neutrino_msg_data_t data; + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Footer-Key pressed. Press EXIT to return"); + hintBox->paint(); + while (1) + { + g_RCInput->getMsg(&msg, &data, 100); + if (msg == CRCInput::RC_home) + break; + } + delete hintBox; + + return res; + } return showTestMenu(); @@ -689,6 +704,16 @@ int CTestMenu::showTestMenu() f_bi->setHint(NEUTRINO_ICON_HINT_IMAGEINFO, LOCALE_MENU_HINT_BUILDINFO); w_test.addItem(f_bi); + //footer buttons + static const struct button_label footerButtons[2] = { + { NEUTRINO_ICON_BUTTON_RED, LOCALE_COLORCHOOSER_RED }, + { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_COLORCHOOSER_GREEN } + }; + + w_test.setFooter(footerButtons, 2); + w_test.addKey(CRCInput::RC_red, this, "footer_key"); + w_test.addKey(CRCInput::RC_green, this, "footer_key"); + //exit return w_test.exec(NULL, "");; } diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index bf309adb5..d7bd79543 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -334,6 +334,7 @@ CMenuWidget::CMenuWidget() from_wizard = false; fade = true; sb_width = 0; + sb_height = 0; savescreen = false; background = NULL; preselected = -1; @@ -407,6 +408,9 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg has_hints = false; hint_painted = false; hint_height = 0; + fbutton_count = 0; + fbutton_labels = NULL; + fbutton_height = 0; } void CMenuWidget::move(int xoff, int yoff) @@ -869,7 +873,7 @@ void CMenuWidget::calcSize() for (unsigned int i= 0; i< items.size(); i++) { int item_height=items[i]->getHeight(); heightCurrPage+=item_height; - if(heightCurrPage > (height-hheight)) { + if(heightCurrPage > (height-hheight-fbutton_height)) { page_start.push_back(i); total_pages++; heightCurrPage=item_height; @@ -901,18 +905,29 @@ void CMenuWidget::calcSize() width = frameBuffer->getScreenWidth(); // shrink menu if less items - if(hheight+itemHeightTotal < height) - height=hheight+itemHeightTotal; + if (hheight + itemHeightTotal + fbutton_height < height) + height = hheight + itemHeightTotal + fbutton_height; - //scrollbar width + //scrollbar sb_width=0; if(total_pages > 1) sb_width=15; + sb_height=itemHeightTotal; full_width = /*ConnectLineBox_Width+*/width+sb_width+SHADOW_OFFSET; full_height = height+RADIUS_LARGE+SHADOW_OFFSET*2 /*+hint_height+INFO_BOX_Y_OFFSET*/; + /* + ConnectLineBox_Width for the hintbox connection line + * + center_offset for symmetry + * + 20 for setMenuPos calculates 10 pixels border left and right */ + int center_offset = (g_settings.menu_pos == MENU_POS_CENTER) ? ConnectLineBox_Width : 0; + int max_possible = (int)frameBuffer->getScreenWidth() - ConnectLineBox_Width - center_offset - 20; + if (full_width > max_possible) + { + width = max_possible - sb_width - SHADOW_OFFSET; + full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ + } - setMenuPos(width - sb_width); + setMenuPos(width + sb_width); } void CMenuWidget::paint() @@ -929,11 +944,13 @@ void CMenuWidget::paint() // paint body shadow frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y + hheight + SHADOW_OFFSET, width + sb_width, height - hheight + RADIUS_LARGE, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // paint body background - frameBuffer->paintBoxRel(x ,y+hheight, width + sb_width, height-hheight + RADIUS_LARGE ,COL_MENUCONTENT_PLUS_0 ,RADIUS_LARGE, CORNER_BOTTOM); + frameBuffer->paintBoxRel(x, y + hheight, width + sb_width, height - hheight + RADIUS_LARGE - fbutton_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? 0 /*CORNER_NONE*/ : CORNER_BOTTOM)); item_start_y = y+hheight; paintItems(); washidden = false; + if (fbutton_count) + ::paintButtons(x, y + height + RADIUS_LARGE - fbutton_height, width + sb_width, fbutton_count, fbutton_labels, width, fbutton_height); } void CMenuWidget::setMenuPos(const int& menu_width) @@ -943,12 +960,14 @@ void CMenuWidget::setMenuPos(const int& menu_width) int scr_w = frameBuffer->getScreenWidth(); int scr_h = frameBuffer->getScreenHeight(); + int real_h = full_height + hint_height; + //configured positions switch(g_settings.menu_pos) { case MENU_POS_CENTER: x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); - y = offy + scr_y + ((scr_h - height - hint_height) >> 1 ); + y = offy + scr_y + ((scr_h - real_h) >> 1 ); break; case MENU_POS_TOP_LEFT: @@ -962,12 +981,12 @@ void CMenuWidget::setMenuPos(const int& menu_width) break; case MENU_POS_BOTTOM_LEFT: - y = offy + scr_y + scr_h - height - hint_height - 10; + y = offy + scr_y + scr_h - real_h - 10; x = offx + scr_x + 10; break; case MENU_POS_BOTTOM_RIGHT: - y = offy + scr_y + scr_h - height - hint_height - 10; + y = offy + scr_y + scr_h - real_h - 10; x = offx + scr_x + scr_w - menu_width - 10; break; } @@ -987,12 +1006,11 @@ void CMenuWidget::paintItems() // Scrollbar if(total_pages>1) { - int item_height=height-(item_start_y-y); - frameBuffer->paintBoxRel(x+ width,item_start_y, 15, item_height, COL_MENUCONTENT_PLUS_1, RADIUS_MIN); - frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page*(item_height-4)/total_pages, 11, (item_height-4)/total_pages, COL_MENUCONTENT_PLUS_3, RADIUS_MIN); + frameBuffer->paintBoxRel(x+ width,item_start_y, sb_width, sb_height, COL_MENUCONTENT_PLUS_1, RADIUS_MIN); + frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page*(sb_height-4)/total_pages, sb_width-4, (sb_height-4)/total_pages, COL_MENUCONTENT_PLUS_3, RADIUS_MIN); /* background of menu items, paint every time because different items can have * different height and this might leave artifacts otherwise after changing pages */ - frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x,item_start_y, width, sb_height, COL_MENUCONTENT_PLUS_0); } int ypos=item_start_y; for (int count = 0; count < (int)items.size(); count++) @@ -1168,6 +1186,21 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri keyActionMap[key].action = action; } +void CMenuWidget::setFooter(const struct button_label *_fbutton_labels, const int _fbutton_count, bool repaint) +{ + fbutton_count = _fbutton_count; + fbutton_labels = _fbutton_labels; + fbutton_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6; // init min buttonbar height + int h = 0, w = 0; + for (int i = 0; i < fbutton_count; i++) { + frameBuffer->getIconSize(fbutton_labels[i].button, &w, &h); + fbutton_height = std::max(fbutton_height, h + 4); + } + if (repaint) + paint(); +} + + //------------------------------------------------------------------------------------------------------------------------------- CMenuOptionNumberChooser::CMenuOptionNumberChooser( const neutrino_locale_t Name, int * const OptionValue, diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 65f4ae6b3..12be61110 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -652,12 +653,17 @@ class CMenuWidget : public CMenuTarget int selected; int iconOffset; int sb_width; + int sb_height; fb_pixel_t *background; int full_width, full_height; bool savescreen; bool has_hints; // is any items has hints bool hint_painted; // is hint painted + int fbutton_height; + int fbutton_count; + const struct button_label *fbutton_labels; + unsigned int item_start_y; unsigned int current_page; unsigned int total_pages; @@ -719,6 +725,7 @@ class CMenuWidget : public CMenuTarget MENU_POS_BOTTOM_RIGHT }; void addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string &action); + void setFooter(const struct button_label *_fbutton_label, const int _fbutton_count, bool repaint = false); }; class CPINProtection