diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 1ec9642c0..1300d2b6b 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1702,13 +1702,12 @@ const struct button_label ScondLineButtons[2] = else top = m_y + (m_height - 2 * m_buttonHeight); - int ButtonWidth = (m_width - 20) / 5; //int ButtonWidth2 = (m_width - 50) / 2; m_frameBuffer->paintBoxRel(m_x, top, m_width, 2 * m_buttonHeight, COL_INFOBAR_SHADOW_PLUS_1, c_rad_mid, CORNER_BOTTOM); m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_1); if (!m_playlist.empty()) - ::paintButtons(m_x, top+m_buttonHeight, m_width, 2, ScondLineButtons, m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top+m_buttonHeight, m_width, 2, ScondLineButtons, m_width, m_buttonHeight); if (m_key_level == 0) @@ -1716,37 +1715,37 @@ const struct button_label ScondLineButtons[2] = if (m_playlist.empty()) { if (m_inetmode) - ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[7], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[7], m_width, m_buttonHeight); else - ::paintButtons(m_x, top, m_width, 1, &(AudioPlayerButtons[7][0]), m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 1, &(AudioPlayerButtons[7][0]), m_width, m_buttonHeight); } else if (m_inetmode) - ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[8], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[8], m_width, m_buttonHeight); else - ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[1], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[1], m_width, m_buttonHeight); } else if (m_key_level == 1) { if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) - ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[0], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 4, AudioPlayerButtons[0], m_width, m_buttonHeight); else - ::paintButtons( m_x, top, m_width, 2, AudioPlayerButtons[6], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[6], m_width, m_buttonHeight); } else { // key_level == 2 if (m_state == CAudioPlayerGui::STOP) { if (m_select_title_by_name) - ::paintButtons(m_x /*+ ButtonWidth*/, top, m_width, 2, AudioPlayerButtons[5], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[5], m_width, m_buttonHeight); else - ::paintButtons(m_x/* + ButtonWidth*/, top, m_width, 2, AudioPlayerButtons[4], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[4], m_width, m_buttonHeight); } else { if (m_select_title_by_name) - ::paintButtons(m_x/* + ButtonWidth*/, top, m_width, 2, AudioPlayerButtons[3], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[3], m_width, m_buttonHeight); else - ::paintButtons(m_x/* + ButtonWidth*/, top, m_width, 2, AudioPlayerButtons[2], m_buttonHeight, ButtonWidth); + ::paintButtons(m_x, top, m_width, 2, AudioPlayerButtons[2], m_width, m_buttonHeight); } } } diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 8ec03bfd5..1efd6d39f 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -153,15 +153,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) ); +*/ // fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); @@ -185,8 +187,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 9c9452fdf..feef9b827 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -167,7 +167,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 7f0bad20f..16051daba 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -186,7 +186,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 62774d385..556bf70d5 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -600,7 +600,7 @@ void CBouquetList::paint() frameBuffer->paintBoxRel(x, y+theight, width, height - theight - footerHeight, COL_MENUCONTENT_PLUS_0); - ::paintButtons(x, y + (height - footerHeight), width, sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]), CBouquetListButtons, footerHeight); + ::paintButtons(x, y + (height - footerHeight), width, sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]), CBouquetListButtons, width, footerHeight); if(Bouquets.size()) { diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index a6f38d16f..53cd61e6c 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1862,7 +1862,7 @@ void CChannelList::paintButtonBar(bool is_current) //paint buttons int y_foot = y + (height - footerHeight); - ::paintButtons(x, y_foot, width, NUM_LIST_BUTTONS, SChannelListButtons, footerHeight/*, (width - 20) / NUM_LIST_BUTTONS*/); //buttonwidth will set automaticly + ::paintButtons(x, y_foot, width, NUM_LIST_BUTTONS, SChannelListButtons, width, footerHeight); } void CChannelList::paintItem(int pos) diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index f9cc57ec3..727a7aa2b 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -508,7 +508,7 @@ void EpgPlus::Footer::paintButtons (button_label * pbuttonLabels, int numberOfBu { int buttonWidth = (this->width); 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 d4ad4202d..54be78c0e 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -1097,10 +1097,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, 2, EpgButtons, h); + ::paintButtons(x, y, 0, 2, EpgButtons, aw, h); else - ::paintButtons(x, y, 0, 1, &EpgButtons[1], h); + ::paintButtons(x, y, 0, 1, &EpgButtons[1], aw, h); #if 0 // Button: Timer Record & Channelswitch diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index bfc2fcaee..d2fd4cda0 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -251,7 +251,7 @@ int EventList::exec(const t_channel_id channel_id, const std::string& channelnam // 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; @@ -864,31 +864,6 @@ void EventList::paint(t_channel_id channel_id) } - -#define NUM_EVENTLIST_FIRST_BUTTON 1 -struct button_label EventListFirstButton[NUM_EVENTLIST_FIRST_BUTTON] = -{ - { "", LOCALE_EVENTLISTBAR_RECORDEVENT } // record button -}; - -#define NUM_EVENTLIST_SECOND_BUTTON 1 -struct button_label EventListSecondButton[NUM_EVENTLIST_SECOND_BUTTON] = -{ - { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_EVENTFINDER_SEARCH } // search button -}; - -#define NUM_EVENTLIST_THIRD_BUTTON 1 -struct button_label EventListThirdButton[NUM_EVENTLIST_THIRD_BUTTON] = -{ - { "", LOCALE_EVENTLISTBAR_CHANNELSWITCH } // timer event channel switch button -}; - -#define NUM_EVENTLIST_FOURTH_BUTTON 1 -struct button_label EventListFourthButton[NUM_EVENTLIST_FOURTH_BUTTON] = -{ - { "", LOCALE_EVENTLISTBAR_EVENTSORT } // sort event button -}; - void EventList::showFunctionBar (bool show, t_channel_id channel_id) { int border_space = 4; @@ -896,12 +871,12 @@ void EventList::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); @@ -916,58 +891,48 @@ void EventList::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++; } } - - // 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; } // 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 2f5487ccf..4c94289ed 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -1437,12 +1437,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 }, @@ -1451,14 +1445,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); @@ -1471,31 +1471,37 @@ 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) { char cKey[2]={m_SMSKeyInput.getOldKey(),0}; - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x + width - 16, by2 , 16, cKey, COL_MENUHEAD, 0, true); // UTF-8 + cKey[0] = toupper(cKey[0]); + int len = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(cKey); + g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x + width - 10 - len, by2 + foheight, len, cKey, COL_MENUHEAD, 0, true); } } } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index f2c5694b2..c5d4bbf00 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -669,12 +669,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 238e153cc..8b02ef68d 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -848,9 +848,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 1995b9f70..3a0b1fa33 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -76,10 +76,13 @@ extern cVideo * videoDecoder; #define ConnectLineBox_Width 15 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 } +}; //------------------------------------------------------------------------ @@ -1049,7 +1052,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 } @@ -1170,14 +1173,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 b04e3cef6..76a572c30 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -2,10 +2,11 @@ * $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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -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,48 +88,62 @@ 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; //calculate button heigth h_button = std::max(h_max_icon, h_max_text); //calculate optimal button height @@ -146,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; @@ -155,21 +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) : ""; + 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, @@ -191,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 064461be3..2d7a4344a 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -758,7 +758,7 @@ void CStringInputSMS::paint(bool /*unused*/) frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT); //buttonbar - ::paintButtons(x, y + height, width, 2, CStringInputSMSButtons); + ::paintButtons(x, y + height, width, 2, CStringInputSMSButtons, width); } void CPINInput::paintChar(int pos)