diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index c8e56e5b3..7aeba723c 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1736,50 +1736,51 @@ const struct button_label ScondLineButtons[3] = else top = m_y + (m_height - 2 * m_buttonHeight); - int ButtonWidth = (m_width - 20) / 5; + //int ButtonWidth = (m_width - 20) / 5; m_frameBuffer->paintBoxRel(m_x, top, m_width, 2 * m_buttonHeight, COL_INFOBAR_SHADOW_PLUS_1, c_rad_mid, (m_show_playlist ? CORNER_BOTTOM : CORNER_ALL)); // why? m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_1); + int bwidth = m_width - (2*c_rad_mid); if (!m_playlist.empty()) - ::paintButtons(m_x + c_rad_mid, top+m_buttonHeight, m_width - (2*c_rad_mid), 3, ScondLineButtons, m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top+m_buttonHeight, bwidth, 3, ScondLineButtons, bwidth, m_buttonHeight); if (m_key_level == 0) { if (m_playlist.empty()) { if (m_inetmode) - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[7], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[7], bwidth, m_buttonHeight); else - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 1, &(AudioPlayerButtons[7][0]), m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 1, &(AudioPlayerButtons[7][0]), bwidth, m_buttonHeight); } else if (m_inetmode) - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 4, AudioPlayerButtons[8], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[8], bwidth, m_buttonHeight); else - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 4, AudioPlayerButtons[1], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[1], bwidth, m_buttonHeight); } else if (m_key_level == 1) { if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 4, AudioPlayerButtons[0], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[0], bwidth, m_buttonHeight); else - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[6], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[6], bwidth, m_buttonHeight); } else { // key_level == 2 if (m_state == CAudioPlayerGui::STOP) { if (m_select_title_by_name) - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[5], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[5], bwidth, m_buttonHeight); else - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[4], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[4], bwidth, m_buttonHeight); } else { if (m_select_title_by_name) - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[3], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[3], bwidth, m_buttonHeight); else - ::paintButtons(m_x + c_rad_mid, top, m_width - (2*c_rad_mid), 2, AudioPlayerButtons[2], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[2], bwidth, m_buttonHeight); } } } diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index b24bf70b1..5b868a63d 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -143,15 +143,17 @@ const struct button_label CBEBouquetWidgetButtons[3] = void CBEBouquetWidget::paintFoot() { int icol_w, icol_h, h2; - struct button_label Button[4]; + struct button_label Button[5]; Button[0] = CBEBouquetWidgetButtons[0]; Button[1] = CBEBouquetWidgetButtons[1]; Button[2] = CBEBouquetWidgetButtons[2]; Button[3].button = NEUTRINO_ICON_BUTTON_BLUE; +/* I have a more elegant solution in buttons.cpp const neutrino_locale_t button_ids[] = {LOCALE_BOUQUETEDITOR_RENAME,LOCALE_BOUQUETEDITOR_HIDE,LOCALE_BOUQUETEDITOR_LOCK}; const std::vector buttonID_rest (button_ids, button_ids + sizeof(button_ids) / sizeof(neutrino_locale_t) ); +*/ frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h); frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &icol_w, &h2); @@ -168,8 +170,9 @@ void CBEBouquetWidget::paintFoot() Button[3].locale = LOCALE_BOUQUETEDITOR_LOCK; break; } - ::paintButtons(x, y+height, width, 4, Button, ButtonHeight,0,false,COL_INFOBAR_SHADOW,NULL,0,true, buttonID_rest); - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MENU, x + width - 10 - icol_w, y + height, ButtonHeight); + Button[4].button = NEUTRINO_ICON_BUTTON_MENU; + Button[4].locale = NONEXISTANT_LOCALE; + ::paintButtons(x, y+height, width, 5, Button, width, ButtonHeight); } void CBEBouquetWidget::hide() diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index e52a7d067..99aa51b1b 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -181,7 +181,7 @@ const struct button_label CBEChannelWidgetButtons[4] = void CBEChannelWidget::paintFoot() { - ::paintButtons(x, y + (height-footerHeight), width, 4, CBEChannelWidgetButtons, footerHeight); + ::paintButtons(x, y + (height-footerHeight), width, 4, CBEChannelWidgetButtons, width, footerHeight); } void CBEChannelWidget::paintDetails(int index) diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index 2ddfe19de..befe9ae41 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -199,7 +199,7 @@ const struct button_label CBEChannelSelectButtons[] = void CBEChannelSelectWidget::paintFoot() { - ::paintButtons(x, y + (height-footerHeight), width, 2, CBEChannelSelectButtons, footerHeight); + ::paintButtons(x, y + (height-footerHeight), width, 2, CBEChannelSelectButtons, width, footerHeight); #if 0 frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_OKAY, x+width- 3* ButtonWidth+ 8, y+height+1); diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 2a1d7fa86..a419cf70f 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -600,10 +600,9 @@ void CBouquetList::paint() int numbuttons = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); if (favonly) /* this actually shows favorites and providers button, but both are active anyway */ numbuttons = 2; - //::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight); - - ::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, footerHeight); + ::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight); + if(!Bouquets.empty()) { for(unsigned int count=0;countwidth); int yPos = this->y + this->getUsedHeight(); - ::paintButtons (this->x, yPos, buttonWidth, numberOfButtons, pbuttonLabels, buttonHeight); + ::paintButtons (this->x, yPos, buttonWidth, numberOfButtons, pbuttonLabels, buttonWidth, buttonHeight); } EpgPlus::EpgPlus() diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 16f7dd77e..61b0d53bc 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -1107,10 +1107,12 @@ void CEpgData::showTimerEventBar (bool pshow) frameBuffer->paintBoxRel(sx,y,ox,h, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM);//round + /* 2 * ICON_LARGE_WIDTH for potential 16:9 and DD icons */ + int aw = ox - 20 - 2 * (ICON_LARGE_WIDTH + 2); if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) - ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 3:2, EpgButtons, h); + ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 3:2, EpgButtons, aw, h); else - ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 2:1, &EpgButtons[1], h); + ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 2:1, &EpgButtons[1], aw, h); #if 0 // Button: Timer Record & Channelswitch diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 936606b12..cb52b88ce 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -247,7 +247,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c showfollow = false; // Calculate iheight struct button_label tmp_button[1] = { { NEUTRINO_ICON_BUTTON_RED, NONEXISTANT_LOCALE } }; - iheight = ::paintButtons(0, 0, 0, 1, tmp_button, 0, 0, false, COL_INFOBAR_SHADOW, NULL, 0, false); + iheight = ::paintButtons(0, 0, 0, 1, tmp_button, 0, 0, "", false, COL_INFOBAR_SHADOW, NULL, 0, false); if(iheight < fh) iheight = fh; @@ -894,12 +894,12 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) int bw = width - 16; int bh = iheight; int by = y + height-iheight; - int w_button = bw / 4 - border_space;// 4 cells - + CColorKeyHelper keyhelper; //user_menue.h neutrino_msg_t dummy = CRCInput::RC_nokey; const char * icon = NULL; -// std::string btncaption; + struct button_label buttons[4]; + int btn_cnt = 0; bh = std::max(FunctionBarHeight, bh); frameBuffer->paintBackgroundBoxRel(x,by,width,bh); @@ -914,60 +914,51 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) int tID = -1; //any value, not NULL CTimerd::CTimerEventTypes is_timer = isScheduled(channel_id, &evtlist[selected], &tID); - + // -- Button: Timer Record & Channelswitch if ((g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) && ((uint) g_settings.key_channelList_addrecord != CRCInput::RC_nokey)) { if (!g_settings.minimode) { // FIXME : display other icons depending on g_settings.key_channelList_addrecord keyhelper.get(&dummy, &icon, g_settings.key_channelList_addrecord); - EventListFirstButton[0].button = icon; - - if(is_timer == CTimerd::TIMER_RECORD ){ -// btncaption = g_Locale->getText(LOCALE_TIMERLIST_DELETE); - EventListFirstButton[0].locale = LOCALE_TIMERLIST_DELETE; - } else { -// btncaption = g_Locale->getText(LOCALE_EVENTLISTBAR_RECORDEVENT); - EventListFirstButton[0].locale = LOCALE_EVENTLISTBAR_RECORDEVENT; - } - - FunctionBarHeight = std::max(::paintButtons(bx, by, w_button, NUM_EVENTLIST_FIRST_BUTTON, EventListFirstButton), FunctionBarHeight); - bx+=w_button+4; + buttons[btn_cnt].button = icon; + if (is_timer == CTimerd::TIMER_RECORD) + buttons[btn_cnt].locale = LOCALE_TIMERLIST_DELETE; + else + buttons[btn_cnt].locale = LOCALE_EVENTLISTBAR_RECORDEVENT; + btn_cnt++; } } if(!showfollow){ - // Button: Search - FunctionBarHeight = std::max(::paintButtons(bx, by, w_button, NUM_EVENTLIST_SECOND_BUTTON, EventListSecondButton), FunctionBarHeight); - bx+=w_button+4; + buttons[btn_cnt].button = NEUTRINO_ICON_BUTTON_GREEN; + buttons[btn_cnt].locale = LOCALE_EVENTFINDER_SEARCH; // search button + btn_cnt++; } // Button: Timer Channelswitch if ((uint) g_settings.key_channelList_addremind != CRCInput::RC_nokey) { if (!g_settings.minimode) { // FIXME : display other icons depending on g_settings.key_channelList_addremind keyhelper.get(&dummy, &icon, g_settings.key_channelList_addremind); - EventListThirdButton[0].button = icon; - if(is_timer == CTimerd::TIMER_ZAPTO) { -// btncaption = g_Locale->getText(LOCALE_TIMERLIST_DELETE); - EventListThirdButton[0].locale = LOCALE_TIMERLIST_DELETE; - } else { -// btncaption = g_Locale->getText(LOCALE_EVENTLISTBAR_CHANNELSWITCH); - EventListThirdButton[0].locale = LOCALE_EVENTLISTBAR_CHANNELSWITCH; - } + buttons[btn_cnt].button = icon; + if (is_timer == CTimerd::TIMER_ZAPTO) + buttons[btn_cnt].locale = LOCALE_TIMERLIST_DELETE; + else + buttons[btn_cnt].locale = LOCALE_EVENTLISTBAR_CHANNELSWITCH; + btn_cnt++; } - - FunctionBarHeight = std::max(::paintButtons(bx, by, w_button, NUM_EVENTLIST_THIRD_BUTTON, EventListThirdButton), FunctionBarHeight); - bx+=w_button+4; } + if(!showfollow){ // Button: Event Re-Sort if ((uint) g_settings.key_channelList_sort != CRCInput::RC_nokey) { // FIXME : display other icons depending on g_settings.key_channelList_sort keyhelper.get(&dummy, &icon, g_settings.key_channelList_sort); - EventListFourthButton[0].button = icon; - FunctionBarHeight = std::max(::paintButtons(bx, by, w_button, NUM_EVENTLIST_THIRD_BUTTON, EventListFourthButton), FunctionBarHeight); -// bx+=w_button+4; + buttons[btn_cnt].button = icon; + buttons[btn_cnt].locale = LOCALE_EVENTLISTBAR_EVENTSORT; + btn_cnt++; } } + FunctionBarHeight = std::max(::paintButtons(bx, by, bw, btn_cnt, buttons, bw), FunctionBarHeight); } int CEventListHandler::exec(CMenuTarget* parent, const std::string &/*actionkey*/) diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index d2d9234af..65cf7bb81 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -1434,12 +1434,6 @@ bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str) //------------------------------------------------------------------------ -const struct button_label FileBrowserButtons[3] = -{ - { NEUTRINO_ICON_BUTTON_RED , LOCALE_FILEBROWSER_NEXTPAGE }, - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_FILEBROWSER_PREVPAGE }, - { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_FILEBROWSER_MARK }, -}; const struct button_label FileBrowserFilterButton[2] = { { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_FILEBROWSER_FILTER_INACTIVE }, @@ -1448,14 +1442,20 @@ const struct button_label FileBrowserFilterButton[2] = void CFileBrowser::paintFoot() { - const struct button_label FileBrowserButtons2[3] = -{ - { NEUTRINO_ICON_BUTTON_OKAY , LOCALE_FILEBROWSER_SELECT }, - { NEUTRINO_ICON_BUTTON_HELP_SMALL , sortByNames[g_settings.filebrowser_sortmethod] }, - { NEUTRINO_ICON_BUTTON_MUTE_SMALL, LOCALE_FILEBROWSER_DELETE }, -}; + struct button_label FileBrowserButtons[4] = + { + { NEUTRINO_ICON_BUTTON_RED , LOCALE_FILEBROWSER_NEXTPAGE }, + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_FILEBROWSER_PREVPAGE }, + { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_FILEBROWSER_MARK }, + }; + + const struct button_label FileBrowserButtons2[3] = + { + { NEUTRINO_ICON_BUTTON_OKAY , LOCALE_FILEBROWSER_SELECT }, + { NEUTRINO_ICON_BUTTON_HELP_SMALL , sortByNames[g_settings.filebrowser_sortmethod] }, + { NEUTRINO_ICON_BUTTON_MUTE_SMALL, LOCALE_FILEBROWSER_DELETE }, + }; - int dx = (width-20) / 4; // int iw = 0, ih = 0; // frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &iw, &ih); @@ -1468,26 +1468,30 @@ void CFileBrowser::paintFoot() if (!(filelist.empty())) { - //red, green, yellow button - ::paintButtons(x, by0, 0, Multi_Select ? 3 : 2, FileBrowserButtons, foheight); - - //blue filter - if(Filter != NULL) - ::paintButtons(x + 10 + (3 * dx), by0, 0, 1, &(FileBrowserFilterButton[use_filter?0:1]), foheight); - - //OK-Button - if( (filelist[selected].getType() != CFile::FILE_UNKNOWN) || (S_ISDIR(filelist[selected].Mode)) ) - ::paintButtons(x, by2, 0, 1,&(FileBrowserButtons2[0]), foheight); - - //help-Button - ::paintButtons(x + 10 + dx , by2, 0, 1,&(FileBrowserButtons2[1]), foheight); - - - //Mute-Button - if (strncmp(Path.c_str(), VLC_URI, strlen(VLC_URI)) != 0) { //Not in vlc mode - ::paintButtons(x + 10 + (dx * 2) , by2, 0, 1,&(FileBrowserButtons2[2])); - + int idx = 1; + int num_buttons = Multi_Select ? 3 : 2; + if (Filter != NULL) + { + FileBrowserButtons[num_buttons].button = FileBrowserFilterButton[!use_filter].button; + FileBrowserButtons[num_buttons].locale = FileBrowserFilterButton[!use_filter].locale; + num_buttons++; } + //red, green, yellow button + ::paintButtons(x, by0, 0, num_buttons, FileBrowserButtons, width, foheight); + + /* TODO: the changing existence of the OK button makes the sort button + * shift its place :-( */ + num_buttons = 1; + //OK-Button + if ((filelist[selected].getType() != CFile::FILE_UNKNOWN) || S_ISDIR(filelist[selected].Mode)) + { + idx = 0; + num_buttons++; + } + if (strncmp(Path.c_str(), VLC_URI, strlen(VLC_URI)) != 0) // No delete in vlc mode + num_buttons++; + /* width-26 to leave room for the SMSinput indicator */ + ::paintButtons(x, by2, 0, num_buttons, &(FileBrowserButtons2[idx]), width - 26, foheight); if(m_SMSKeyInput.getOldKey()!=0) { diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index a80532cad..f281f9bc7 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -726,12 +726,11 @@ void CPictureViewerGui::paintFoot() if (!playlist.empty()) { - ::paintButtons(x, y + (height - 2 * buttonHeight), 0, 5, PictureViewerButtons); - - ::paintButtons(x, y + (height - buttonHeight), 0, 2, (m_sort==FILENAME)?PictureViewerButtons2[0]:PictureViewerButtons2[1]); + ::paintButtons(x, y + (height - 2 * buttonHeight), 0, 5, PictureViewerButtons, width); + ::paintButtons(x, y + (height - buttonHeight), 0, 2, (m_sort==FILENAME)?PictureViewerButtons2[0]:PictureViewerButtons2[1], width); } else - ::paintButtons(x , y + (height - 2 * buttonHeight), 0, 1, &(PictureViewerButtons[1])); + ::paintButtons(x , y + (height - 2 * buttonHeight), 0, 1, &(PictureViewerButtons[1]), width); // printf("paintFoot}\n"); } //------------------------------------------------------------------------ diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index d06f5ea6b..9c6e21ae7 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -885,9 +885,9 @@ void CTimerList::paintFoot() { if (timerlist.empty()) - ::paintButtons( x, y + height, width, 2, &(TimerListButtons[1])); + ::paintButtons(x, y + height, width, 2, &(TimerListButtons[1]), width); else - ::paintButtons( x, y + height, width, 4, TimerListButtons); + ::paintButtons(x, y + height, width, 4, TimerListButtons, width); } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index b94734237..c6df7735f 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -70,10 +70,13 @@ extern cVideo * videoDecoder; const struct button_label RescanButton = {NEUTRINO_ICON_BUTTON_BLUE , LOCALE_UPNPBROWSER_RESCAN}; -const struct button_label StopButton = {NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_STOP}; -const struct button_label PUpButton = {NEUTRINO_ICON_BUTTON_RED , LOCALE_FILEBROWSER_NEXTPAGE}; -const struct button_label PDownButton = {NEUTRINO_ICON_BUTTON_GREEN , LOCALE_FILEBROWSER_PREVPAGE}; -const struct button_label PPlayButton = {NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY}; +const struct button_label BrowseButtons[4] = +{ + { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_STOP }, + { NEUTRINO_ICON_BUTTON_RED , LOCALE_FILEBROWSER_NEXTPAGE }, + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_FILEBROWSER_PREVPAGE }, + { NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY } +}; //------------------------------------------------------------------------ @@ -1039,7 +1042,7 @@ void CUpnpBrowserGui::paintDevice() //int ButtonWidth = (m_width - 20) / 4; m_frameBuffer->paintBoxRel(m_x, top, m_width, m_buttonHeight+2, COL_INFOBAR_SHADOW_PLUS_1, c_rad_mid, CORNER_BOTTOM); // m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_0); - ::paintButtons(m_x, top, 0, 1, &RescanButton, m_buttonHeight); + ::paintButtons(m_x, top, 0, 1, &RescanButton, m_width, m_buttonHeight); clearItem2DetailsLine(); // clear it } @@ -1160,14 +1163,8 @@ void CUpnpBrowserGui::paintItem(std::vector *entry, unsigned int sele // Foot buttons top = m_y + (m_height - m_info_height - 2 * m_buttonHeight); - int ButtonWidth = (m_width - 20) / 4; m_frameBuffer->paintBoxRel(m_x, top, m_width, m_buttonHeight+2, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM); -// m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_0); - - ::paintButtons(m_x, top, 0, 1, &StopButton, m_buttonHeight); - ::paintButtons(m_x + ButtonWidth, top, 0, 1, &PUpButton, m_buttonHeight); - ::paintButtons(m_x + 2 * ButtonWidth, top, 0, 1, &PDownButton, m_buttonHeight); - ::paintButtons(m_x + 3 * ButtonWidth, top, 0, 1, &PPlayButton, m_buttonHeight); + ::paintButtons(m_x, top, 0, 4, BrowseButtons, m_width, m_buttonHeight); } diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index a97a5a3bc..0a0edfa36 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -2,6 +2,7 @@ * $Id: buttons.cpp,v 1.10 2010/07/12 08:24:55 dbt Exp $ * * (C) 2003 by thegoodguy + * (C) 2011 B1 Systems GmbH, Author: Stefan Seyfried * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,20 +30,28 @@ #include #include #include +//#include -/* paintButtons usage, - use this fucntion for painting icons with captions in horizontal or vertical direction. +/* paintButtons usage, + use this function for painting icons with captions in horizontal or vertical direction. + Icons automatically use the available maxwidth. + If not enough space is available, captions are shortened. + If there is extra space, space between icons is increased. - * x set horizontal startposition - * y set vertical startposition - * footerwidth set width of buttonbar as similar to footer, value 0 (default) means: do nothing, then paint it extra - * count set count of buttons - * content set struct buttonlabel with iconfile and locales, for an empty text let locale constant empty, so you can paint icons without captions, - * width width of footer, contains the buttons - * footerheigth set height of buttonbar as similar to footer, value 0 (default) means: value calculates automaticly depends of maximal height of icon and caption - * buttonwidth set width of buttonlabel include icon, caption and offsets, value 0 (default), calculates automaticly the buttonwidth, buttons will be paint like a chain + * x set horizontal startposition + * y set vertical startposition + * footerwidth set width of buttonbar as similar to footer, value 0 (default) means: do nothing, + then paint it extra + * count set count of buttons + * content set struct buttonlabel with iconfile and locales, for an empty text let locale + constant empty, so you can paint icons without captions, + * maxwidth maximum horizontal space for the buttons + * footerheight set height of buttonbar as similar to footer, value 0 (default) means: + value calculates automaticly depends of maximal height of icon and caption + + * stuff below here was obviously not tested recently * vertical_paint optional, default value is false (horizontal) sets direction of painted buttons * fcolor optional, default value is COL_INFOBAR_SHADOW, use it to render font with other color * alt_buttontext optional, default NULL, overwrites button caption at definied buttonlabel id (see parameter alt_buttontext_id) with this text @@ -50,28 +59,20 @@ * show optional, default value is true (show button), if false, then no show and return the height of the button. */ -// y-------+ +-----------+ -// | ID0 ID1 | -// | +-----buttonwidth------+---------+-----buttonwidth------+ | -// | [icon][w_space][caption][w_space][icon][w_space][caption] | footerheight -// | | -// rounded +----------------------------------footerwidth----------------------------------+rounded----+ | -// | -// x -// int paintButtons( const int &x, const int &y, const int &footerwidth, const uint &count, const struct button_label * const content, + const int &maxwidth, const int &footerheight, - const int &buttonwidth, + std::string /* just to make sure nobody uses anything below */, bool vertical_paint, const unsigned char fcolor, const char * alt_buttontext, const uint &buttontext_id, bool show, - const std::vector& all_buttontext_id) + const std::vector& /*all_buttontext_id*/) { CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); Font * font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]; @@ -87,55 +88,63 @@ int paintButtons( const int &x, int x_caption = 0; int x_button = x_icon; - int w_button = 0; int h_button = 0; //calculate max of h + w //icon int h_max_icon = 0; - int w_max_icon = 0; + int w_icons = 0; //text - int w_max_text = 0; + int w_text = 0; int h_max_text = font->getHeight(); - for (uint i = 0; i < cnt; i++) + int count_items = 0; + /* more than 16 buttons? noooooo*/ + int iconw[16]; + int iconh[16]; + int fwidth[16]; + const char *buttontext[16]; + + /* sanity check... */ + if (count > 16 || count == 0) + { + fprintf(stderr, "paintButtons does only support max 16 buttons yet (%d)\n", count); + //print_stacktrace(); + return 0; + } + if (maxwidth < 200 && show) + { + fprintf(stderr, "paintButtons: maxwidth very small\n"); + fprintf(stderr, " x: %d y: %d footw: %d count: %d maxw: %d footh: %d\n ", + x, y, footerwidth, count, maxwidth, footerheight); + //print_stacktrace(); + } + + uint i; + for (i = 0; i < cnt; i++) { //icon int w = 0; int h = 0; frameBuffer->getIconSize(content[i].button, &w, &h); + iconw[i] = w; + iconh[i] = h; h_max_icon = std::max(h_max_icon, h); - w_max_icon = std::max(w_max_icon, w); + w_icons += w; + if (w) + count_items++; //text - const char * buttontext = content[i].locale ? g_Locale->getText(content[i].locale) : ""; + buttontext[i] = (content[i].locale ? g_Locale->getText(content[i].locale) : ""); //text width - int fwidth = font->getRenderWidth(buttontext, true); - w_max_text = std::max(w_max_text, fwidth); + fwidth[i] = font->getRenderWidth(buttontext[i], true); + w_text += fwidth[i]; + if (fwidth[i]) + count_items++; } - if(!all_buttontext_id.empty()) - { - for(vector::const_iterator it = all_buttontext_id.begin(); it != all_buttontext_id.end(); ++it) - { - //text - const char * buttontext = *it ? g_Locale->getText( *it ) : ""; - - //text width - int fwidth = font->getRenderWidth(buttontext, true); - w_max_text = std::max(w_max_text, fwidth); - } - } - //calculate button width - w_button = buttonwidth == 0 ? (w_max_icon + w_space + w_max_text) : buttonwidth; - //workaround for to small screen (1) - int skip_last_button_txt = false; - if( (w_footer > 0) && ( ((w_button*cnt) + ((cnt -1) * w_space)) > (uint) w_footer) ){ - w_button= ((w_footer+w_max_icon)/(cnt)); - skip_last_button_txt = true; - } //calculate button heigth h_button = std::max(h_max_icon, h_max_text); //calculate optimal button height @@ -152,8 +161,26 @@ int paintButtons( const int &x, //baseline int y_base = y_footer + h_footer/2; - - + int spacing = maxwidth - w_space * 2 - w_text - w_icons - (count_items - 1) * h_space; +#if 0 + /* debug */ + fprintf(stderr, "PB: sp %d mw %d w_t %d w_i %d w_s %d c_i %d\n", + spacing, maxwidth, w_text, w_icons, w_space, count_items); +#endif + if (spacing >= 0) + { /* add half of the inter-object space to the */ + spacing /= (int)count; /* left and right (this might break vertical */ + x_button += spacing / 2; /* alignment, but nobody is using this (yet) */ + } /* and I'm don't know how it should work. */ + else + { + spacing /= (int)(count - 1); /* one space less than buttons */ + /* shorten captions */ + for (i = 0; i < cnt; i++) + fwidth[i] += spacing; /* spacing is negative...*/ + spacing = 0; + } + for (uint j = 0; j < cnt; j++) { const char * caption = NULL; @@ -161,25 +188,17 @@ int paintButtons( const int &x, if (alt_buttontext != NULL && j == buttontext_id) caption = alt_buttontext; //...with an alternate buttontext else - caption = content[j].locale ? g_Locale->getText(content[j].locale) : ""; - - //workaround for to small screen (2) - if(skip_last_button_txt && j == cnt-1) - caption=""; + caption = buttontext[j]; const char * icon = content[j].button ? content[j].button : ""; - //get height/width of icon - int iconw, iconh; - frameBuffer->getIconSize(content[j].button, &iconw, &iconh); - // calculate baseline startposition of icon and text in y int y_caption = y_base + h_max_text/2+1; // paint icon and text - frameBuffer->paintIcon(icon, x_button , y_base-iconh/2); - x_caption = x_button + iconw + h_space; - font->RenderString(x_caption, y_caption, w_max_text, caption, fcolor, 0, true); // UTF-8 + frameBuffer->paintIcon(icon, x_button , y_base - iconh[j]/2); + x_caption = x_button + iconw[j] + h_space; + font->RenderString(x_caption, y_caption, fwidth[j], caption, fcolor, 0, true); /* set next startposition x, if text is length=0 then offset is =renderwidth of icon, * for generating buttons without captions, @@ -201,8 +220,8 @@ int paintButtons( const int &x, } else { - //set x_icon for painting buttons with horizontal arrangement as default - x_button = lentext !=0 ? (x_button + w_button + w_space) : x_button; + /* increase x position */ + x_button = x_caption + fwidth[j] + spacing + h_space; } } diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index 90adfb51b..d4a187ab6 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -40,8 +40,9 @@ int paintButtons( const int &x, const int &footerwidth, const uint &count, const struct button_label * const content, + const int &maxwidth, const int &footerheight = 0, - const int &buttonwidth = 0, + std::string tmp = "", /* just to make sure compilation breaks */ bool vertical_paint = false, const unsigned char fcolor = COL_INFOBAR_SHADOW, const char * alt_buttontext = NULL, diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 96d123035..306d00116 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -573,7 +573,8 @@ void CStringInput::paint(bool sms) frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x + (width/2) - (icol_w/2), tmp_y, 0, COL_MENUCONTENT); //buttonbar - ::paintButtons(x, y+ hheight+ bheight, width, CStringInputSMSButtonsCount, CStringInputSMSButtons, fheight); + ::paintButtons(x, y+ hheight+ bheight, width, CStringInputSMSButtonsCount, CStringInputSMSButtons, width, fheight); + //::paintButtons(x, y + height, width, 2, CStringInputSMSButtons, width); } for (int count=0;count