diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 853702e75..4173a2956 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -300,6 +300,7 @@ colormenusetup.menuhead Titelleiste colorstatusbar.text Infobar colorthememenu.head Theme auswählen colorthememenu.head2 Themes laden +colorthememenu.menu_hints Hinweisfenster colorthememenu.name Themename colorthememenu.neutrino_theme Neutrino Theme colorthememenu.question Aktuelles Theme beibehalten? @@ -587,9 +588,9 @@ flashupdate.fileis0bytes die Dateigröße ist 0 Byte flashupdate.fileselector Datei-Auswahl flashupdate.flashreadyreboot Das Image wurde erfolgreich geflasht.\nIhre Box wird jetzt neu gestartet. flashupdate.getinfofile lade Versioninfo -flashupdate.getinfofileerror kann Info nicht laden +flashupdate.getinfofileerror Kann Aktualisierungs-Info nicht laden! flashupdate.getupdatefile lade Update -flashupdate.getupdatefileerror kann Update nicht laden +flashupdate.getupdatefileerror Kann Aktualisierung nicht laden! flashupdate.globalprogress Gesamtstatus: flashupdate.head Aktualisierung flashupdate.md5check Imageprüfung @@ -599,7 +600,7 @@ flashupdate.menu_apply_settings Settingsübernahme erlauben flashupdate.mkfs_create_image Image erstellen flashupdate.mkfs_preparing_files Dateien und Verzeichnisse vorbereiten flashupdate.mkfs_using_sumtool Benutze Sumtool -flashupdate.msgbox Es wurde folgendes neues File gefunden:\nDatum: %s, %s\nBasisImage: %s\nTyp: %s\n\nWollen Sie diese Version jetzt herunterladen\nund installieren? +flashupdate.msgbox Es wurde folgende neue Datei gefunden:\nDatum: %s, %s\nBasisImage: %s\nTyp: %s\n\nWollen Sie diese Version jetzt herunterladen und installieren? flashupdate.msgbox_manual Es wurde ein neues Image gefunden:\nDatum: %s, %s\nBasisImage: %s\nImageTyp: %s\n\nWollen Sie diese Version jetzt installieren? flashupdate.mtdselector Partitions-Auswahl flashupdate.namemode1 Dateiname Settingsfile diff --git a/data/locale/english.locale b/data/locale/english.locale index a32433095..43c7a2c7e 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -300,6 +300,7 @@ colormenusetup.menuhead Header colorstatusbar.text Infobar colorthememenu.head Select theme colorthememenu.head2 Load themes +colorthememenu.menu_hints Hint box colorthememenu.name Theme name colorthememenu.neutrino_theme Neutrino Theme colorthememenu.question Use selected theme? @@ -587,9 +588,9 @@ flashupdate.fileis0bytes the filesize is 0 Bytes flashupdate.fileselector File-Selector flashupdate.flashreadyreboot The image was successfully flashed.\nThe box will be rebooted now. flashupdate.getinfofile getting versioninfo -flashupdate.getinfofileerror can't get versioninfo +flashupdate.getinfofileerror Can't get update versioninfo! flashupdate.getupdatefile getting update -flashupdate.getupdatefileerror can't get update +flashupdate.getupdatefileerror Can't get update! flashupdate.globalprogress Global Progress: flashupdate.head Software Update flashupdate.md5check checking image diff --git a/data/locale/nederlands.locale b/data/locale/nederlands.locale index 60d32f8ee..7685f5222 100644 --- a/data/locale/nederlands.locale +++ b/data/locale/nederlands.locale @@ -294,6 +294,7 @@ colormenusetup.menuhead Menu kop colorstatusbar.text Infobalk colorthememenu.head Selecteer thema colorthememenu.head2 Thema's laden +colorthememenu.menu_hints Hint box colorthememenu.name Naam thema colorthememenu.neutrino_theme Neutrino Thema colorthememenu.question Geselecteerde thema gebruiken? diff --git a/data/locale/slovak.locale b/data/locale/slovak.locale index b9507ce04..04a5f69f4 100644 --- a/data/locale/slovak.locale +++ b/data/locale/slovak.locale @@ -300,6 +300,7 @@ colormenusetup.menuhead Hlavička colorstatusbar.text Text stavového riadku colorthememenu.head Výber vzhľadu colorthememenu.head2 Nahraj vzhľad +colorthememenu.menu_hints Tip Box colorthememenu.name Názov vzhľadu colorthememenu.neutrino_theme Neutrino colorthememenu.question Použiť vybraný vzhľad? diff --git a/data/themes/Classic.theme b/data/themes/Classic.theme index 2d2562217..d194eb8f6 100644 --- a/data/themes/Classic.theme +++ b/data/themes/Classic.theme @@ -38,3 +38,5 @@ menu_Content_inactive_Text_alpha=0 menu_Content_inactive_Text_red=80 menu_Content_inactive_Text_green=80 menu_Content_inactive_Text_blue=80 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/Crema.theme b/data/themes/Crema.theme index 0abd780bb..5ce2ed3ad 100644 --- a/data/themes/Crema.theme +++ b/data/themes/Crema.theme @@ -38,3 +38,5 @@ menu_Head_alpha=0 menu_Head_blue=28 menu_Head_green=0 menu_Head_red=0 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/DVB2000.theme b/data/themes/DVB2000.theme index 5a9ad7ae7..1f5f73301 100644 --- a/data/themes/DVB2000.theme +++ b/data/themes/DVB2000.theme @@ -38,3 +38,5 @@ menu_Content_inactive_Text_alpha=0 menu_Content_inactive_Text_red=100 menu_Content_inactive_Text_green=100 menu_Content_inactive_Text_blue=0 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/DarkBlue.theme b/data/themes/DarkBlue.theme index 9bc2849d1..fc3a262af 100644 --- a/data/themes/DarkBlue.theme +++ b/data/themes/DarkBlue.theme @@ -38,3 +38,5 @@ menu_Content_inactive_Text_alpha=0 menu_Content_inactive_Text_red=55 menu_Content_inactive_Text_green=70 menu_Content_inactive_Text_blue=85 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/DarkBrown.theme b/data/themes/DarkBrown.theme index 903181d21..b337df705 100644 --- a/data/themes/DarkBrown.theme +++ b/data/themes/DarkBrown.theme @@ -38,3 +38,5 @@ menu_Content_inactive_Text_alpha=0 menu_Content_inactive_Text_red=60 menu_Content_inactive_Text_green=60 menu_Content_inactive_Text_blue=60 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/Gray.theme b/data/themes/Gray.theme index 6356e7d1b..245fa5e93 100644 --- a/data/themes/Gray.theme +++ b/data/themes/Gray.theme @@ -49,3 +49,5 @@ menu_Head_alpha=0 menu_Head_blue=30 menu_Head_green=20 menu_Head_red=15 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/Grey-Blue.theme b/data/themes/Grey-Blue.theme index d274fb352..9a8c9190b 100644 --- a/data/themes/Grey-Blue.theme +++ b/data/themes/Grey-Blue.theme @@ -46,3 +46,5 @@ menu_Head_alpha=4 menu_Head_blue=0 menu_Head_green=0 menu_Head_red=0 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/MonoChrom.theme b/data/themes/MonoChrom.theme index 4ed999dc0..bed644c00 100644 --- a/data/themes/MonoChrom.theme +++ b/data/themes/MonoChrom.theme @@ -38,3 +38,5 @@ menu_Head_alpha=0 menu_Head_blue=0 menu_Head_green=0 menu_Head_red=0 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/Olive.theme b/data/themes/Olive.theme index c30b4eba1..8696172e6 100644 --- a/data/themes/Olive.theme +++ b/data/themes/Olive.theme @@ -38,3 +38,5 @@ menu_Head_alpha=0 menu_Head_blue=80 menu_Head_green=80 menu_Head_red=80 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/Red.theme b/data/themes/Red.theme index 714fea08c..4b1b4ad09 100644 --- a/data/themes/Red.theme +++ b/data/themes/Red.theme @@ -49,3 +49,5 @@ menu_Head_alpha=0 menu_Head_blue=0 menu_Head_green=10 menu_Head_red=40 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/data/themes/VirginMedia.theme b/data/themes/VirginMedia.theme index 23a3b8f21..9fb66a4b2 100644 --- a/data/themes/VirginMedia.theme +++ b/data/themes/VirginMedia.theme @@ -38,3 +38,5 @@ menu_Content_inactive_Text_alpha=0 menu_Content_inactive_Text_red=60 menu_Content_inactive_Text_green=60 menu_Content_inactive_Text_blue=60 +menu_Hint_gradient=0 +menu_Head_gradient=0 diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 6060ddb39..19f927b09 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -1075,7 +1075,7 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in data = g_PicViewer->getIcon(newname, &width, &height); - if(data) { + if(data) { //TODO: intercepting of possible full icon cache, that could cause strange behavior while painting of uncached icons int dsize = width*height*sizeof(fb_pixel_t); //printf("CFrameBuffer::paintIcon: %s found, data %x size %d x %d\n", newname.c_str(), data, width, height);fflush(stdout); if(cache_size+dsize < ICON_CACHE_SIZE) { diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index 3cf0ddb03..d0a2b6ad0 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -117,7 +117,7 @@ void CNeutrinoFonts::SetupDynamicFonts(bool initRenderClass/*=true*/) dynFontStyle[0] = g_dynFontRenderer->AddFont(fontDescr.filename.c_str()); fontDescr.name = g_dynFontRenderer->getFamily(fontDescr.filename.c_str()); - dprintf(DEBUG_NORMAL, " dynamic font family: %s\n", fontDescr.name.c_str()); + dprintf(DEBUG_NORMAL, "[CNeutrinoFonts] [%s - %d] dynamic font family: %s\n", __func__, __LINE__, fontDescr.name.c_str()); dynFontStyle[1] = "Bold Regular"; g_dynFontRenderer->AddFont(fontDescr.filename.c_str(), true); // make italics @@ -135,14 +135,14 @@ void CNeutrinoFonts::SetupNeutrinoFonts(bool initRenderClass/*=true*/) old_fontDescr.size_offset = fontDescr.size_offset; old_fontDescr.filename = fontDescr.filename; fontDescr.filename = ""; - dprintf(DEBUG_NORMAL, "font file: %s\n", g_settings.font_file.c_str()); + dprintf(DEBUG_NORMAL, "[CNeutrinoFonts] [%s - %d] font file: %s\n", __func__, __LINE__, g_settings.font_file.c_str()); if (access(g_settings.font_file.c_str(), F_OK)) { if (!access(FONTDIR"/neutrino.ttf", F_OK)) { fontDescr.filename = FONTDIR"/neutrino.ttf"; g_settings.font_file = fontDescr.filename; } else { - fprintf( stderr,"[neutrino] font file [%s] not found\n neutrino exit\n",FONTDIR"/neutrino.ttf"); + fprintf( stderr,"[CNeutrinoFonts] [%s - %d] font file [%s] not found\n neutrino exit\n", __func__, __LINE__, FONTDIR"/neutrino.ttf"); _exit(0); } } @@ -154,7 +154,7 @@ void CNeutrinoFonts::SetupNeutrinoFonts(bool initRenderClass/*=true*/) old_fontDescr.name = fontDescr.name; fontDescr.name = ""; fontDescr.name = g_fontRenderer->getFamily(fontDescr.filename.c_str()); - dprintf(DEBUG_NORMAL, "standard font family: %s\n", fontDescr.name.c_str()); + dprintf(DEBUG_NORMAL, "[CNeutrinoFonts] [%s - %d] standard font family: %s\n", __func__, __LINE__, fontDescr.name.c_str()); fontStyle[1] = "Bold Regular"; g_fontRenderer->AddFont(fontDescr.filename.c_str(), true); // make italics @@ -209,10 +209,11 @@ void CNeutrinoFonts::refreshDynFont(int dx, int dy, std::string text, int style, Font *dynFont = g_dynFontRenderer->getFont(fontDescr.name.c_str(), dynFontStyle[style].c_str(), dynSize); dyn_font->font = dynFont; dyn_font->size = dynSize; - if (dyn_font->size != dynSize) - printf("##### [%s] change %s_font size old %d to new %d, index: %u\n", __FUNCTION__, (isShare)?"share":"dyn", oldSize, dyn_font->size, index); - else - printf("##### [%s] refresh %s_font size %d, index: %u\n", __FUNCTION__, (isShare)?"share":"dyn", dyn_font->size, index); + if (dyn_font->size != dynSize){ + dprintf(DEBUG_NORMAL, "[CNeutrinoFonts] [%s - %d] change %s_font size old %d to new %d, index: %u\n", __func__, __LINE__, (isShare)?"share":"dyn", oldSize, dyn_font->size, index); + }else{ + dprintf(DEBUG_NORMAL, "[CNeutrinoFonts] [%s - %d] refresh %s_font size %d, index: %u\n",__func__, __LINE__, (isShare)?"share":"dyn", dyn_font->size, index); + } } int CNeutrinoFonts::getFontHeight(Font* fnt) diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index dd696e2d4..8400b1148 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -3,14 +3,14 @@ #include #include "pictureviewer.h" #include "pv_config.h" - +#include #include #include #include #include #include #include - +#include #include #ifdef FBV_SUPPORT_GIF @@ -170,7 +170,7 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign, } m_NextPic_Buffer = (unsigned char *) malloc (x * y * 3); if (m_NextPic_Buffer == NULL) { - printf ("DecodeImage: Error: malloc\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno)); return false; } // dbout("---Decoding Start(%d/%d)\n",x,y); @@ -207,11 +207,11 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign, else m_NextPic_YPan = 0; } else { - printf ("Unable to read file !\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Unable to read file !, %s\n", __func__, __LINE__, strerror(errno)); free (m_NextPic_Buffer); m_NextPic_Buffer = (unsigned char *) malloc (3); if (m_NextPic_Buffer == NULL) { - printf ("DecodeImage: Error: malloc\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno)); return false; } memset (m_NextPic_Buffer, 0, 3); @@ -223,14 +223,14 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign, m_NextPic_YPan = 0; } } else { - printf ("Unable to read file or format not recognized!\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Unable to read file or format not recognized!\n", __func__, __LINE__); if (m_NextPic_Buffer != NULL) { free (m_NextPic_Buffer); m_NextPic_Buffer = NULL; } m_NextPic_Buffer = (unsigned char *) malloc (3); if (m_NextPic_Buffer == NULL) { - printf ("DecodeImage: Error: malloc\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno)); return false; } memset (m_NextPic_Buffer, 0, 3); @@ -304,8 +304,8 @@ void CPictureViewer::Zoom (float factor) int oldx = m_CurrentPic_X; int oldy = m_CurrentPic_Y; unsigned char *oldBuf = m_CurrentPic_Buffer; - m_CurrentPic_X = (int) (factor * m_CurrentPic_X); - m_CurrentPic_Y = (int) (factor * m_CurrentPic_Y); + m_CurrentPic_X = int(factor * (float)m_CurrentPic_X); + m_CurrentPic_Y = int(factor * (float)m_CurrentPic_Y); m_CurrentPic_Buffer = Resize(m_CurrentPic_Buffer, oldx, oldy, m_CurrentPic_X, m_CurrentPic_Y, m_scaling); @@ -379,7 +379,7 @@ CPictureViewer::CPictureViewer () fh_root = NULL; m_scaling = COLOR; //m_aspect = 4.0 / 3; - m_aspect = 16.0 / 9; + m_aspect = float(16.0 / 9.0); m_CurrentPic_Name = ""; m_CurrentPic_Buffer = NULL; m_CurrentPic_X = 0; @@ -436,7 +436,7 @@ void CPictureViewer::showBusy (int sx, int sy, int width, char r, char g, char b fb_buffer = (unsigned char *) CFrameBuffer::getInstance()->convertRGB2FB (rgb_buffer, 1, 1); if (fb_buffer == NULL) { - printf ("showBusy: Error: malloc 1\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc\n", __func__, __LINE__); return; } if (m_busy_buffer != NULL) { @@ -445,7 +445,7 @@ void CPictureViewer::showBusy (int sx, int sy, int width, char r, char g, char b } m_busy_buffer = (unsigned char *) malloc (width * width * cpp); if (m_busy_buffer == NULL) { - printf ("showBusy: Error: malloc 2: \n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc\n", __func__, __LINE__); return; } busy_buffer_wrk = m_busy_buffer; @@ -609,10 +609,10 @@ void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int m aspect = (float)(*width) / (float)(*height); if (((float)(*width) / (float)max_width) > ((float)(*height) / (float)max_height)) { *width = max_width; - *height = (int)(max_width / aspect); + *height = int((float)max_width / aspect); }else{ *height = max_height; - *width = (int)(max_height * aspect); + *width = int((float)max_height * aspect); } } @@ -625,22 +625,27 @@ bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, /* TODO: cache or check for same */ fb_pixel_t * data = getImage(name, width, height); - if (transp > CFrameBuffer::TM_EMPTY) - frameBuffer->SetTransparentDefault(); + if (data){ + if (transp > CFrameBuffer::TM_EMPTY) + frameBuffer->SetTransparentDefault(); - if(data) { - frameBuffer->blit2FB(data, width, height, posx, posy); - cs_free_uncached(data); - return true; + if(data) { + frameBuffer->blit2FB(data, width, height, posx, posy); + cs_free_uncached(data); + return true; + } } return false; } fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width, int *height, bool GetImage) { + if (access(name.c_str(), R_OK) == -1) + return NULL; + int x, y, load_ret, bpp = 0; - CFormathandler *fh; - unsigned char * buffer; + CFormathandler *fh = NULL; + unsigned char * buffer = NULL; fb_pixel_t * ret = NULL; std::string mode_str; @@ -655,8 +660,8 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width, buffer = (unsigned char *) malloc(x * y * 4); if (buffer == NULL) { - printf("%s: Error: malloc\n", mode_str.c_str()); - return 0; + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error: malloc\n", __func__, __LINE__, mode_str.c_str()); + return NULL; } #ifdef FBV_SUPPORT_PNG if ((name.find(".png") == (name.length() - 4)) && (fh_png_id(name.c_str()))) @@ -664,13 +669,15 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width, else #endif load_ret = fh->get_pic(name.c_str (), &buffer, &x, &y); + dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] load_result: %d \n", __func__, __LINE__, load_ret); + if (load_ret == FH_ERROR_OK) { -// printf("%s: decoded %s, %d x %d \n", mode_str.c_str(), name.c_str(), x, y); + dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] mode %s, decoded %s, (Pos: %d %d) ,bpp = %d \n", __func__, __LINE__, mode_str.c_str(), name.c_str(), x, y, bpp); // resize only getImage if ((GetImage) && (x != *width || y != *height)) { - printf("%s: resize %s to %d x %d \n", mode_str.c_str(), name.c_str(), *width, *height); + dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] resize %s to %d x %d \n", __func__, __LINE__, name.c_str(), *width, *height); if (bpp == 4) buffer = ResizeA(buffer, x, y, *width, *height); else @@ -684,11 +691,13 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width, ret = (fb_pixel_t *) CFrameBuffer::getInstance()->convertRGB2FB(buffer, x, y, convertSetupAlpha2Alpha(g_settings.theme.infobar_alpha)); *width = x; *height = y; - }else - printf("%s: Error decoding file %s\n", mode_str.c_str(), name.c_str()); + }else{ + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error decoding file %s\n", __func__, __LINE__, mode_str.c_str(), name.c_str()); + return NULL; + } free(buffer); }else - printf("%s: Error open file %s\n", mode_str.c_str(), name.c_str()); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode: %s, file: %s Error: %s, buffer = %p (Pos: %d %d, Dim: %d x %d)\n", __func__, __LINE__, mode_str.c_str(), name.c_str(), strerror(errno), buffer, x, y, *width, *height); return ret; } @@ -711,7 +720,7 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, if(cr == NULL) { - printf("Resize Error: malloc\n"); + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Resize Error: malloc\n", __func__, __LINE__); return(orgin); } }else @@ -767,7 +776,10 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, r+=q[0]; g+=q[1]; b+=q[2]; a+=q[3]; } } - p[0]=r/sq; p[1]=g/sq; p[2]=b/sq; p[3]=a/sq; + p[0]= uint8_t(r/sq); + p[1]= uint8_t(g/sq); + p[2]= uint8_t(b/sq); + p[3]= uint8_t(a/sq); } } }else @@ -786,7 +798,9 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, r+=q[0]; g+=q[1]; b+=q[2]; } } - p[0]=r/sq; p[1]=g/sq; p[2]=b/sq; + p[0]= uint8_t(r/sq); + p[1]= uint8_t(g/sq); + p[2]= uint8_t(b/sq); } } } diff --git a/src/eitd/SIsections.hpp b/src/eitd/SIsections.hpp index b537cadaf..f5d652c31 100644 --- a/src/eitd/SIsections.hpp +++ b/src/eitd/SIsections.hpp @@ -194,7 +194,7 @@ class SIsectionTIME parsed = 0; parse(buf); } - time_t getTime() { return dvbtime; } + time_t getTime() const { return dvbtime; } int is_parsed(void) const { return parsed; } }; diff --git a/src/eitd/SIservices.hpp b/src/eitd/SIservices.hpp index 186a58861..ee2c1d395 100644 --- a/src/eitd/SIservices.hpp +++ b/src/eitd/SIservices.hpp @@ -121,7 +121,7 @@ public: int eitScheduleFlag(void) { return (int)flags.EIT_schedule_flag; } int eitPresentFollowingFlag(void) { return (int)flags.EIT_present_following_flag; } #endif - int runningStatus(void) { return (int)flags.running_status; } + int runningStatus(void) const { return (int)flags.running_status; } #if 0 // unused int freeCAmode(void) { return (int)flags.free_CA_mode; } diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 7af727702..210489723 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -37,7 +37,7 @@ #include #include #include - +#include #include #include @@ -100,7 +100,7 @@ static bool messaging_zap_detected = false; //NTP-Config #define CONF_FILE CONFIGDIR "/neutrino.conf" -std::string ntp_system_cmd_prefix = "/sbin/ntpdate "; +std::string ntp_system_cmd_prefix = find_executable("ntpdate") + " "; std::string ntp_system_cmd; std::string ntpserver; @@ -1370,12 +1370,12 @@ void CTimeThread::waitForTimeset(void) void CTimeThread::setSystemTime(time_t tim) { struct timeval tv; - + struct tm t; time_t now = time(NULL); - struct tm *tmTime = localtime(&now); + struct tm *tmTime = localtime_r(&now, &t); gettimeofday(&tv, NULL); - timediff = (int64_t)tim * (int64_t)1000000 - (tv.tv_usec + tv.tv_sec * (int64_t)1000000); + timediff = int64_t(tim * 1000000 - (tv.tv_usec + tv.tv_sec * 1000000)); xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff, tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, @@ -1392,8 +1392,8 @@ void CTimeThread::setSystemTime(time_t tim) return; if (timeset && abs(tim - tv.tv_sec) < 120) { /* abs() is int */ struct timeval oldd; - tv.tv_sec = timediff / 1000000LL; - tv.tv_usec = timediff % 1000000LL; + tv.tv_sec = time_t(timediff / 1000000LL); + tv.tv_usec = suseconds_t(timediff % 1000000LL); if (adjtime(&tv, &oldd)) xprintf("adjtime(%d, %d) failed: %m\n", (int)tv.tv_sec, (int)tv.tv_usec); else { @@ -2147,8 +2147,16 @@ bool CEitManager::Start() max_events = config.epg_max_events; epg_save_frequently = config.epg_save_frequently; - if (find_executable("ntpdate").empty()) - ntp_system_cmd_prefix = "ntpd -n -q -p "; + if (find_executable("ntpdate").empty()){ + ntp_system_cmd_prefix = find_executable("ntpd"); + if (!ntp_system_cmd_prefix.empty()){ + ntp_system_cmd_prefix += " -n -q -p "; + } + else{ + printf("[sectionsd] NTP Error: time sync not possible, ntpdate/ntpd not found\n"); + ntpenable = false; + } + } printf("[sectionsd] Caching: %d days, %d hours Extended Text, max %d events, Events are old %d hours after end time\n", config.epg_cache, config.epg_extendedcache, config.epg_max_events, config.epg_old_events); diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 0930ca12b..e4f4cf2a8 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -6,9 +6,10 @@ version.h: echo '#define BUILT_DATE "'`date`'"' > $@ @if test -d $(top_srcdir)/.git ; then \ pushd $(top_srcdir) ; \ - GITDESCRIBE=$$(git describe --always --dirty || echo 'VCS failed') ; \ + GITBRANCH=$$(git rev-parse --abbrev-ref HEAD) ; \ + GITDESCRIBE=$$(git describe --always --tags --dirty || echo 'VCS failed') ; \ popd ; \ - echo '#define VCS "'$${GITDESCRIBE}'"' >> $@ ; \ + echo '#define VCS "'$${GITDESCRIBE} [$${GITBRANCH}]'"' >> $@ ; \ fi noinst_HEADERS = version.h .PHONY: version.h diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 89ac9e7a6..e13edc997 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1142,7 +1142,7 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, listPos++; // show status int global = 100*listPos / maxProgress; - progress.showGlobalStatus(global); + progress.showStatus(global); #ifdef LCD_UPDATE CVFD::getInstance()->showProgressBar(global, "read xmldata..."); CVFD::getInstance()->setMode(CVFD::MODE_PROGRESSBAR); @@ -1238,7 +1238,7 @@ bool CAudioPlayerGui::openFilebrowser(void) currentProgress++; // show status int global = 100*currentProgress/maxProgress; - progress.showGlobalStatus(global); + progress.showStatus(global); progress.showStatusMessageUTF(files->Name); #ifdef LCD_UPDATE CVFD::getInstance()->showProgressBar(global, "read metadata..."); @@ -1432,7 +1432,7 @@ bool CAudioPlayerGui::openSCbrowser(void) currentProgress++; // show progress int global = 100*currentProgress/maxProgress; - progress.showGlobalStatus(global); + progress.showStatus(global); progress.showStatusMessageUTF(files->Name); #ifdef LCD_UPDATE CVFD::getInstance()->showProgressBar(global, "read metadata..."); @@ -1826,10 +1826,6 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos) if (dline != NULL) dline->kill(); - // clear infobox - if (ibox != NULL) - ibox->kill(); - // paint Line if detail info (and not valid list pos) and info box if (!m_playlist.empty() && (pos >= 0)) { @@ -1840,39 +1836,41 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos) dline->paint(false); // paint id3 infobox - if (ibox == NULL) + if (ibox == NULL){ ibox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height); - ibox->setCorner(RADIUS_LARGE); - ibox->setYPos(ypos2); - ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); - ibox->setFrameThickness(2); - ibox->paint(false); + ibox->setFrameThickness(2); + ibox->setCorner(RADIUS_LARGE); + ibox->setYPos(ypos2); + ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); + ibox->forceTextPaint(false); + } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + 10, ypos2 + 2 + 1*m_fheight, m_width- 80, - m_playlist[m_selected].MetaData.title, COL_MENUCONTENTDARK_TEXT); - std::string tmp; + //title + std::string text_info = m_playlist[m_selected].MetaData.title; + + //date, genre if (m_playlist[m_selected].MetaData.genre.empty()) - tmp = m_playlist[m_selected].MetaData.date; + text_info = m_playlist[m_selected].MetaData.date; else if (m_playlist[m_selected].MetaData.date.empty()) - tmp = m_playlist[m_selected].MetaData.genre; + text_info = m_playlist[m_selected].MetaData.genre; else { - tmp = m_playlist[m_selected].MetaData.genre; - tmp += " / "; - tmp += m_playlist[m_selected].MetaData.date; + text_info = m_playlist[m_selected].MetaData.genre; + text_info += " / "; + text_info += m_playlist[m_selected].MetaData.date; } - int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp) + 10; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + m_width - w - 5, ypos2 + 2 + 1*m_fheight, - w, tmp, COL_MENUCONTENTDARK_TEXT); - tmp = m_playlist[m_selected].MetaData.artist; + + //artist, album + text_info = m_playlist[m_selected].MetaData.artist; if (!(m_playlist[m_selected].MetaData.album.empty())) { - tmp += " ("; - tmp += m_playlist[m_selected].MetaData.album; - tmp += ')'; + text_info += " ("; + text_info += m_playlist[m_selected].MetaData.album; + text_info += ')'; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + 10, ypos2 + 2*m_fheight - 2, m_width - 20, - tmp, COL_MENUCONTENTDARK_TEXT); + + ibox->setText(text_info, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO], COL_MENUCONTENT_TEXT); + ibox->paint(false); } else { @@ -2169,7 +2167,7 @@ void CAudioPlayerGui::updateTimes(const bool force) } if ((updatePlayed || updateTotal) && m_curr_audiofile.FileType != CFile::STREAM_AUDIO && m_time_total != 0) { - CVFD::getInstance()->showAudioProgress(100 * m_time_played / m_time_total); + CVFD::getInstance()->showAudioProgress(uint8_t(100 * m_time_played / m_time_total)); } } } @@ -2187,7 +2185,7 @@ void CAudioPlayerGui::paintLCD() CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, m_curr_audiofile.MetaData.album); if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO && m_time_total != 0) - CVFD::getInstance()->showAudioProgress(100 * m_time_played / m_time_total); + CVFD::getInstance()->showAudioProgress(uint8_t(100 * m_time_played / m_time_total)); break; case CAudioPlayerGui::PAUSE: CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_PAUSE); @@ -2330,7 +2328,7 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &fileInfo, CAudiofileExt { fileInfo += "Unknown"; } - file.firstChar = tolower(fileInfo[0]); + file.firstChar = (char)tolower(fileInfo[0]); //info += fileInfo; } @@ -2503,7 +2501,7 @@ void CAudioPlayerGui::buildSearchTree() it!=m_playlist.end(); ++it) { listPos++; - progress.showGlobalStatus(100*listPos / maxProgress); + progress.showStatus(100*listPos / maxProgress); progress.showStatusMessageUTF(it->Filename); unsigned char firstChar = getFirstChar(*it); const std::pair item = diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h index f41dc98c2..6d8db5bbc 100644 --- a/src/gui/audioplayer.h +++ b/src/gui/audioplayer.h @@ -81,7 +81,7 @@ class RandomNumber int operator()(int n) { - return ((int64_t)n * rand() / RAND_MAX); + return (n * rand() / RAND_MAX); } }; diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 39cdfa421..c68d26427 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -41,7 +41,7 @@ #include #include #include -#include + #include #include #include @@ -67,7 +67,7 @@ CBEBouquetWidget::CBEBouquetWidget() state = beDefault; Bouquets = NULL; iheight = 0; - ButtonHeight = 0; + ButtonHeight = footer.getHeight(); fheight = 0; theight = 0; } @@ -138,7 +138,7 @@ void CBEBouquetWidget::paint() void CBEBouquetWidget::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeaderLocalized::CC_BTN_MENU); + CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeaderLocalized::CC_BTN_EXIT); header.paint(CC_SAVE_SCREEN_NO); } @@ -154,12 +154,14 @@ const struct button_label CBEBouquetWidgetButtons[6] = void CBEBouquetWidget::paintFoot() { - ::paintButtons(x, y+height, width, 6, CBEBouquetWidgetButtons, width, ButtonHeight); + size_t numbuttons = sizeof(CBEBouquetWidgetButtons)/sizeof(CBEBouquetWidgetButtons[0]); + footer.paintButtons(x, y+height, width, ButtonHeight, numbuttons, CBEBouquetWidgetButtons, width/numbuttons-20); } void CBEBouquetWidget::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height+ButtonHeight); + frameBuffer->paintBackgroundBoxRel(x,y, width,height); + footer.kill(); } void CBEBouquetWidget::updateSelection(unsigned int newpos) @@ -194,7 +196,6 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* if (parent) parent->hide(); - ButtonHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+8; theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); diff --git a/src/gui/bedit/bouqueteditor_bouquets.h b/src/gui/bedit/bouqueteditor_bouquets.h index f7f2c1f8e..1c935b587 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.h +++ b/src/gui/bedit/bouqueteditor_bouquets.h @@ -38,7 +38,7 @@ #include #include #include - +#include #include /* class for handling when bouquets changed. */ @@ -57,7 +57,7 @@ class CBEBouquetWidget : public CMenuTarget private: CFrameBuffer *frameBuffer; - + CComponentsFooter footer; enum { beDefault, diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index c33646742..8126de0c8 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -44,7 +44,7 @@ #include #include #include "bouqueteditor_chanselect.h" -#include +#include #include #include #include @@ -73,7 +73,7 @@ CBEChannelWidget::CBEChannelWidget(const std::string & Caption, unsigned int Bou theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); - footerHeight= g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; + footerHeight= footer.getHeight(); frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icol_w, &icol_h); iheight = std::max(fheight, icol_h+2); @@ -179,7 +179,7 @@ void CBEChannelWidget::paint() void CBEChannelWidget::paintHead() { - CComponentsHeader header(x, y, width, theight, caption); + CComponentsHeader header(x, y, width, theight, caption, "" /*no header icon*/, CComponentsHeader::CC_BTN_EXIT); header.paint(CC_SAVE_SCREEN_NO); } @@ -196,7 +196,8 @@ const struct button_label CBEChannelWidgetButtons[6] = void CBEChannelWidget::paintFoot() { - ::paintButtons(x, y + (height-footerHeight), width, 6, CBEChannelWidgetButtons, width, footerHeight); + size_t numbuttons = sizeof(CBEChannelWidgetButtons)/sizeof(CBEChannelWidgetButtons[0]); + footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, CBEChannelWidgetButtons, width/numbuttons-20); } std::string CBEChannelWidget::getInfoText(int index) @@ -225,7 +226,7 @@ void CBEChannelWidget::paintDetails(int index) std::string str = getInfoText(index); //info box - ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]); + ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); ibox->paint(CC_SAVE_SCREEN_NO); } @@ -249,19 +250,13 @@ void CBEChannelWidget::initItem2DetailsLine (int pos, int /*ch_index*/) dline->setYPos(ypos1a); //infobox - if (ibox == NULL) + if (ibox == NULL){ ibox = new CComponentsInfoBox(); - - if (ibox->isPainted()) - ibox->hide(CC_SAVE_SCREEN_NO); - - ibox->setDimensionsAll(x, ypos2, width, info_height); - ibox->setFrameThickness(2); -#if 0 - ibox->paint(false,true); -#endif - ibox->setCorner(RADIUS_LARGE); - ibox->setShadowOnOff(CC_SHADOW_OFF); + ibox->setDimensionsAll(x, ypos2, width, info_height); + ibox->setFrameThickness(2); + ibox->setCorner(RADIUS_LARGE); + ibox->setShadowOnOff(CC_SHADOW_OFF); + } } } diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h index 6b834cf7a..fd17636fb 100644 --- a/src/gui/bedit/bouqueteditor_channels.h +++ b/src/gui/bedit/bouqueteditor_channels.h @@ -49,7 +49,7 @@ class CBEChannelWidget : public CMenuTarget CFrameBuffer *frameBuffer; CComponentsDetailLine *dline; CComponentsInfoBox *ibox; - + CComponentsFooter footer; enum state_ { beDefault, diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index fcc12c1d1..0875d657b 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -41,7 +41,7 @@ #include #include #include -#include + #include #include @@ -59,7 +59,7 @@ CBEChannelSelectWidget::CBEChannelSelectWidget(const std::string & Caption, CZap info_height = 0; theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); - footerHeight= g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; + footerHeight= footer.getHeight(); frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_GREEN, &icol_w, &icol_h); iheight = std::max(fheight, icol_h+2); @@ -251,7 +251,8 @@ void CBEChannelSelectWidget::paintFoot() Button[0].locale = LOCALE_CHANNELLIST_FOOT_SORT_ALPHA; break; } - ::paintButtons(x, y + (height-footerHeight), width, numbuttons, Button, width, footerHeight); + + footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, Button, width/numbuttons-20); } std::string CBEChannelSelectWidget::getInfoText(int index) @@ -280,7 +281,7 @@ void CBEChannelSelectWidget::paintDetails(int index) std::string str = getInfoText(index); //info box - ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]); + ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); ibox->paint(false); } diff --git a/src/gui/bedit/bouqueteditor_chanselect.h b/src/gui/bedit/bouqueteditor_chanselect.h index af5ce6743..a4d2ccaeb 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.h +++ b/src/gui/bedit/bouqueteditor_chanselect.h @@ -52,7 +52,7 @@ class CBEChannelSelectWidget : public CListBox bool isChannelInBouquet( int index); CComponentsDetailLine *dline; CComponentsInfoBox *ibox; - + CComponentsFooter footer; uint getItemCount(); void paintItem(uint32_t itemNr, int paintNr, bool selected); void paintDetails(int index); diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 983b6c1cf..0754fd1e5 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1681,9 +1681,16 @@ void CChannelList::showChannelLogo() CChannelLogo->hide(); delete CChannelLogo; } - CChannelLogo = new CComponentsChannelLogo(0, 0, logo_w_max, theight, - (*chanlist)[selected]->getName(), (*chanlist)[selected]->channel_id); - if (CChannelLogo->hasLogo()) { + CChannelLogo = new CComponentsChannelLogoScalable(0, 0, (*chanlist)[selected]->getName(), (*chanlist)[selected]->channel_id); + + if (CChannelLogo->hasLogo()){ + int h_logo = CChannelLogo->getHeight(); + if (h_logo > theight){ //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + uint8_t h_ratio = uint8_t(theight*100/h_logo); + CChannelLogo->setHeight(theight); + int w_logo = h_ratio*CChannelLogo->getWidth()/100; + CChannelLogo->setWidth(min(w_logo, logo_w_max)); + } CChannelLogo->setXPos(x + full_width - logo_off - CChannelLogo->getWidth()); CChannelLogo->setYPos(y + (theight - CChannelLogo->getHeight()) / 2); CChannelLogo->paint(); @@ -2061,7 +2068,7 @@ void CChannelList::paint() void CChannelList::paintHead() { - static int gradient = g_settings.gradiant; + static int gradient = g_settings.theme.menu_Head_gradient; CComponentsHeader header(x, y, full_width, theight, name /*no header icon*/); if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked != g_settings.parentallock_defaultlocked) @@ -2071,8 +2078,8 @@ void CChannelList::paintHead() header.paint(CC_SAVE_SCREEN_NO); - if (gradient != g_settings.gradiant && headerClock != NULL) { - gradient = g_settings.gradiant; + if (gradient != g_settings.theme.menu_Head_gradient && headerClock != NULL) { + gradient = g_settings.theme.menu_Head_gradient; headerClock->clearSavedScreen(); delete headerClock; headerClock = NULL; diff --git a/src/gui/channellist.h b/src/gui/channellist.h index f0d7d0cb9..33a033977 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -127,7 +127,7 @@ private: int ChannelList_Rec; - CComponentsChannelLogo* CChannelLogo; + CComponentsChannelLogoScalable* CChannelLogo; bool headerNew; void paintDetails(int index); diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index aea0dfe3a..deec9ea97 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -65,8 +65,9 @@ CComponents::CComponents() : COSDFader(g_settings.theme.menu_Content_alpha) frameBuffer = CFrameBuffer::getInstance(); v_fbdata.clear(); saved_screen.pixbuf = NULL; - cc_body_gradientBuf = NULL; col_body_gradient = false; + cc_gradientData.gradientBuf = NULL; + cc_gradientData.boxBuf = NULL; } CComponents::~CComponents() @@ -74,8 +75,10 @@ CComponents::~CComponents() hide(); clearSavedScreen(); clearFbData(); - if (cc_body_gradientBuf) - free(cc_body_gradientBuf); + if (cc_gradientData.gradientBuf) + free(cc_gradientData.gradientBuf); + if (cc_gradientData.boxBuf) + cs_free_uncached(cc_gradientData.boxBuf); } void CComponents::clearSavedScreen() @@ -195,7 +198,7 @@ void CComponents::paintFbItems(bool do_save_bg) //calculate current shadow width depends of current corner_rad sw_cur = max(2*v_fbdata[i].r, sw); } - if (cc_allow_paint){ + if (cc_allow_paint && !is_painted){ // shadow right frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT); // shadow bottom @@ -293,11 +296,13 @@ void CComponents::clearFbData() if (v_fbdata[i].pixbuf) delete[] v_fbdata[i].pixbuf; +#if 0 if (v_fbdata[i].data && (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX)) { gradientData_t *gradientData = static_cast (v_fbdata[i].data); if (gradientData->boxBuf) cs_free_uncached(gradientData->boxBuf); } +#endif } v_fbdata.clear(); } @@ -323,5 +328,5 @@ void CComponents::setFrameThickness(const int& thickness, const int& thickness_s void CComponents::enableColBodyGradient(bool do_paint_gradient) { - col_body_gradient = g_settings.gradiant ? do_paint_gradient : false; + col_body_gradient = do_paint_gradient; } diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 35d3e9437..3aa0f740d 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -72,6 +72,7 @@ class CComponents : public CComponentsSignals, public COSDFader void *cc_tag; ///property: color of body fb_pixel_t col_body; + fb_pixel_t old_gradient_color; ///property: color of shadow fb_pixel_t col_shadow; ///property: color of frame @@ -81,8 +82,6 @@ class CComponents : public CComponentsSignals, public COSDFader ///property: contains data for gradiant handling gradientData_t cc_gradientData; - ///gradiant pixel buffer - fb_pixel_t *cc_body_gradientBuf; ///property: true component can paint gradient, see also enableColBodyGradient() bool col_body_gradient; ///property: background gradient mode @@ -251,7 +250,7 @@ class CComponents : public CComponentsSignals, public COSDFader ///allow/disalows paint of item and its contents, but initialize of other properties are not touched ///this can be understood as a counterpart to isPainted(), but before paint and value of is_painted is modified temporarily till next paint of item //TODO: is this sufficiently? - virtual void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;}; + void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;}; ///returns visibility mode virtual bool paintAllowed(){return cc_allow_paint;}; @@ -346,6 +345,10 @@ class CComponentsItem : public CComponents ///returns current number of page location of current item, see: cc_page_number virtual u_int8_t getPageNumber(){return cc_page_number;}; + ///set screen x-position, parameter as int + virtual void setXPos(const int& xpos); + ///set screen y-position, parameter as int + virtual void setYPos(const int& ypos); ///set screen x-position, parameter as uint8_t, percent x value related to current width of parent form or screen virtual void setXPosP(const uint8_t& xpos_percent); ///set screen y-position, parameter as uint8_t, percent y value related to current height of parent form or screen diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index cd916cdc3..fb4b3c779 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -250,6 +250,11 @@ int CComponentsForm::genIndex() CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) { + if (cc_item_id >= size()){ + dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: parameter cc_item_id = %u, out of range (size = %u)...\n", __func__, __LINE__, cc_item_id, size()); + return NULL; + } + if (v_cc_items[cc_item_id]) return v_cc_items[cc_item_id]; return NULL; @@ -363,6 +368,7 @@ void CComponentsForm::paintCCItems() //using of real x/y values to paint items if this text object is bound in a parent form int this_x = x, auto_x = x, this_y = y, auto_y = y, this_w = width; + int w_parent_frame = 0; if (cc_parent){ this_x = auto_x = cc_xr; this_y = auto_y = cc_yr; @@ -404,16 +410,16 @@ void CComponentsForm::paintCCItems() //assign item object CComponentsItem *cc_item = v_cc_items[i]; - dprintf(DEBUG_INFO, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page); - - //get current dimension of item - int w_item = cc_item->getWidth(); - int h_item = cc_item->getHeight(); + dprintf(DEBUG_DEBUG, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page); //get current position of item int xpos = cc_item->getXPos(); int ypos = cc_item->getYPos(); + //get current dimension of item + int w_item = cc_item->getWidth() - (xpos <= fr_thickness ? fr_thickness : 0); + int h_item = cc_item->getHeight() - (ypos <= fr_thickness ? fr_thickness : 0); + //check item for corrupt position, skip current item if found problems if (ypos > height || xpos > this_w){ dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined this_w=%d \ndefinied y=%d, defined height=%d \n", @@ -422,40 +428,53 @@ void CComponentsForm::paintCCItems() continue; } + //move item x-position, if we have a frame on parent, TODO: other constellations not considered at the moment + w_parent_frame = xpos <= fr_thickness ? fr_thickness : 0; + //set required x-position to item: //append vertical if (xpos == CC_APPEND){ auto_x += append_x_offset; - cc_item->setRealXPos(auto_x + xpos); + cc_item->setRealXPos(auto_x + xpos + w_parent_frame); auto_x += w_item; } //positionize vertical centered else if (xpos == CC_CENTERED){ auto_x = this_w/2 - w_item/2; - cc_item->setRealXPos(this_x + auto_x); + cc_item->setRealXPos(this_x + auto_x + w_parent_frame); } else{ - cc_item->setRealXPos(this_x + xpos); + cc_item->setRealXPos(this_x + xpos + w_parent_frame); auto_x = (cc_item->getRealXPos() + w_item); } + //move item y-position, if we have a frame on parent, TODO: other constellations not considered at the moment + w_parent_frame = ypos <= fr_thickness ? fr_thickness : 0; + //set required y-position to item //append hor if (ypos == CC_APPEND){ auto_y += append_y_offset; - cc_item->setRealYPos(auto_y + ypos); + cc_item->setRealYPos(auto_y + ypos + w_parent_frame); auto_y += h_item; } //positionize hor centered else if (ypos == CC_CENTERED){ auto_y = height/2 - h_item/2; - cc_item->setRealYPos(this_y + auto_y); + cc_item->setRealYPos(this_y + auto_y + w_parent_frame); } else{ - cc_item->setRealYPos(this_y + ypos); + cc_item->setRealYPos(this_y + ypos + w_parent_frame); auto_y = (cc_item->getRealYPos() + h_item); } + //reduce corner radius, if we have a frame around parent item, ensure matching corners inside of embedded item, this avoids ugly unpainted spaces between frame and item border + //TODO: other constellations not considered at the moment + if (w_parent_frame){ + if(xpos <= fr_thickness || ypos <= fr_thickness) + cc_item->setCorner(max(0, cc_item->getCornerRadius()-w_parent_frame), cc_item->getCornerType()); + } + //These steps check whether the element can be painted into the container. //Is it too wide or too high, it will be shortened and displayed in the log. //This should be avoid! @@ -535,14 +554,14 @@ void CComponentsForm::setPageCount(const u_int8_t& pageCount) u_int8_t CComponentsForm::getPageCount() { - u_int8_t num = 0; + u_int8_t num = 1; for(size_t i=0; igetPageNumber(); num = max(item_num, num); } //convert type, possible -Wconversion warnings! - page_count = static_cast(num + 1); + page_count = static_cast(num); return page_count; } @@ -608,9 +627,14 @@ CComponentsItem* CComponentsForm::getSelectedItemObject() void CComponentsForm::ScrollPage(int direction, bool do_paint) { + if (getPageCount() == 1){ + cur_page = 0; + return; + } + OnBeforeScrollPage(); - int target_page_id = (int)getPageCount() - 1; + int target_page_id = (int)page_count - 1; int target_page = (int)cur_page; if (direction == SCROLL_P_DOWN) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index cb5d8b322..0d5a3ed17 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -101,21 +101,22 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const height = h; shadow = has_shadow; shadow_w = SHADOW_OFFSET; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - col_body_gradient = g_settings.gradiant; - setColBodyGradient(CColorGradient::gradientDark2Light2Dark, CFrameBuffer::gradientVertical, CColorGradient::light); + col_body_gradient = false/*g_settings.gradiant*/; //gradient is prepared for use but disabled at the moment till some other parts of gui parts are provide gradient + setColBodyGradient(CColorGradient::gradientLight2Dark, CFrameBuffer::gradientVertical, CColorGradient::light); + col_frame = color_frame; + col_body = col_body_gradient? COL_DARK_GRAY : color_body; + col_shadow = color_shadow; cc_item_enabled = enabled; cc_item_selected = selected; fr_thickness = 3; append_x_offset = 6; append_y_offset = 0; - corner_rad = RADIUS_MID; + corner_rad = 0; - cc_btn_capt_col = COL_MENUCONTENT_TEXT; + cc_btn_capt_col = col_body_gradient ? COL_BUTTON_TEXT_ENABLED : COL_INFOBAR_SHADOW_TEXT; + cc_btn_capt_disable_col = col_body_gradient ? COL_BUTTON_TEXT_DISABLED : COL_MENUCONTENTINACTIVE_TEXT; cc_btn_icon_obj = NULL; cc_btn_capt_obj = NULL; cc_btn_dy_font = CNeutrinoFonts::getInstance(); @@ -144,18 +145,25 @@ void CComponentsButton::initIcon() if (cc_btn_icon_obj == NULL){ int w_icon = 0; int h_icon = 0; - frameBuffer->getIconSize(cc_btn_icon.c_str(), &w_icon, &h_icon); + int y_icon = 0; - h_icon = min(height-2*fr_thickness, h_icon); -// if (h_icon != h_max){ -// int ratio = h_icon/h_max; -// cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon; -// cc_btn_icon += ".png"; -// w_icon = w_icon*ratio; -// } - - int y_icon = height/2 - h_icon/2; - cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, w_icon, h_icon, cc_btn_icon, this); + string::size_type pos = cc_btn_icon.find("/", 0); + if (pos == string::npos) + cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon + ".png"; + + cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, cc_btn_icon, this); + h_icon = cc_btn_icon_obj->getHeight(); + + if (h_icon > (height-2*fr_thickness)){ + cc_btn_icon_obj->setHeight(height*80/100); + uint8_t h_ratio = uint8_t(height*100/h_icon); + w_icon = h_ratio*cc_btn_icon_obj->getWidth()/100; + cc_btn_icon_obj->setWidth(w_icon); + } + + y_icon = height/2 - cc_btn_icon_obj->getHeight()/2; + + cc_btn_icon_obj->setYPos(y_icon); cc_btn_icon_obj->doPaintBg(false); } } @@ -184,7 +192,7 @@ void CComponentsButton::initCaption() x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0; int w_cap = width - fr_thickness - append_x_offset - x_cap - fr_thickness; - int h_cap = height - 2*fr_thickness; + int h_cap = height*80/100/* - 2*fr_thickness*/; /*NOTE: paint of centered text in y direction without y_offset @@ -192,7 +200,7 @@ void CComponentsButton::initCaption() but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered! Therefore we here need other icons or a hack, that considers some different height values. */ - int y_cap = height/2 - h_cap/2 - fr_thickness; + int y_cap = height/2 - h_cap/2 + fr_thickness/2; cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap); @@ -204,7 +212,7 @@ void CComponentsButton::initCaption() cc_btn_capt_obj->forceTextPaint(); //here required; //set color - cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT_TEXT : COL_MENUCONTENTINACTIVE_TEXT); + cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? cc_btn_capt_col : cc_btn_capt_disable_col); //corner of text item cc_btn_capt_obj->setCorner(corner_rad-fr_thickness, corner_type); diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 9472c8f33..95d2a9d09 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -35,6 +35,10 @@ #include #include +#define COL_BUTTON_BODY COL_INFOBAR_SHADOW_PLUS_1 +#define COL_BUTTON_TEXT_ENABLED COL_BLACK +#define COL_BUTTON_TEXT_DISABLED COL_LIGHT_GRAY + //! Sub class of CComponentsForm. /*! Shows a button box with caption and optional icon. @@ -74,6 +78,8 @@ class CComponentsButton : public CComponentsFrmChain ///property: text color fb_pixel_t cc_btn_capt_col; + ///property: text color for disabled button + fb_pixel_t cc_btn_capt_disable_col; ///object: text font Font* cc_btn_font; ///object: dynamic font object handler @@ -96,7 +102,7 @@ class CComponentsButton : public CComponentsFrmChain bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const neutrino_locale_t& caption_locale, @@ -105,7 +111,7 @@ class CComponentsButton : public CComponentsFrmChain bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const neutrino_locale_t& caption_locale, @@ -114,7 +120,7 @@ class CComponentsButton : public CComponentsFrmChain bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption, @@ -123,10 +129,10 @@ class CComponentsButton : public CComponentsFrmChain bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ///set text color - virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;}; + virtual void setButtonTextColor(fb_pixel_t text_color, fb_pixel_t text_color_disabled = COL_MENUCONTENTINACTIVE_TEXT){cc_btn_capt_col = text_color; cc_btn_capt_disable_col = text_color_disabled;} ///set caption: parameter as string virtual void setCaption(const std::string& text); @@ -176,7 +182,7 @@ class CComponentsButtonRed : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_RED; @@ -187,7 +193,7 @@ class CComponentsButtonRed : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_RED; @@ -207,7 +213,7 @@ class CComponentsButtonGreen : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_GREEN; @@ -218,7 +224,7 @@ class CComponentsButtonGreen : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_GREEN; @@ -238,7 +244,7 @@ class CComponentsButtonYellow : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW; @@ -249,7 +255,7 @@ class CComponentsButtonYellow : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW; @@ -269,7 +275,7 @@ class CComponentsButtonBlue : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_BLUE; @@ -280,7 +286,7 @@ class CComponentsButtonBlue : public CComponentsButton bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_BLUE; diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 87687b29e..cb84e182c 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -77,11 +77,12 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const col_body = color_body; col_shadow = color_shadow; col_body_gradient = false; + btn_auto_frame_col = false; corner_rad = RADIUS_LARGE; corner_type = CORNER_BOTTOM; - btn_contour = false; + btn_contour = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment ccf_btn_font = NULL; chain = NULL; @@ -146,14 +147,19 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont btn->setButtonResult(content[i].btn_result); btn->setButtonAlias(content[i].btn_alias); - if (btn_name == NEUTRINO_ICON_BUTTON_RED) - btn->setColorFrame(COL_DARK_RED); - if (btn_name == NEUTRINO_ICON_BUTTON_GREEN) - btn->setColorFrame(COL_DARK_GREEN); - if (btn_name == NEUTRINO_ICON_BUTTON_YELLOW) - btn->setColorFrame(COL_OLIVE); - if (btn_name == NEUTRINO_ICON_BUTTON_BLUE) - btn->setColorFrame(COL_DARK_BLUE); + //set button frames to icon color, predefined for available color buttons + if (btn_auto_frame_col){ + fb_pixel_t f_col = btn->getColorFrame(); + if (btn_name == NEUTRINO_ICON_BUTTON_RED) + f_col = COL_DARK_RED; + if (btn_name == NEUTRINO_ICON_BUTTON_GREEN) + f_col = COL_DARK_GREEN; + if (btn_name == NEUTRINO_ICON_BUTTON_YELLOW) + f_col = COL_OLIVE; + if (btn_name == NEUTRINO_ICON_BUTTON_BLUE) + f_col = COL_DARK_BLUE; + btn->setColorFrame(f_col); + } chain->addCCItem(btn); @@ -215,7 +221,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label * const conten setButtonLabels(buttons, label_count, chain_width, label_width); } -void CComponentsFooter::setButtonLabels(const vectorv_content, const int& chain_width, const int& label_width) +void CComponentsFooter::setButtonLabels(const vector &v_content, const int& chain_width, const int& label_width) { size_t label_count = v_content.size(); button_label_l buttons[label_count]; @@ -231,7 +237,7 @@ void CComponentsFooter::setButtonLabels(const vectorv_content, c setButtonLabels(buttons, label_count, chain_width, label_width); } -void CComponentsFooter::setButtonLabels(const vectorv_content, const int& chain_width, const int& label_width) +void CComponentsFooter::setButtonLabels(const vector &v_content, const int& chain_width, const int& label_width) { size_t label_count = v_content.size(); button_label_s buttons[label_count]; diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index 2606a1cca..602c06963 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -69,6 +69,8 @@ class CComponentsFooter : public CComponentsHeader ///show button frame and background, default false bool btn_contour; + ///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled + bool btn_auto_frame_col; ///property: set font for label caption, see also setButtonFont() Font* ccf_btn_font; @@ -91,9 +93,12 @@ class CComponentsFooter : public CComponentsHeader ///add button labels with locale label type as content, count as size_t, chain_width as int, label width as int void setButtonLabels(const struct button_label_l * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0); ///add button labels with locale label type as content, parameter 1 as vector, chain_width as int, label width as int - void setButtonLabels(const std::vectorv_content, const int& chain_width, const int& label_width); + void setButtonLabels(const std::vector &v_content, const int& chain_width, const int& label_width); ///add button labels with string label type as content, parameter 1 as vector, chain_width as int, label width as int - void setButtonLabels(const std::vectorv_content, const int& chain_width, const int& label_width); + void setButtonLabels(const std::vector &v_content, const int& chain_width, const int& label_width); + + ///enable/disable button frame in icon color, predefined for red, green, yellow and blue + inline void enableButtonFrameColor(bool enable = true){btn_auto_frame_col = enable;} ///add button labels with old label type, count as size_t, chain_width as int, label width as int ///NOTE: for compatibility with older button handler find in gui/widget/buttons.h, if possible, don't use this diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index d97ef5057..44c363607 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -98,7 +98,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const col_body = color_body; col_shadow = color_shadow; col_body = COL_MENUHEAD_PLUS_0; - col_body_gradient = g_settings.gradiant; + col_body_gradient = g_settings.theme.menu_Head_gradient; cc_body_gradient_direction = CFrameBuffer::gradientVertical; cch_text = caption; cch_icon_name = icon_name; @@ -205,7 +205,7 @@ void CComponentsHeader::initIcon() //get dimensions of header icon int iw = 0; int ih = 0; - cch_icon_obj->getImageSize(&iw, &ih); + cch_icon_obj->getSize(&iw, &ih); dprintf(DEBUG_INFO, "[CComponentsHeader]\n [%s - %d] init icon size: iw = %d, ih = %d\n", __func__, __LINE__, iw, ih); cch_icon_obj->setWidth(iw); cch_icon_obj->setHeight(ih); diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 4f61cd47a..c8e9a516b 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -33,6 +33,7 @@ #include "cc_base.h" #include #include +#include using namespace std; // y @@ -98,8 +99,7 @@ void CComponentsItem::paintInit(bool do_save_bg) ix = cc_xr; iy = cc_yr; } - - cc_gradientData.boxBuf = NULL; + cc_gradientData.mode = CFrameBuffer::pbrg_noFree; void* gradientData = (cc_gradientData.gradientBuf == NULL) ? NULL : &cc_gradientData; comp_fbdata_t fbdata[] = @@ -194,16 +194,30 @@ bool CComponentsItem::isAdded() return false; } +inline void CComponentsItem::setXPos(const int& xpos) +{ + x = xpos; + if (cc_parent) + setRealXPos(cc_parent->getRealXPos() + x); +} + +inline void CComponentsItem::setYPos(const int& ypos) +{ + y = ypos; + if (cc_parent) + setRealYPos(cc_parent->getRealYPos() + y); +} + void CComponentsItem::setXPosP(const uint8_t& xpos_percent) { int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth(); - x = x_tmp/100; + setXPos(x_tmp/100); } void CComponentsItem::setYPosP(const uint8_t& ypos_percent) { int y_tmp = cc_parent ? ypos_percent*cc_parent->getHeight() : ypos_percent*frameBuffer->getScreenHeight(); - x = y_tmp/100; + setYPos(y_tmp/100); } void CComponentsItem::setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent) @@ -243,12 +257,21 @@ void CComponentsItem::setFocus(bool focus) void CComponentsItem::initBodyGradient() { - if (cc_body_gradientBuf == NULL) { + if (col_body_gradient && cc_gradientData.gradientBuf && old_gradient_color != col_body) { + free(cc_gradientData.gradientBuf); + cc_gradientData.gradientBuf = NULL; + if (cc_gradientData.boxBuf) { + cs_free_uncached(cc_gradientData.boxBuf); + cc_gradientData.boxBuf = NULL; + } + } + if (cc_gradientData.gradientBuf == NULL) { CColorGradient ccGradient; int gsize = cc_body_gradient_direction == CFrameBuffer::gradientVertical ? height : width; - cc_body_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity, cc_body_gradient_intensity_v_min, cc_body_gradient_intensity_v_max, cc_body_gradient_saturation); + cc_gradientData.gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity, cc_body_gradient_intensity_v_min, cc_body_gradient_intensity_v_max, cc_body_gradient_saturation); + old_gradient_color = col_body; } - cc_gradientData.gradientBuf = cc_body_gradientBuf; + cc_gradientData.direction = cc_body_gradient_direction; cc_gradientData.mode = CFrameBuffer::pbrg_noOption; } diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp index d87dc39fb..676a1db3a 100644 --- a/src/gui/components/cc_item_infobox.cpp +++ b/src/gui/components/cc_item_infobox.cpp @@ -95,24 +95,27 @@ void CComponentsInfoBox::setPicture(const char* picture_name) void CComponentsInfoBox::paintPicture() { //ensure empty pic object - if (pic) + if (pic){ delete pic; - pic = NULL; + pic = NULL; + } //exit if no image definied if (pic_name.empty()) return; //init pic object and set icon paint position - pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, ""); - - //define icon - pic->setPicture(pic_name); + pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, min(48, height-2*fr_thickness), pic_name); //NOTE: icons do not scale! - //fit icon into infobox - pic->setHeight(height-2*fr_thickness); pic->setColorBody(col_body); + //set gradient behavior of pic object + if (col_body_gradient) + pic->doPaintBg(false); + + //fit icon into frame + pic->setYPos(y+(height/2-pic->getHeight()/2)); + //paint, but set visibility mode pic->allowPaint(cc_allow_paint); pic->paint(CC_SAVE_SCREEN_NO); @@ -137,22 +140,25 @@ void CComponentsInfoBox::paint(bool do_save_bg) if (!ct_text.empty()){ if (cctext) delete cctext; - - cctext = new CComponentsText(); - cctext->setText(ct_text, ct_text_mode, ct_font); - cctext->doPaintTextBoxBg(ct_paint_textbg); - cctext->doPaintBg(false); - cctext->setTextColor(ct_col_text); - cctext->enableTboxSaveScreen(save_tbox_screen); - - //calculate vars for x-position and dimensions - int tx = x_offset + x_text + pic_w; - int tw = width - x_offset - pic_w - 2*fr_thickness; - int th = height-2*fr_thickness; - cctext->setDimensionsAll(tx, y_text, tw, th); - - //paint, but set visibility mode - cctext->allowPaint(cc_allow_paint); - cctext->paint(CC_SAVE_SCREEN_NO); + cctext = NULL; } + + if (cctext == NULL) + cctext = new CComponentsText(); + + cctext->setText(ct_text, ct_text_mode, ct_font); + cctext->doPaintTextBoxBg(ct_paint_textbg); + cctext->doPaintBg(false); + cctext->setTextColor(ct_col_text); + cctext->enableTboxSaveScreen(save_tbox_screen); + + //calculate vars for x-position and dimensions + int tx = x_offset + x_text + pic_w; + int tw = width - x_offset - pic_w - 2*fr_thickness; + int th = height-2*fr_thickness; + cctext->setDimensionsAll(tx, y_text, tw, th); + + //paint, but set visibility mode + cctext->allowPaint(cc_allow_paint); + cctext->paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/components/cc_item_infobox.h b/src/gui/components/cc_item_infobox.h index da6043757..6a86a6dc6 100644 --- a/src/gui/components/cc_item_infobox.h +++ b/src/gui/components/cc_item_infobox.h @@ -57,9 +57,6 @@ class CComponentsInfoBox : public CComponentsText ///property: path or name of displayed image std::string pic_name; - ///set scale mode of image - bool scale_image; - public: ///object: internal used CTextBox object CComponentsText * cctext; @@ -86,7 +83,8 @@ class CComponentsInfoBox : public CComponentsText void setPicture(const std::string& picture_name); ///set property: path or name of displayed image, parameter as const char* void setPicture(const char* picture_name); - + ///set property: gradient behavior + void enableGradient(bool enable) { col_body_gradient = enable; } ///paint item void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index fb68ee7b2..bca05b38d 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -42,12 +42,12 @@ using namespace std; //------------------------------------------------------------------------------------------------------- //sub class CComponentsPicture from CComponentsItem CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h, - const std::string& image_path, + const std::string& image_name, CComponentsForm *parent, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow, int transparent) { - init(x_pos, y_pos, w, h, image_path, parent, has_shadow, color_frame, color_background, color_shadow, transparent, SCALE); + init(x_pos, y_pos, w, h, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent, SCALE); } CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, @@ -59,6 +59,7 @@ CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, init(x_pos, y_pos, 0, 0, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent, NO_SCALE); } + void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, const int &h, const string& image_name, CComponentsForm *parent, @@ -72,25 +73,20 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, //CComponents x = x_pos; y = y_pos; + width = w; height = h; - width = w; + pic_name = image_name; shadow = has_shadow; shadow_w = SHADOW_OFFSET; col_frame = color_frame; col_body = color_background; col_shadow = color_shadow; - - //CComponentsPicture - pic_name = image_name; + do_scale = allow_scale; is_image_painted= false; do_paint = true; - image_transparent = transparent; - do_scale = allow_scale; - g_PicViewer->getSupportedImageFormats(v_ext); - v_ext.resize(unique(v_ext.begin(), v_ext.end()) - v_ext.begin()); initCCItem(); initParent(parent); } @@ -112,64 +108,66 @@ void CComponentsPicture::setPicture(const char* picture_name) void CComponentsPicture::initCCItem() { - //handle size - int w_pic = width; - int h_pic = height; - - if (pic_name.empty()) + if (pic_name.empty()){ + dprintf(DEBUG_INFO, "[CComponentsPicture] %s - %d : no image file assigned...\n", __func__, __LINE__); return; + } - //check for path or name, set icon or image with full path + //check for path or name, set icon or image with full path, has no path, then use as icon and disble scale mode string::size_type pos = pic_name.find("/", 0); if (pos == string::npos) do_scale = false; - dprintf(DEBUG_INFO, "[CComponentsPicture] %s: detected image file: do_scale: %d (pos= %d), pic_name=%s\n", __func__, do_scale, pos, pic_name.c_str()); + //initial internal size + int w_pic = width; + int h_pic = height; - //get current image size - getImageSize(&w_pic, &h_pic); - - //for icons (names without explicit path) set dimensions of "this" to current image...//TODO: centering image/icon if (!do_scale){ - width = max(w_pic, width); - height = max(h_pic, height); + //use image/icon size as object dimension values + frameBuffer->getIconSize(pic_name.c_str(), &width, &height); } - else{ //defined values in constructor or defined via setters defined, have priority, value 0 is not allowed - if (width == 0) - width = w_pic; - if (height == 0) - height = h_pic; - } - - //resize/scale image if required, if no icon mode detected, use real image size - if (do_scale){ - if (width != w_pic || height != h_pic) { - g_PicViewer->rescaleImageDimensions(&w_pic, &h_pic, width, height); - width = w_pic; - height = h_pic; - } + else{ + //if initialized dimension values = 0, set current object dimension values to real image size otherwise use defined size + g_PicViewer->getSize(pic_name.c_str(), (width == 0 ? &width : &w_pic), (height == 0 ? &height : &h_pic)); + g_PicViewer->rescaleImageDimensions(&w_pic, &h_pic, width, height); } } void CComponentsPicture::initPosition(int *x_position, int *y_position) { - //using of real x/y values to paint images if this picture object is bound in a parent form *x_position = x; *y_position = y; - if (cc_parent){ + if (cc_parent){ //using of real x/y values to paint images if this picture object is bound in a parent form *x_position = cc_xr; *y_position = cc_yr; } } -void CComponentsPicture::getImageSize(int* width_image, int *height_image) +void CComponentsPicture::getSize(int* width_image, int *height_image) { - if (do_scale) - g_PicViewer->getSize(pic_name.c_str(), width_image, height_image); - else + initCCItem(); + if (do_scale){ + *width_image = width; + *height_image = height; + }else{ frameBuffer->getIconSize(pic_name.c_str(), width_image, height_image); + } +} + +int CComponentsPicture::getWidth() +{ + int w, h; + getSize(&w, &h); + return w; +} + +int CComponentsPicture::getHeight() +{ + int w, h; + getSize(&w, &h); + return h; } void CComponentsPicture::paintPicture() @@ -196,6 +194,8 @@ void CComponentsPicture::paintPicture() void CComponentsPicture::paint(bool do_save_bg) { + if (pic_name.empty()) + return; paintInit(do_save_bg); paintPicture(); } @@ -217,8 +217,7 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p "", parent, has_shadow, color_frame, color_background, color_shadow, transparent) { - setChannel(channelId, channelName); - alt_pic_name = ""; + init(channelId, channelName, SCALE); } CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos, @@ -231,18 +230,23 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p "", parent, has_shadow, color_frame, color_background, color_shadow, transparent) { - setChannel(channelId, channelName); - alt_pic_name = ""; + init(channelId, channelName, NO_SCALE); } - +void CComponentsChannelLogo::init(const uint64_t& channelId, const std::string& channelName, bool allow_scale) +{ + alt_pic_name = ""; + setChannel(channelId, channelName); + do_scale = allow_scale; +} void CComponentsChannelLogo::setAltLogo(const std::string& picture_name) { alt_pic_name = picture_name; channel_id = 0; channel_name = ""; - has_logo = true; - initCCItem(); + has_logo = !alt_pic_name.empty(); + if (has_logo) + initCCItem(); } void CComponentsChannelLogo::setAltLogo(const char* picture_name) @@ -261,9 +265,18 @@ void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::st has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, pic_name, &dummy, &dummy); - if (!has_logo) + if (!has_logo)//no logo was found, use altrenate icon or logo pic_name = alt_pic_name; - + + //if logo or alternate image still not available, set has logo to false + has_logo = !pic_name.empty(); + + //refresh object initCCItem(); + + //set has_logo to false if no dimensions were detected + if (width && height) + has_logo = true; + doPaintBg(false); } diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index 00cf5d10c..2f84d0eca 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -86,7 +86,15 @@ class CComponentsPicture : public CComponentsItem void SetTransparent(int t){ image_transparent = t; } public: - ///constructor for image objects, use this for scaled images, scaling dimensions are defined with parameters w (width) and h (height) + /*! + Constructor for image objects: use this for scaled images. + Dimensions are defined with parameters w (width) and h (height). + Note: only dimension values >0 causes scaling of image! + Note: See also class CComponentsPictureScalable(). That does the same like this, but uses internal value 0 for parameters w (width) and h (height). + If scaling is not required, you should use overloaded version that comes without dimension parameters. + If no dimensions are defined (in constructor or e.g. with setWidth() or setHeight(), + width and height are defined by image itself and are retrievable e.g. with getWidth() or getHeight(). + */ CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h, const std::string& image_name, CComponentsForm *parent = NULL, @@ -96,7 +104,13 @@ class CComponentsPicture : public CComponentsItem fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0, int transparent = CFrameBuffer::TM_NONE); - ///constructor for image objects, use this for non scaled images, dimensions are defined by image size + /*! + Constructor for image objects, use this for non scaled images. This is similar with known method paintIcon() from framebuffer class. + Dimensions are defined by image itself. + Note: you can use the dimension setters setWidth() or setHeight() too, but this has only effects for item body, not for image! + If scaling is required, you should use overloaded version above, that comes with dimension parameters or use + class CComponentsPictureScalable(). + */ CComponentsPicture( const int &x_pos, const int &y_pos, const std::string& image_name, CComponentsForm *parent = NULL, @@ -111,18 +125,49 @@ class CComponentsPicture : public CComponentsItem ///sets an image name (unscaled icons only), full image path or url to an image file virtual void setPicture(const char* picture_name); + ///handle image size + virtual void getSize(int* width_image, int *height_image); + ///return width of component + virtual int getWidth(); + ///return height of component + virtual int getHeight(); + + ///set width of object and image, value >0 causes scale of image + virtual void setWidth(const int& w){CComponentsItem::setWidth(w), do_scale = true; initCCItem();} + ///set height of object and image, value >0 causes scale of image + virtual void setHeight(const int& h){CComponentsItem::setHeight(h), do_scale = true; initCCItem();} + ///set width of object and image related to current screen size, see also CComponentsItem::setWidthP(), parameter as uint8_t + virtual void setWidthP(const uint8_t& w_percent){CComponentsItem::setWidthP(w_percent), do_scale = true; initCCItem();} + ///set height of object and image related to current screen size, see also CComponentsItem::setHeightP(), parameter as uint8_t + virtual void setHeightP(const uint8_t& h_percent){CComponentsItem::setHeightP(h_percent), do_scale = true; initCCItem();} + ///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself. virtual inline bool isPicPainted(){return is_image_painted;}; - ///handle image size - void getImageSize(int* width_image, int *height_image); - ///paint item virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); ///hide item virtual void hide(bool no_restore = false); }; +class CComponentsPictureScalable : public CComponentsPicture +{ + public: + /*! + Constructor for image objects: use this for scaled images. + Does the same like class CComponentsPicture() with assigned value 0 for parameters w (width) and h (height). + */ + CComponentsPictureScalable( const int &x_pos, const int &y_pos, + const std::string& image_name, + CComponentsForm *parent = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_background = 0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0, + int transparent = CFrameBuffer::TM_NONE) + : CComponentsPicture(x_pos, y_pos, 0, 0, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent){}; +}; + class CComponentsChannelLogo : public CComponentsPicture { private: @@ -137,7 +182,15 @@ class CComponentsChannelLogo : public CComponentsPicture ///indicates that logo is available, after paint or new instance, value = false bool has_logo; + void init(const uint64_t& channelId, const std::string& channelName, bool allow_scale); + public: + /*! + Constructor for channel image objects: use this for scaled channel logos. + Does the same like class CComponentsPicture() with parameters w (width) and h (height), see above! + Requires parameter channel_name or channelId instead image filename + NOTE: channel name string is prefered! + */ CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h, const std::string& channelName = "", const uint64_t& channelId =0, @@ -147,7 +200,13 @@ class CComponentsChannelLogo : public CComponentsPicture fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0, int transparent = CFrameBuffer::TM_BLACK); - + + /*! + Constructor for channel image objects: use this for non scaled channel logos. + Does the same like class CComponentsPicture() without parameters w (width) and h (height), see above! + Requires parameter channel_name or channelId instead image filename + NOTE: channel name string is prefered! + */ CComponentsChannelLogo( const int &x_pos, const int &y_pos, const std::string& channelName = "", const uint64_t& channelId =0, @@ -171,4 +230,25 @@ class CComponentsChannelLogo : public CComponentsPicture }; +class CComponentsChannelLogoScalable : public CComponentsChannelLogo +{ + public: + /*! + Constructor for channel image objects: use this for scaled channel logos. + Does the same like class CComponentsPictureScalable(), see above! + Requires parameter channel_name or channelId instead image filename. + NOTE: channel name string is prefered! + */ + CComponentsChannelLogoScalable( const int &x_pos, const int &y_pos, + const std::string& channelName = "", + const uint64_t& channelId =0, + CComponentsForm *parent = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_background = 0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0, + int transparent = CFrameBuffer::TM_BLACK) + : CComponentsChannelLogo(x_pos, y_pos, 0, 0, channelName, channelId, parent, has_shadow, color_frame, color_background, color_shadow, transparent){}; +}; + #endif diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 47db76b46..4f7453aec 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -379,9 +379,9 @@ void CProgressBarCache::applyGradient(fb_pixel_t *b) if (v != last_old) { last_old = v; double s = sin((y + .5) * M_PI / pb_height) * .8 + .2; - float fr = ((last_old >> 16) & 0xff) * s + 0.5; - float fg = ((last_old >> 8) & 0xff) * s + 0.5; - float fb = ((last_old ) & 0xff) * s + 0.5; + float fr = float(((last_old >> 16) & 0xff) * s + 0.5); + float fg = float(((last_old >> 8) & 0xff) * s + 0.5); + float fb = float(((last_old ) & 0xff) * s + 0.5); last_new = (last_old & 0xFF000000) | ((unsigned int)fr << 16) | ((unsigned int)fg << 8) @@ -422,11 +422,14 @@ void CProgressBar::paintProgress(bool do_save_bg) //progress bool pb_invert = (pb_type == PB_REDRIGHT) || ((pb_type == PB_TIMESCALE) && g_settings.progressbar_timescale_invert); - if (pb_active_width != pb_last_width) { - CProgressBarCache *pbc = CProgressBarCache::lookup(pb_height, pb_max_width, pb_active_col, pb_passive_col, *pb_design, pb_invert, *pb_gradient, pb_red, pb_yellow, pb_green); - if (pbc) - pbc->paint(pb_x, pb_y, pb_active_width, pb_passive_width); - is_painted = true; + + if (cc_allow_paint){ + if (pb_active_width != pb_last_width) { + CProgressBarCache *pbc = CProgressBarCache::lookup(pb_height, pb_max_width, pb_active_col, pb_passive_col, *pb_design, pb_invert, *pb_gradient, pb_red, pb_yellow, pb_green); + if (pbc) + pbc->paint(pb_x, pb_y, pb_active_width, pb_passive_width); + is_painted = true; + } } if (is_painted) diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 0023cd578..c24e255e0 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -81,6 +81,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w ct_text = text; ct_old_text = ct_text; ct_text_mode = mode; + ct_text_style = FONT_STYLE_REGULAR; iX = x = x_pos; iY = y = y_pos; @@ -180,33 +181,37 @@ void CComponentsText::clearCCText() ct_textbox = NULL; } -void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text) +void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { ct_old_text = ct_text; ct_text = stext; - ct_text_mode = mode; - ct_font = font_text; + if (mode != ~CTextBox::AUTO_WIDTH) + ct_text_mode = mode; + if (font_text) + ct_font = font_text; if (color_text != 0) - ct_col_text = color_text; + setTextColor(color_text); + if (style != FONT_STYLE_REGULAR) + ct_text_style = style; dprintf(DEBUG_DEBUG, "[CComponentsText] [%s - %d] ct_text: %s \n", __func__, __LINE__, ct_text.c_str()); } -void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text) +void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { string stext = g_Locale->getText(locale_text); - setText(stext, mode, font_text, color_text); + setText(stext, mode, font_text, color_text, style); } -void CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text) +void CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { - setText((string)ctext, mode, font_text, color_text); + setText((string)ctext, mode, font_text, color_text, style); } -void CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text) +void CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { string s_digit = iToString(digit); - setText(s_digit, mode, font_text, color_text); + setText(s_digit, mode, font_text, color_text, style); } string CComponentsText::getTextFromFile(const string& path_to_textfile) @@ -230,14 +235,14 @@ string CComponentsText::getTextFromFile(const string& path_to_textfile) } //set text lines directly from a file, returns true on succsess -bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text, const fb_pixel_t& color_text) +bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { string txt = getTextFromFile(path_to_textfile); if (txt.empty()) return false; - setText(txt, mode, font_text, color_text); + setText(txt, mode, font_text, color_text, style); return true; } @@ -298,3 +303,10 @@ int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int& return ret; } + +void CComponentsText::setTextColor(const fb_pixel_t& color_text) +{ + ct_col_text = color_text; + if (ct_textbox) + ct_textbox->setTextColor(ct_col_text); +} diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index feeda5125..96307f2b7 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -45,6 +45,8 @@ class CComponentsText : public CComponentsItem, public CBox CTextBox * ct_textbox; ///object: Fontrenderer object Font * ct_font; + ///property: font style + int ct_text_style; ///property: text color fb_pixel_t ct_col_text; @@ -89,6 +91,12 @@ class CComponentsText : public CComponentsItem, public CBox ///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES); public: + enum { + FONT_STYLE_REGULAR = 0, + FONT_STYLE_BOLD = 1, + FONT_STYLE_ITALIC = 2 + }; + CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50, std::string text = "", const int mode = CTextBox::AUTO_WIDTH, @@ -116,7 +124,7 @@ class CComponentsText : public CComponentsItem, public CBox ///send options for text font (size and type), color and mode (allignment) virtual inline void setTextFont(Font* font_text){ct_font = font_text;}; ///set text color - virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;}; + virtual void setTextColor(const fb_pixel_t& color_text); ///get text color virtual inline fb_pixel_t getTextColor(){return ct_col_text;}; ///set text alignment, also see textbox.h for possible alignment modes @@ -128,15 +136,15 @@ class CComponentsText : public CComponentsItem, public CBox virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; ///set text as string also possible with overloades members for loacales, const char and text file - virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0); + virtual void 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* - virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0); + virtual void setText(const char* ctext, 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 from locale - virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0); + virtual void setText(neutrino_locale_t locale_text, 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 from digit, digit is integer - virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0); + virtual void setText(const int digit, 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 directly from a textfile, path as string is required - virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0); + virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR); ///get text directly from a textfile, path as string is required virtual std::string getTextFromFile(const std::string& path_to_textfile); ///returns current text content of text/label object as std::string diff --git a/src/gui/components/cc_item_tvpic.cpp b/src/gui/components/cc_item_tvpic.cpp index 40ea55adf..8bc4a5ee1 100644 --- a/src/gui/components/cc_item_tvpic.cpp +++ b/src/gui/components/cc_item_tvpic.cpp @@ -101,6 +101,10 @@ void CComponentsPIP::paint(bool do_save_bg) } else{ //paint an alternate image if no tv mode available CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, NULL, false, col_frame, col_frame); + pic.doPaintBg(false); + int w, h; + pic.getSize(&w, &h); + pic.setPos(pig_x + pig_w/2-w/2, pig_y + pig_h/2-h/2); pic.setCorner(corner_rad, corner_type); pic.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/components/cc_signals.h b/src/gui/components/cc_signals.h index 91bc79a5f..4a8cf0bb2 100644 --- a/src/gui/components/cc_signals.h +++ b/src/gui/components/cc_signals.h @@ -111,9 +111,16 @@ class CComponentsSignals : public sigc::trackable ///signal on leave CComponentsForm::ScrollPage() sigc::signal OnAfterScrollPage; + ///signal on before paint() sigc::signal OnBeforePaint; + ///signal on after paint() sigc::signal OnAfterPaint; + ///signal on before execute hide() + sigc::signal OnBeforeHide; + ///signal on after execute hide() + sigc::signal OnAfterHide; + ///signal on CComponentsForm::setSelectedItem() is completed sigc::signal OnSelect; }; diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index d056e0932..a2d30ec75 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -40,7 +40,10 @@ CComponentsTimer::CComponentsTimer( const int& interval) { tm_thread = 0; tm_interval = interval; - startTimer(); + + sl = sigc::mem_fun(*this, &CComponentsTimer::stopTimer); + if (interval > 0) + startTimer(); } CComponentsTimer::~CComponentsTimer() @@ -52,17 +55,14 @@ CComponentsTimer::~CComponentsTimer() //thread handle void* CComponentsTimer::initTimerThread(void *arg) { - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); - CComponentsTimer *timer = static_cast(arg); //start loop while(timer) { timer->mutex.lock(); timer->OnTimer(); - timer->mutex.unlock(); mySleep(timer->tm_interval); + timer->mutex.unlock(); } return 0; @@ -73,14 +73,20 @@ bool CComponentsTimer::startTimer() { void *ptr = static_cast(this); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); + pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); + if(!tm_thread) { int res = pthread_create (&tm_thread, NULL, initTimerThread, ptr) ; if (res != 0){ dprintf(DEBUG_NORMAL,"[CComponentsTimer] [%s] pthread_create %s\n", __func__, strerror(errno)); return false; } + dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval); } - dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval); + + //ensure kill of thread on any restart of neutrino + CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl); return true; } @@ -99,6 +105,8 @@ bool CComponentsTimer::stopTimer() } if (thres == 0){ tm_thread = 0; + //ensure disconnect of unused slot + sl.disconnect(); return true; } diff --git a/src/gui/components/cc_timer.h b/src/gui/components/cc_timer.h index 4151b298c..5be4b252b 100644 --- a/src/gui/components/cc_timer.h +++ b/src/gui/components/cc_timer.h @@ -50,6 +50,8 @@ class CComponentsTimer : public sigc::trackable static void* initTimerThread(void *arg); ///mutex for timer OpenThreads::Mutex mutex; + ///slot for signals + sigc::slot0 sl; public: ///class constructor, parameter interval sets the interval in seconds, default value=1 (1 sec) @@ -62,7 +64,7 @@ class CComponentsTimer : public sigc::trackable bool stopTimer(); ///returns true, if timer is running in thread - bool isRun() const {return tm_thread == 0 ? false:true;}; + bool isRun() const {return tm_thread;}; ///set another interval in seconds void setTimerIntervall(const int& seconds){tm_interval = seconds;}; diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 383f9b828..2594e744e 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -1237,10 +1237,10 @@ void EpgPlus::paint() this->frameBuffer->paintBoxRel (this->sliderX, this->sliderY, this->sliderWidth, this->sliderHeight, COL_MENUCONTENT_PLUS_0); int tmp = ((this->channelList->getSize() - 1) / this->maxNumberOfDisplayableEntries) + 1; - float sliderKnobHeight = (sliderHeight - 4) / tmp; + float sliderKnobHeight = float((sliderHeight - 4) / tmp); int sliderKnobPosition = this->selectedChannelEntry == NULL ? 0 : (this->selectedChannelEntry->index / this->maxNumberOfDisplayableEntries); - this->frameBuffer->paintBoxRel (this->sliderX + 2, this->sliderY + int (sliderKnobPosition * sliderKnobHeight) + this->frameBuffer->paintBoxRel (this->sliderX + 2, this->sliderY + (int(sliderKnobPosition * sliderKnobHeight)) , this->sliderWidth - 4, int (sliderKnobHeight) , COL_MENUCONTENT_PLUS_3); } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index a87a81eff..c83a4f4ad 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -851,71 +851,55 @@ void CEventList::paintDescription(int index) void CEventList::paintHead(t_channel_id _channel_id, std::string _channelname, std::string _channelname_prev, std::string _channelname_next) { - CComponentsHeader* header = NULL; - CComponentsChannelLogo* midLogo = NULL; - CComponentsText* midText = NULL; - CComponentsText* lText = NULL; - CComponentsText* rText = NULL; - int font_mid = SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE; int font_lr = SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE; - header = new CComponentsHeader(x, y, full_width, theight); - header->paint(CC_SAVE_SCREEN_NO); + CComponentsFrmChain header(x, y, full_width, theight); + header.enableColBodyGradient(g_settings.theme.menu_Head_gradient); + header.setCorner(RADIUS_LARGE, CORNER_TOP); - int logo_w_max = full_width / 4; - int name_w = 0; int x_off = 10; - int y_off = std::max((theight - g_Font[font_lr]->getHeight()) / 2, 0); - int x_pos = x; - int y_pos = y; int mid_width = full_width * 40 / 100; // 40% int side_width = ((full_width - mid_width) / 2) - (2 * x_off); - midLogo = new CComponentsChannelLogo(0, 0, logo_w_max, theight, _channelname, _channel_id); + //create an logo object + CComponentsChannelLogo* midLogo = new CComponentsChannelLogo(0, 0, _channelname, _channel_id, &header); if (midLogo->hasLogo()) { - int logo_w = midLogo->getWidth(); - midLogo->setXPos(x + (full_width - logo_w) / 2); - midLogo->setYPos(y + (theight - midLogo->getHeight()) / 2); - midLogo->paint(); + //if logo object has found a logo and was ititialized, the hand it's size + int w_logo = midLogo->getWidth(); + + //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + int h_logo = midLogo->getHeight(); + if (h_logo > theight){ + uint8_t h_ratio = uint8_t(theight*100/h_logo); + midLogo->setHeight(theight); + w_logo = h_ratio*w_logo/100; + midLogo->setWidth(w_logo); + } + midLogo->setPos(CC_CENTERED, CC_CENTERED); + // recalc widths - mid_width = logo_w; - side_width = ((full_width - mid_width) / 2) - (4 * x_off); + side_width = ((full_width - w_logo) / 2) - (4 * x_off); } else { - name_w = g_Font[font_mid]->getRenderWidth(_channelname); - x_pos = x + (full_width - std::min(name_w, mid_width))/2; - y_pos = y; - midText = new CComponentsText(x_pos, y_pos, mid_width, theight, _channelname, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_mid]); + header.removeCCItem(midLogo); //remove/destroy logo object, if it is not available + CComponentsText *midText = new CComponentsText(CC_CENTERED, CC_CENTERED, mid_width, theight, _channelname, CTextBox::CENTER, g_Font[font_mid], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); midText->doPaintBg(false); - midText->setTextColor(COL_MENUHEAD_TEXT); - midText->paint(CC_SAVE_SCREEN_NO); } if (!_channelname_prev.empty()) { - x_pos = x + x_off; - y_pos = y + y_off; - lText = new CComponentsText(x_pos, y_pos, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr]); + CComponentsText *lText = new CComponentsText(x_off, CC_CENTERED, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); lText->doPaintBg(false); - lText->setTextColor(COL_MENUHEAD_TEXT); - lText->paint(CC_SAVE_SCREEN_NO); } if (!_channelname_next.empty()) { - name_w = g_Font[font_lr]->getRenderWidth(_channelname_next); - x_pos = x + full_width - std::min(name_w, side_width) - x_off; - y_pos = y + y_off; - rText = new CComponentsText(x_pos, y_pos, std::min(name_w, side_width), theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr]); + int name_w = std::min(g_Font[font_lr]->getRenderWidth(_channelname_next), side_width); + int x_pos = full_width - name_w - x_off; + CComponentsText *rText = new CComponentsText(x_pos, CC_CENTERED, name_w, theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], &header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); rText->doPaintBg(false); - rText->setTextColor(COL_MENUHEAD_TEXT); - rText->paint(CC_SAVE_SCREEN_NO); } - if (rText) delete rText; - if (lText) delete lText; - if (midText) delete midText; - if (midLogo) delete midLogo; - if (header) delete header; + header.paint(CC_SAVE_SCREEN_NO); } void CEventList::paint(t_channel_id channel_id) diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 8a4c03123..94d06805b 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -185,7 +185,8 @@ void CImageInfo::ShowWindow() cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); footer = cc_win->getFooterObject(); int h_footer = footer->getHeight(); - btn_red = new CComponentsButtonRed(10, CC_CENTERED, 250, h_footer-h_footer/4, LOCALE_BUILDINFO_MENU, footer, false , true, false, footer->getColorBody(), footer->getColorBody()); + fb_pixel_t btn_col = /*g_settings.theme.Button_gradient ? COL_BUTTON_BODY :*/ footer->getColorBody(); //TODO: Button_gradient option + btn_red = new CComponentsButtonRed(10, CC_CENTERED, 250, h_footer-h_footer/4, LOCALE_BUILDINFO_MENU, footer, false , true, false, footer->getColorBody(), btn_col); } //prepare minitv diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 69a8f6777..181bd748c 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1260,12 +1260,20 @@ void CMovieBrowser::refreshMovieInfo(void) CChannelLogo = NULL; } if (old_EpgId != m_movieSelectionHandler->epgEpgId >>16) { - CChannelLogo = new CComponentsChannelLogo(0, 0, logo_w_max, m_cBoxFrameTitleRel.iHeight, - m_movieSelectionHandler->epgChannel, m_movieSelectionHandler->epgEpgId >>16); + CChannelLogo = new CComponentsChannelLogo(0, 0, m_movieSelectionHandler->epgChannel, m_movieSelectionHandler->epgEpgId >>16); old_EpgId = m_movieSelectionHandler->epgEpgId >>16; } if (CChannelLogo && CChannelLogo->hasLogo()) { + //scale image if required, TODO: move into an own handler, eg. header, so channel logo should be paint in header object + int h_logo = CChannelLogo->getHeight(); + if (h_logo > m_cBoxFrameTitleRel.iHeight){ + uint8_t ratio = m_cBoxFrameTitleRel.iHeight*100/h_logo; + CChannelLogo->setHeight(m_cBoxFrameTitleRel.iHeight); + int w_logo = ratio*CChannelLogo->getWidth()/100; + CChannelLogo->setWidth(min(w_logo, logo_w_max)); + } + lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-CChannelLogo->getWidth()-10; ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-CChannelLogo->getHeight())/2; CChannelLogo->setXPos(lx - pb_hdd_offset); diff --git a/src/gui/network_service.cpp b/src/gui/network_service.cpp index 0111f7058..fd14d9318 100644 --- a/src/gui/network_service.cpp +++ b/src/gui/network_service.cpp @@ -140,8 +140,8 @@ int CNetworkServiceSetup::showNetworkServiceSetup() { int shortcut = 1; - CMenuWidget* setup = new CMenuWidget(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width); - setup->setSelected(selected); + CMenuWidget* setup = new CMenuWidget(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_NETWORKSETUP_SERVICES); + setup->addIntroItems(LOCALE_NETWORKMENU_SERVICES); CNetworkService * items[SERVICE_COUNT]; @@ -194,7 +194,7 @@ int CNetworkServiceSetup::showNetworkServiceSetup() } int res = setup->exec (NULL, ""); - selected = setup->getSelected(); + delete setup; for(unsigned i = 0; i < SERVICE_COUNT; i++) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 28a20fa3f..76d5296b3 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -187,12 +187,52 @@ static const struct button_label COPKGManagerFooterButtonsExpert[COPKGManagerFoo { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_OPKG_BUTTON_UNINSTALL } }; +/* TODO: this should go into a config file... */ +static std::string bad_pattern[] = { + "-dev$", + "-doc$", + "-dbg$", + "-ptest$", + "-staticdev$", + "-locale-", + "-charmap-", + "-gconv-", + "-localedata-", + "^locale-base-", + "^perl-module-", + "" +}; + +bool COPKGManager::badpackage(std::string &s) +{ + int i; + for (i = 0; !bad_pattern[i].empty(); i++) + { + std::string p = bad_pattern[i]; + size_t patlen = p.length() - 1; + /* poor man's regex :-) only supported are "^" and "$" */ + if (p.substr(patlen, 1) == "$") { /* match at end */ + if (s.rfind(p.substr(0, patlen)) == (s.length() - patlen)) + return true; + } else if (p.substr(0, 1) == "^") { /* match at beginning */ + if (s.find(p.substr(1)) == 0) + return true; + } else { /* match everywhere */ + if (s.find(p) != std::string::npos) + return true; + } + } + return false; +} + void COPKGManager::updateMenu() { bool upgradesAvailable = false; getPkgData(OM_LIST_INSTALLED); getPkgData(OM_LIST_UPGRADEABLE); for (std::map::iterator it = pkg_map.begin(); it != pkg_map.end(); it++) { + if (badpackage(it->second.name)) + continue; it->second.forwarder->iconName_Info_right = ""; it->second.forwarder->setActive(true); if (it->second.upgradable) { @@ -249,6 +289,8 @@ int COPKGManager::showMenu() pkg_vec.clear(); for (std::map::iterator it = pkg_map.begin(); it != pkg_map.end(); it++) { + if (badpackage(it->second.name)) + continue; it->second.forwarder = new CMenuForwarder(it->second.desc, true, NULL , this, it->second.name.c_str()); it->second.forwarder->setHint("", it->second.desc); menu->addItem(it->second.forwarder); @@ -322,6 +364,8 @@ void COPKGManager::getPkgData(const int pkg_content_id) while (fgets(buf, sizeof(buf), f)) { + if (buf[0] == ' ') + continue; /* second, third, ... line of description will not be shown anyway */ std::string line(buf); trim(line); diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index 26e89afcb..c5f014ea5 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -67,6 +67,7 @@ class COPKGManager : public CMenuTarget int showMenu(); void updateMenu(); void refreshMenu(); + bool badpackage(std::string &s); struct pkg { std::string name; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 1aec4df06..b5de2ee23 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -605,11 +605,6 @@ int COsdSetup::showOsdSetup() mfWindowSize->setHint("", LOCALE_MENU_HINT_WINDOW_SIZE); osd_menu->addItem(mfWindowSize); - // color gradient - mc = new CMenuOptionChooser(LOCALE_COLOR_GRADIENT, &g_settings.gradiant, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true, this ); - mc->setHint("", LOCALE_MENU_HINT_COLOR_GRADIENT); - osd_menu->addItem(mc); - osd_menu->addItem(GenericMenuSeparatorLine); // scrambled @@ -656,6 +651,7 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors) menu_colors->addItem(mf); SNeutrinoTheme &t = g_settings.theme; + sigc::slot0 slot_repaint = sigc::mem_fun(menu_colors, &CMenuWidget::paint); //we want to repaint after changed Option CColorChooser* chHeadcolor = new CColorChooser(LOCALE_COLORMENU_BACKGROUND, &t.menu_Head_red, &t.menu_Head_green, &t.menu_Head_blue, &t.menu_Head_alpha, colorSetupNotifier); @@ -686,6 +682,13 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors) mf->setHint("", LOCALE_MENU_HINT_HEAD_TEXTCOLOR); menu_colors->addItem(mf); + // head color gradient + CMenuOptionChooser *oj; + oj = new CMenuOptionChooser(LOCALE_COLOR_GRADIENT, &g_settings.theme.menu_Head_gradient, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true ); + oj->OnAfterChangeOption.connect(slot_repaint); + oj->setHint("", LOCALE_MENU_HINT_COLOR_GRADIENT); + menu_colors->addItem(oj); + menu_colors->addItem( new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_COLORMENUSETUP_MENUCONTENT)); mf = new CMenuDForwarder(LOCALE_COLORMENU_BACKGROUND, true, NULL, chContentcolor ); mf->setHint("", LOCALE_MENU_HINT_CONTENT_BACK); @@ -713,6 +716,13 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors) mf->setHint("", LOCALE_MENU_HINT_SELECTED_TEXT); menu_colors->addItem(mf); + // hintbox color gradient + menu_colors->addItem( new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_COLORTHEMEMENU_MENU_HINTS)); + oj = new CMenuOptionChooser(LOCALE_COLOR_GRADIENT, &t.menu_Hint_gradient, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + oj->OnAfterChangeOption.connect(slot_repaint); + oj->setHint("", LOCALE_MENU_HINT_COLOR_GRADIENT); + menu_colors->addItem(oj); + CColorChooser* chInfobarcolor = new CColorChooser(LOCALE_COLORMENU_BACKGROUND, &t.infobar_red, &t.infobar_green, &t.infobar_blue, &t.infobar_alpha, colorSetupNotifier); CColorChooser* chInfobarTextcolor = new CColorChooser(LOCALE_COLORMENU_TEXTCOLOR, &t.infobar_Text_red, @@ -1145,10 +1155,6 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) g_InfoViewer->changePB(); return false; } - else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_COLOR_GRADIENT)) { - osd_menu->hide(); - return true; - } else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_OSD_PRESET)) { int preset = * (int *) data; printf("preset %d (setting %d)\n", preset, g_settings.screen_preset); diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 5541800be..6106912e6 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -36,7 +36,7 @@ #include #include "audiomute.h" #include "screensaver.h" - +#include #include extern CInfoClock *InfoClock; @@ -87,9 +87,9 @@ void CScreenSaver::Start() m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY); if (g_settings.video_Format == 3) - m_viewer->SetAspectRatio(16.0/9); + m_viewer->SetAspectRatio(float(16.0/9)); else - m_viewer->SetAspectRatio(4.0/3); + m_viewer->SetAspectRatio(float(4.0/3)); m_viewer->Cleanup(); @@ -167,7 +167,7 @@ bool CScreenSaver::ReadDir() /* open dir */ if((dir=opendir(dir_name)) == NULL) { - fprintf(stderr,"[CScreenSaver] Error opendir ...\n"); + fprintf(stderr,"[CScreenSaver] %s - %d : error open dir...\n", __func__, __LINE__); return ret; } @@ -207,12 +207,12 @@ bool CScreenSaver::ReadDir() /* close pointer */ if(closedir(dir) == -1) - printf("[CScreenSaver] Error no closed %s\n", dir_name); + dprintf(DEBUG_NORMAL, "[CScreenSaver] %s - %d : Error no closed %s\n", __func__, __LINE__, dir_name); if(!v_bg_files.empty()) ret = true; else - printf("[CScreenSaver] no picture found\n"); + dprintf(DEBUG_NORMAL, "[CScreenSaver] %s - %d : no picture found\n", __func__, __LINE__); return ret; } @@ -230,7 +230,7 @@ void CScreenSaver::PaintPicture() return; } - printf("[CScreenSaver] PaintPicture: %s\n", v_bg_files.at(index).c_str()); + dprintf(DEBUG_INFO, "[CScreenSaver] %s - %d : %s\n", __func__, __LINE__, v_bg_files.at(index).c_str()); m_viewer->ShowImage(v_bg_files.at(index).c_str(), false /*unscaled*/); index++; diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 91d018d08..cf66ef895 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -311,6 +311,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) return res; } +#if 0 //some parts DEPRECATED else if (actionKey.find("22kon") != std::string::npos) { int fnum = atoi(actionKey.substr(5, 1).c_str()); @@ -366,6 +367,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) scanTs.exec(NULL, "manual"); return res; } +#endif else if (actionKey == "button"){ if (button == NULL) button = new CComponentsButtonRed(100, 100, 100, 50, "Test"); @@ -796,7 +798,7 @@ void CTestMenu::showHWTests(CMenuWidget *widget) widget->addItem(new CMenuForwarder("Smartcard 2", true, NULL, this, "card1")); widget->addItem(new CMenuForwarder("HDD", true, NULL, this, "hdd")); widget->addItem(new CMenuForwarder("SD/MMC", true, NULL, this, "mmc")); - +#if 0 //some parts DEPRECATED for (unsigned i = 0; i < sizeof(test_pos)/sizeof(int); i++) { CServiceManager::getInstance()->InitSatPosition(test_pos[i], NULL, true); } @@ -843,4 +845,5 @@ void CTestMenu::showHWTests(CMenuWidget *widget) } } CFEManager::getInstance()->linkFrontends(true); +#endif } diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 285092b14..269b248ea 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -163,8 +163,9 @@ int CThemes::Show() CKeyboardInput nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name); CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_green); - if (mkdirhier(THEMEDIR_VAR) && errno != EEXIST) { + if (CFileHelpers::createDir(THEMEDIR_VAR) && errno != EEXIST) { printf("[neutrino theme] error creating %s\n", THEMEDIR_VAR); + } if (access(THEMEDIR_VAR, F_OK) == 0 ) { themes.addItem(GenericMenuSeparatorLine); @@ -244,6 +245,7 @@ void CThemes::setTheme(CConfigFile &configfile) configfile.setInt32( "menu_Head_Text_red", t.menu_Head_Text_red ); configfile.setInt32( "menu_Head_Text_green", t.menu_Head_Text_green ); configfile.setInt32( "menu_Head_Text_blue", t.menu_Head_Text_blue ); + configfile.setInt32( "menu_Head_gradient" , t.menu_Head_gradient); configfile.setInt32( "menu_Content_alpha", t.menu_Content_alpha ); configfile.setInt32( "menu_Content_red", t.menu_Content_red ); configfile.setInt32( "menu_Content_green", t.menu_Content_green ); @@ -268,6 +270,7 @@ void CThemes::setTheme(CConfigFile &configfile) configfile.setInt32( "menu_Content_inactive_Text_red", t.menu_Content_inactive_Text_red ); configfile.setInt32( "menu_Content_inactive_Text_green", t.menu_Content_inactive_Text_green ); configfile.setInt32( "menu_Content_inactive_Text_blue", t.menu_Content_inactive_Text_blue ); + configfile.setInt32( "menu_Hint_gradient" , t.menu_Hint_gradient); configfile.setInt32( "infobar_alpha", t.infobar_alpha ); configfile.setInt32( "infobar_red", t.infobar_red ); configfile.setInt32( "infobar_green", t.infobar_green ); @@ -297,6 +300,7 @@ void CThemes::getTheme(CConfigFile &configfile) t.menu_Head_Text_red = configfile.getInt32( "menu_Head_Text_red", 0x5f ); t.menu_Head_Text_green = configfile.getInt32( "menu_Head_Text_green", 0x46 ); t.menu_Head_Text_blue = configfile.getInt32( "menu_Head_Text_blue", 0x00 ); + t.menu_Head_gradient = configfile.getInt32( "menu_Head_gradient", 1); t.menu_Content_alpha = configfile.getInt32( "menu_Content_alpha", 0x14 ); t.menu_Content_red = configfile.getInt32( "menu_Content_red", 0x00 ); t.menu_Content_green = configfile.getInt32( "menu_Content_green", 0x0f ); @@ -321,6 +325,7 @@ void CThemes::getTheme(CConfigFile &configfile) t.menu_Content_inactive_Text_red = configfile.getInt32( "menu_Content_inactive_Text_red", 55 ); t.menu_Content_inactive_Text_green = configfile.getInt32( "menu_Content_inactive_Text_green", 70 ); t.menu_Content_inactive_Text_blue = configfile.getInt32( "menu_Content_inactive_Text_blue", 85 ); + t.menu_Hint_gradient = configfile.getInt32( "menu_Hint_gradient", 0); t.infobar_alpha = configfile.getInt32( "infobar_alpha", 0x14 ); t.infobar_red = configfile.getInt32( "infobar_red", 0x00 ); t.infobar_green = configfile.getInt32( "infobar_green", 0x0e ); @@ -343,7 +348,7 @@ void CThemes::move_userDir() { if (access(USERDIR, F_OK) == 0) { - if (mkdirhier(THEMEDIR_VAR) && errno != EEXIST) + if (CFileHelpers::createDir(THEMEDIR_VAR) && errno != EEXIST) { printf("[neutrino theme] error creating %s\n", THEMEDIR_VAR); return; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 9198d9559..739be5a19 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -415,18 +415,18 @@ printf("[update] mode is %d\n", softupdate_mode); UpdatesBrowser.Filter = &UpdatesFilter; - CFile * CFileSelected = NULL; + CFile * file_selected = NULL; if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str()))) { menu_ret = UpdatesBrowser.getMenuRet(); return false; } - CFileSelected = UpdatesBrowser.getSelectedFile(); + file_selected = UpdatesBrowser.getSelectedFile(); - if (CFileSelected == NULL) + if (file_selected == NULL) return false; - filename = CFileSelected->Name; + filename = file_selected->Name; FILE* fd = fopen(filename.c_str(), "r"); if(fd) diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index bed085121..66e6a5804 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -48,7 +48,7 @@ void CVolumeBar::initVarVolumeBar() col_body = COL_MENUCONTENT_PLUS_0; vb_item_offset = 4; - height = 4*vb_item_offset; //default height + height = g_settings.volume_size; //default height //assume volume value as pointer to global setting vb_vol = &g_settings.current_volume; @@ -89,14 +89,14 @@ void CVolumeBar::initVolumeBarSize() vb_pbw = 200; vb_pbh = height-4*vb_item_offset; - //adapt x-pos - vb_icon_x = vb_item_offset; - vb_pbx = vb_icon_x + vb_icon_w + vb_item_offset; - vb_digit_x = vb_pbx + vb_pbw + vb_item_offset; - //result for width width = (vb_icon_w + vb_pbw + vb_digit_w) + 4*vb_item_offset; + //adapt x-pos + vb_pbx = vb_item_offset + vb_icon_w + vb_item_offset; + vb_icon_x = vb_pbx/2 - vb_icon_w/2 + vb_item_offset; + vb_digit_x = vb_pbx + vb_pbw + vb_item_offset; + // mute icon cvh->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy); // info clock @@ -173,7 +173,7 @@ void CVolumeBar::initVolumeBarItems() //init current icon object void CVolumeBar::initVolumeBarIcon() { - vb_icon = new CComponentsPicture(vb_icon_x, 0, vb_icon_w, height, NEUTRINO_ICON_VOLUME); + vb_icon = new CComponentsPicture(vb_icon_x, CC_CENTERED, vb_icon_w, height, NEUTRINO_ICON_VOLUME); vb_icon->setColorBody(col_body); vb_icon->setCorner(cornerRad(), CORNER_LEFT); diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 8f758dc45..e2924c173 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -107,7 +107,7 @@ void CColorChooser::setColor() int w_col = mheight*4; int h_col = mheight*4-10; - if ((g_settings.gradiant) && ((chooser_gradient == gradient_head_body) || (chooser_gradient == gradient_head_text))) { + if ((g_settings.theme.menu_Head_gradient) && ((chooser_gradient == gradient_head_body) || (chooser_gradient == gradient_head_text))) { CComponentsHeader header(x_col, y_col+((h_col-hheight)/2), w_col, hheight, "Head"); if (chooser_gradient == gradient_head_body) header.setColorBody(col); @@ -270,7 +270,7 @@ void CColorChooser::paint() for (int i = 0; i < 4; i++) paintSlider(x + 10, y + hheight + mheight * i, value[i], colorchooser_names[i], iconnames[i], (i == 0)); - if ((!g_settings.gradiant) || ((chooser_gradient != gradient_head_body) && (chooser_gradient != gradient_head_text))) { + if ((!g_settings.theme.menu_Head_gradient) || ((chooser_gradient != gradient_head_body) && (chooser_gradient != gradient_head_text))) { //color preview frameBuffer->paintBoxRel(x+offset+160,y+hheight+5, mheight*4, mheight*4-10, COL_MENUHEAD_PLUS_0); frameBuffer->paintBoxRel(x+offset+162,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, 254); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index d7565b616..1303269f1 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -38,7 +38,7 @@ #include #include -#include + #include #include #include @@ -1302,6 +1302,9 @@ void CMenuWidget::paintHint(int pos) if (pos < 0 && !hint_painted) return; + + info_box->enableGradient(g_settings.theme.menu_Hint_gradient != 0); + info_box->setColorBody(COL_MENUCONTENT_PLUS_0); if (hint_painted) { /* clear detailsline line */ @@ -1357,7 +1360,7 @@ void CMenuWidget::paintHint(int pos) info_box->setDimensionsAll(x, ypos2, iwidth, hint_height); info_box->setFrameThickness(2); info_box->removeLineBreaks(str); - info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); + info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT); info_box->setCorner(RADIUS_LARGE); info_box->syncSysColors(); info_box->setColorBody(COL_MENUCONTENTDARK_PLUS_0); @@ -1823,6 +1826,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) } } paint(true); + OnAfterChangeOption(); if(observ && !luaAction.empty()) { if (optionValname) wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 74fd2051e..6d3c20ed4 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -46,6 +46,7 @@ #include #include #include +#include extern "C" { #include #include @@ -354,7 +355,7 @@ struct CMenuOptionChooserCompareItem: public std::binary_function OnAfterChangeOption; int paint(bool selected); int exec(CMenuTarget* parent); @@ -569,7 +570,7 @@ class CMenuWidget : public CMenuTarget virtual int exec(CMenuTarget* parent, const std::string & actionKey); virtual const char *getName(); virtual void integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut=CRCInput::RC_nokey); - void setSelected(const int &Preselected){ preselected = Preselected; }; + void setSelected(const int &Preselected){ selected = Preselected; }; int getSelected()const { return selected; }; void move(int xoff, int yoff); int getSelectedLine(void)const {return exit_pressed ? -1 : selected;}; diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index 20171253f..82169f84e 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -63,6 +63,7 @@ void CProgressWindow::Init() //create local_bar object local_bar = new CProgressBar(); + local_bar->allowPaint(false); local_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); local_bar->setColorBody(col_body); local_bar->setActiveColor(COL_MENUCONTENT_PLUS_7); @@ -73,6 +74,7 @@ void CProgressWindow::Init() //create global_bar object global_bar = new CProgressBar(); + global_bar->allowPaint(false); global_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); global_bar->setColorBody(col_body); global_bar->setActiveColor(COL_MENUCONTENT_PLUS_7); @@ -81,7 +83,8 @@ void CProgressWindow::Init() addWindowItem(global_bar); y_item += 2*h_pbar; - height = y_item + ccw_head->getHeight(); + h_height = ccw_head->getHeight(); + height = y_item + h_height; setCenterPos(); } @@ -95,12 +98,38 @@ void CProgressWindow::setTitle(const neutrino_locale_t title) #endif // VFD_UPDATE } +//if header is disabled we need new position for body items +void CProgressWindow::fitItems() +{ + if (ccw_show_header) + return; + + for(size_t i=0; isize() ;i++){ + int y_item = ccw_body->getCCItem(i)->getYPos() + h_height - 10; + ccw_body->getCCItem(i)->setYPos(y_item); + } +} + +void CProgressWindow::showStatus(const unsigned int prog) +{ + if (global_progress == prog) + return; + + if (!global_bar->isPainted()){ + int g_height = global_bar->getHeight(); + global_bar->setYPos(local_bar->getYPos() + g_height/2); + global_bar->setHeight(g_height + g_height/2); + } + + showGlobalStatus(prog); +} void CProgressWindow::showGlobalStatus(const unsigned int prog) { if (global_progress == prog) return; + global_bar->allowPaint(true); global_progress = prog; global_bar->setValues(prog, 100); global_bar->paint(false); @@ -115,6 +144,7 @@ void CProgressWindow::showLocalStatus(const unsigned int prog) if (local_progress == prog) return; + local_bar->allowPaint(true); local_progress = prog; local_bar->setValues(prog, 100); local_bar->paint(false); @@ -161,3 +191,9 @@ int CProgressWindow::exec(CMenuTarget* parent, const std::string & /*actionKey*/ return menu_return::RETURN_REPAINT; } + +void CProgressWindow::paint(bool do_save_bg) +{ + fitItems(); + CComponentsWindow::paint(do_save_bg); +} diff --git a/src/gui/widget/progresswindow.h b/src/gui/widget/progresswindow.h index 42cbbf32a..5bf54a7ba 100644 --- a/src/gui/widget/progresswindow.h +++ b/src/gui/widget/progresswindow.h @@ -37,8 +37,9 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget unsigned int global_progress; unsigned int local_progress; int w_bar_frame; - + int h_height; void Init(); + void fitItems(); public: @@ -48,10 +49,12 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget virtual int exec( CMenuTarget* parent, const std::string & actionKey ); - virtual void showGlobalStatus(const unsigned int prog); - virtual unsigned int getGlobalStatus(void); - virtual void showLocalStatus(const unsigned int prog); - virtual void showStatusMessageUTF(const std::string & text); // UTF-8 + void showStatus(const unsigned int prog); + void showGlobalStatus(const unsigned int prog); + unsigned int getGlobalStatus(void); + void showLocalStatus(const unsigned int prog); + void showStatusMessageUTF(const std::string & text); // UTF-8 + void paint(bool do_save_bg = true); }; diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 021c4cd95..bbe28d4a3 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -56,7 +56,7 @@ #endif #include - +#include #include "textbox.h" #include @@ -553,13 +553,13 @@ void CTextBox::refreshText(void) //bg variables int ax = m_cFrameTextRel.iX+m_cFrame.iX; - int ay = /*m_cFrameTextRel.iY+*/m_cFrame.iY; + int ay = m_cFrameTextRel.iY+m_cFrame.iY; int dx = m_cFrameTextRel.iWidth; int dy = m_cFrameTextRel.iHeight; //find changes bool has_changed = hasChanged(&ax, &ay, &dx, &dy); - + //destroy pixel buffer on changed property values if (has_changed){ if (m_bgpixbuf){ @@ -569,6 +569,12 @@ void CTextBox::refreshText(void) } } + //detect corrupt position values + if ((ax<=0) || (ay<=0)){ + dprintf(DEBUG_NORMAL, "\033[33m[CTextBox] [%s - %d] ERROR! position out of range: ax = %d, ay = %d, dx = %d, dy = %d\033[0m\n", __func__, __LINE__, ax, ay, dx, dy); + return; + } + //save screen only if no paint of background required if (!m_nPaintBackground && m_SaveScreen) { if (m_bgpixbuf == NULL){ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f10a3554e..00886a63d 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -235,7 +235,8 @@ CNeutrinoApp::CNeutrinoApp() favorites_changed = false; bouquets_changed = false; channels_init = false; - channellist_visible = false; + channelList_allowed = true; + channelList_painted = false; } /*------------------------------------------------------------------------------------- @@ -544,7 +545,7 @@ int CNeutrinoApp::loadSetup(const char * fname) CThemes::getTheme(configfile); - g_settings.gradiant = (configfile.getBool( "gradiant", false ))? 1 : 0; + //personalize g_settings.personalize_pincode = configfile.getString( "personalize_pincode", "0000" ); @@ -1069,7 +1070,7 @@ void CNeutrinoApp::saveSetup(const char * fname) CThemes::setTheme(configfile); - configfile.setBool( "gradiant", (g_settings.gradiant!=0)?true:false ); + //personalize configfile.setString("personalize_pincode", g_settings.personalize_pincode); @@ -1951,9 +1952,7 @@ TIMER_START(); /* later on, we'll crash anyway, so tell about it. */ if (! zapit_init) - ShowMsg(LOCALE_MESSAGEBOX_INFO, - "Zapit initialization failed.\nThis is a fatal error, sorry.", - CMessageBox::mbrBack, CMessageBox::mbBack); + DisplayErrorMessage("Zapit initialization failed. This is a fatal error, sorry."); InitZapitClient(); g_Zapit->setStandby(false); @@ -2496,10 +2495,18 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) int CNeutrinoApp::showChannelList(const neutrino_msg_t _msg, bool from_menu) { + /* Exit here if paint of channlellist is not allowed, disallow could be possible, eg: if + * RC_ok or other stuff is shared with other window handlers and + * it's easy here to disable channellist paint if required! + */ + if (!channelList_allowed){ + channelList_allowed = true; + return menu_return::RETURN_NONE; + } + channelList_painted = true; + neutrino_msg_t msg = _msg; InfoClock->enableInfoClock(false); - channellist_visible = true; - StopSubtitles(); //_show: @@ -2588,7 +2595,8 @@ _repeat: SetChannelMode(LIST_MODE_FAV); } - channellist_visible = false; + channelList_painted = false; + if (!from_menu) InfoClock->enableInfoClock(true); @@ -3875,6 +3883,9 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) return menu_return::RETURN_EXIT_ALL; } else if(actionKey=="restart") { + //usage of slots from any classes + OnBeforeRestart(); + if (recordingstatus) DisplayErrorMessage(g_Locale->getText(LOCALE_SERVICEMENU_RESTART_REFUSED_RECORDING)); else { diff --git a/src/neutrino.h b/src/neutrino.h index 0a704617b..424a05d03 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -39,7 +39,7 @@ #include "gui/personalize.h" #include "gui/user_menue.h" #include - +#include #include #define ANNOUNCETIME (1 * 60) @@ -57,7 +57,7 @@ class CFrameBuffer; class CConfigFile; class CScanSettings; -class CNeutrinoApp : public CMenuTarget, CChangeObserver +class CNeutrinoApp : public CMenuTarget, CChangeObserver, sigc::trackable { public: enum @@ -105,7 +105,8 @@ private: int tvsort[LIST_MODE_LAST]; int radiosort[LIST_MODE_LAST]; - bool channellist_visible; + bool channelList_allowed; + bool channelList_painted; int first_mode_found; void SDT_ReloadChannels(); @@ -219,8 +220,9 @@ public: void saveEpg(bool cvfd_mode); void stopDaemonsForFlash(); int showChannelList(const neutrino_msg_t msg, bool from_menu = false); + void allowChannelList(bool allow){channelList_allowed = allow;} CPersonalizeGui & getPersonalizeGui() { return personalize; } - bool getChannellistIsVisible() { return channellist_visible; } + bool getChannellistIsVisible() { return channelList_painted; } void zapTo(t_channel_id channel_id); bool wakeupFromStandby(void); void standbyToStandby(void); @@ -228,6 +230,8 @@ public: void stopPlayBack(bool lock = false); bool adjustToChannelID(const t_channel_id channel_id); void screensaver(bool); + //signal/event handler before restart of neutrino gui + sigc::signal OnBeforeRestart; }; #endif diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index cb261abab..1318d7402 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -185,6 +185,9 @@ enum MN_WIDGET_ID MN_WIDGET_ID_TESTMENU_HARDWARE, MN_WIDGET_ID_TESTMENU_COMPONENTS, + //network services + MN_WIDGET_ID_NETWORKSETUP_SERVICES, + MN_WIDGET_ID_MAX }; diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 4280c0913..d273f26fe 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -38,19 +38,21 @@ #include #include #include +#include #include #include #include - +#include "debug.h" #include #include +using namespace std; -void mySleep(int sec) { +int mySleep(int sec) { struct timeval timeout; timeout.tv_sec = sec; timeout.tv_usec = 0; - select(0,0,0,0, &timeout); + return select(0,0,0,0, &timeout); } off_t file_size(const char *filename) @@ -215,7 +217,7 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type) } return(fp); } - +#if 0 int mkdirhier(const char *pathname, mode_t mode) { int res = -1; @@ -236,7 +238,7 @@ int mkdirhier(const char *pathname, mode_t mode) res = 0; return res; } - +# endif int safe_mkdir(const char * path) { @@ -338,7 +340,7 @@ std::string find_executable(const char *name) if (tmpPath) path = strdupa(tmpPath); else - path = strdupa("/bin:/usr/bin:/sbin:/usr/sbin"); + path = strdupa("/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"); if (name[0] == '/') { /* full path given */ if (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)) return std::string(name); @@ -421,8 +423,9 @@ std::string getNowTimeStr(const char* format) { char tmpStr[256]; struct timeval tv; + struct tm t; gettimeofday(&tv, NULL); - strftime(tmpStr, sizeof(tmpStr), format, localtime(&tv.tv_sec)); + strftime(tmpStr, sizeof(tmpStr), format, localtime_r(&tv.tv_sec, &t)); return (std::string)tmpStr; } @@ -671,32 +674,25 @@ bool CFileHelpers::copyDir(const char *Src, const char *Dst, bool backupMode) return true; } -bool CFileHelpers::createDir(const char *Dir, mode_t mode) +int CFileHelpers::createDir(string& Dir, mode_t mode) { - char dirPath[PATH_MAX]; - DIR *dir; - if ((dir = opendir(Dir)) != NULL) { - closedir(dir); - errno = EEXIST; - return false; - } - - int ret = -1; - while (ret == -1) { - strcpy(dirPath, Dir); - ret = mkdir(dirPath, mode); - if ((errno == ENOENT) && (ret == -1)) { - char * pos = strrchr(dirPath,'/'); - if (pos != NULL) { - pos[0] = '\0'; - createDir(dirPath, mode); - } + struct stat st; + int res = 0; + for(string::iterator iter = Dir.begin() ; iter != Dir.end();) { + string::iterator newIter = find(iter, Dir.end(), '/' ); + string newPath = string( Dir.begin(), newIter ); + if( !newPath.empty() && stat(newPath.c_str(), &st) != 0) { + res = mkdir( newPath.c_str(), mode); + if (errno == EEXIST) + res = 0; + if(res != 0) + dprintf(DEBUG_NORMAL, "[CFileHelpers %s] creating directory %s: %s\n", __func__, newPath.c_str(), strerror(errno)); } - else - return !ret || (errno == EEXIST); + iter = newIter; + if(newIter != Dir.end()) + ++ iter; } - errno = 0; - return true; + return res; } bool CFileHelpers::removeDir(const char *Dir) @@ -726,6 +722,41 @@ bool CFileHelpers::removeDir(const char *Dir) return true; } +u_int64_t CFileHelpers::getDirSize(const char *dirname) +{ + DIR *dir; + char fullDirName[500]; + struct dirent *dirPnt; + struct stat cur_file; + uint64_t total_size = 0; + + //open current dir + sprintf(fullDirName, "%s/", dirname); + if((dir = opendir(fullDirName)) == NULL) { + fprintf(stderr, "Couldn't open %s\n", fullDirName); + return 0; + } + + //go through the directory + while( (dirPnt = readdir(dir)) != NULL ) { + if(strcmp((*dirPnt).d_name, "..") == 0 || strcmp((*dirPnt).d_name, ".") == 0) + continue; + + //create current filepath + sprintf(fullDirName, "%s/%s", dirname, (*dirPnt).d_name); + if(stat(fullDirName, &cur_file) == -1) + continue; + + if(cur_file.st_mode & S_IFREG) //file... + total_size += cur_file.st_size; + else if(cur_file.st_mode & S_IFDIR) //dir... + total_size += getDirSize(fullDirName); + } + closedir(dir); + + return total_size; +} + static int hdd_open_dev(const char * fname) { FILE * fp; diff --git a/src/system/helpers.h b/src/system/helpers.h index afa14d132..3b9060c60 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -44,15 +44,15 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type); int safe_mkdir(const char * path); inline int safe_mkdir(std::string path) { return safe_mkdir(path.c_str()); } -int mkdirhier(const char *pathname, mode_t mode = 0755); -inline int mkdirhier(std::string path, mode_t mode = 0755) { return mkdirhier(path.c_str(), mode); } +//int mkdirhier(const char *pathname, mode_t mode = 0755); +//inline int mkdirhier(std::string path, mode_t mode = 0755) { return mkdirhier(path.c_str(), mode); } off_t file_size(const char *filename); bool file_exists(const char *filename); void wakeup_hdd(const char *hdd_dir); int check_dir(const char * dir, bool allow_tmp = false); bool get_fs_usage(const char * dir, uint64_t &btotal, uint64_t &bused, long *bsize=NULL); bool get_mem_usage(unsigned long &total, unsigned long &free); -void mySleep(int sec); +int mySleep(int sec); std::string find_executable(const char *name); /* basically what "foo=`command`" does in the shell */ @@ -88,8 +88,11 @@ class CFileHelpers bool copyFile(const char *Src, const char *Dst, mode_t mode); bool copyDir(const char *Src, const char *Dst, bool backupMode=false); - bool createDir(const char *Dir, mode_t mode); - bool removeDir(const char *Dir); + static int createDir(std::string& Dir, mode_t mode = 755); + static int createDir(const char *Dir, mode_t mode = 755){std::string dir = std::string(Dir);return createDir(dir, mode);} + static bool removeDir(const char *Dir); + static uint64_t getDirSize(const char *dir); + static uint64_t getDirSize(const std::string& dir){return getDirSize(dir.c_str());}; }; std::string to_string(int); diff --git a/src/system/locals.h b/src/system/locals.h index 9a80dacc1..0d5177d46 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -327,6 +327,7 @@ typedef enum LOCALE_COLORSTATUSBAR_TEXT, LOCALE_COLORTHEMEMENU_HEAD, LOCALE_COLORTHEMEMENU_HEAD2, + LOCALE_COLORTHEMEMENU_MENU_HINTS, LOCALE_COLORTHEMEMENU_NAME, LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, LOCALE_COLORTHEMEMENU_QUESTION, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 551bc2bdf..a3ed6ffea 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -327,6 +327,7 @@ const char * locale_real_names[] = "colorstatusbar.text", "colorthememenu.head", "colorthememenu.head2", + "colorthememenu.menu_hints", "colorthememenu.name", "colorthememenu.neutrino_theme", "colorthememenu.question", diff --git a/src/system/settings.h b/src/system/settings.h index 5f8ef9855..37c27d6ca 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -60,6 +60,8 @@ struct SNeutrinoTheme unsigned char menu_Head_Text_green; unsigned char menu_Head_Text_blue; + int menu_Head_gradient; + unsigned char menu_Content_alpha; unsigned char menu_Content_red; unsigned char menu_Content_green; @@ -90,6 +92,8 @@ struct SNeutrinoTheme unsigned char menu_Content_inactive_Text_green; unsigned char menu_Content_inactive_Text_blue; + int menu_Hint_gradient; + unsigned char infobar_alpha; unsigned char infobar_red; unsigned char infobar_green; @@ -366,7 +370,6 @@ struct SNeutrinoSettings int colored_events_channellist; int colored_events_infobar; int contrast_fonts; - int gradiant; //network #define NETWORK_NFS_NR_OF_ENTRIES 8 diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index 2bc885346..dcad640e0 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -694,7 +694,7 @@ struct dvb_frontend_event CFrontend::getEvent(void) } else if (event.status & FE_TIMEDOUT) { if(timedout < timer_msec) timedout = timer_msec; - printf("[fe%d] ############################## FE_TIMEDOUT (max %d)\n", fenumber, timedout); + printf("[fe%d] ############################## FE_TIMEDOUT (max %u)\n", fenumber, timedout); /*break;*/ } else { if (event.status & FE_HAS_SIGNAL) diff --git a/src/zapit/src/pzapit.cpp b/src/zapit/src/pzapit.cpp index 269283171..d31e8a718 100644 --- a/src/zapit/src/pzapit.cpp +++ b/src/zapit/src/pzapit.cpp @@ -653,7 +653,7 @@ int main (int argc, char** argv) std::vector::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, ++channel) //std::cout << channel << ": " << ch_resp->name << ": " << ch_resp->channel_id<< std::endl; - printf("%3d: %s (%04x)\n", channel, ch_resp->name, (short) (ch_resp->channel_id &0xFFFF)); + printf("%3u: %s (%04x)\n", channel, ch_resp->name, (short) (ch_resp->channel_id &0xFFFF)); return 0; } }