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); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b2cee1652..05791d791 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2325,61 +2325,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 73fe72f05..a59779b83 100644 --- a/src/gui/moviebrowser.h +++ b/src/gui/moviebrowser.h @@ -430,6 +430,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); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 7117810ff..d80a82fe8 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1447,7 +1447,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; @@ -1457,7 +1457,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; } diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 25139f927..34b137082 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -567,6 +567,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 d952c5ed8..9d0efec01 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 */ @@ -69,6 +71,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);