From cb31f448c3f014bb452301e26cb2a3769a61d422 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 25 Jul 2016 23:55:20 +0200 Subject: [PATCH 1/4] CMenuWidget: use real paint mode of info box Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5788d744c69e56b89f1aa9a98634dc9cd7e07c55 Author: Thilo Graf Date: 2016-07-25 (Mon, 25 Jul 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 607be4f60..a1898b661 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1429,7 +1429,7 @@ void CMenuWidget::paintHint(int pos) /* clear info box */ if ((info_box) && (pos < 0)) savescreen ? info_box->hide() : info_box->kill(); - hint_painted = false; + hint_painted = info_box->isPainted(); } if (pos < 0) return; @@ -1439,7 +1439,7 @@ void CMenuWidget::paintHint(int pos) if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) { if (info_box) { savescreen ? info_box->hide() : info_box->kill(); - hint_painted = false; + hint_painted = info_box->isPainted(); } return; } From 7f737d3199f956f008a14c510d6fa886797bb3aa Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 31 Jul 2016 16:48:23 +0200 Subject: [PATCH 2/4] CCDraw: add comment Add comment where to find corner radius defines Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c317e4dbb4425225f5d19565ed27f070888ad5c0 Author: Thilo Graf Date: 2016-07-31 (Sun, 31 Jul 2016) ------------------ This commit was generated by Migit --- src/gui/components/cc_draw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/components/cc_draw.h b/src/gui/components/cc_draw.h index 9eb925937..08db89f5e 100644 --- a/src/gui/components/cc_draw.h +++ b/src/gui/components/cc_draw.h @@ -236,7 +236,7 @@ class CCDraw : public COSDFader, public CComponentsSignals ///set corner types ///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h) - ///Note: default values are given from settings + ///Note: default values are given from settings and corner radius sizes are predefined in /system/settings.h virtual void setCornerType(const int& type); ///set corner radius and type virtual void setCorner(const int& radius, const int& type = CORNER_ALL); From c3a7bcfd5b39a6d2999373f481935bfffb705c13 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Fri, 12 Aug 2016 19:19:24 +0200 Subject: [PATCH 3/4] src/system/helpers.cpp: Add cutString() function Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/71674d0f8aab183ad93d7220d5e6a8bfa6505588 Author: Michael Liebmann Date: 2016-08-12 (Fri, 12 Aug 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 21 +++++++++++++++++++++ src/system/helpers.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index d77efa230..a45fcfc48 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -438,6 +438,27 @@ std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/) return result.erase(0, result.find_first_not_of(trimChars)); } +std::string cutString(const std::string str, Font *msgFont, const int width) +{ + std::string ret = str; + ret = trim(ret); + int sw = msgFont->getRenderWidth(ret); + if (sw <= width) + return ret; + else { + std::string z = "..."; + int zw = msgFont->getRenderWidth(z); + if (width <= 2*zw) + return ret; + do { + ret = ret.substr(0, ret.length()-1); + sw = msgFont->getRenderWidth(ret); + } while (sw+zw > width); + ret = trim(ret) + z; + } + return ret; +} + std::string strftime(const char *format, const struct tm *tm) { char buf[4096]; diff --git a/src/system/helpers.h b/src/system/helpers.h index 486d1e8e6..5d9efa8d9 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -37,6 +37,8 @@ #include #include +#include + int my_system(const char * cmd); int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */ @@ -67,6 +69,7 @@ std::string getFileName(std::string &file); std::string getFileExt(std::string &file); std::string getNowTimeStr(const char* format); std::string trim(std::string &str, const std::string &trimChars = " \n\r\t"); +std::string cutString(const std::string str, Font *msgFont, const int width); std::string strftime(const char *format, const struct tm *tm); std::string strftime(const char *format, time_t when, bool gm = false); time_t toEpoch(std::string &date); From c7be05d5db1ed09d0b9a41f5ec2c714434eceaf8 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Fri, 12 Aug 2016 19:19:32 +0200 Subject: [PATCH 4/4] moviebrowser: Fix text display in message box when deleting a movie Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4fd7808afd9191f8a8dab491cc9e6151dcc93198 Author: Michael Liebmann Date: 2016-08-12 (Fri, 12 Aug 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/moviebrowser.cpp | 80 ++++++++++++++++++++-------------------- src/gui/moviebrowser.h | 1 + 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 711be53dc..fe76b04af 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2223,61 +2223,61 @@ bool CMovieBrowser::onButtonPressMovieInfoList(neutrino_msg_t msg) return (result); } -bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk) +std::string CMovieBrowser::formatDeleteMsg(MI_MOVIE_INFO *movieinfo, Font *msgFont, const int boxWidth) { - //TRACE("[onDeleteFile] "); - bool result = false; -#if 0 - int test= movieinfo->file.Name.find(".ts", movieinfo->file.Name.length()-3); - if (test == -1) { - // not a TS file, return!!!!! - TRACE("show_ts_info: not a TS file "); - return; - } -#endif - size_t msgMax = 50; + int msgWidth = boxWidth - 20; std::string msg = g_Locale->getText(LOCALE_FILEBROWSER_DODELETE1); - msg += "\n "; + msg += "\n"; + if (!movieinfo->epgTitle.empty()) { - if ((movieinfo->epgTitle.length() + movieinfo->epgInfo1.length()) <= msgMax) { - msg += movieinfo->epgTitle; + int titleW = msgFont->getRenderWidth(movieinfo->epgTitle); + int infoW = 0; + int zW = 0; + if (!movieinfo->epgInfo1.empty()) { + infoW = msgFont->getRenderWidth(movieinfo->epgInfo1); + zW = msgFont->getRenderWidth(" ()"); + } + + if ((titleW+infoW+zW) <= msgWidth) { + /* one line */ + msg += trim(movieinfo->epgTitle); if (!movieinfo->epgInfo1.empty()) { msg += " ("; - msg += movieinfo->epgInfo1; + msg += trim(movieinfo->epgInfo1); msg += ")"; } } else { - if (movieinfo->epgTitle.length() > msgMax) { - msg += movieinfo->epgTitle.substr(0, msgMax); - msg += "..."; - } - else { - msg += movieinfo->epgTitle; - if (!movieinfo->epgInfo1.empty()) { - msg += "\n ("; - if (movieinfo->epgInfo1.length() > msgMax) { - msg = movieinfo->epgInfo1.substr(0, msgMax); - msg += "..."; - } - else - msg += movieinfo->epgInfo1; + /* two lines */ + msg += cutString(movieinfo->epgTitle, msgFont, msgWidth); + if (!movieinfo->epgInfo1.empty()) { + msg += "\n("; + msg += cutString(movieinfo->epgInfo1, msgFont, msgWidth); msg += ")"; - } } } } - else { - if (movieinfo->file.Name.length() > msgMax) { - msg += movieinfo->file.Name.substr(0, msgMax); - msg += "..."; - } - else - msg += movieinfo->file.Name; - } + else + msg += cutString(movieinfo->file.Name, msgFont, msgWidth); + msg += "\n"; msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)) + + return msg; +} + +bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk) +{ + //TRACE("[onDeleteFile] "); + bool result = false; + + /* default font for ShowMsg */ + Font *msgFont = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + /* default width for ShowMsg */ + int msgBoxWidth = 450; + + std::string msg = formatDeleteMsg(movieinfo, msgFont, msgBoxWidth); + if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo, NULL, msgBoxWidth)==CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); hintBox->paint(); diff --git a/src/gui/moviebrowser.h b/src/gui/moviebrowser.h index 2f662334f..01e3ca39a 100644 --- a/src/gui/moviebrowser.h +++ b/src/gui/moviebrowser.h @@ -428,6 +428,7 @@ class CMovieBrowser : public CMenuTarget void onSetGUIWindowNext(void); void onSetGUIWindowPrev(void); bool onDelete(bool cursor_only = false); + std::string formatDeleteMsg(MI_MOVIE_INFO *movieinfo, Font *msgFont, const int boxWidth = 450); bool onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk = false); // P4 bool onSortMovieInfoHandleList(std::vector& pv_handle_list, MB_INFO_ITEM sort_type, MB_DIRECTION direction);