diff options
author | louis <louis.braun@gmx.de> | 2012-12-15 13:09:50 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2012-12-15 13:09:50 +0100 |
commit | 9c6b259eb786439fd4d1bbfdf8bff0bb059f9edd (patch) | |
tree | 9577e50f62d678e3b33b01525756634d9c51903b /menuitem.c | |
parent | a8a2bd61fd2931b79c0f39812ef30a0cc7292d82 (diff) | |
download | skin-nopacity-9c6b259eb786439fd4d1bbfdf8bff0bb059f9edd.tar.gz skin-nopacity-9c6b259eb786439fd4d1bbfdf8bff0bb059f9edd.tar.bz2 |
Introduced scrolling for menus
Diffstat (limited to 'menuitem.c')
-rw-r--r-- | menuitem.c | 625 |
1 files changed, 439 insertions, 186 deletions
@@ -6,39 +6,64 @@ // cNopacityMenuItem ------------- -cNopacityMenuItem::cNopacityMenuItem(cOsd *osd, const char *text, bool cur, bool sel) { +cNopacityMenuItem::cNopacityMenuItem(cOsd *osd, const char *text, bool sel) { this->osd = osd; hasIcon = false; - iconDrawn = false; + drawn = false; Text = text; selectable = sel; - current = cur; + current = false; + wasCurrent = false; + scrollable = false; itemTabs = NULL; tabWidth = NULL; pixmapIcon = NULL; + pixmapTextScroller = NULL; } cNopacityMenuItem::~cNopacityMenuItem(void) { + Cancel(-1); + while (Active()) + cCondWait::SleepMs(10); delete [] itemTabs; delete [] tabWidth; osd->DestroyPixmap(pixmap); if (pixmapIcon) { osd->DestroyPixmap(pixmapIcon); } + if (pixmapTextScroller) { + osd->DestroyPixmap(pixmapTextScroller); + } } -void cNopacityMenuItem::CreatePixmap(int top, int space, int index, int width, int height) { - pixmap = osd->CreatePixmap(3, cRect(space, top + index * (height + space), width, height)); +void cNopacityMenuItem::SetCurrent(bool cur) { + wasCurrent = current; + current = cur; +} + +void cNopacityMenuItem::SetGeometry(int index, int top, int left, int width, int height) { + this->index = index; + this->top = top; + this->left = left; this->width = width; this->height = height; } -void cNopacityMenuItem::CreatePixmapIcon(int top, int space, int index, int itemHeight, int iconWidth, int iconHeight) { - pixmapIcon = osd->CreatePixmap(4, cRect(space, top + index * (itemHeight + space), iconWidth, iconHeight)); +void cNopacityMenuItem::CreatePixmap() { + pixmap = osd->CreatePixmap(3, cRect(left, top + index * (height + left), width, height)); +} + +void cNopacityMenuItem::CreatePixmapIcon(int iconWidth, int iconHeight) { + pixmapIcon = osd->CreatePixmap(5, cRect(left, top + index * (height + left), iconWidth, iconHeight)); pixmapIcon->Fill(clrTransparent); hasIcon = true; } +void cNopacityMenuItem::CreatePixmapTextScroller(int totalWidth) { + pixmapTextScroller = osd->CreatePixmap(4, cRect(left, top + index * (height + left), width, height), cRect(0, 0, totalWidth+10, height)); + pixmapTextScroller->Fill(clrTransparent); +} + void cNopacityMenuItem::SetTabs(cString *tabs, int *tabWidths, int numtabs) { if (itemTabs) delete [] itemTabs; @@ -57,11 +82,15 @@ void cNopacityMenuItem::DrawDelimiter(const char *del, const char *icon, int han pixmap->Fill(Theme.Color(clrMenuItem)); pixmap->DrawImage(cPoint(1, 1), handleBgrd); cImageLoader imgLoader; - if (!iconDrawn) { + if (!drawn) { if (imgLoader.LoadIcon(icon, config.iconHeight)) { + if (pixmapIcon == NULL) { + pixmapIcon = osd->CreatePixmap(5, cRect(left, top + index * (height + left), config.menuItemLogoWidth, config.menuItemLogoWidth)); + pixmapIcon->Fill(clrTransparent); + } pixmapIcon->DrawImage(cPoint(1, (height - config.iconHeight) / 2), imgLoader.GetImage()); } - iconDrawn = true; + drawn = true; } std::string delimiter = del; delimiter.erase(delimiter.find_last_not_of("-")+1); @@ -70,15 +99,66 @@ void cNopacityMenuItem::DrawDelimiter(const char *del, const char *icon, int han pixmap->DrawText(cPoint(x, y), delimiter.c_str(), Theme.Color(clrMenuFontMenuItemSep), clrTransparent, font); } +void cNopacityMenuItem::Action(void) { + int sleepTime = 10; + for (int i = 0; Running() && (i*sleepTime < config.menuScrollDelay); i++) + cCondWait::SleepMs(sleepTime); + cPixmap::Lock(); + if (Running()) + SetTextFull(); + cPixmap::Unlock(); + int drawPortX; + int FrameTime = config.menuScrollFrameTime; + int maxX = pixmapTextScroller->DrawPort().Width() - pixmapTextScroller->ViewPort().Width(); + while (Running()) { + uint64_t Now = cTimeMs::Now(); + cPixmap::Lock(); + drawPortX = pixmapTextScroller->DrawPort().X(); + drawPortX -= 1; + if (abs(drawPortX) > maxX) { + for (int i = 0; Running() && (i*sleepTime < config.menuScrollDelay); i++) + cCondWait::SleepMs(sleepTime); + drawPortX = 0; + } + if (Running()) + pixmapTextScroller->SetDrawPortPoint(cPoint(drawPortX, 0)); + cPixmap::Unlock(); + int Delta = cTimeMs::Now() - Now; + if (Running()) + osd->Flush(); + if (Running() && (Delta < FrameTime)) + cCondWait::SleepMs(FrameTime - Delta); + } +} + // cNopacityMainMenuItem ------------- -cNopacityMainMenuItem::cNopacityMainMenuItem(cOsd *osd, const char *text, bool cur, bool sel) : cNopacityMenuItem (osd, text, cur, sel) { +cNopacityMainMenuItem::cNopacityMainMenuItem(cOsd *osd, const char *text, bool sel) : cNopacityMenuItem (osd, text, sel) { } cNopacityMainMenuItem::~cNopacityMainMenuItem(void) { } -void cNopacityMainMenuItem::SplitMenuItem() { +std::string cNopacityMainMenuItem::items[6] = {"Schedule", "Channels", "Timers", "Recordings", "Setup", "Commands"}; + +cString cNopacityMainMenuItem::GetIconName() { + std::string element = *menuEntry; + for (int i=0; i<6; i++) { + std::string s = trVDR(items[i].c_str()); + if (s == element) + return items[i].c_str(); + } + return menuEntry; +} + +void cNopacityMainMenuItem::CreatePixmapTextScroller(int totalWidth) { + int drawPortWidth = totalWidth + 10; + if (hasIcon) + drawPortWidth += config.iconHeight + 10; + pixmapTextScroller = osd->CreatePixmap(4, cRect(left, top + index * (height + left), width, height), cRect(0, 0, drawPortWidth, height)); + pixmapTextScroller->Fill(clrTransparent); +} +void cNopacityMainMenuItem::CreateText() { std::string text = skipspace(Text); bool found = false; bool doBreak = false; @@ -105,81 +185,105 @@ void cNopacityMainMenuItem::SplitMenuItem() { menuNumber = ""; menuEntry = text.c_str(); } + strEntry = *menuEntry; } -std::string cNopacityMainMenuItem::items[6] = {"Schedule", "Channels", "Timers", "Recordings", "Setup", "Commands"}; - -cString cNopacityMainMenuItem::GetIconName() { - std::string element = *menuEntry; - for (int i=0; i<6; i++) { - std::string s = trVDR(items[i].c_str()); - if (s == element) - return items[i].c_str(); +int cNopacityMainMenuItem::CheckScrollable(bool hasIcon) { + int spaceLeft = left; + if (hasIcon) + spaceLeft += config.iconHeight; + int totalTextWidth = width - spaceLeft; + int numberWidth = font->Width("xxx"); + int textWidth = font->Width(*menuEntry); + if ((numberWidth + textWidth) > (width - spaceLeft)) { + scrollable = true; + totalTextWidth = max(numberWidth + textWidth, totalTextWidth); + strEntryFull = strEntry.c_str(); + cTextWrapper twEntry; + std::stringstream sstrEntry; + twEntry.Set(strEntry.c_str(), font, width - spaceLeft - numberWidth); + sstrEntry << twEntry.GetLine(0) << "..."; + strEntry = sstrEntry.str(); } - return menuEntry; + return totalTextWidth; } -void cNopacityMainMenuItem::Render() { - - pixmap->Fill(Theme.Color(clrMenuBorder)); - int handleBgrd = (current)?handleBackgrounds[3]:handleBackgrounds[2]; +void cNopacityMainMenuItem::SetTextFull(void) { tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); - pixmap->DrawImage(cPoint(1, 1), handleBgrd); - SplitMenuItem(); - cString cIcon = GetIconName(); - if (!iconDrawn) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon(*cIcon, config.iconHeight)) { - pixmapIcon->DrawImage(cPoint(1, 1), imgLoader.GetImage()); - } - iconDrawn = true; - } - + pixmapTextScroller->Fill(clrTransparent); int x = config.iconHeight; int numberTotalWidth = font->Width("xxx"); int numberWidth = font->Width(*menuNumber); - pixmap->DrawText(cPoint(x + (numberTotalWidth - numberWidth)/2, (height - font->Height())/2), *menuNumber, clrFont, clrTransparent, font); + pixmapTextScroller->DrawText(cPoint(x + (numberTotalWidth - numberWidth)/2, (height - font->Height())/2), *menuNumber, clrFont, clrTransparent, font); x += numberTotalWidth; + pixmapTextScroller->DrawText(cPoint(x, (height - font->Height())/2), strEntryFull.c_str(), clrFont, clrTransparent, font); +} - int textWidth = font->Width(*menuEntry); - if (textWidth <= width - x) { - pixmap->DrawText(cPoint(x, (height - font->Height())/2), *menuEntry, clrFont, clrTransparent, font); +void cNopacityMainMenuItem::SetTextShort(void) { + tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); + pixmapTextScroller->Fill(clrTransparent); + int x = config.iconHeight; + int numberTotalWidth = font->Width("xxx"); + int numberWidth = font->Width(*menuNumber); + pixmapTextScroller->DrawText(cPoint(x + (numberTotalWidth - numberWidth)/2, (height - font->Height())/2), *menuNumber, clrFont, clrTransparent, font); + x += numberTotalWidth; + pixmapTextScroller->DrawText(cPoint(x, (height - font->Height())/2), strEntry.c_str(), clrFont, clrTransparent, font); +} + +void cNopacityMainMenuItem::Render() { + pixmap->Fill(Theme.Color(clrMenuBorder)); + int handleBgrd = (current)?handleBackgrounds[3]:handleBackgrounds[2]; + pixmap->DrawImage(cPoint(1, 1), handleBgrd); + if (selectable) { + cString cIcon = GetIconName(); + if (!drawn) { + cImageLoader imgLoader; + if (imgLoader.LoadIcon(*cIcon, config.iconHeight)) { + pixmapIcon->DrawImage(cPoint(1, 1), imgLoader.GetImage()); + } + drawn = true; + } + SetTextShort(); + if (current && scrollable && config.menuScrollSpeed) { + Start(); + } + if (wasCurrent && scrollable && Running()) { + pixmapTextScroller->SetDrawPortPoint(cPoint(0, 0)); + SetTextShort(); + Cancel(-1); + } } else { - cTextWrapper menuText; - menuText.Set(*menuEntry, font, width - x); - //max. 2 lines - pixmap->DrawText(cPoint(x, (height/2 - font->Height()) / 2 ), menuText.GetLine(0), clrFont, clrTransparent, font); - pixmap->DrawText(cPoint(x, (height/2 - font->Height()) / 2 + height/2), menuText.GetLine(1), clrFont, clrTransparent, font); + DrawDelimiter(*itemTabs[1], "Channelseparator", handleBgrd); } } // cNopacityScheduleMenuItem ------------- -cNopacityScheduleMenuItem::cNopacityScheduleMenuItem(cOsd *osd, const char *text, bool cur, bool sel, eMenuSubCategory subCat) : cNopacityMenuItem (osd, text, cur, sel) { +cNopacityScheduleMenuItem::cNopacityScheduleMenuItem(cOsd *osd, const char *text, bool sel, eMenuSubCategory subCat) : cNopacityMenuItem (osd, text, sel) { subCategory = subCat; + strDateTime = ""; + strTitle = ""; + strSubTitle = ""; + strTitleFull = ""; + strSubTitleFull = ""; + strProgressbar = ""; + hasProgressBar = false; + hasLogo = false; + delimiterType = "daydelimiter"; } cNopacityScheduleMenuItem::~cNopacityScheduleMenuItem(void) { } -void cNopacityScheduleMenuItem::Render() { - int logoWidth = config.menuItemLogoWidth; - int logoHeight = config.menuItemLogoHeight; - std::stringstream sstrDateTime; - std::string strTitle; - std::string strSubtitle; - std::string strChannelName; - std::string strProgressbar; - eEPGModes mode; - bool hasLogo = false; - int left = 5; - std::string delimiterType = "daydelimiter"; - bool hasProgressBar = false; - int handleBgrd = (current)?handleBackgrounds[5]:handleBackgrounds[4]; - - pixmap->Fill(Theme.Color(clrMenuBorder)); - pixmap->DrawImage(cPoint(1, 1), handleBgrd); - +void cNopacityScheduleMenuItem::CreatePixmapTextScroller(int totalWidth) { + int drawPortWidth = totalWidth + 10; + if (hasIcon) + drawPortWidth += config.menuItemLogoWidth + 10; + pixmapTextScroller = osd->CreatePixmap(4, cRect(left, top + index * (height + left), width, height), cRect(0, 0, drawPortWidth, height)); + pixmapTextScroller->Fill(clrTransparent); +} + +void cNopacityScheduleMenuItem::SetDisplayMode(void) { switch (subCategory) { case mcSubSchedule: mode = eMenuSchedule; @@ -215,98 +319,145 @@ void cNopacityScheduleMenuItem::Render() { mode = eMenuSchedule; break; } - - if (hasLogo) - left = logoWidth + 10; - - if (selectable) { - //Build Date & Time & Status - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGdate] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGdate] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGdate]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGstatus] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGstatus] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGstatus]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGt_status] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGt_status] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGt_status]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGv_status] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGv_status] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGv_status]] << " "; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGr_status] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGr_status] < MAXITEMTABS)) - sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGr_status]] << " "; - //Build title and subtitle - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtitle] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtitle] < MAXITEMTABS)) { - strTitle = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtitle]]; - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle] < MAXITEMTABS)) { - strSubtitle = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle]]; +} + +void cNopacityScheduleMenuItem::CreateText() { + std::stringstream sstrDateTime; + //Build Date & Time & Status + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime_d]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime_w]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGdate] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGdate] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGdate]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGdatesh]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtime] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtime] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtime]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtimespan]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGstatus] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGstatus] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGstatus]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGt_status] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGt_status] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGt_status]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGv_status] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGv_status] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGv_status]] << " "; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGr_status] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGr_status] < MAXITEMTABS)) + sstrDateTime << *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGr_status]] << " "; + strDateTime = sstrDateTime.str(); + //Build title and subtitle + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGtitle] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGtitle] < MAXITEMTABS)) { + strTitle = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGtitle]]; + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle] < MAXITEMTABS)) { + strSubTitle = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGsubtitle]]; + } else { + size_t delimiter = strTitle.find("~"); + if (delimiter != std::string::npos) { + strSubTitle = strTitle.substr(delimiter+2); + strTitle = strTitle.substr(0, delimiter); } else { - size_t delimiter = strTitle.find("~"); - if (delimiter != std::string::npos) { - strSubtitle = strTitle.substr(delimiter+2); - strTitle = strTitle.substr(0, delimiter); - } else { - strSubtitle = ""; - } + strSubTitle = ""; } } - if (font->Width(strTitle.c_str()) > (width - left)) { - cTextWrapper twTitle; - std::stringstream sstrTitle; - twTitle.Set(strTitle.c_str(), font, width - left); - sstrTitle << twTitle.GetLine(0) << "..."; - strTitle = sstrTitle.str(); - } - if (fontSmall->Width(strSubtitle.c_str()) > (width - left)) { - cTextWrapper twSubtitle; - std::stringstream sstrSubtitle; - twSubtitle.Set(strSubtitle.c_str(), fontSmall, width - left); - sstrSubtitle << twSubtitle.GetLine(0) << "..."; - strSubtitle = sstrSubtitle.str(); - } - //Build Channel Name - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGchlng] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGchlng] < MAXITEMTABS)) - strChannelName = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGchlng]]; - else if ((config.epgSearchConf->epgSearchConfig[mode][eEPGchsh] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGchsh] < MAXITEMTABS)) - strChannelName = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGchsh]]; - else - strChannelName = ""; - //Build Progressbar - if ((config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S] > -1) - &&(config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S] < MAXITEMTABS)) { - strProgressbar = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S]]; - hasProgressBar = true; + } + //Build Channel Name + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGchlng] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGchlng] < MAXITEMTABS)) + strChannelName = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGchlng]]; + else if ((config.epgSearchConf->epgSearchConfig[mode][eEPGchsh] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGchsh] < MAXITEMTABS)) + strChannelName = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGchsh]]; + else + strChannelName = " "; + //Build Progressbar + if ((config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S] > -1) + &&(config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S] < MAXITEMTABS)) { + strProgressbar = *itemTabs[config.epgSearchConf->epgSearchConfig[mode][eEPGprogrT2S]]; + hasProgressBar = true; + } +} + +int cNopacityScheduleMenuItem::CheckScrollable(bool hasIcon) { + int spaceLeft = left; + if (hasIcon) + spaceLeft += config.menuItemLogoWidth; + int totalTextWidth = width - spaceLeft; + if (font->Width(strTitle.c_str()) > (width - spaceLeft)) { + scrollable = true; + totalTextWidth = max(font->Width(strTitle.c_str()), totalTextWidth); + strTitleFull = strTitle.c_str(); + strSubTitleFull = strSubTitle.c_str(); + cTextWrapper twTitle; + std::stringstream sstrTitle; + twTitle.Set(strTitle.c_str(), font, width - spaceLeft); + sstrTitle << twTitle.GetLine(0) << "..."; + strTitle = sstrTitle.str(); + } + if (fontSmall->Width(strSubTitle.c_str()) > (width - spaceLeft)) { + if (!scrollable) { + scrollable = true; + strTitleFull = strTitle.c_str(); + strSubTitleFull = strSubTitle.c_str(); } + totalTextWidth = max(fontSmall->Width(strSubTitle.c_str()), totalTextWidth); + cTextWrapper twSubtitle; + std::stringstream sstrSubtitle; + twSubtitle.Set(strSubTitle.c_str(), fontSmall, width - spaceLeft); + sstrSubtitle << twSubtitle.GetLine(0) << "..."; + strSubTitle = sstrSubtitle.str(); + } + return totalTextWidth; - //DISPLAY - int titleY = (height - font->Height())/2 - 2; - if (strSubtitle.length() == 0) - titleY = font->Height() + (height - 2*font->Height())/2; - pixmap->DrawText(cPoint(left, 3), sstrDateTime.str().c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, font); - pixmap->DrawText(cPoint(left, titleY), strTitle.c_str(), Theme.Color(clrMenuFontMenuItemTitle), clrTransparent, font); - pixmap->DrawText(cPoint(left, titleY + font->Height() - 2), strSubtitle.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, fontSmall); - if (hasIcon) { - if (!iconDrawn) { +} + +void cNopacityScheduleMenuItem::SetTextFull(void) { + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(textLeft, 3), strDateTime.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, font); + pixmapTextScroller->DrawText(cPoint(textLeft, titleY), strTitleFull.c_str(), Theme.Color(clrMenuFontMenuItemTitle), clrTransparent, font); + pixmapTextScroller->DrawText(cPoint(textLeft, titleY + font->Height() - 2), strSubTitleFull.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, fontSmall); +} + +void cNopacityScheduleMenuItem::SetTextShort(void) { + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(textLeft, 3), strDateTime.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, font); + pixmapTextScroller->DrawText(cPoint(textLeft, titleY), strTitle.c_str(), Theme.Color(clrMenuFontMenuItemTitle), clrTransparent, font); + pixmapTextScroller->DrawText(cPoint(textLeft, titleY + font->Height() - 2), strSubTitle.c_str(), Theme.Color(clrMenuFontMenuItem), clrTransparent, fontSmall); +} + +void cNopacityScheduleMenuItem::Render() { + int logoWidth = config.menuItemLogoWidth; + int logoHeight = config.menuItemLogoHeight; + textLeft = 5; + int handleBgrd = (current)?handleBackgrounds[5]:handleBackgrounds[4]; + + pixmap->Fill(Theme.Color(clrMenuBorder)); + pixmap->DrawImage(cPoint(1, 1), handleBgrd); + + if (hasLogo) + textLeft = logoWidth + 10; + + if (selectable) { + titleY = (height - font->Height())/2 - 2; + //draw ProgressBar + if (hasProgressBar) { + DrawRemaining(strProgressbar.c_str(), textLeft, height*7/8, width - textLeft - 10); + } + //draw new? + if (!drawn) { + //draw Icon + if (hasIcon) { cImageLoader imgLoader; if (imgLoader.LoadLogo(strChannelName.c_str(), logoWidth, logoHeight)) { pixmapIcon->DrawImage(cPoint(1, 1), imgLoader.GetImage()); @@ -321,16 +472,22 @@ void cNopacityScheduleMenuItem::Render() { pixmapIcon->DrawText(cPoint((logoWidth - font->Width(channel.GetLine(line)))/2, y+lineHeight*line), channel.GetLine(line), Theme.Color(clrMenuFontMenuItemHigh), clrTransparent, font); } } - iconDrawn = true; } + SetTextShort(); + drawn = true; } - if (hasProgressBar) { - DrawRemaining(strProgressbar.c_str(), left, height*7/8, width - left - 10); + if (current && scrollable && config.menuScrollSpeed) { + Start(); + } + if (wasCurrent && scrollable && Running()) { + pixmapTextScroller->SetDrawPortPoint(cPoint(0, 0)); + SetTextShort(); + Cancel(-1); } - } else { DrawDelimiter(*itemTabs[1], delimiterType.c_str(), handleBgrd); } + } void cNopacityScheduleMenuItem::DrawRemaining(cString remaining, int x, int y, int width) { @@ -359,45 +516,89 @@ void cNopacityScheduleMenuItem::DrawRemaining(cString remaining, int x, int y, i // cNopacityChannelMenuItem ------------- -cNopacityChannelMenuItem::cNopacityChannelMenuItem(cOsd *osd, const char *text, bool cur, bool sel) : cNopacityMenuItem (osd, text, cur, sel) { +cNopacityChannelMenuItem::cNopacityChannelMenuItem(cOsd *osd, const char *text, bool sel) : cNopacityMenuItem (osd, text, sel) { } cNopacityChannelMenuItem::~cNopacityChannelMenuItem(void) { } +void cNopacityChannelMenuItem::CreatePixmapTextScroller(int totalWidth) { + int drawPortWidth = totalWidth + 10; + if (hasIcon) + drawPortWidth += config.menuItemLogoWidth + 10; + pixmapTextScroller = osd->CreatePixmap(4, cRect(left, top + index * (height + left), width, height), cRect(0, 0, drawPortWidth, height)); + pixmapTextScroller->Fill(clrTransparent); +} + +void cNopacityChannelMenuItem::CreateText() { + std::string strChannelNumber = *itemTabs[0]; + std::string strChannelName = *itemTabs[1]; + std::string name = strChannelName.c_str(); + if ((name.length() > 0) && !isalnum(name.at(0))) { + if (name.length() > 3) + name = name.substr(4); + } + name.erase(name.find_last_not_of(" ")+1); + std::stringstream sstrEntry; + sstrEntry << strChannelNumber << " " << name; + strEntry = sstrEntry.str(); + strLogo = name.c_str(); +} + +int cNopacityChannelMenuItem::CheckScrollable(bool hasIcon) { + int spaceLeft = left; + if (hasIcon) + spaceLeft += config.menuItemLogoWidth; + int totalTextWidth = width - spaceLeft; + if (font->Width(strEntry.c_str()) > (width - spaceLeft)) { + scrollable = true; + totalTextWidth = max(font->Width(strEntry.c_str()), totalTextWidth); + strEntryFull = strEntry.c_str(); + cTextWrapper twEntry; + std::stringstream sstrEntry; + twEntry.Set(strEntry.c_str(), font, width - spaceLeft); + sstrEntry << twEntry.GetLine(0) << "..."; + strEntry = sstrEntry.str(); + } + return totalTextWidth; +} + +void cNopacityChannelMenuItem::SetTextFull(void) { + tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(config.menuItemLogoWidth + 10, (height - font->Height())/2), strEntryFull.c_str(), clrFont, clrTransparent, font); +} + +void cNopacityChannelMenuItem::SetTextShort(void) { + tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(config.menuItemLogoWidth + 10, (height - font->Height())/2), strEntry.c_str(), clrFont, clrTransparent, font); +} + void cNopacityChannelMenuItem::Render() { int handleBgrd = (current)?handleBackgrounds[5]:handleBackgrounds[4]; - tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); - cString channelNumber = *itemTabs[0]; - cString channelName = *itemTabs[1]; + if (selectable) { //Channels pixmap->Fill(Theme.Color(clrMenuBorder)); int logoWidth = config.menuItemLogoWidth; int logoHeight = config.menuItemLogoHeight; - //eliminate strange wareagle icons :-/ - std::string name = *channelName; - if (!isalnum(name.at(0))) { - if (name.length() > 3) - name = name.substr(4); - } - name.erase(name.find_last_not_of(" ")+1); pixmap->DrawImage(cPoint(1, 1), handleBgrd); - if (!iconDrawn) { + if (!drawn) { cImageLoader imgLoader; - if (imgLoader.LoadLogo(name.c_str(), logoWidth, logoHeight)) { + if (imgLoader.LoadLogo(strLogo.c_str(), logoWidth, logoHeight)) { pixmapIcon->DrawImage(cPoint(1, 1), imgLoader.GetImage()); } - iconDrawn = true; + drawn = true; + } + SetTextShort(); + if (current && scrollable && config.menuScrollSpeed) { + Start(); } - cTextWrapper channel; - channel.Set(*cString::sprintf("%s %s", *channelNumber, *channelName), font, width - logoWidth - 6); - int lineHeight = font->Height(); - int lines = channel.Lines(); - int heightChannel = lines * lineHeight; - int y = (heightChannel>height)?0:(height-heightChannel)/2; - for (int line = 0; line < lines; line++) { - pixmap->DrawText(cPoint(logoWidth + 10, y+lineHeight*line), channel.GetLine(line), clrFont, clrTransparent, font); + if (wasCurrent && scrollable && Running()) { + pixmapTextScroller->SetDrawPortPoint(cPoint(0, 0)); + SetTextShort(); + Cancel(-1); } } else { //Channelseparators DrawDelimiter(*itemTabs[1], "Channelseparator", handleBgrd); @@ -406,40 +607,92 @@ void cNopacityChannelMenuItem::Render() { // cNopacityDefaultMenuItem ------------- -cNopacityDefaultMenuItem::cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool cur, bool sel) : cNopacityMenuItem (osd, text, cur, sel) { +cNopacityDefaultMenuItem::cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool sel) : cNopacityMenuItem (osd, text, sel) { + scrollCol = -1; } cNopacityDefaultMenuItem::~cNopacityDefaultMenuItem(void) { } -void cNopacityDefaultMenuItem::Render() { - pixmap->Fill(Theme.Color(clrMenuBorder)); - int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0]; +void cNopacityDefaultMenuItem::SetTextFull(void) { tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(0, (height - font->Height()) / 2), strEntryFull.c_str(), clrFont, clrTransparent, font); +} + +void cNopacityDefaultMenuItem::SetTextShort(void) { + tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); + pixmapTextScroller->Fill(clrTransparent); + pixmapTextScroller->DrawText(cPoint(0, (height - font->Height()) / 2), strEntry.c_str(), clrFont, clrTransparent, font); +} + +int cNopacityDefaultMenuItem::CheckScrollable(bool hasIcon) { int colWidth = 0; int colTextWidth = 0; - cString itemText(""); for (int i=0; i<numTabs; i++) { if (tabWidth[i] > 0) { colWidth = tabWidth[i+cSkinDisplayMenu::MaxTabs]; colTextWidth = font->Width(*itemTabs[i]); if (colTextWidth > colWidth) { + scrollable = true; + scrollCol = i; + strEntryFull = *itemTabs[i]; cTextWrapper itemTextWrapped; itemTextWrapped.Set(*itemTabs[i], font, colWidth - font->Width("... ")); - itemText = cString::sprintf("%s... ", itemTextWrapped.GetLine(0)); + strEntry = cString::sprintf("%s... ", itemTextWrapped.GetLine(0)); + break; + } + } else + break; + } + if (scrollable) { + pixmapTextScroller = osd->CreatePixmap(4, cRect(left + tabWidth[scrollCol], top + index * (height + left), tabWidth[scrollCol+numTabs], height), cRect(0, 0, colTextWidth+10, height)); + pixmapTextScroller->Fill(clrTransparent); + } + return 0; +} + +void cNopacityDefaultMenuItem::Render() { + pixmap->Fill(Theme.Color(clrMenuBorder)); + int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0]; + tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); + pixmap->DrawImage(cPoint(1, 1), handleBgrd); + int colWidth = 0; + int colTextWidth = 0; + cString itemText(""); + for (int i=0; i<numTabs; i++) { + if (tabWidth[i] > 0) { + if (i != scrollCol) { + colWidth = tabWidth[i+cSkinDisplayMenu::MaxTabs]; + colTextWidth = font->Width(*itemTabs[i]); + if (colTextWidth > colWidth) { + cTextWrapper itemTextWrapped; + itemTextWrapped.Set(*itemTabs[i], font, colWidth - font->Width("... ")); + itemText = cString::sprintf("%s... ", itemTextWrapped.GetLine(0)); + } else { + itemText = itemTabs[i]; + } + pixmap->DrawText(cPoint(tabWidth[i], (height - font->Height()) / 2), *itemText, clrFont, clrTransparent, font); } else { - itemText = itemTabs[i]; + if (!Running()) + SetTextShort(); } - pixmap->DrawText(cPoint(tabWidth[i], (height - font->Height()) / 2), *itemText, clrFont, clrTransparent, font); } else break; } + if (current && scrollable && !Running() && config.menuScrollSpeed) { + Start(); + } + if (wasCurrent && (current != wasCurrent) && scrollable && Running()) { + pixmapTextScroller->SetDrawPortPoint(cPoint(0, 0)); + SetTextShort(); + Cancel(-1); + } } // cNopacityTrackMenuItem ------------- -cNopacityTrackMenuItem::cNopacityTrackMenuItem(cOsd *osd, const char *text, bool cur) : cNopacityMenuItem (osd, text, cur, true) { +cNopacityTrackMenuItem::cNopacityTrackMenuItem(cOsd *osd, const char *text) : cNopacityMenuItem (osd, text, true) { } cNopacityTrackMenuItem::~cNopacityTrackMenuItem(void) { |