diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index ba4cc593b..1a0574724 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -162,8 +162,8 @@ audioplayer.artist_title Interpret, Titel audioplayer.building_search_index Erstelle Suchindex audioplayer.button_select_title_by_id Suche n. ID audioplayer.button_select_title_by_name Suche n. Name -audioplayer.defdir Start-Verz. -audioplayer.delete entfernen +audioplayer.defdir Start-Verzeichnis +audioplayer.delete Entfernen audioplayer.deleteall Alle entfernen audioplayer.display_order Anzeige audioplayer.enable_sc_metadata Aktiviere SHOUTcast Meta-Daten Parsing @@ -1007,7 +1007,7 @@ lcd4l_weather Wetter im Standby-Modus lcd_info_line Zeige in Infozeile lcd_info_line_channel Kanalname lcd_info_line_clock Uhrzeit -lcdcontroler.brightness normale +lcdcontroler.brightness Normalbetrieb lcdcontroler.brightnessdeepstandby Deep-Standby lcdcontroler.brightnessstandby Standby lcdmenu.dim_brightness nach Dimm-Timeout @@ -2234,7 +2234,7 @@ personalize.usermenu_plugin_types Anzuzeigende Plugin-Typen wählen personalize.usermenu_preferred_buttons Bevorzugte Tasten zuweisen personalize.usermenu_show_cancel Zeige Schalter "Abbrechen" personalize.visible sichtbar -pictureviewer.defdir Start-Verz. +pictureviewer.defdir Start-Verzeichnis pictureviewer.head Bildbetrachter pictureviewer.help1 Menü-Modus pictureviewer.help10 Bild neu einlesen @@ -2268,8 +2268,8 @@ pictureviewer.scaling Skalierung pictureviewer.show Anzeigen pictureviewer.slide_time Diaschau-Anzeigedauer pictureviewer.slideshow Diaschau -pictureviewer.sortorder.date Sortierreihenf. ändern (Datum) -pictureviewer.sortorder.filename Sortierreihenf. ändern (Dateiname) +pictureviewer.sortorder.date Sortierreihenfolge: Datum +pictureviewer.sortorder.filename Sortierreihenfolge: Dateiname ping.ok ist erreichbar (ping) ping.protocol ist nicht erreichbar (Host- oder Protokoll-Fehler) ping.socket ist nicht erreichbar (Socket-Fehler) diff --git a/data/locale/english.locale b/data/locale/english.locale index 636cc9c71..772a07ea8 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -159,46 +159,46 @@ audioplayer.add_ic Icecast audioplayer.add_loc Local radio list audioplayer.add_sc SHOUTcast audioplayer.artist_title Artist, Title -audioplayer.building_search_index building search index -audioplayer.button_select_title_by_id search by ID -audioplayer.button_select_title_by_name search by name -audioplayer.defdir start dir. +audioplayer.building_search_index Building search index +audioplayer.button_select_title_by_id Search by ID +audioplayer.button_select_title_by_name Search by name +audioplayer.defdir Start directory audioplayer.delete Remove -audioplayer.deleteall remove all -audioplayer.display_order display order -audioplayer.enable_sc_metadata enable SHOUTcast meta data parsing -audioplayer.fastforward fast forw. -audioplayer.follow auto select current +audioplayer.deleteall Remove all +audioplayer.display_order Display order +audioplayer.enable_sc_metadata Enable SHOUTcast meta data parsing +audioplayer.fastforward Fast forward +audioplayer.follow Auto select current audioplayer.head Audio Playlist audioplayer.highprio High decode priority -audioplayer.jump_backwards jump backwards +audioplayer.jump_backwards Jump backwards audioplayer.jump_dialog_hint1 Please enter jump target audioplayer.jump_dialog_hint2 (relative, in seconds) audioplayer.jump_dialog_title Enter jump target -audioplayer.jump_forwards jump forwards -audioplayer.keylevel key level +audioplayer.jump_forwards Jump forwards +audioplayer.keylevel Key level audioplayer.load_radio_stations Load internet radios audioplayer.name Audioplayer -audioplayer.pause pause +audioplayer.pause Pause audioplayer.play Play -audioplayer.playing Current Track +audioplayer.playing Current track audioplayer.playlist_fileerror_msg File could not be created: audioplayer.playlist_fileoverwrite_msg Do you want to overwrite this file: audioplayer.playlist_fileoverwrite_title Overwrite? -audioplayer.playlist_name filename of the play list +audioplayer.playlist_name Filename of the play list audioplayer.playlist_name_hint1 Please enter the filename of the playlist audioplayer.playlist_name_hint2 The extension .m3u will be added automatically -audioplayer.reading_files reading files -audioplayer.receiving_list Receiving list, please wait -audioplayer.repeat_on enable repeat mode -audioplayer.rewind rewind -audioplayer.save_playlist save play list -audioplayer.select_title_by_name search title by name (SMS) -audioplayer.show_playlist Show Playlist -audioplayer.shuffle shuffle -audioplayer.spectrum lcd a-spectrum +audioplayer.reading_files Reading files +audioplayer.receiving_list Receiving list, please wait ... +audioplayer.repeat_on Enable repeat mode +audioplayer.rewind Rewind +audioplayer.save_playlist Save play list +audioplayer.select_title_by_name Search title by name (SMS) +audioplayer.show_playlist Show playlist +audioplayer.shuffle Shuffle +audioplayer.spectrum LCD spectrum audioplayer.stop Stop -audioplayer.title_artist Title, Artist +audioplayer.title_artist Title, artist blank_screen Blank screen bookmarkmanager.delete delete bookmarkmanager.name bookmarks @@ -1007,9 +1007,9 @@ lcd4l_weather Weather in Standby-Mode lcd_info_line show in infoline lcd_info_line_channel Channelname lcd_info_line_clock clock -lcdcontroler.brightness normal Brightness -lcdcontroler.brightnessdeepstandby DeepStandby Brightness -lcdcontroler.brightnessstandby Standby Brightness +lcdcontroler.brightness Normal mode +lcdcontroler.brightnessdeepstandby Deep standby +lcdcontroler.brightnessstandby Standby lcdmenu.dim_brightness Brightness after dim timeout lcdmenu.dim_time Dim timeout lcdmenu.head VFD/LED Settings @@ -2234,14 +2234,14 @@ personalize.usermenu_plugin_types Choose Plugin types to show personalize.usermenu_preferred_buttons Assigning of preferred keys personalize.usermenu_show_cancel Show "Cancel"-Button personalize.visible Visible -pictureviewer.defdir start dir. +pictureviewer.defdir Start directory pictureviewer.head Picture viewer pictureviewer.help1 menu mode pictureviewer.help10 reread image pictureviewer.help11 previous image pictureviewer.help12 next image -pictureviewer.help13 Zoom out -pictureviewer.help14 Zoom in +pictureviewer.help13 zoom out +pictureviewer.help14 zoom in pictureviewer.help15 scroll up pictureviewer.help16 scroll left pictureviewer.help17 scroll right @@ -2264,12 +2264,12 @@ pictureviewer.help9 show mode pictureviewer.resize.color_average advanced pictureviewer.resize.none none pictureviewer.resize.simple simple -pictureviewer.scaling scaling -pictureviewer.show show -pictureviewer.slide_time slideshow display time -pictureviewer.slideshow slideshow -pictureviewer.sortorder.date change sort order (date) -pictureviewer.sortorder.filename change sort order (filename) +pictureviewer.scaling Scaling +pictureviewer.show Show +pictureviewer.slide_time Slideshow display time +pictureviewer.slideshow Slideshow +pictureviewer.sortorder.date Sort order: Date +pictureviewer.sortorder.filename Sort order: Filename ping.ok is reachable (ping) ping.protocol is unreachable (host or protocol error) ping.socket is unreachable (socket error) diff --git a/lib/hardware/coolstream/hardware_caps.cpp b/lib/hardware/coolstream/hardware_caps.cpp index b4d4c0a46..139825c32 100644 --- a/lib/hardware/coolstream/hardware_caps.cpp +++ b/lib/hardware/coolstream/hardware_caps.cpp @@ -75,6 +75,7 @@ hw_caps_t *get_hwcaps(void) { strcpy(caps.boxname, "Trinity V2"); strcpy(caps.boxarch, "Kronos"); } + caps.can_set_display_brightness = 0; break; case 12: strcpy(caps.boxname, "Zee2"); @@ -87,6 +88,7 @@ hw_caps_t *get_hwcaps(void) { case 14: strcpy(caps.boxname, "Trinity Duo"); strcpy(caps.boxarch, "Kronos"); + caps.can_set_display_brightness = 0; break; default: strcpy(caps.boxname, "UNKNOWN_BOX"); diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 2fa2f8827..86dfea4ea 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -99,7 +99,7 @@ FBFontRenderClass::~FBFontRenderClass() for (fontListEntry * f = font; f; f = g) { g = f->next; - delete f; + delete f; f = NULL; } FTC_Manager_Done(cacheManager); diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index 16fa1de89..64da5fe44 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -92,14 +92,18 @@ void CNeutrinoFonts::InitDynFonts() CNeutrinoFonts::~CNeutrinoFonts() { if (!v_share_fonts.empty()) { - for (unsigned int i = 0; i < v_share_fonts.size(); i++) + for (unsigned int i = 0; i < v_share_fonts.size(); i++){ delete v_share_fonts[i].font; + v_share_fonts[i].font = NULL; + } v_share_fonts.clear(); } if (!v_dyn_fonts.empty()) { - for (unsigned int i = 0; i < v_dyn_fonts.size(); i++) + for (unsigned int i = 0; i < v_dyn_fonts.size(); i++){ delete v_dyn_fonts[i].font; + v_dyn_fonts[i].font = NULL; + } v_dyn_fonts.clear(); } if (!vDynSize.empty()) { @@ -402,8 +406,10 @@ void CNeutrinoFonts::deleteDynFontExtAll() { if (!v_dyn_fonts_ext.empty()) { for (size_t i = 0; i < v_dyn_fonts_ext.size(); ++i) { - if (v_dyn_fonts_ext[i].font != NULL) + if (v_dyn_fonts_ext[i].font != NULL){ delete v_dyn_fonts_ext[i].font; + v_dyn_fonts_ext[i].font = NULL; + } } v_dyn_fonts_ext.clear(); } diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 6474321e3..5d5118ab1 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -883,12 +883,38 @@ unsigned char * CPictureViewer::ResizeA(unsigned char *orgin, int ox, int oy, in return int_Resize(orgin, ox, oy, dx, dy, COLOR, NULL, true); } +static size_t getCachedMemSize(void) +{ + FILE *procmeminfo = fopen("/proc/meminfo", "r"); + size_t cached = 0; + if (procmeminfo) { + char buf[80] = {0}, a[80] = {0}; + size_t v = 0; + while (fgets(buf, sizeof(buf), procmeminfo)) { + char unit[10]; + *unit = 0; + if ((3 == sscanf(buf, "%[^:]: %zu %s", a, &v, unit)) + || (2 == sscanf(buf, "%[^:]: %zu", a, &v))) { + if (*unit == 'k') + v <<= 10; + if (!strcasecmp(a, "Cached")){ + cached = v; + break; + } + } + } + fclose(procmeminfo); + } + return cached; +} + bool CPictureViewer::checkfreemem(size_t bufsize) { struct sysinfo info; sysinfo( &info ); - if(bufsize + 4096 > (size_t)info.freeram + (size_t)info.freeswap){ - dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory: need %zu > free %zu\n", __func__, __LINE__,bufsize,(size_t)info.freeram + (size_t)info.freeswap); + size_t cached = getCachedMemSize(); + if(bufsize + sysconf(_SC_PAGESIZE) > (size_t)info.freeram + (size_t)info.freeswap + (size_t)info.bufferram + cached){ + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory: need %zu > free %zu\n", __func__, __LINE__,bufsize,(size_t)info.freeram + (size_t)info.freeswap + (size_t)info.bufferram + cached); return false; } return true; diff --git a/src/global.h b/src/global.h index 7c77611e9..304ccd195 100644 --- a/src/global.h +++ b/src/global.h @@ -43,6 +43,7 @@ #define MOVIEPLAYER_START_SCRIPT CONFIGDIR "/movieplayer.start" #define MOVIEPLAYER_END_SCRIPT CONFIGDIR "/movieplayer.end" #define NEUTRINO_ENTER_FLASH_SCRIPT CONFIGDIR "/flash.start" +#define NEUTRINO_APP_START_SCRIPT CONFIGDIR "/neutrino.start" #define NEUTRINO_NI_MIGRATION_SCRIPT CONFIGDIR "/ni-migration.sh" //NI #define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index b48579fe4..2334aefde 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -721,7 +721,6 @@ void CBouquetList::paint() CInfoClock::getInstance()->disableInfoClock(); liststart = (selected/listmaxshow)*listmaxshow; int lastnum = liststart + listmaxshow; - int bsize = Bouquets.empty() ? 1 : Bouquets.size(); numwidth = 0; int maxDigitWidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getMaxDigitWidth(); @@ -754,9 +753,9 @@ void CBouquetList::paint() } } - int _listmaxshow = listmaxshow ? listmaxshow : 1; //avoid division by zero - int total_pages = ((bsize - 1) / _listmaxshow) + 1; - int current_page = selected / _listmaxshow; + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, Bouquets.size(), listmaxshow, selected); paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page); } diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index ac89f1e68..5a07ccf99 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2173,7 +2173,8 @@ void CChannelList::paintHead() header->removeContextButtons(); header->enableClock(true, "%H:%M", "%H %M", true); - header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); + if (header->getClockObject()) + header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); }else{ if (header->getClockObject()){ header->disableClock(); diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 0089ac8a1..e43158b13 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -18,6 +18,7 @@ noinst_LIBRARIES = libneutrino_gui_components.a libneutrino_gui_components_a_SOURCES = \ cc_base.cpp \ + cc_button_select.cpp \ cc_detailsline.cpp \ cc_draw.cpp \ cc_extra.cpp \ diff --git a/src/gui/components/cc_button_select.cpp b/src/gui/components/cc_button_select.cpp new file mode 100644 index 000000000..cb396d7cb --- /dev/null +++ b/src/gui/components/cc_button_select.cpp @@ -0,0 +1,82 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + 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 (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "config.h" +#include "cc_button_select.h" +#include + +CCButtonSelect::CCButtonSelect() +{ + btn_container = NULL; +} + +CComponentsFrmChain* CCButtonSelect::getButtonChainObject() +{ + return btn_container; +} + +CComponentsButton* CCButtonSelect::getSelectedButtonObject() +{ + CComponentsButton* ret = static_cast(btn_container->getSelectedItemObject()); + return ret; +} + +int CCButtonSelect::getSelectedButton() +{ + if (btn_container) + return btn_container->getSelectedItem(); + return -1; +} + +void CCButtonSelect::setSelectedButton(size_t item_id, + const fb_pixel_t& fr_col, + const fb_pixel_t& sel_fr_col, + const fb_pixel_t& bg_col, + const fb_pixel_t& sel_bg_col, + const fb_pixel_t& text_col, + const fb_pixel_t& sel_text_col, + const int& frame_width, + const int& sel_frame_width) +{ + CComponentsButton *btn = NULL; + if (btn_container){ + for (size_t i= 0; i< btn_container->size(); i++){ + CComponentsItem *item = btn_container->getCCItem(i); + if (item->getItemType() >= CC_ITEMTYPE_BUTTON && item->getItemType() <= CC_ITEMTYPE_BUTTON_BLUE){ + btn = static_cast(item); + btn->setButtonTextColor(text_col); + } + } + if (!btn) + dprintf(DEBUG_NORMAL, "\033[33m[CCButtonSelect]\t[%s - %d], no button object found...\033[0m\n", __func__, __LINE__); + + fb_pixel_t sel_col = fr_col; + if (btn_container->size() > 1) + sel_col = sel_fr_col; //TODO: make it configurable + btn_container->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width); + + getSelectedButtonObject()->setButtonTextColor(sel_text_col); + } +} + + diff --git a/src/gui/components/cc_button_select.h b/src/gui/components/cc_button_select.h new file mode 100644 index 000000000..928f48861 --- /dev/null +++ b/src/gui/components/cc_button_select.h @@ -0,0 +1,81 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + 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 (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __CC_BTN_SEL_H__ +#define __CC_BTN_SEL_H__ + + +#include "cc_frm_button.h" + +/*! +Class for inheritation of button select handling inside other CComponentsForm objects and their derivations +*/ +class CCButtonSelect +{ + protected: + CComponentsFrmChain *btn_container; + + public: + CCButtonSelect(); + + ///returns selected button object, return value as pointer to object, NULL means nothing is selected + CComponentsButton* getSelectedButtonObject(); + + ///returns pointer to internal button container + CComponentsFrmChain* getButtonChainObject(); + + ///returns id of select button, return value as int, -1 = nothing is selected + int getSelectedButton(); + + /**Select a definied button inside button chain object + * @param[in] item_id + * @li optional: expects type size_t + * @param[in] fr_col + * @li optional: expects type fb_pixel_t, as default frame color + * @param[in] sel_fr_col + * @li optional: expects type fb_pixel_t, as selected frame color + * @param[in] bg_col + * @li optional: expects type fb_pixel_t, as default background color + * @param[in] sel_bg_col + * @li optional: expects type fb_pixel_t, as selected background color + * @param[in] text_col + * @li optional: expects type fb_pixel_t, as default text color + * @param[in] sel_text_col + * @li optional: expects type fb_pixel_t, as selected text color + * @param[in] frame_width + * @li optional: expects type int, default = 1 + * @param[in] sel_frame_width + * @li optional: expects type int, default = 1 + */ + void setSelectedButton(size_t item_id, + const fb_pixel_t& fr_col = COL_FRAME_PLUS_0, + const fb_pixel_t& sel_fr_col = COL_FRAME_PLUS_0, + const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0, + const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT, + const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT, + const int& frame_width = 1, + const int& sel_frame_width = 1); +}; + +#endif //__CC_BTN_SEL_H__ diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 078edf940..c28144444 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -440,11 +440,13 @@ bool CCDraw::CheckFbData(const cc_fbdata_t& fbdata, const char* func, const int //screen area save fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) { + fb_pixel_t* pixbuf = NULL; + if (dx < 1 || dy < 1 || dx * dy == 0) return NULL; + else + pixbuf = new fb_pixel_t[dx * dy]; - dprintf(DEBUG_INFO, "[CCDraw] INFO! [%s - %d], ax = %d, ay = %d, dx = %d, dy = %d\n", __func__, __LINE__, ax, ay, dx, dy); - fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; frameBuffer->waitForIdle("CCDraw::getScreen()"); frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); return pixbuf; @@ -453,8 +455,14 @@ fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) cc_screen_data_t CCDraw::getScreenData(const int& ax, const int& ay, const int& dx, const int& dy) { cc_screen_data_t res; + res.x = res.y = res.dx = res.dy = 0; res.pixbuf = getScreen(ax, ay, dx, dy); - res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + + if (res.pixbuf){ + res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + } + else + dprintf(DEBUG_NORMAL, "\033[33m[CCDraw]\[%s - %d], Warning: initialize of screen buffer failed!\033[0m\n", __func__, __LINE__); return res; } diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index b93df7c50..58ea974d9 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -185,11 +185,10 @@ void CComponentsForm::clear() return; for(size_t i=0; igetItemType(), item); - delete item; - item = NULL; + if (v_cc_items[i]){ + dprintf(DEBUG_DEBUG, "[CComponentsForm] %s... delete form cc-item %d of %d (type=%d)\taddress = %p\n", __func__, (int)i+1, (int)v_cc_items.size(), v_cc_items[i]->getItemType(), v_cc_items[i]); + delete v_cc_items[i]; + v_cc_items[i] = NULL; } } v_cc_items.clear(); diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index f1aba0a9c..0b7b74401 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -28,7 +28,7 @@ #include "config.h" #include "cc_base.h" #include "cc_item.h" -#include "cc_frm_scrollbar.h" + class CComponentsForm : public CComponentsItem { diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 46d4781df..1beb3d70f 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -112,8 +112,9 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, CComponentsFrmClock::~CComponentsFrmClock() { - if (cl_timer) - delete cl_timer; + if (cl_timer){ + delete cl_timer; cl_timer = NULL; + } } void CComponentsFrmClock::initClockFont(int dx, int dy) diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index a5fca52fa..c7011978c 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -35,7 +35,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------- //sub class CComponentsFooter inherit from CComponentsHeader -CComponentsFooter::CComponentsFooter(CComponentsForm* parent) +CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect() { //CComponentsFooter initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0); @@ -47,7 +47,7 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int shadow_mode, fb_pixel_t color_frame, fb_pixel_t color_body, - fb_pixel_t color_shadow ) + fb_pixel_t color_shadow ):CCButtonSelect() { //CComponentsFooter initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow); @@ -95,7 +95,6 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const corner_type = CORNER_BOTTOM; ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment - chain = NULL; addContextButton(buttons); initCCItems(); @@ -108,8 +107,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width) { /* clean up before init*/ - if (chain) - chain->clear(); + if (btn_container) + btn_container->clear(); if (label_count == 0) return; @@ -150,11 +149,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con int y_chain = height/2 - h_chain/2; if (cch_icon_obj) x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset; - if (chain == NULL){ - chain = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body); - chain->setAppendOffset(0, 0); - chain->setCorner(this->corner_rad, this->corner_type); - chain->doPaintBg(false); + if (btn_container == NULL){ + btn_container = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body); + btn_container->setAppendOffset(0, 0); + btn_container->setCorner(this->corner_rad, this->corner_type); + btn_container->doPaintBg(false); } /* Calculate usable width of button labels inside button object container @@ -166,11 +165,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con * button objects itself. */ int w_offset = int((label_count-1)*cch_offset); - int w_btn = chain->getWidth()/label_count - w_offset; + int w_btn = btn_container->getWidth()/label_count - w_offset; if (label_width){ int w_label = label_width; int w_defined = int(label_width*label_count); - int w_max = chain->getWidth() - w_offset; + int w_max = btn_container->getWidth() - w_offset; while (w_defined > w_max){ w_label--; w_defined = int(w_label*label_count) - w_offset; @@ -182,7 +181,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con * with default width to chain object. */ vector v_btns; - int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width; + int h_btn = /*(ccf_enable_button_bg ? */btn_container->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width; for (size_t i= 0; i< label_count; i++){ string txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale); string icon_name = string(content[i].button); @@ -193,7 +192,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con continue; } - int y_btn = chain->getHeight()/2 - h_btn/2; + int y_btn = btn_container->getHeight()/2 - h_btn/2; dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width); CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow); @@ -224,27 +223,27 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con btn->setButtonFont(NULL); } - dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%zu] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, chain->getWidth()); + dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%zu] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, btn_container->getWidth()); } /* add generated button objects to chain object. */ if (!v_btns.empty()){ /*add all buttons into button container*/ - chain->addCCItem(v_btns); + btn_container->addCCItem(v_btns); /* set position of labels, as centered inside button container*/ int w_chain_used = 0; - for (size_t a= 0; a< chain->size(); a++) - w_chain_used += chain->getCCItem(a)->getWidth(); - w_chain_used += (chain->size()-1)*cch_offset; + for (size_t a= 0; a< btn_container->size(); a++) + w_chain_used += btn_container->getCCItem(a)->getWidth(); + w_chain_used += (btn_container->size()-1)*cch_offset; - int x_btn = chain->getWidth()/2 - w_chain_used/2; - chain->getCCItem(0)->setXPos(x_btn); + int x_btn = btn_container->getWidth()/2 - w_chain_used/2; + btn_container->getCCItem(0)->setXPos(x_btn); - for (size_t c= 1; c< chain->size(); c++){ - x_btn += chain->getCCItem(c-1)->getWidth()+ cch_offset; - chain->getCCItem(c)->setXPos(x_btn); + for (size_t c= 1; c< btn_container->size(); c++){ + x_btn += btn_container->getCCItem(c-1)->getWidth()+ cch_offset; + btn_container->getCCItem(c)->setXPos(x_btn); } } } @@ -317,49 +316,12 @@ void CComponentsFooter::setButtonLabel( const char *button_icon, void CComponentsFooter::enableButtonBg(bool enable) { ccf_enable_button_bg = enable; - if (chain) { - for (size_t i= 0; i< chain->size(); i++) - chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg); + if (btn_container) { + for (size_t i= 0; i< btn_container->size(); i++) + btn_container->getCCItem(i)->doPaintBg(ccf_enable_button_bg); } } -void CComponentsFooter::setSelectedButton(size_t item_id, - const fb_pixel_t& fr_col, const fb_pixel_t& sel_fr_col, - const fb_pixel_t& bg_col, const fb_pixel_t& sel_bg_col, - const fb_pixel_t& text_col, const fb_pixel_t& sel_text_col, - const int& frame_width, - const int& sel_frame_width) -{ - if (chain){ - for (size_t i= 0; i< chain->size(); i++){ - CComponentsButton *btn = static_cast(chain->getCCItem(i)); - btn->setButtonTextColor(text_col); - } - fb_pixel_t sel_col = fr_col; - if (chain->size() > 1) - sel_col = sel_fr_col; //TODO: make it configurable - chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width); - - getSelectedButtonObject()->setButtonTextColor(sel_text_col); - } -} - -int CComponentsFooter::getSelectedButton() -{ - int ret = -1; - if (chain) - ret = chain->getSelectedItem(); - - return ret; -} - -CComponentsButton* CComponentsFooter::getSelectedButtonObject() -{ - CComponentsButton* ret = static_cast(chain->getSelectedItemObject()); - return ret; -} - - void CComponentsFooter::paintButtons(const int& x_pos, const int& y_pos, const int& w, @@ -395,12 +357,12 @@ void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bo ccf_enable_button_shadow = mode; ccf_button_shadow_width = shadow_width; ccf_button_shadow_force_paint = force_paint; - if (chain){ - for(size_t i=0; isize(); i++){ - chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint); + if (btn_container){ + for(size_t i=0; isize(); i++){ + btn_container->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint); //int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width; - int y_btn = chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2; - chain->getCCItem(i)->setYPos(y_btn); + int y_btn = btn_container->getHeight()/2 - btn_container->getCCItem(i)->getHeight()/2; + btn_container->getCCItem(i)->setYPos(y_btn); } } } diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index c9de5b953..2586d1772 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -26,6 +26,8 @@ #include "cc_frm_header.h" #include "cc_frm_button.h" +#include "cc_button_select.h" + #include #include //for compatibility with 'button_label' type @@ -39,7 +41,7 @@ to add button labels known by older button handler, to find in gui/widget/button functionality. Why limited ?: old parameter 'struct button_label' doesn't provide newer parameters. Missing parameters are filled with default values and must be assigned afterward, if required. */ -class CComponentsFooter : public CComponentsHeader +class CComponentsFooter : public CComponentsHeader, public CCButtonSelect { private: void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h, @@ -67,9 +69,6 @@ class CComponentsFooter : public CComponentsHeader ///init default fonts for size modes virtual void initDefaultFonts(); - ///container for button objects - CComponentsFrmChain *chain; - public: CComponentsFooter(CComponentsForm *parent = NULL); CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, @@ -114,40 +113,6 @@ class CComponentsFooter : public CComponentsHeader ///disables background of buttons void disableButtonBg(){enableButtonBg(false);} - /**Select a definied button inside button chain object - * @param[in] item_id - * @li optional: exepts type size_t - * @param[in] fr_col - * @li optional: exepts type fb_pixel_t, as default frame color - * @param[in] sel_fr_col - * @li optional: exepts type fb_pixel_t, as selected frame color - * @param[in] bg_col - * @li optional: exepts type fb_pixel_t, as default background color - * @param[in] sel_bg_col - * @li optional: exepts type fb_pixel_t, as selected background color - * @param[in] text_col - * @li optional: exepts type fb_pixel_t, as default text color - * @param[in] sel_text_col - * @li optional: exepts type fb_pixel_t, as selected text color - * @param[in] frame_width - * @li optional: exepts type int, default = 1 - * @param[in] sel_frame_width - * @li optional: exepts type int, default = 2 - */ - void setSelectedButton(size_t item_id, - const fb_pixel_t& fr_col = COL_SHADOW_PLUS_0, //NI - const fb_pixel_t& sel_fr_col = COL_SHADOW_PLUS_0, //NI - const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0, - const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT, - const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT, - const int& frame_width = 1, - const int& sel_frame_width = 1); - ///returns id of select button, return value as int, -1 = nothing is selected - int getSelectedButton(); - ///returns selected button object, return value as pointer to object, NULL means nothing is selected - CComponentsButton* getSelectedButtonObject(); - /*! Sets a new text to an already predefined button. 1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string @@ -164,10 +129,6 @@ class CComponentsFooter : public CComponentsHeader ///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font void setButtonFont(Font* font){ccf_btn_font = font;}; - ///returns pointer to internal button container - CComponentsFrmChain* getButtonChainObject(){return chain;}; - - ///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input ///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required void paintButtons( const int& x_pos, @@ -196,4 +157,6 @@ class CComponentsFooter : public CComponentsHeader void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);} }; + + #endif diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 586772e77..3d7158d07 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -302,7 +302,7 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT } ///returns the clock object - virtual CComponentsFrmClock* getClockObject(){return cch_cl_obj;} + CComponentsFrmClock* getClockObject(){return cch_cl_obj;} ///enable display of clock, parameter bool enable, const char* format, bool run virtual void enableClock(bool enable = true, const char* format = "%H:%M", const char* sec_format_str = NULL, bool run = false); diff --git a/src/gui/components/cc_frm_scrollbar.cpp b/src/gui/components/cc_frm_scrollbar.cpp index 2a553950e..a2ea040a2 100644 --- a/src/gui/components/cc_frm_scrollbar.cpp +++ b/src/gui/components/cc_frm_scrollbar.cpp @@ -220,6 +220,16 @@ void CComponentsScrollBar::initSegments() } } +void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item) +{ + // avoid divison by zero and fix wrong values + total_items = std::max(total_items, 1); + items_per_page = std::max(items_per_page, 1); + selected_item = std::max(selected_item, 0); + + *total_pages = ((total_items - 1) / items_per_page) + 1; + *current_page = selected_item / items_per_page; +} void paintScrollBar( const int &x_pos, const int &y_pos, diff --git a/src/gui/components/cc_frm_scrollbar.h b/src/gui/components/cc_frm_scrollbar.h index 8658d5428..8bd1c0568 100644 --- a/src/gui/components/cc_frm_scrollbar.h +++ b/src/gui/components/cc_frm_scrollbar.h @@ -145,6 +145,8 @@ class CComponentsScrollBar : public CComponentsFrmChain void disableVisualize(){enableVisualize(false);} }; +void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item); + /**Small and easy to apply scrollbar paint methode without expilcit object declaration * @return void * diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp index bc41347b0..2dccb9820 100644 --- a/src/gui/components/cc_item_infobox.cpp +++ b/src/gui/components/cc_item_infobox.cpp @@ -51,10 +51,10 @@ CComponentsInfoBox::CComponentsInfoBox( const int& x_pos, { cc_item_type = CC_ITEMTYPE_TEXT_INFOBOX; - x = x_pos; - y = y_pos; - width = w; - height = h; + x = x_old = x_pos; + y = y_old = y_pos; + width = width_old = w; + height = height_old = h; shadow = shadow_mode; col_frame = color_frame; cc_enable_frame = true; @@ -124,7 +124,7 @@ void CComponentsInfoBox::paintPicture() pic->doPaintBg(false); //fit icon into frame - pic->setYPos(y_pic+(height/2-pic->getHeight()/2)); + pic->setYPos(y_pic+(height-2*fr_thickness)/2-pic->getHeight()/2); //paint, but set visibility mode pic->allowPaint(cc_allow_paint); diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 045889db2..366c37515 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -61,10 +61,10 @@ CProgressBar::CProgressBar( const int x_pos, cc_item_type = CC_ITEMTYPE_PROGRESSBAR; //CComponents - x = x_pos; - y = y_pos; - width = w; - height = h; + x = x_old = x_pos; + y = y_old = y_pos; + width = width_old = w; + height = height_old = h; col_frame = color_frame; col_body = color_body; @@ -202,6 +202,7 @@ void CProgressBarCache::pbcClear() if ((*it)->pbc_passive) free((*it)->pbc_passive); delete (*it); + (*it) = NULL; } pbCache.clear(); } diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 5e5d53d48..8f716dc0b 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -95,8 +95,6 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///destroy current CTextBox and CBox objects void clearCCText(); - ///initialize all required attributes for text and send to the CTextBox object - void initCCText(); ///init internal CBox object required by CTextBox object void initCBox(); @@ -164,6 +162,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///send option to CTextBox object to paint background box behind text or not virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; + ///initialize all required attributes for text and send to the CTextBox object + void initCCText(); + ///set text as string also possible with overloades members for loacales, const char and text file, returns true if text was changed virtual bool setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR); ///set text with const char*, returns true if text was changed diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 1db5ed7aa..e24f5cc03 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -34,6 +34,7 @@ struct gradientData_t; class Font; class CComponentsForm; class CComponentsScrollBar; +class CCButtonSelect; ///cc item types typedef enum diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index dafdbb1fb..d6795c407 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -1429,8 +1429,12 @@ void EpgPlus::paint() this->timeLine->paintGrid(); // paint slider - int total_pages = ((this->channelList->getSize() - 1) / this->maxNumberOfDisplayableEntries) + 1; - int current_page = this->selectedChannelEntry == NULL ? 0 : (this->selectedChannelEntry->index / this->maxNumberOfDisplayableEntries); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, + this->channelList->getSize(), + this->maxNumberOfDisplayableEntries, + this->selectedChannelEntry == NULL ? 0 : this->selectedChannelEntry->index); paintScrollBar(this->sliderX, this->sliderY, this->sliderWidth, this->sliderHeight, total_pages, current_page); } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 0dabc9b93..044c29b37 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -897,7 +897,7 @@ void CEventList::paintHead(t_channel_id _channel_id, std::string _channelname, s header->getChannelLogoObject()->hide(); if (g_settings.channellist_show_channellogo) //NI header->setChannelLogo(_channel_id,_channelname); - header->setCaption(_channelname); //NI + header->setCaption(_channelname, CCHeaderTypes::CC_TITLE_LEFT); header->paint(CC_SAVE_SCREEN_NO); diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index d3a0050f4..85918b6ea 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -555,19 +556,29 @@ bool CFileBrowser::readDir_std(const std::string & dirname, CFileList* flist) struct stat64 statbuf; dirent64 **namelist; int n; + std::string to_scan_dir = dirname; - n = scandir64(dirname.c_str(), &namelist, 0, alphasort64); + n = scandir64(to_scan_dir.c_str(), &namelist, 0, alphasort64); if (n < 0) { - perror(("Filebrowser scandir: "+dirname).c_str()); + std::string scn_err = "Filebrowser scandir: " + to_scan_dir + " "; + to_scan_dir = "/media/"; + dprintf(DEBUG_NORMAL, "\033[33m[CFileBrowser]\[%s - %d], %s failed, %s, try fallback to [%s]\033[0m\n", __func__, __LINE__, scn_err.c_str(), strerror(errno), to_scan_dir.c_str()); + n = scandir64(to_scan_dir.c_str(), &namelist, 0, alphasort64); + name = to_scan_dir; + } + + if (n < 0){ //fallback failed + perror(("Filebrowser scandir: "+to_scan_dir).c_str()); return false; } + for (int i = 0; i < n; i++) { CFile file; if(strcmp(namelist[i]->d_name,".") != 0) { - file.Name = dirname + namelist[i]->d_name; + file.Name = to_scan_dir + namelist[i]->d_name; // printf("file.Name: '%s', getFileName: '%s' getPath: '%s'\n",file.Name.c_str(),file.getFileName().c_str(),file.getPath().c_str()); if(stat64((file.Name).c_str(),&statbuf) != 0) @@ -1472,8 +1483,9 @@ void CFileBrowser::paint() paintItem(count); //scrollbar - int total_pages = filelist.size() == 0 ? 1 : ((filelist.size() - 1) / listmaxshow) + 1; - int current_page = (selected / listmaxshow); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, filelist.size(), listmaxshow, selected); paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page); } diff --git a/src/gui/lua/lua_api_version.h b/src/gui/lua/lua_api_version.h index 4320eacbe..6f932f261 100644 --- a/src/gui/lua/lua_api_version.h +++ b/src/gui/lua/lua_api_version.h @@ -4,4 +4,4 @@ * to luainstance.h changes */ #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 75 +#define LUA_API_VERSION_MINOR 76 diff --git a/src/gui/lua/lua_cc_text.cpp b/src/gui/lua/lua_cc_text.cpp index 2cbaa45d3..3e2158e52 100644 --- a/src/gui/lua/lua_cc_text.cpp +++ b/src/gui/lua/lua_cc_text.cpp @@ -229,6 +229,7 @@ int CLuaInstCCText::CCTextGetLines(lua_State *L) } else { CTextBox* ctb = D->ct->getCTextBoxObject(); + D->ct->initCCText(); if (ctb) lines = (lua_Integer)ctb->getLines(); } diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index f15cfb601..add4e8bcd 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -972,7 +972,7 @@ bool CMoviePlayerGui::selectLivestream(std::vector &streamLis #endif bool resIO = false; - while (1) { + while (!streamList.empty()) { size_t i; for (i = 0; i < streamList.size(); ++i) { _info = &(streamList[i]); diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 4ac249668..a0098d63d 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -168,19 +168,19 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) width = frameBuffer->getScreenWidthRel(); height = frameBuffer->getScreenHeightRel(); - theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + item_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - //get footerHeight from paintButtons - buttons1Height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); - buttons2Height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); - footerHeight = buttons1Height + buttons2Height; + //get footer_height from paintButtons + buttons1_height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); + buttons2_height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); + footer_height = buttons1_height + buttons2_height; - listmaxshow = (height-theight-footerHeight)/(fheight); - height = theight+listmaxshow*fheight+footerHeight; // recalc height + listmaxshow = (height - header_height - footer_height)/item_height; + height = header_height + listmaxshow*item_height + footer_height; // recalc height - x=getScreenStartX( width ); - y=getScreenStartY( height ); + x=getScreenStartX(width); + y=getScreenStartY(height); m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling); m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY); @@ -672,7 +672,7 @@ void CPictureViewerGui::hide() void CPictureViewerGui::paintItem(int pos) { // printf("paintItem{\n"); - int ypos = y+ theight + 0 + pos*fheight; + int ypos = y + header_height + pos*item_height; unsigned int currpos = liststart + pos; @@ -690,8 +690,8 @@ void CPictureViewerGui::paintItem(int pos) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x, ypos, width - 15, fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, width - 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius); if (currpos < playlist.size()) { @@ -702,8 +702,8 @@ void CPictureViewerGui::paintItem(int pos) char timestring[18]; strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&playlist[currpos].Date)); int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(timestring); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10,ypos+fheight, width-30 - w, tmp, color, fheight); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+width-20-w,ypos+fheight, w, timestring, color, fheight); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID, ypos + item_height, width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - w, tmp, color, item_height); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, ypos + item_height, w, timestring, color, item_height); } // printf("paintItem}\n"); @@ -713,7 +713,7 @@ void CPictureViewerGui::paintItem(int pos) void CPictureViewerGui::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_PICTUREVIEWER, CComponentsHeaderLocalized::CC_BTN_HELP); //NI + CComponentsHeaderLocalized header(x, y, width, header_height, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_PICTUREVIEWER, CComponentsHeaderLocalized::CC_BTN_HELP); #ifdef ENABLE_GUI_MOUNT header.setContextButton(NEUTRINO_ICON_BUTTON_MENU); @@ -731,15 +731,15 @@ void CPictureViewerGui::paintFoot() else PictureViewerButtons2[0].locale = LOCALE_PICTUREVIEWER_SORTORDER_DATE; - frameBuffer->paintBoxRel(x, y + (height - footerHeight), width, footerHeight, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + frameBuffer->paintBoxRel(x, y + (height - footer_height), width, footer_height, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); if (!playlist.empty()) { - ::paintButtons(x, y + (height - footerHeight), 0, PictureViewerButtons1Count, PictureViewerButtons1, width); - ::paintButtons(x, y + (height - buttons2Height), 0, PictureViewerButtons2Count, PictureViewerButtons2, width); + ::paintButtons(x, y + (height - footer_height), 0, PictureViewerButtons1Count, PictureViewerButtons1, width); + ::paintButtons(x, y + (height - buttons2_height), 0, PictureViewerButtons2Count, PictureViewerButtons2, width); } else - ::paintButtons(x, y + (height - footerHeight), 0, 1, &(PictureViewerButtons1[1]), width); + ::paintButtons(x, y + (height - footer_height), 0, 1, &(PictureViewerButtons1[1]), width); } //------------------------------------------------------------------------ @@ -760,19 +760,12 @@ void CPictureViewerGui::paint() paintItem(count); } - int ypos = y+ theight; - int sb = fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PLUS_0); + //scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, playlist.size(), listmaxshow, selected); - unsigned int tmp_max = listmaxshow; - if(!tmp_max) - tmp_max = 1; - int sbc= ((playlist.size()- 1)/ tmp_max)+ 1; - int sbs= (selected/tmp_max); - if (sbc < 1) - sbc = 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page); paintFoot(); paintInfo(); diff --git a/src/gui/pictureviewer.h b/src/gui/pictureviewer.h index 6e89ccbcd..70b38fd16 100644 --- a/src/gui/pictureviewer.h +++ b/src/gui/pictureviewer.h @@ -74,11 +74,11 @@ class CPictureViewerGui : public CMenuTarget unsigned int selected; unsigned int liststart; unsigned int listmaxshow; - int fheight; // Fonthoehe Playlist-Inhalt - int theight; // Fonthoehe Playlist-Titel - int footerHeight; - int buttons1Height; - int buttons2Height; + int item_height; + int header_height; + int footer_height; + int buttons1_height; + int buttons2_height; bool visible; State m_state; SortOrder m_sort; diff --git a/src/gui/vfd_setup.cpp b/src/gui/vfd_setup.cpp index d2b5a199c..a64996a21 100644 --- a/src/gui/vfd_setup.cpp +++ b/src/gui/vfd_setup.cpp @@ -130,12 +130,16 @@ int CVfdSetup::showSetup() vfds->addItem(mf); } - if (CVFD::getInstance()->has_lcd) { + if (g_info.hw_caps->can_set_display_brightness) + { //vfd brightness menu mf = new CMenuForwarder(LOCALE_LCDMENU_LCDCONTROLER, vfd_enabled, NULL, this, "brightness", CRCInput::RC_green); mf->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS_SETUP); vfds->addItem(mf); + } + if (CVFD::getInstance()->has_lcd) + { if (cs_get_revision() == 9) // Tank only { //backlight menu diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 8322aea65..d4eada083 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -92,7 +92,7 @@ void CVolumeBar::initVolumeBarSize() //scale vb_pbw = CFrameBuffer::getInstance()->scale2Res(200); - vb_pbh = height-4*vb_item_offset; + vb_pbh = height-2*vb_item_offset; //result for width width = (vb_icon_w + vb_pbw + vb_digit_w) + 4*vb_item_offset + corner_rad/2; @@ -112,8 +112,6 @@ void CVolumeBar::initVolumeBarSize() mute_corrY = (height - mute_dy) / 2; cvh->setMuteIconCorrY(mute_corrY); - vb_pbh = height-8; - vb_pby = height/2-vb_pbh/2; } @@ -267,8 +265,8 @@ void CVolumeBar::paint(bool do_save_bg) CVolumeHelper::CVolumeHelper() { - h_spacer = 11; - v_spacer = 6; + h_spacer = OFFSET_INNER_MID; + v_spacer = OFFSET_INNER_SMALL; vb_font = NULL; clock_font = NULL; @@ -359,8 +357,8 @@ void CVolumeHelper::initVolBarSize() digit_width = 0; frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_width, &icon_height); icon_height = max(icon_height, 16); // if no icon available - icon_height += 2; - icon_width += 8; + icon_height += OFFSET_INNER_MIN; + icon_width += OFFSET_INNER_MID; g_settings.volume_size = max(g_settings.volume_size, icon_height); vol_height = CFrameBuffer::getInstance()->scale2Res(g_settings.volume_size); @@ -370,7 +368,7 @@ void CVolumeHelper::initVolBarSize() int tmp_h = vol_height; digit_width = 0; vb_font = cnf->getDynFont(digit_width, tmp_h, "100", CNeutrinoFonts::FONT_STYLE_REGULAR, CNeutrinoFonts::FONT_ID_VOLBAR); - digit_width += 6; + digit_width += OFFSET_INNER_SMALL; vol_height = max(vol_height, tmp_h); } } diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 068bd8475..915b4b754 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -2345,7 +2345,7 @@ int CMenuSeparator::paint(bool selected) if ((type & LINE)) { int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; - paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); //NI + paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); } if ((type & STRING)) { diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 23ed96132..7a9e326b1 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -900,6 +900,16 @@ int CTextBox::getLines(const std::string& text) return count; } +int CTextBox::getLines() +{ + if (m_cText.empty()) + return 0; + + refreshTextLineArray(); + + return m_nNrOfLines; +} + int CTextBox::getMaxLineWidth(const std::string& text, Font* font) { std::string txt = text; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 0c182eaa8..5980985e5 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -164,7 +164,7 @@ class CTextBox : public sigc::trackable int text_Hborder_width; int text_Vborder_width; bool m_FontUseDigitHeight; - + public: /* Constructor */ CTextBox(); @@ -199,28 +199,30 @@ class CTextBox : public sigc::trackable void enableUTF8(bool enable = true){m_utf8_encoded = enable;} void disableUTF8(bool enable = false){enableUTF8(enable);} - inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; - inline CBox getWindowsPos(void) {return(m_cFrame);}; + bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; + CBox getWindowsPos(void) {return(m_cFrame);}; - inline int getLinesPerPage(void) {return m_nLinesPerPage;}; - inline int getPages(void) {return(m_nNrOfPages);}; - inline int getBackGroundRadius(void) {return(m_nBgRadius);}; + int getLinesPerPage(void) {return m_nLinesPerPage;}; + int getPages(void) {return(m_nNrOfPages);}; + int getBackGroundRadius(void) {return(m_nBgRadius);}; /** * Returns count of lines of a passed text. * @param[in] text - * @li exepts type std::string + * @li expects type std::string * @return count of lines as int * @see getLines() */ - static int getLines(const std::string& text); + static int getLines(const std::string& text); /** - * Returns count of evaluated lines from an existent CTextBox instance. + * Returns count of calculated lines from an existing CTextBox instance. * @return count of lines as int * @see static version getLines() + * @note Real count of lines will be only returned if CTextBox object is initialized with a valid CBox instance, \n + * otherwise count of 0 lines will be returned! */ - int getLines(){return(m_nNrOfLines);} + int getLines(); /** * Returns width of largest line from passed text diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 2890c8688..9969b2512 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2312,6 +2312,10 @@ void wake_up(bool &wakeup) int CNeutrinoApp::run(int argc, char **argv) { + puts("[neutrino] executing " NEUTRINO_APP_START_SCRIPT "."); + if (my_system(NEUTRINO_APP_START_SCRIPT) != 0) + perror(NEUTRINO_APP_START_SCRIPT " failed"); + CmdParser(argc, argv); TIMER_START();