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 | |
parent | a8a2bd61fd2931b79c0f39812ef30a0cc7292d82 (diff) | |
download | skin-nopacity-9c6b259eb786439fd4d1bbfdf8bff0bb059f9edd.tar.gz skin-nopacity-9c6b259eb786439fd4d1bbfdf8bff0bb059f9edd.tar.bz2 |
Introduced scrolling for menus
-rw-r--r-- | config.c | 16 | ||||
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | displaymenu.c | 56 | ||||
-rw-r--r-- | displaymessage.c | 2 | ||||
-rw-r--r-- | displaytracks.c | 6 | ||||
-rw-r--r-- | menuitem.c | 625 | ||||
-rw-r--r-- | menuitem.h | 77 | ||||
-rw-r--r-- | po/de_DE.po | 20 | ||||
-rw-r--r-- | setup.c | 8 | ||||
-rw-r--r-- | setup.h | 1 | ||||
-rw-r--r-- | skinnopacity.c | 2 |
11 files changed, 590 insertions, 226 deletions
@@ -59,6 +59,8 @@ cNopacityConfig::cNopacityConfig() { useSubtitleRerun = 1; menuFadeTime = 300; menuWidthNarrow = 30; + menuScrollDelay = 1000; + menuScrollSpeed = 2; menuWidthRightItems = 12; headerHeight = 7; footerHeight = 7; @@ -110,7 +112,15 @@ void cNopacityConfig::setDynamicValues() { volumeFrameTime = volumeFadeTime / 10; menuFrameTime = menuFadeTime / 10; - logoPathDefault = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); + menuScrollFrameTime = 0; + if (menuScrollSpeed == 1) + menuScrollFrameTime = 50; + else if (menuScrollSpeed == 2) + menuScrollFrameTime = 30; + else if (menuScrollSpeed == 3) + menuScrollFrameTime = 15; + + logoPathDefault = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); iconPathDefault = cString::sprintf("%s/icons/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); epgImagePathDefault = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N)); @@ -195,6 +205,8 @@ bool cNopacityConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "volumeBorderBottom") == 0) volumeBorderBottom = atoi(Value); else if (strcmp(Name, "fontVolume") == 0) fontVolume = atoi(Value); else if (strcmp(Name, "menuFadeTime") == 0) menuFadeTime = atoi(Value); + else if (strcmp(Name, "menuScrollDelay") == 0) menuScrollDelay = atoi(Value); + else if (strcmp(Name, "menuScrollSpeed") == 0) menuScrollSpeed = atoi(Value); else if (strcmp(Name, "scalePicture") == 0) scalePicture = atoi(Value); else if (strcmp(Name, "displayRerunsDetailEPGView") == 0) displayRerunsDetailEPGView = atoi(Value); else if (strcmp(Name, "numReruns") == 0) numReruns = atoi(Value); @@ -224,7 +236,7 @@ bool cNopacityConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "fontTimersHead") == 0) fontTimersHead = atoi(Value); else if (strcmp(Name, "fontTimers") == 0) fontTimers = atoi(Value); else if (strcmp(Name, "fontButtons") == 0) fontButtons = atoi(Value); - else if (strcmp(Name, "fontMessageMenu") == 0) fontMessage = atoi(Value); + else if (strcmp(Name, "fontMessageMenu") == 0) fontMessageMenu = atoi(Value); else if (strcmp(Name, "fontDetailView") == 0) fontDetailView = atoi(Value); else if (strcmp(Name, "fontDetailViewHeader") == 0) fontDetailViewHeader = atoi(Value); else if (strcmp(Name, "fontDetailViewHeaderLarge") == 0) fontDetailViewHeaderLarge = atoi(Value); @@ -82,6 +82,9 @@ class cNopacityConfig { int useSubtitleRerun;
int menuFadeTime;
int menuFrameTime;
+ int menuScrollDelay;
+ int menuScrollSpeed;
+ int menuScrollFrameTime;
int menuWidthNarrow;
int menuWidthRightItems;
int headerHeight;
diff --git a/displaymenu.c b/displaymenu.c index 701e749..34f8af3 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -175,7 +175,7 @@ void cNopacityDisplayMenu::SetTitle(const char *Title) { if (startswith(Title, trVDR("Schedule"))) { menuSubCategory = mcSubSchedule; left += menuView->ShowHeaderIconChannelLogo(Title); - menuHasIcons = true; + menuHasIcons = false; contentNarrow = true; //What's on now } else if ( (strTitle.find(trVDR("Button$Now")) != std::string::npos) @@ -280,6 +280,8 @@ void cNopacityDisplayMenu::SetMessage(eMessageType Type, const char *Text) { } void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { + int menuIconWidth = 0; + int menuIconHeight = 0; cString *strItems = new cString[MaxTabs]; int *tabItems = new int[2*MaxTabs]; for (int i=0; i<MaxTabs; i++) { @@ -288,54 +290,58 @@ void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bo tabItems[i+MaxTabs] = 0; } SplitItem(Text, strItems, tabItems); - int menuIconWidth = 0; - int menuIconHeight = 0; if (initMenu) { if (Index > menuItemIndexLast) { cNopacityMenuItem *item; cPoint itemSize; if (MenuCategory() == mcMain) { - item = new cNopacityMainMenuItem(osd, Text, Current, Selectable); + item = new cNopacityMainMenuItem(osd, Text, Selectable); menuView->GetMenuItemSize(mcMain, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcMain)); menuIconWidth = menuIconHeight = config.iconHeight; } else if (MenuCategory() == mcSchedule) { if (menuSubCategory == mcSubScheduleTimer) { - item = new cNopacityDefaultMenuItem(osd, Text, Current, Selectable); + item = new cNopacityDefaultMenuItem(osd, Text, Selectable); menuView->GetMenuItemSize(mcUnknown, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcUnknown)); } else { - item = new cNopacityScheduleMenuItem(osd, Text, Current, Selectable, menuSubCategory); + item = new cNopacityScheduleMenuItem(osd, Text, Selectable, menuSubCategory); menuView->GetMenuItemSize(mcSchedule, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcSchedule)); item->SetFontSmall(menuView->GetMenuItemFontSmall()); + item->SetDisplayMode(); menuIconWidth = config.menuItemLogoWidth; menuIconHeight = config.menuItemLogoHeight; } } else if (MenuCategory() == mcChannel) { if (menuSubCategory == mcSubChannels) { - item = new cNopacityChannelMenuItem(osd, Text, Current, Selectable); + item = new cNopacityChannelMenuItem(osd, Text, Selectable); menuView->GetMenuItemSize(mcChannel, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcChannel)); menuIconWidth = config.menuItemLogoWidth; menuIconHeight = config.menuItemLogoHeight; } else { - item = new cNopacityDefaultMenuItem(osd, Text, Current, Selectable); + item = new cNopacityDefaultMenuItem(osd, Text, Selectable); menuView->GetMenuItemSize(mcUnknown, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcUnknown)); } } else { - item = new cNopacityDefaultMenuItem(osd, Text, Current, Selectable); + item = new cNopacityDefaultMenuItem(osd, Text, Selectable); menuView->GetMenuItemSize(mcUnknown, &itemSize); item->SetFont(menuView->GetMenuItemFont(mcUnknown)); } + int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); + item->SetGeometry(Index, spaceTop, menuView->spaceMenu, itemSize.X(), itemSize.Y()); + item->SetCurrent(Current); item->SetBackgrounds(handleBackgrounds); item->SetTabs(strItems, tabItems, MaxTabs); - int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - if (menuHasIcons) { - item->CreatePixmapIcon(spaceTop, menuView->spaceMenu, Index, itemSize.Y(), menuIconWidth, menuIconHeight); - } - item->CreatePixmap(spaceTop, menuView->spaceMenu, Index, itemSize.X(), itemSize.Y()); + item->CreateText(); + int textWidth = item->CheckScrollable(menuHasIcons); + item->CreatePixmap(); + if (menuHasIcons) + item->CreatePixmapIcon(menuIconWidth, menuIconHeight); + if (textWidth > 0) + item->CreatePixmapTextScroller(textWidth); menuItems.Add(item); item->Render(); menuItemIndexLast = Index; @@ -343,6 +349,7 @@ void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bo if (FadeTime) { item->SetAlpha(0); item->SetAlphaIcon(0); + item->SetAlphaText(0); } } } else { @@ -352,12 +359,12 @@ void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bo item->Render(); } } else { + //redraw item when switching through menu cNopacityMenuItem *item = menuItems.Get(Index); item->SetTabs(strItems, tabItems, MaxTabs); item->SetCurrent(Current); item->Render(); } - SetEditableWidth(menuView->GetEditableWidth()); } @@ -367,14 +374,20 @@ void cNopacityDisplayMenu::SplitItem(const char *Text, cString *strItems, int *t const char *s = GetTabbedText(Text, i); if (s) { strItems[i] = s; - tabItems[i] = Tab(i); - if (i>0) { - tabItems[(i-1) + MaxTabs] = Tab(i) - x; - } - x += Tab(i) - x; } + tabItems[i] = Tab(i); + if (i>0) { + tabItems[(i-1) + MaxTabs] = Tab(i) - x; + x += Tab(i) - x; + } if (!Tab(i + 1)) { - tabItems[i + MaxTabs] = menuView->GetWidthDefaultMenu() - x; + if (s) + tabItems[i + MaxTabs] = menuView->GetWidthDefaultMenu() - x; + else if (i==1) { + tabItems[MaxTabs] = menuView->GetWidthDefaultMenu() - 1; + tabItems[1] = 0; + tabItems[MaxTabs+1] = 0; + } break; } } @@ -486,6 +499,7 @@ void cNopacityDisplayMenu::Action(void) { for (cNopacityMenuItem *item = menuItems.First(); Running() && item; item = menuItems.Next(item)) { item->SetAlpha(Alpha); item->SetAlphaIcon(Alpha); + item->SetAlphaText(Alpha); } for (cNopacityTimer *t = timers.First(); Running() && t; t = timers.Next(t)) t->SetAlpha(Alpha); diff --git a/displaymessage.c b/displaymessage.c index 64e772a..999af3b 100644 --- a/displaymessage.c +++ b/displaymessage.c @@ -10,7 +10,7 @@ cNopacityDisplayMessage::cNopacityDisplayMessage(void) { pixmap = osd->CreatePixmap(1, cRect(0, 0, width, height)); if (config.messageFadeTime) pixmap->SetAlpha(0); - font = cFont::CreateFont(config.fontName, height / 4 + config.fontMessage); + font = cFont::CreateFont(config.fontName, height / 4 + 15 + config.fontMessage); FrameTime = config.messageFrameTime; FadeTime = config.messageFadeTime; } diff --git a/displaytracks.c b/displaytracks.c index f0d239f..5948aa7 100644 --- a/displaytracks.c +++ b/displaytracks.c @@ -124,9 +124,11 @@ void cNopacityDisplayTracks::DrawHeader(const char *Title) { void cNopacityDisplayTracks::SetItem(const char *Text, int Index, bool Current) { cNopacityMenuItem *item; - item = new cNopacityTrackMenuItem(osd, Text, Current); + item = new cNopacityTrackMenuItem(osd, Text); + item->SetCurrent(Current); item->SetFont(font); - item->CreatePixmap(menuItemHeight+5, 2, Index, menuItemWidth, menuItemHeight); + item->SetGeometry(Index, menuItemHeight+5, 2, menuItemWidth, menuItemHeight); + item->CreatePixmap(); item->SetBackgrounds(handleBackgrounds); menuItems.Add(item); item->Render(); @@ -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) { @@ -1,36 +1,51 @@ #ifndef __NOPACITY_MENUITEM_H #define __NOPACITY_MENUITEM_H -class cNopacityMenuItem : public cListObject { +class cNopacityMenuItem : public cListObject, public cThread { protected: cOsd *osd; cPixmap *pixmap; cPixmap *pixmapIcon; + cPixmap *pixmapTextScroller; bool hasIcon; - bool iconDrawn; int *handleBackgrounds; const char *Text; bool selectable; bool current; + bool wasCurrent; + bool scrollable; + bool drawn; cFont *font; cFont *fontSmall; int width, height; + int top, left; + int textLeft; + int index; cString *itemTabs; int *tabWidth; int numTabs; void DrawDelimiter(const char *del, const char *icon, int handleBgrd); + virtual void Action(void); + virtual void SetTextFull(void) {}; + virtual void SetTextShort(void) {}; public: - cNopacityMenuItem(cOsd *osd, const char *text, bool cur, bool sel); + cNopacityMenuItem(cOsd *osd, const char *text, bool sel); virtual ~cNopacityMenuItem(void); - void CreatePixmap(int top, int space, int index, int width, int height); - void CreatePixmapIcon(int top, int space, int index, int itemHeight, int iconWidth, int iconHeight); + void CreatePixmap(); + void CreatePixmapIcon(int iconWidth, int iconHeight); + virtual void CreatePixmapTextScroller(int totalWidth); + void SetGeometry(int index, int top, int left, int width, int height); void SetFont(cFont *font) {this->font = font;} void SetFontSmall(cFont *fontSmall) {this->fontSmall = fontSmall;} - void SetCurrent(bool cur) {current = cur;} + void SetCurrent(bool cur); void SetAlpha(int alpha) {this->pixmap->SetAlpha(alpha);} void SetAlphaIcon(int alpha) {if (hasIcon) this->pixmapIcon->SetAlpha(alpha);} + void SetAlphaText(int alpha) {if (pixmapTextScroller) this->pixmapTextScroller->SetAlpha(alpha);} void SetTabs(cString *tabs, int *tabWidths, int numtabs); void SetBackgrounds(int *handleBackgrounds); + virtual void CreateText(void) {}; + virtual void SetDisplayMode(void) {}; + virtual int CheckScrollable(bool hasIcon) {return 0;}; virtual void Render() = 0; }; @@ -38,12 +53,18 @@ class cNopacityMainMenuItem : public cNopacityMenuItem { private: cString menuNumber; cString menuEntry; - void SplitMenuItem(); + std::string strEntry; + std::string strEntryFull; static std::string items[6]; cString GetIconName(); + void SetTextFull(void); + void SetTextShort(void); public: - cNopacityMainMenuItem(cOsd *osd, const char *text, bool cur, bool sel); + cNopacityMainMenuItem(cOsd *osd, const char *text, bool sel); ~cNopacityMainMenuItem(void); + void CreatePixmapTextScroller(int totalWidth); + void CreateText(void); + int CheckScrollable(bool hasIcon); void Render(); }; @@ -63,33 +84,65 @@ enum eMenuSubCategory { mcSubUndefined = -1, class cNopacityScheduleMenuItem : public cNopacityMenuItem { private: eMenuSubCategory subCategory; + std::string strDateTime; + std::string strTitle; + std::string strSubTitle; + std::string strTitleFull; + std::string strSubTitleFull; + std::string strChannelName; + std::string strProgressbar; + bool hasProgressBar; + eEPGModes mode; + bool hasLogo; + int titleY; + std::string delimiterType; void DrawRemaining(cString remaining, int x, int y, int width); + void SetTextFull(void); + void SetTextShort(void); public: - cNopacityScheduleMenuItem(cOsd *osd, const char *text, bool cur, bool sel, eMenuSubCategory subCat); + cNopacityScheduleMenuItem(cOsd *osd, const char *text, bool sel, eMenuSubCategory subCat); ~cNopacityScheduleMenuItem(void); + void CreatePixmapTextScroller(int totalWidth); + void SetDisplayMode(void); + void CreateText(void); + int CheckScrollable(bool hasIcon); void Render(); }; class cNopacityChannelMenuItem : public cNopacityMenuItem { private: + std::string strLogo; + std::string strEntry; + std::string strEntryFull; + void SetTextFull(void); + void SetTextShort(void); public: - cNopacityChannelMenuItem(cOsd *osd, const char *text, bool cur, bool sel); + cNopacityChannelMenuItem(cOsd *osd, const char *text, bool sel); ~cNopacityChannelMenuItem(void); + void CreatePixmapTextScroller(int totalWidth); + void CreateText(void); + int CheckScrollable(bool hasIcon); void Render(); }; class cNopacityDefaultMenuItem : public cNopacityMenuItem { private: + std::string strEntry; + std::string strEntryFull; + int scrollCol; + void SetTextFull(void); + void SetTextShort(void); public: - cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool cur, bool sel); + cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool sel); ~cNopacityDefaultMenuItem(void); + int CheckScrollable(bool hasIcon); void Render(); }; class cNopacityTrackMenuItem : public cNopacityMenuItem { private: public: - cNopacityTrackMenuItem(cOsd *osd, const char *text, bool cur); + cNopacityTrackMenuItem(cOsd *osd, const char *text); ~cNopacityTrackMenuItem(void); void Render(); }; diff --git a/po/de_DE.po b/po/de_DE.po index 2c0480d..4df2a68 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: skinnopacity 0.0.1\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2012-12-05 19:48+0100\n" +"POT-Creation-Date: 2012-12-15 12:57+0100\n" "PO-Revision-Date: 2012-11-11 17:49+0200\n" "Last-Translator: louis\n" "Language-Team: \n" @@ -47,9 +47,27 @@ msgstr "falls vorhanden" msgid "always" msgstr "immer" +msgid "off" +msgstr "aus" + +msgid "slow" +msgstr "langsam" + +msgid "medium" +msgstr "mittel" + +msgid "fast" +msgstr "schnell" + msgid "Fade-In Time in ms (Zero for switching off fading)" msgstr "Fade-In Zeit in ms (Null zum Abschalten)" +msgid "Scrolling Speed" +msgstr "Scroll Geschwindigkeit" + +msgid "Scrolling Delay in ms" +msgstr "Scroll Verzögerung in ms" + msgid "Scale Video size to fit into menu window" msgstr "TV-Bildgröße in Menüfenster einpassen" @@ -96,6 +96,8 @@ void cNopacitySetup::Store(void) { SetupStore("numReruns", config.numReruns); SetupStore("useSubtitleRerun", config.useSubtitleRerun); SetupStore("menuFadeTime", config.menuFadeTime); + SetupStore("menuScrollDelay", config.menuScrollDelay); + SetupStore("menuScrollSpeed", config.menuScrollSpeed); SetupStore("menuWidthNarrow", config.menuWidthNarrow); SetupStore("menuWidthRightItems", config.menuWidthRightItems); SetupStore("headerHeight", config.headerHeight); @@ -159,6 +161,10 @@ cNopacitySetupMenuDisplay::cNopacitySetupMenuDisplay(cNopacityConfig* data) : c useSubtitleRerunTexts[0] = tr("never"); useSubtitleRerunTexts[1] = tr("if exists"); useSubtitleRerunTexts[2] = tr("always"); + scrollSpeed[0] = tr("off"); + scrollSpeed[1] = tr("slow"); + scrollSpeed[2] = tr("medium"); + scrollSpeed[3] = tr("fast"); Set(); } @@ -166,6 +172,8 @@ void cNopacitySetupMenuDisplay::Set(void) { int currentItem = Current(); Clear(); Add(new cMenuEditIntItem(tr("Fade-In Time in ms (Zero for switching off fading)"), &tmpNopacityConfig->menuFadeTime, 0, 1000)); + Add(new cMenuEditStraItem(tr("Scrolling Speed"), &tmpNopacityConfig->menuScrollSpeed, 4, scrollSpeed)); + Add(new cMenuEditIntItem(tr("Scrolling Delay in ms"), &tmpNopacityConfig->menuScrollDelay, 0, 2000)); Add(new cMenuEditBoolItem(tr("Scale Video size to fit into menu window"), &tmpNopacityConfig->scalePicture)); Add(new cMenuEditBoolItem(tr("Display Reruns in detailed EPG View"), &tmpNopacityConfig->displayRerunsDetailEPGView)); Add(new cMenuEditIntItem(tr("Number of reruns to display"), &tmpNopacityConfig->numReruns, 1, 10)); @@ -29,6 +29,7 @@ class cMenuSetupSubMenu : public cOsdMenu { class cNopacitySetupMenuDisplay : public cMenuSetupSubMenu { protected: const char *useSubtitleRerunTexts[3]; + const char *scrollSpeed[4]; void Set(void); public: cNopacitySetupMenuDisplay(cNopacityConfig *data); diff --git a/skinnopacity.c b/skinnopacity.c index 58426ad..b661dea 100644 --- a/skinnopacity.c +++ b/skinnopacity.c @@ -11,7 +11,7 @@ #include "nopacity.c" #if defined(APIVERSNUM) && APIVERSNUM < 10730 -#error "VDR-1.7. API version or greater is required!" +#error "VDR-1.7.30 API version or greater is required!" #endif |