diff options
author | louis <louis.braun@gmx.de> | 2013-09-29 12:03:45 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-09-29 12:03:45 +0200 |
commit | acce422dcfe6bb57818f062b3a6e2db99b4cb2d3 (patch) | |
tree | 33d129161784818b95890a656c7a802f1118bfed | |
parent | 9a0778bbdf309018a635229bd0523b3435388978 (diff) | |
download | skin-nopacity-acce422dcfe6bb57818f062b3a6e2db99b4cb2d3.tar.gz skin-nopacity-acce422dcfe6bb57818f062b3a6e2db99b4cb2d3.tar.bz2 |
Added Cache for images and fonts
40 files changed, 1798 insertions, 1278 deletions
@@ -292,3 +292,4 @@ Version 0.1.4 - if background color and blending color in displayChannel and displayReplay are the same, no blending effect is shown - updated slovak translation +- Added cache for images and fonts @@ -65,6 +65,8 @@ cNopacityConfig::cNopacityConfig() { volumeBorderBottom = 10; fontVolume = 0; //DisplayMenu + spaceMenu = 5; + widthScrollbar = 20; menuAdjustLeft = 1; scalePicture = 1; roundedCorners = 0; @@ -94,6 +94,8 @@ class cNopacityConfig { int volumeBorderBottom; int fontVolume; //DisplayMenu + int spaceMenu; + int widthScrollbar; int menuAdjustLeft; int scalePicture; int roundedCorners; diff --git a/displaychannel.c b/displaychannel.c index f908300..7d29ffc 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -1,13 +1,15 @@ #include "displaychannel.h" #include "services/tvscraper.h" -cNopacityDisplayChannel::cNopacityDisplayChannel(bool WithInfo) { +cNopacityDisplayChannel::cNopacityDisplayChannel(cImageCache *imgCache, bool WithInfo) { if (firstDisplay) { + imgCache->CreateCache2(); firstDisplay = false; doOutput = false; return; } else - doOutput = true; + doOutput = true; + this->imgCache = imgCache; config.setDynamicValues(); withInfo = WithInfo; groupSep = false; @@ -25,9 +27,9 @@ cNopacityDisplayChannel::cNopacityDisplayChannel(bool WithInfo) { FrameTime = config.channelFrameTime; FadeTime = config.channelFadeTime; lastDate = ""; - SetGeometry(); + signalX = 0; + createOsd(); CreatePixmaps(); - CreateFonts(); DrawBackground(); DrawSignalMeter(); } @@ -68,87 +70,53 @@ cNopacityDisplayChannel::~cNopacityDisplayChannel() { if (config.displaySignalStrength && showSignal) { delete fontInfoline; } - delete fontHeader; - delete fontDate; - delete fontEPG; - delete fontEPGSmall; - delete fontChannelGroup; - delete fontChannelGroupSmall; delete osd; } -void cNopacityDisplayChannel::SetGeometry(void) { - height = cOsd::OsdHeight() * config.channelHeight / 100; - top = cOsd::OsdTop() + cOsd::OsdHeight() - height - config.channelBorderBottom; - osd = CreateOsd(cOsd::OsdLeft(), cOsd::OsdTop(), cOsd::OsdWidth(), cOsd::OsdHeight()); - switch (config.logoPosition) { - case lpLeft: - infoWidth = osd->Width() - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder); - infoX = config.logoWidth + config.channelBorderVertical + config.logoBorder; - break; - case lpRight: - infoWidth = osd->Width() - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder); - infoX = config.channelBorderVertical; - break; - case lpNone: - infoWidth = osd->Width() - 2 * config.channelBorderVertical; - infoX = config.channelBorderVertical; - break; - } - channelInfoWidth = infoWidth * 0.7; - dateWidth = infoWidth - channelInfoWidth; - channelInfoHeight = height * 0.2; - if (channelInfoHeight%2 != 0) - channelInfoHeight++; - progressBarHeight = height * 0.1; - streamInfoHeight = height * 0.2; - if (streamInfoHeight%2 != 0) - streamInfoHeight++; - epgInfoHeight = height - channelInfoHeight - streamInfoHeight - progressBarHeight; - epgInfoLineHeight = epgInfoHeight / 4; - streamInfoY = channelInfoHeight + progressBarHeight + epgInfoHeight; - iconSize = config.statusIconSize; - iconsWidth = 5*iconSize; - signalX = 0; +void cNopacityDisplayChannel::createOsd(void) { + osd = CreateOsd(geoManager->osdLeft, + geoManager->osdTop, + geoManager->osdWidth, + geoManager->osdHeight); } void cNopacityDisplayChannel::CreatePixmaps(void) { int channelInfoY = 0; if (withInfo) { - pixmapProgressBar = osd->CreatePixmap(2, cRect(infoX, top + channelInfoHeight, infoWidth, progressBarHeight)); - pixmapEPGInfo = osd->CreatePixmap(2, cRect(infoX, top + channelInfoHeight + progressBarHeight, infoWidth, epgInfoHeight)); - pixmapBackgroundMiddle = osd->CreatePixmap(1, cRect(infoX, top + channelInfoHeight, infoWidth, progressBarHeight + epgInfoHeight)); + pixmapProgressBar = osd->CreatePixmap(2, cRect(geoManager->channelX, geoManager->channelTop + geoManager->channelInfoHeight, geoManager->channelWidth, geoManager->channelProgressBarHeight)); + pixmapEPGInfo = osd->CreatePixmap(2, cRect(geoManager->channelX, geoManager->channelTop + geoManager->channelInfoHeight + geoManager->channelProgressBarHeight, geoManager->channelWidth, geoManager->channelEpgInfoHeight)); + pixmapBackgroundMiddle = osd->CreatePixmap(1, cRect(geoManager->channelX, geoManager->channelTop + geoManager->channelInfoHeight, geoManager->channelWidth, geoManager->channelProgressBarHeight + geoManager->channelEpgInfoHeight)); } else { - channelInfoY = (height - channelInfoHeight) / 3; - streamInfoY = (height - channelInfoHeight) / 3 + channelInfoHeight; + channelInfoY = (geoManager->channelHeight - geoManager->channelInfoHeight) / 3; + geoManager->channelStreamInfoY = (geoManager->channelHeight - geoManager->channelInfoHeight) / 3 + geoManager->channelInfoHeight; } - pixmapBackgroundTop = osd->CreatePixmap(1, cRect(infoX, top + channelInfoY, infoWidth, channelInfoHeight)); - pixmapBackgroundBottom = osd->CreatePixmap(1, cRect(infoX, top + streamInfoY, infoWidth, streamInfoHeight)); + pixmapBackgroundTop = osd->CreatePixmap(1, cRect(geoManager->channelX, geoManager->channelTop + channelInfoY, geoManager->channelWidth, geoManager->channelInfoHeight)); + pixmapBackgroundBottom = osd->CreatePixmap(1, cRect(geoManager->channelX, geoManager->channelTop + geoManager->channelStreamInfoY, geoManager->channelWidth, geoManager->channelStreamInfoHeight)); - pixmapChannelInfo = osd->CreatePixmap(2, cRect(infoX, top + channelInfoY, channelInfoWidth, channelInfoHeight)); - pixmapDate = osd->CreatePixmap(2, cRect(infoX + channelInfoWidth, top + channelInfoY, dateWidth, channelInfoHeight)); - pixmapFooter = osd->CreatePixmap(2, cRect(infoX, top + streamInfoY, infoWidth, streamInfoHeight)); - pixmapStreamInfo = osd->CreatePixmap(4, cRect(infoX + (infoWidth - iconsWidth - config.resolutionIconSize - 35), top + height - iconSize - 10, iconsWidth, iconSize)); - pixmapStreamInfoBack = osd->CreatePixmap(3, cRect(infoX + (infoWidth - iconsWidth - config.resolutionIconSize - 35), top + height - iconSize - 10, iconsWidth, iconSize)); + pixmapChannelInfo = osd->CreatePixmap(2, cRect(geoManager->channelX, geoManager->channelTop + channelInfoY, geoManager->channelInfoWidth, geoManager->channelInfoHeight)); + pixmapDate = osd->CreatePixmap(2, cRect(geoManager->channelX + geoManager->channelInfoWidth, geoManager->channelTop + channelInfoY, geoManager->channelDateWidth, geoManager->channelInfoHeight)); + pixmapFooter = osd->CreatePixmap(2, cRect(geoManager->channelX, geoManager->channelTop + geoManager->channelStreamInfoY, geoManager->channelWidth, geoManager->channelStreamInfoHeight)); + pixmapStreamInfo = osd->CreatePixmap(4, cRect(geoManager->channelX + (geoManager->channelWidth - geoManager->channelIconsWidth - config.resolutionIconSize - 35), geoManager->channelTop + geoManager->channelHeight - geoManager->channelIconSize - 10, geoManager->channelIconsWidth, geoManager->channelIconSize)); + pixmapStreamInfoBack = osd->CreatePixmap(3, cRect(geoManager->channelX + (geoManager->channelWidth - geoManager->channelIconsWidth - config.resolutionIconSize - 35), geoManager->channelTop + geoManager->channelHeight - geoManager->channelIconSize - 10, geoManager->channelIconsWidth, geoManager->channelIconSize)); switch (config.logoPosition) { case lpLeft: - pixmapLogoBackgroundTop = osd->CreatePixmap(1, cRect(config.channelBorderVertical, top, infoX - config.channelBorderVertical, channelInfoHeight)); - pixmapLogoBackground = osd->CreatePixmap(1, cRect(config.channelBorderVertical, top + channelInfoHeight, infoX - config.channelBorderVertical, progressBarHeight + epgInfoHeight)); - pixmapLogoBackgroundBottom = osd->CreatePixmap(1, cRect(config.channelBorderVertical, top + streamInfoY, infoX - config.channelBorderVertical, streamInfoHeight)); - pixmapLogo = osd->CreatePixmap(2, cRect(0, top, config.logoWidth + 2 * config.logoBorder, height)); + pixmapLogoBackgroundTop = osd->CreatePixmap(1, cRect(config.channelBorderVertical, geoManager->channelTop, geoManager->channelX - config.channelBorderVertical, geoManager->channelInfoHeight)); + pixmapLogoBackground = osd->CreatePixmap(1, cRect(config.channelBorderVertical, geoManager->channelTop + geoManager->channelInfoHeight, geoManager->channelX - config.channelBorderVertical, geoManager->channelProgressBarHeight + geoManager->channelEpgInfoHeight)); + pixmapLogoBackgroundBottom = osd->CreatePixmap(1, cRect(config.channelBorderVertical, geoManager->channelTop + geoManager->channelStreamInfoY, geoManager->channelX - config.channelBorderVertical, geoManager->channelStreamInfoHeight)); + pixmapLogo = osd->CreatePixmap(2, cRect(0, geoManager->channelTop, config.logoWidth + 2 * config.logoBorder, geoManager->channelHeight)); break; case lpRight: - pixmapLogoBackgroundTop = osd->CreatePixmap(1, cRect(infoX + infoWidth, top, cOsd::OsdWidth() - 2*config.channelBorderVertical - infoWidth, channelInfoHeight)); - pixmapLogoBackground = osd->CreatePixmap(1, cRect(infoX + infoWidth, top + channelInfoHeight, cOsd::OsdWidth() - 2*config.channelBorderVertical - infoWidth, progressBarHeight + epgInfoHeight)); - pixmapLogoBackgroundBottom = osd->CreatePixmap(1, cRect(infoX + infoWidth, top + streamInfoY, cOsd::OsdWidth() - 2*config.channelBorderVertical - infoWidth, streamInfoHeight)); - pixmapLogo = osd->CreatePixmap(2, cRect(infoX + infoWidth, top, config.logoWidth + 2 * config.logoBorder, height)); + pixmapLogoBackgroundTop = osd->CreatePixmap(1, cRect(geoManager->channelX + geoManager->channelWidth, geoManager->channelTop, cOsd::OsdWidth() - 2*config.channelBorderVertical - geoManager->channelWidth, geoManager->channelInfoHeight)); + pixmapLogoBackground = osd->CreatePixmap(1, cRect(geoManager->channelX + geoManager->channelWidth, geoManager->channelTop + geoManager->channelInfoHeight, cOsd::OsdWidth() - 2*config.channelBorderVertical - geoManager->channelWidth, geoManager->channelProgressBarHeight + geoManager->channelEpgInfoHeight)); + pixmapLogoBackgroundBottom = osd->CreatePixmap(1, cRect(geoManager->channelX + geoManager->channelWidth, geoManager->channelTop + geoManager->channelStreamInfoY, cOsd::OsdWidth() - 2*config.channelBorderVertical - geoManager->channelWidth, geoManager->channelStreamInfoHeight)); + pixmapLogo = osd->CreatePixmap(2, cRect(geoManager->channelX + geoManager->channelWidth, geoManager->channelTop, config.logoWidth + 2 * config.logoBorder, geoManager->channelHeight)); break; case lpNone: - pixmapLogo = osd->CreatePixmap(-1, cRect(0, top, 1, 1)); - pixmapLogoBackground = osd->CreatePixmap(-1, cRect(0, top, 1, 1)); - pixmapLogoBackgroundTop = osd->CreatePixmap(-1, cRect(0, top, 1, 1)); - pixmapLogoBackgroundBottom = osd->CreatePixmap(-1, cRect(0, top, 1, 1)); + pixmapLogo = osd->CreatePixmap(-1, cRect(0, geoManager->channelTop, 1, 1)); + pixmapLogoBackground = osd->CreatePixmap(-1, cRect(0, geoManager->channelTop, 1, 1)); + pixmapLogoBackgroundTop = osd->CreatePixmap(-1, cRect(0, geoManager->channelTop, 1, 1)); + pixmapLogoBackgroundBottom = osd->CreatePixmap(-1, cRect(0, geoManager->channelTop, 1, 1)); break; } @@ -182,15 +150,6 @@ void cNopacityDisplayChannel::CreatePixmaps(void) { pixmapPoster = NULL; } -void cNopacityDisplayChannel::CreateFonts(void) { - fontHeader = cFont::CreateFont(config.fontName, channelInfoHeight - 8 + config.fontChannelHeaderSize); - fontDate = cFont::CreateFont(config.fontName, channelInfoHeight/2 + config.fontChannelDateSize); - fontEPG = cFont::CreateFont(config.fontName, epgInfoLineHeight + config.fontEPGSize); - fontEPGSmall = cFont::CreateFont(config.fontName, epgInfoLineHeight - 6 + config.fontEPGSmallSize); - fontChannelGroup = cFont::CreateFont(config.fontName, epgInfoHeight/3 + config.fontChannelGroupSize); - fontChannelGroupSmall = cFont::CreateFont(config.fontName, epgInfoHeight/3 - 5 + config.fontChannelGroupSmallSize); -} - void cNopacityDisplayChannel::DrawBackground(void){ if (config.doBlending && (Theme.Color(clrChannelBackground) != Theme.Color(clrChannelBackBlend))) { DrawBlendedBackground(pixmapBackgroundTop, Theme.Color(clrChannelBackground), Theme.Color(clrChannelBackBlend), true); @@ -217,19 +176,19 @@ void cNopacityDisplayChannel::DrawBackground(void){ pixmapLogoBackgroundBottom->Fill(clrTransparent); } if (config.roundedCornersChannel) { - int cornerTopSize = channelInfoHeight/2; - int cornerBottomSize = streamInfoHeight/2; + int cornerTopSize = geoManager->channelInfoHeight/2; + int cornerBottomSize = geoManager->channelStreamInfoHeight/2; if ((cornerTopSize > 2)&&(cornerBottomSize > 2)) { if ((config.backgroundStyle == bsTrans) || ((config.logoPosition == lpNone))) { pixmapBackgroundTop->DrawEllipse(cRect(0, 0, cornerTopSize, cornerTopSize), clrTransparent, -2); - pixmapBackgroundTop->DrawEllipse(cRect(infoWidth - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); + pixmapBackgroundTop->DrawEllipse(cRect(geoManager->channelWidth - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); pixmapBackgroundBottom->DrawEllipse(cRect(0, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -3); - pixmapBackgroundBottom->DrawEllipse(cRect(infoWidth - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); + pixmapBackgroundBottom->DrawEllipse(cRect(geoManager->channelWidth - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); } else if ((config.backgroundStyle == bsFull) && (config.logoPosition == lpLeft)){ pixmapLogoBackgroundTop->DrawEllipse(cRect(0, 0, cornerTopSize, cornerTopSize), clrTransparent, -2); - pixmapBackgroundTop->DrawEllipse(cRect(infoWidth - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); + pixmapBackgroundTop->DrawEllipse(cRect(geoManager->channelWidth - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); pixmapLogoBackgroundBottom->DrawEllipse(cRect(0, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -3); - pixmapBackgroundBottom->DrawEllipse(cRect(infoWidth - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); + pixmapBackgroundBottom->DrawEllipse(cRect(geoManager->channelWidth - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); } else if ((config.backgroundStyle == bsFull) && (config.logoPosition == lpRight)){ pixmapBackgroundTop->DrawEllipse(cRect(0, 0, cornerTopSize, cornerTopSize), clrTransparent, -2); pixmapLogoBackgroundTop->DrawEllipse(cRect(pixmapLogoBackgroundTop->ViewPort().Width() - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); @@ -249,26 +208,26 @@ void cNopacityDisplayChannel::DrawBackground(void){ void cNopacityDisplayChannel::DrawDate(void) { cString curDate = DayDateTime(); if (initial || channelChange || strcmp(curDate, lastDate)) { - int strDateWidth = fontDate->Width(curDate); - int strDateHeight = fontDate->Height(); - int x = dateWidth - strDateWidth - channelInfoHeight/2; - int y = (channelInfoHeight - strDateHeight) / 2; + int strDateWidth = fontManager->channelDate->Width(curDate); + int strDateHeight = fontManager->channelDate->Height(); + int x = geoManager->channelDateWidth - strDateWidth - geoManager->channelInfoHeight/2; + int y = (geoManager->channelInfoHeight - strDateHeight) / 2; pixmapDate->Fill(clrTransparent); - pixmapDate->DrawText(cPoint(x, y), curDate, Theme.Color(clrChannelHead), clrTransparent, fontDate); + pixmapDate->DrawText(cPoint(x, y), curDate, Theme.Color(clrChannelHead), clrTransparent, fontManager->channelDate); lastDate = curDate; } } void cNopacityDisplayChannel::DrawIconMask(void) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/channelsymbols", iconsWidth, iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(0, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/channelsymbols"); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(0,0), *imgIcon); } void cNopacityDisplayChannel::DrawIcons(const cChannel *Channel) { isRadioChannel = ((!Channel->Vpid())&&(Channel->Apid(0)))?true:false; + int iconSize = geoManager->channelIconSize; int backX = 5; int backY = 5; @@ -310,65 +269,66 @@ void cNopacityDisplayChannel::DrawIcons(const cChannel *Channel) { void cNopacityDisplayChannel::DrawIconsSingle(const cChannel *Channel) { isRadioChannel = ((!Channel->Vpid())&&(Channel->Apid(0)))?true:false; pixmapStreamInfo->Fill(clrTransparent); + int iconSize = geoManager->channelIconSize; int iconX = 0; cImageLoader imgLoader; if (Channel->Vpid() && Channel->Tpid()) { - if (imgLoader.LoadIcon("skinIcons/txton", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/txton", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(0,0), *imgIcon); } else { - if (imgLoader.LoadIcon("skinIcons/txtoff", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/txtoff", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(0,0), *imgIcon); } iconX += iconSize; if (Channel->Apid(0)) { - if (imgLoader.LoadIcon("skinIcons/stereoon", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/stereoon", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } else { - if (imgLoader.LoadIcon("skinIcons/stereooff", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/stereooff", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } iconX += iconSize; if (Channel->Dpid(0)) { - if (imgLoader.LoadIcon("skinIcons/dolbyon", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/dolbyon", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } else { - if (imgLoader.LoadIcon("skinIcons/dolbyoff", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/dolbyoff", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } iconX += iconSize; if (Channel->Ca()) { - if (imgLoader.LoadIcon("skinIcons/crypted", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/crypted", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } else { - if (imgLoader.LoadIcon("skinIcons/fta", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/fta", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } iconX += iconSize; if (cRecordControls::Active()) { - if (imgLoader.LoadIcon("skinIcons/recon", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/recon", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } else { - if (imgLoader.LoadIcon("skinIcons/recoff", iconSize)) { - pixmapStreamInfo->DrawImage(cPoint(iconX, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/recoff", iconSize, iconSize); + if (imgIcon) + pixmapStreamInfo->DrawImage(cPoint(iconX,0), *imgIcon); } } @@ -380,8 +340,8 @@ void cNopacityDisplayChannel::DrawScreenResolution(void) { double aspect = 0; if (!pixmapScreenResolution) { - int x = infoX + infoWidth - config.resolutionIconSize - 2*spacing; - int y = top + height - config.resolutionIconSize - 10; + int x = geoManager->channelX + geoManager->channelWidth - config.resolutionIconSize - 2*spacing; + int y = geoManager->channelTop + geoManager->channelHeight - config.resolutionIconSize - 10; pixmapScreenResolution = osd->CreatePixmap(3, cRect(x, y, config.resolutionIconSize, config.resolutionIconSize)); pixmapScreenResolution->Fill(clrTransparent); if ((initial)&&(config.channelFadeTime)) @@ -391,9 +351,9 @@ void cNopacityDisplayChannel::DrawScreenResolution(void) { cImageLoader imgLoader; if (isRadioChannel) { if (!radioIconDrawn) { - if (imgLoader.LoadIcon("skinIcons/radio", config.resolutionIconSize)) { - pixmapScreenResolution->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/radio", config.resolutionIconSize, config.resolutionIconSize); + if (imgIcon) + pixmapScreenResolution->DrawImage(cPoint(0,0), *imgIcon); lastScreenWidth = 0; radioIconDrawn = true; } @@ -419,9 +379,9 @@ void cNopacityDisplayChannel::DrawScreenResolution(void) { iconName = "skinIcons/sd576i"; break; } - if (imgLoader.LoadIcon(*iconName, config.resolutionIconSize)) { - pixmapScreenResolution->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon(*iconName, config.resolutionIconSize, config.resolutionIconSize); + if (imgIcon) + pixmapScreenResolution->DrawImage(cPoint(0,0), *imgIcon); lastScreenWidth = screenWidth; radioIconDrawn = false; } @@ -429,26 +389,25 @@ void cNopacityDisplayChannel::DrawScreenResolution(void) { } void cNopacityDisplayChannel::DrawSignalMeter(void) { - signalWidth = infoWidth * 0.15; + signalWidth = geoManager->channelWidth * 0.15; signalHeight = signalWidth *15 / 200; showSignal = false; if (config.displaySignalStrength) { - cImageLoader imgLoader; cString signalStrength = "STR"; cString signalQuality = "SNR"; - if (imgLoader.LoadIcon("skinIcons/signal", signalWidth, signalHeight, false)) { - cImage imgSignal = imgLoader.GetImage(); - signalWidth = imgSignal.Width(); - signalHeight = imgSignal.Height(); - int signalMeterY = streamInfoY + (streamInfoHeight - 2*signalHeight - 5)/2; + cImage *imgSignal = imgCache->GetSkinIcon("skinIcons/signal", signalWidth, signalHeight, true); + if (imgSignal) { + signalWidth = imgSignal->Width(); + signalHeight = imgSignal->Height(); + int signalMeterY = geoManager->channelStreamInfoY + (geoManager->channelStreamInfoHeight - 2*signalHeight - 5)/2; fontInfoline = cFont::CreateFont(config.fontName, signalHeight - 2); int labelWidth = max(fontInfoline->Width(*signalStrength), fontInfoline->Width(*signalQuality)) + 2; - signalX = streamInfoHeight / 2 + labelWidth; + signalX = geoManager->channelStreamInfoHeight / 2 + labelWidth; showSignal = true; - pixmapSignalStrength = osd->CreatePixmap(3, cRect(infoX + signalX, top + signalMeterY + 2, signalWidth + 2, signalHeight + 2)); - pixmapSignalQuality = osd->CreatePixmap(3, cRect(infoX + signalX, top + signalMeterY + signalHeight + 5, signalWidth + 2, signalHeight + 2)); - pixmapSignalMeter = osd->CreatePixmap(4, cRect(infoX + signalX + 1, top + signalMeterY + 3, signalWidth, 2*signalHeight + 3)); - pixmapSignalLabel = osd->CreatePixmap(3, cRect(infoX + streamInfoHeight / 2, top + signalMeterY + 2, labelWidth, 2*signalHeight + 3)); + pixmapSignalStrength = osd->CreatePixmap(3, cRect(geoManager->channelX + signalX, geoManager->channelTop + signalMeterY + 2, signalWidth + 2, signalHeight + 2)); + pixmapSignalQuality = osd->CreatePixmap(3, cRect(geoManager->channelX + signalX, geoManager->channelTop + signalMeterY + signalHeight + 5, signalWidth + 2, signalHeight + 2)); + pixmapSignalMeter = osd->CreatePixmap(4, cRect(geoManager->channelX + signalX + 1, geoManager->channelTop + signalMeterY + 3, signalWidth, 2*signalHeight + 3)); + pixmapSignalLabel = osd->CreatePixmap(3, cRect(geoManager->channelX + geoManager->channelStreamInfoHeight / 2, geoManager->channelTop + signalMeterY + 2, labelWidth, 2*signalHeight + 3)); pixmapSignalStrength->Fill(Theme.Color(clrProgressBarBack)); pixmapSignalQuality->Fill(Theme.Color(clrProgressBarBack)); pixmapSignalMeter->Fill(clrTransparent); @@ -459,8 +418,8 @@ void cNopacityDisplayChannel::DrawSignalMeter(void) { pixmapSignalMeter->SetAlpha(0); pixmapSignalLabel->SetAlpha(0); } - pixmapSignalStrength->DrawImage(cPoint(1,1), imgSignal); - pixmapSignalQuality->DrawImage(cPoint(1,1), imgSignal); + pixmapSignalStrength->DrawImage(cPoint(1,1), *imgSignal); + pixmapSignalQuality->DrawImage(cPoint(1,1), *imgSignal); pixmapSignalLabel->DrawText(cPoint(0, 2), *signalStrength, Theme.Color(clrChannelEPGInfo), clrTransparent, fontInfoline); pixmapSignalLabel->DrawText(cPoint(0, signalHeight + 4), *signalQuality, Theme.Color(clrChannelEPGInfo), clrTransparent, fontInfoline); } @@ -516,7 +475,7 @@ void cNopacityDisplayChannel::DrawSourceInfo(const cChannel *Channel) { if (config.displaySignalStrength) x += signalWidth; pixmapFooter->Fill(clrTransparent); - pixmapFooter->DrawText(cPoint(x, (streamInfoHeight - fontDate->Height())/2), channelInfo, Theme.Color(clrChannelHead), clrTransparent, fontDate); + pixmapFooter->DrawText(cPoint(x, (geoManager->channelStreamInfoHeight - fontManager->channelDate->Height())/2), channelInfo, Theme.Color(clrChannelHead), clrTransparent, fontManager->channelDate); } void cNopacityDisplayChannel::SetChannel(const cChannel *Channel, int Number) { @@ -562,13 +521,13 @@ void cNopacityDisplayChannel::SetChannel(const cChannel *Channel, int Number) { DrawSourceInfo(Channel); } cString channelString = cString::sprintf("%s %s", *ChannelNumber, *ChannelName); - pixmapChannelInfo->DrawText(cPoint(channelInfoHeight/2, (channelInfoHeight-fontHeader->Height())/2), channelString, Theme.Color(clrChannelHead), clrTransparent, fontHeader); + pixmapChannelInfo->DrawText(cPoint(geoManager->channelInfoHeight/2, (geoManager->channelInfoHeight-fontManager->channelHeader->Height())/2), channelString, Theme.Color(clrChannelHead), clrTransparent, fontManager->channelHeader); if (config.logoPosition != lpNone) { cImageLoader imgLoader; if (imgLoader.LoadLogo(*ChannelName)) { - pixmapLogo->DrawImage(cPoint(config.logoBorder, (height-config.logoHeight)/2), imgLoader.GetImage()); + pixmapLogo->DrawImage(cPoint(config.logoBorder, (geoManager->channelHeight-config.logoHeight)/2), imgLoader.GetImage()); } else if (Channel && imgLoader.LoadLogo(*(Channel->GetChannelID().ToString()))) { - pixmapLogo->DrawImage(cPoint(config.logoBorder, (height-config.logoHeight)/2), imgLoader.GetImage()); + pixmapLogo->DrawImage(cPoint(config.logoBorder, (geoManager->channelHeight-config.logoHeight)/2), imgLoader.GetImage()); } } ShowSignalMeter(); @@ -588,25 +547,27 @@ void cNopacityDisplayChannel::DrawChannelGroups(const cChannel *Channel, cString if (withInfo) { pixmapProgressBar->Fill(clrTransparent); pixmapEPGInfo->Fill(clrTransparent); - ySep = (epgInfoHeight-fontChannelGroup->Height())/2 - fontChannelGroup->Height()/2; - ySepNextPrevIcon = (epgInfoHeight - prevNextSize)/2 - fontChannelGroup->Height()/2; + ySep = (geoManager->channelEpgInfoHeight-fontManager->channelChannelGroup->Height())/2 - fontManager->channelChannelGroup->Height()/2; + ySepNextPrevIcon = (geoManager->channelEpgInfoHeight - prevNextSize)/2 - fontManager->channelChannelGroup->Height()/2; infoPixmap = pixmapEPGInfo; } else { - ySep = (channelInfoHeight - fontChannelGroup->Height())/2; - ySepNextPrevIcon = (channelInfoHeight - prevNextSize)/2; + ySep = (geoManager->channelInfoHeight - fontManager->channelChannelGroup->Height())/2; + ySepNextPrevIcon = (geoManager->channelInfoHeight - prevNextSize)/2; infoPixmap = pixmapChannelInfo; } - int widthSep = fontChannelGroup->Width(*ChannelName); - int xSep = (config.displayPrevNextChannelGroup)?(infoWidth * 2 / 5):0; - infoPixmap->DrawText(cPoint(xSep, ySep), *ChannelName, Theme.Color(clrChannelHead), clrTransparent, fontChannelGroup); + int widthSep = fontManager->channelChannelGroup->Width(*ChannelName); + int xSep = (config.displayPrevNextChannelGroup)?(geoManager->channelWidth * 2 / 5):0; + infoPixmap->DrawText(cPoint(xSep, ySep), *ChannelName, Theme.Color(clrChannelHead), clrTransparent, fontManager->channelChannelGroup); cImageLoader imgLoader; if (config.logoPosition != lpNone) { cString separator = cString::sprintf("separatorlogos/%s", *ChannelName); if (imgLoader.LoadLogo(*separator)) { - pixmapLogo->DrawImage(cPoint(config.logoBorder, (height-config.logoHeight)/2), imgLoader.GetImage()); - } else if (imgLoader.LoadIcon("skinIcons/Channelseparator", config.logoWidth, config.logoHeight)) { - pixmapLogo->DrawImage(cPoint(config.logoBorder + (config.logoWidth - config.logoWidth)/2, (height-config.logoHeight)/2), imgLoader.GetImage()); + pixmapLogo->DrawImage(cPoint(config.logoBorder, (geoManager->channelHeight-config.logoHeight)/2), imgLoader.GetImage()); + } else { + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/Channelseparator", config.logoWidth, config.logoHeight); + if (imgIcon) + pixmapLogo->DrawImage(cPoint(config.logoBorder + (config.logoWidth - config.logoWidth)/2, (geoManager->channelHeight-config.logoHeight)/2), *imgIcon); } } @@ -619,30 +580,30 @@ void cNopacityDisplayChannel::DrawChannelGroups(const cChannel *Channel, cString bool nextAvailable = (strlen(*nextChannelSep) > 0)?true:false; - int ySepNextPrev = ySep + (fontChannelGroup->Height() - fontChannelGroupSmall->Height())/2; + int ySepNextPrev = ySep + (fontManager->channelChannelGroup->Height() - fontManager->channelChannelGroupSmall->Height())/2; if (prevAvailable) { int xSymbol = xSep - prevNextSize - 10; - if (imgLoader.LoadIcon("skinIcons/arrowLeftChannelSep", prevNextSize)) { - infoPixmap->DrawImage(cPoint(xSymbol, ySepNextPrevIcon), imgLoader.GetImage()); - } - int xSepPrev = xSymbol - 10 - fontChannelGroupSmall->Width(prevChannelSep); + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/arrowLeftChannelSep", prevNextSize, prevNextSize); + if (imgIcon) + infoPixmap->DrawImage(cPoint(xSymbol, ySepNextPrevIcon), *imgIcon); + int xSepPrev = xSymbol - 10 - fontManager->channelChannelGroupSmall->Width(prevChannelSep); if (xSepPrev < 0) { - prevChannelSep = CutText(*prevChannelSep, xSymbol, fontChannelGroupSmall).c_str(); - xSepPrev = xSymbol - 10 - fontChannelGroupSmall->Width(prevChannelSep); + prevChannelSep = CutText(*prevChannelSep, xSymbol, fontManager->channelChannelGroupSmall).c_str(); + xSepPrev = xSymbol - 10 - fontManager->channelChannelGroupSmall->Width(prevChannelSep); } - infoPixmap->DrawText(cPoint(xSepPrev, ySepNextPrev), *prevChannelSep, Theme.Color(clrChannelEPGInfoNext), clrTransparent, fontChannelGroupSmall); + infoPixmap->DrawText(cPoint(xSepPrev, ySepNextPrev), *prevChannelSep, Theme.Color(clrChannelEPGInfoNext), clrTransparent, fontManager->channelChannelGroupSmall); } if (nextAvailable) { int xSymbol = xSep + widthSep + 10; - if (imgLoader.LoadIcon("skinIcons/arrowRightChannelSep", prevNextSize)) { - infoPixmap->DrawImage(cPoint(xSymbol, ySepNextPrevIcon), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/arrowRightChannelSep", prevNextSize, prevNextSize); + if (imgIcon) + infoPixmap->DrawImage(cPoint(xSymbol, ySepNextPrevIcon), *imgIcon); int xSepNext = xSymbol + 10 + prevNextSize; int spaceAvailable = infoPixmap->DrawPort().Width() - xSepNext; - if (fontChannelGroupSmall->Width(nextChannelSep) > spaceAvailable) { - nextChannelSep = CutText(*nextChannelSep, spaceAvailable, fontChannelGroupSmall).c_str(); + if (fontManager->channelChannelGroupSmall->Width(nextChannelSep) > spaceAvailable) { + nextChannelSep = CutText(*nextChannelSep, spaceAvailable, fontManager->channelChannelGroupSmall).c_str(); } - infoPixmap->DrawText(cPoint(xSepNext, ySepNextPrev), *nextChannelSep, Theme.Color(clrChannelEPGInfoNext), clrTransparent, fontChannelGroupSmall); + infoPixmap->DrawText(cPoint(xSepNext, ySepNextPrev), *nextChannelSep, Theme.Color(clrChannelEPGInfoNext), clrTransparent, fontManager->channelChannelGroupSmall); } } @@ -679,9 +640,9 @@ void cNopacityDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Fol int y = !i ? 0 : 2; if (e) { cString startTime = e->GetTimeString(); - int startTimeWidth = fontEPG->Width(*startTime); - int epgWidth = fontEPG->Width(e->Title()); - int epgWidthShort = fontEPGSmall->Width(e->ShortText()); + int startTimeWidth = fontManager->channelEPG->Width(*startTime); + int epgWidth = fontManager->channelEPG->Width(e->Title()); + int epgWidthShort = fontManager->channelEPGSmall->Width(e->ShortText()); cString strSeen(""); if (i==0) { if (config.progressCurrentSchedule == 0) { @@ -696,42 +657,42 @@ void cNopacityDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Fol } else { strSeen = cString::sprintf("%dmin", e->Duration()/60); } - int seenWidth = fontEPG->Width(*strSeen); - int space = infoWidth - 9*indent - seenWidth - startTimeWidth - config.resolutionIconSize; + int seenWidth = fontManager->channelEPG->Width(*strSeen); + int space = geoManager->channelWidth - 9*indent - seenWidth - startTimeWidth - config.resolutionIconSize; bool drawRecIcon = false; int widthRecIcon = 0; if (e->HasTimer()) { drawRecIcon = true; - widthRecIcon = fontEPGSmall->Width(" REC "); + widthRecIcon = fontManager->channelEPGSmall->Width(" REC "); space -= widthRecIcon + indent/2; } cString strEPG = e->Title(); if (space < epgWidth) { - strEPG = CutText(e->Title(), space, fontEPG).c_str(); + strEPG = CutText(e->Title(), space, fontManager->channelEPG).c_str(); } cString strEPGShort = e->ShortText(); - int spaceShort = infoWidth - 6*indent - startTimeWidth - config.resolutionIconSize; + int spaceShort = geoManager->channelWidth - 6*indent - startTimeWidth - config.resolutionIconSize; if (spaceShort < epgWidthShort) { - strEPGShort = CutText(e->ShortText(), spaceShort, fontEPGSmall).c_str(); + strEPGShort = CutText(e->ShortText(), spaceShort, fontManager->channelEPGSmall).c_str(); } tColor fontColor = (i==0)?Theme.Color(clrChannelEPG):Theme.Color(clrChannelEPGNext); tColor fontColorInfo = (i==0)?Theme.Color(clrChannelEPGInfo):Theme.Color(clrChannelEPGInfoNext); - pixmapEPGInfo->DrawText(cPoint(indent, y * epgInfoLineHeight), *startTime, fontColor, clrTransparent, fontEPG); + pixmapEPGInfo->DrawText(cPoint(indent, y * geoManager->channelEpgInfoLineHeight), *startTime, fontColor, clrTransparent, fontManager->channelEPG); int xEPGInfo = 2 * indent + startTimeWidth; if (drawRecIcon) { tColor clrRecIcon = (i==0)?Theme.Color(clrRecNow):Theme.Color(clrRecNext); tColor clrRecIconText = (i==0)?Theme.Color(clrRecNowFont):Theme.Color(clrRecNextFont); - pixmapEPGInfo->DrawRectangle(cRect(xEPGInfo, y * epgInfoLineHeight , widthRecIcon, epgInfoLineHeight), clrRecIcon); - int xRecText = xEPGInfo + (widthRecIcon - fontEPGSmall->Width("REC"))/2; - int yRecText = y * epgInfoLineHeight + (epgInfoLineHeight - fontEPGSmall->Height())/2; - pixmapEPGInfo->DrawText(cPoint(xRecText, yRecText), "REC", clrRecIconText, clrRecIcon, fontEPGSmall); + pixmapEPGInfo->DrawRectangle(cRect(xEPGInfo, y * geoManager->channelEpgInfoLineHeight , widthRecIcon, geoManager->channelEpgInfoLineHeight), clrRecIcon); + int xRecText = xEPGInfo + (widthRecIcon - fontManager->channelEPGSmall->Width("REC"))/2; + int yRecText = y * geoManager->channelEpgInfoLineHeight + (geoManager->channelEpgInfoLineHeight - fontManager->channelEPGSmall->Height())/2; + pixmapEPGInfo->DrawText(cPoint(xRecText, yRecText), "REC", clrRecIconText, clrRecIcon, fontManager->channelEPGSmall); xEPGInfo += widthRecIcon + indent/2; } - pixmapEPGInfo->DrawText(cPoint(xEPGInfo, y * epgInfoLineHeight), *strEPG, fontColor, clrTransparent, fontEPG); - pixmapEPGInfo->DrawText(cPoint(2 * indent + startTimeWidth, (y+1) * epgInfoLineHeight + 3), *strEPGShort, fontColorInfo, clrTransparent, fontEPGSmall); - int x = infoWidth - indent - seenWidth - config.resolutionIconSize - indent; - pixmapEPGInfo->DrawText(cPoint(x, y * epgInfoLineHeight), *strSeen, fontColor, clrTransparent, fontEPG); + pixmapEPGInfo->DrawText(cPoint(xEPGInfo, y * geoManager->channelEpgInfoLineHeight), *strEPG, fontColor, clrTransparent, fontManager->channelEPG); + pixmapEPGInfo->DrawText(cPoint(2 * indent + startTimeWidth, (y+1) * geoManager->channelEpgInfoLineHeight + 3), *strEPGShort, fontColorInfo, clrTransparent, fontManager->channelEPGSmall); + int x = geoManager->channelWidth - indent - seenWidth - config.resolutionIconSize - indent; + pixmapEPGInfo->DrawText(cPoint(x, y * geoManager->channelEpgInfoLineHeight), *strSeen, fontColor, clrTransparent, fontManager->channelEPG); } } } diff --git a/displaychannel.h b/displaychannel.h index d4d1403..2280b46 100644 --- a/displaychannel.h +++ b/displaychannel.h @@ -1,7 +1,7 @@ #ifndef __NOPACITY_DISPLAYCHANNEL_H #define __NOPACITY_DISPLAYCHANNEL_H -enum eLogoPosition {lpNone = 0, lpLeft, lpRight}; +//enum eLogoPosition {lpNone = 0, lpLeft, lpRight}; enum eBackgroundStyle {bsTrans = 0, bsFull}; class cNopacityDisplayChannel : public cSkinDisplayChannel, cThread { @@ -25,6 +25,7 @@ private: bool showSignal; const cEvent *present; cOsd *osd; + cImageCache *imgCache; cPixmap *pixmapBackgroundTop; cPixmap *pixmapBackgroundMiddle; cPixmap *pixmapBackgroundBottom; @@ -45,31 +46,11 @@ private: cPixmap *pixmapSignalLabel; cPixmap *pixmapScreenResolution; cPixmap *pixmapPoster; - int top, height; - int infoWidth; - int infoX; - int channelInfoWidth; - int channelInfoHeight; - int dateWidth; - int progressBarHeight; - int epgInfoHeight; - int epgInfoLineHeight; - int streamInfoHeight; - int streamInfoY; - int iconSize; - int iconsWidth; int signalWidth, signalHeight, signalX; - cFont *fontHeader; - cFont *fontDate; - cFont *fontEPG; - cFont *fontEPGSmall; cFont *fontInfoline; - cFont *fontChannelGroup; - cFont *fontChannelGroupSmall; virtual void Action(void); - void SetGeometry(void); + void createOsd(void); void CreatePixmaps(void); - void CreateFonts(void); void DrawBackground(void); void DrawDate(void); void DrawProgressBar(int Current, int Total); @@ -87,7 +68,7 @@ private: cString GetChannelSep(const cChannel *channel, bool prev); void DrawPoster(const cEvent *event); public: - cNopacityDisplayChannel(bool WithInfo); + cNopacityDisplayChannel(cImageCache *imgCache, bool WithInfo); virtual ~cNopacityDisplayChannel(); virtual void SetChannel(const cChannel *Channel, int Number); virtual void SetEvents(const cEvent *Present, const cEvent *Following); diff --git a/displaymenu.c b/displaymenu.c index 75b0016..ef85f25 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -8,7 +8,8 @@ namespace PluginRemoteTimers { #include "displaymenu.h" #include <string> -cNopacityDisplayMenu::cNopacityDisplayMenu(void) { +cNopacityDisplayMenu::cNopacityDisplayMenu(cImageCache *imgCache) { + this->imgCache = imgCache; config.setDynamicValues(); menuCategoryLast = mcUndefined; FrameTime = config.menuFrameTime; @@ -23,19 +24,17 @@ cNopacityDisplayMenu::cNopacityDisplayMenu(void) { currentNumItems = 0; detailView = NULL; SetButtonPositions(); - menuView = new cNopacityDisplayMenuView(); + menuView = new cNopacityDisplayMenuView(imgCache); osd = menuView->createOsd(); - menuView->SetGeometry(); + menuView->SetDescriptionTextWindowSize(); menuView->CreatePixmaps(); - menuView->CreateFonts(); menuView->SetAvrgFontWidth(); - menuView->CreateBackgroundImages(handleBackgrounds, handleButtons); menuView->DrawHeaderLogo(); menuView->DrawBorderDecoration(); currentFeed = 0; if (config.displayRSSFeed) { menuView->DrawRssFeed(config.rssFeeds[config.rssFeed[currentFeed]].name); - rssReader = new cRssReader(osd, menuView->GetRssFeedFont(), menuView->GetRssFeedPosition(), menuView->GetRssFeedSize()); + rssReader = new cRssReader(osd, fontManager->menuRssFeed, menuView->GetRssFeedPosition(), menuView->GetRssFeedSize()); rssReader->SetFeed(config.rssFeeds[config.rssFeed[currentFeed]].url); rssReader->Start(); } else @@ -59,12 +58,6 @@ cNopacityDisplayMenu::~cNopacityDisplayMenu() { delete detailView; } timers.Clear(); - if (config.doBlending) { - for (int i=0; i<14; i++) - cOsdProvider::DropImage(handleBackgrounds[i]); - for (int i=0; i<4; i++) - cOsdProvider::DropImage(handleButtons[i]); - } delete osd; cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); menuActive = false; @@ -138,7 +131,7 @@ void cNopacityDisplayMenu::DrawTimers(bool timersChanged, int numConflicts) { if (initial) if (FadeTime) t->SetAlpha(0); - currentHeight += t->GetHeight() + menuView->spaceMenu; + currentHeight += t->GetHeight() + geoManager->menuSpace; timers.Add(t); } int numTimersDisplayed = 0; @@ -149,7 +142,7 @@ void cNopacityDisplayMenu::DrawTimers(bool timersChanged, int numConflicts) { if (initial) if (FadeTime) t->SetAlpha(0); - currentHeight += t->GetHeight() + menuView->spaceMenu; + currentHeight += t->GetHeight() + geoManager->menuSpace; if (currentHeight < maxTimersHeight) { timers.Add(t); numTimersDisplayed++; @@ -363,22 +356,22 @@ void cNopacityDisplayMenu::SetButtonPositions(void) { void cNopacityDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) { if (Red) { - menuView->DrawButton(Red, handleButtons[0], Theme.Color(clrButtonRed), Theme.Color(clrButtonRedBorder), Theme.Color(clrButtonRedFont), positionButtons[0]); + menuView->DrawButton(Red, btButtonRed, Theme.Color(clrButtonRed), Theme.Color(clrButtonRedBorder), Theme.Color(clrButtonRedFont), positionButtons[0]); } else menuView->ClearButton(positionButtons[0]); if (Green) { - menuView->DrawButton(Green, handleButtons[1],Theme.Color(clrButtonGreen), Theme.Color(clrButtonGreenBorder), Theme.Color(clrButtonGreenFont), positionButtons[1]); + menuView->DrawButton(Green, btButtonGreen,Theme.Color(clrButtonGreen), Theme.Color(clrButtonGreenBorder), Theme.Color(clrButtonGreenFont), positionButtons[1]); } else menuView->ClearButton(positionButtons[1]); if (Yellow) { - menuView->DrawButton(Yellow, handleButtons[2], Theme.Color(clrButtonYellow), Theme.Color(clrButtonYellowBorder), Theme.Color(clrButtonYellowFont), positionButtons[2]); + menuView->DrawButton(Yellow, btButtonYellow, Theme.Color(clrButtonYellow), Theme.Color(clrButtonYellowBorder), Theme.Color(clrButtonYellowFont), positionButtons[2]); } else menuView->ClearButton(positionButtons[2]); if (Blue) { - menuView->DrawButton(Blue, handleButtons[3], Theme.Color(clrButtonBlue), Theme.Color(clrButtonBlueBorder), Theme.Color(clrButtonBlueFont), positionButtons[3]); + menuView->DrawButton(Blue, btButtonBlue, Theme.Color(clrButtonBlue), Theme.Color(clrButtonBlueBorder), Theme.Color(clrButtonBlueFont), positionButtons[3]); } else menuView->ClearButton(positionButtons[3]); } @@ -396,18 +389,17 @@ bool cNopacityDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Cur if (!config.narrowScheduleMenu) return false; if ((initMenu)&&(Index > menuItemIndexLast)) { - cNopacityMenuItem *item = new cNopacityScheduleMenuItem(osd, Event, Channel, TimerMatch, Selectable, MenuCategory(), &videoWindowRect); + cNopacityMenuItem *item = new cNopacityScheduleMenuItem(osd, imgCache, Event, Channel, TimerMatch, Selectable, MenuCategory(), &videoWindowRect); cPoint itemSize; menuView->GetMenuItemSize(MenuCategory(), &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcSchedule)); - item->SetFontSmall(menuView->GetMenuItemFontSmall(mcSchedule)); - item->SetFontEPGWindow(menuView->GetEPGWindowFont()); - item->SetFontEPGWindowLarge(menuView->GetEPGWindowFontLarge()); + item->SetFont(fontManager->menuItemSchedule); + item->SetFontSmall(fontManager->menuItemScheduleSmall); + item->SetFontEPGWindow(fontManager->menuEPGInfoWindow); + item->SetFontEPGWindowLarge(fontManager->menuEPGInfoWindowLarge); int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), menuView->spaceMenu); + item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace); item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcSchedule)); item->SetCurrent(Current); - item->SetBackgrounds(handleBackgrounds); item->CreateText(); int textWidth = item->CheckScrollable((Channel)?true:false); item->CreatePixmap(); @@ -435,15 +427,14 @@ bool cNopacityDisplayMenu::SetItemTimer(const cTimer *Timer, int Index, bool Cur if (!config.narrowTimerMenu) return false; if ((initMenu)&&(Index > menuItemIndexLast)) { - cNopacityMenuItem *item = new cNopacityTimerMenuItem(osd, Timer, Selectable); + cNopacityMenuItem *item = new cNopacityTimerMenuItem(osd, imgCache, Timer, Selectable); cPoint itemSize; menuView->GetMenuItemSize(MenuCategory(), &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcTimer)); - item->SetFontSmall(menuView->GetMenuItemFontSmall(mcTimer)); + item->SetFont(fontManager->menuItemTimers); + item->SetFontSmall(fontManager->menuItemTimersSmall); int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), menuView->spaceMenu); + item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace); item->SetCurrent(Current); - item->SetBackgrounds(handleBackgrounds); item->CreateText(); int textWidth = item->CheckScrollable(true); item->CreatePixmap(); @@ -471,17 +462,16 @@ bool cNopacityDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bo if (!config.narrowChannelMenu) return false; if ((initMenu)&&(Index > menuItemIndexLast)) { - cNopacityMenuItem *item = new cNopacityChannelMenuItem(osd, Channel, Selectable, &videoWindowRect); + cNopacityMenuItem *item = new cNopacityChannelMenuItem(osd, imgCache, Channel, Selectable, &videoWindowRect); cPoint itemSize; menuView->GetMenuItemSize(MenuCategory(), &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcChannel)); - item->SetFontSmall(menuView->GetMenuItemFontSmall(mcChannel)); - item->SetFontEPGWindow(menuView->GetEPGWindowFont()); + item->SetFont(fontManager->menuItemChannel); + item->SetFontSmall(fontManager->menuItemChannelSmall); + item->SetFontEPGWindow(fontManager->menuEPGInfoWindow); int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), menuView->spaceMenu); + item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace); item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcChannel)); item->SetCurrent(Current); - item->SetBackgrounds(handleBackgrounds); item->CreateText(); int textWidth = item->CheckScrollable(true); item->CreatePixmap(); @@ -513,18 +503,17 @@ bool cNopacityDisplayMenu::SetItemRecording(const cRecording *Recording, int Ind bool isFolder = false; if (Total > 0) isFolder = true; - cNopacityMenuItem *item = new cNopacityRecordingMenuItem(osd, Recording, Selectable, isFolder, Level, Total, New, &videoWindowRect); + cNopacityMenuItem *item = new cNopacityRecordingMenuItem(osd, imgCache, Recording, Selectable, isFolder, Level, Total, New, &videoWindowRect); cPoint itemSize; menuView->GetMenuItemSize(MenuCategory(), &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcRecording)); - item->SetFontSmall(menuView->GetMenuItemFontSmall(mcRecording)); - item->SetFontEPGWindow(menuView->GetEPGWindowFont()); - item->SetFontEPGWindowLarge(menuView->GetEPGWindowFontLarge()); + item->SetFont(fontManager->menuItemRecordings); + item->SetFontSmall(fontManager->menuItemRecordingsSmall); + item->SetFontEPGWindow(fontManager->menuEPGInfoWindow); + item->SetFontEPGWindowLarge(fontManager->menuEPGInfoWindowLarge); int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), menuView->spaceMenu); + item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace); item->SetTextWindow(menuView->GetDescriptionTextWindowSize(mcRecording)); item->SetCurrent(Current); - item->SetBackgrounds(handleBackgrounds); item->CreateText(); item->SetPoster(); int textWidth = item->CheckScrollable(false); @@ -551,6 +540,7 @@ bool cNopacityDisplayMenu::SetItemRecording(const cRecording *Recording, int Ind void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { + //int start = cTimeMs::Now(); bool hasIcons = false; cString *strItems = new cString[MaxTabs]; int *tabItems = new int[2*MaxTabs]; @@ -566,20 +556,19 @@ void cNopacityDisplayMenu::SetItem(const char *Text, int Index, bool Current, bo cPoint itemSize; if (((MenuCategory() == mcMain)&&(config.narrowMainMenu)) || ((MenuCategory() == mcSetup)&&(config.narrowSetupMenu))){ bool isSetup = (MenuCategory() == mcSetup)?true:false; - item = new cNopacityMainMenuItem(osd, Text, Selectable, isSetup); + item = new cNopacityMainMenuItem(osd, imgCache, Text, Selectable, isSetup); menuView->GetMenuItemSize(MenuCategory(), &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcMain)); + item->SetFont(fontManager->menuItemLarge); if (config.useMenuIcons) hasIcons = true; } else { - item = new cNopacityDefaultMenuItem(osd, Text, Selectable); + item = new cNopacityDefaultMenuItem(osd, imgCache, Text, Selectable); menuView->GetMenuItemSize(mcUnknown, &itemSize); - item->SetFont(menuView->GetMenuItemFont(mcUnknown)); + item->SetFont(fontManager->menuItemDefault); } int spaceTop = menuView->GetMenuTop(currentNumItems, itemSize.Y()); - item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), menuView->spaceMenu); + item->SetGeometry(Index, spaceTop, menuView->GetMenuItemLeft(itemSize.X()), itemSize.X(), itemSize.Y(), geoManager->menuSpace); item->SetCurrent(Current); - item->SetBackgrounds(handleBackgrounds); item->SetTabs(strItems, tabItems, MaxTabs); item->CreateText(); int textWidth = item->CheckScrollable(hasIcons); @@ -734,6 +723,7 @@ void cNopacityDisplayMenu::SetText(const char *Text, bool FixedFont) { } void cNopacityDisplayMenu::Flush(void) { + //int start = cTimeMs::Now(); menuView->DrawDate(initial); if (MenuCategory() == mcMain) { if (config.showDiscUsage) @@ -802,7 +792,7 @@ void cNopacityDisplayMenu::SwitchNextRssFeed(void) { SetNextFeed(); int feedNum = (config.rssFeed[currentFeed]==0)?0:(config.rssFeed[currentFeed]-1); menuView->DrawRssFeed(config.rssFeeds[feedNum].name); - rssReader = new cRssReader(osd, menuView->GetRssFeedFont(), menuView->GetRssFeedPosition(), menuView->GetRssFeedSize()); + rssReader = new cRssReader(osd, fontManager->menuRssFeed, menuView->GetRssFeedPosition(), menuView->GetRssFeedSize()); rssReader->SetFeed(config.rssFeeds[feedNum].url); rssReader->Start(); } diff --git a/displaymenu.h b/displaymenu.h index 83692bb..8f7bd69 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -3,6 +3,7 @@ class cNopacityDisplayMenu : public cSkinDisplayMenu , cThread { private: + cImageCache *imgCache; cNopacityDisplayMenuView *menuView; cNopacityMenuDetailView *detailView; cOsd *osd; @@ -19,8 +20,6 @@ private: int currentNumItems; cList<cNopacityTimer> timers; cList<cNopacityMenuItem> menuItems; - int handleBackgrounds[14]; - int handleButtons[4]; int positionButtons[4]; cRect videoWindowRect; cRssReader *rssReader; @@ -35,7 +34,7 @@ private: protected: int Tab(int n); public: - cNopacityDisplayMenu(void); + cNopacityDisplayMenu(cImageCache *imgCache); virtual ~cNopacityDisplayMenu(); virtual void Scroll(bool Up, bool Page); virtual int MaxItems(void); diff --git a/displaymenuview.c b/displaymenuview.c index e0a2838..50423c1 100644 --- a/displaymenuview.c +++ b/displaymenuview.c @@ -1,6 +1,7 @@ #include "displaymenuview.h" -cNopacityDisplayMenuView::cNopacityDisplayMenuView() { +cNopacityDisplayMenuView::cNopacityDisplayMenuView(cImageCache *imgCache) { + this->imgCache = imgCache; diskUsageAlert = 95; pixmapStatus = NULL; pixmapHeaderIcon = NULL; @@ -25,93 +26,51 @@ cNopacityDisplayMenuView::~cNopacityDisplayMenuView(void) { osd->DestroyPixmap(pixmapRssFeedBackground); if (pixmapRssFeedIcon) osd->DestroyPixmap(pixmapRssFeedIcon); - delete fontHeader; - delete fontDate; - delete fontMenuitemLarge; - delete fontMenuitemSchedule; - delete fontMenuitemScheduleSmall; - delete fontMenuitemChannel; - delete fontMenuitemChannelSmall; - delete fontMenuitemRecordings; - delete fontMenuitemRecordingsSmall; - delete fontMenuitemTimers; - delete fontMenuitemTimersSmall; - delete fontMenuitemDefault; - delete fontDiskUsage; - delete fontDiskUsagePercent; - delete fontTimers; - delete fontTimersHead; - delete fontButtons; - delete fontMessage; - delete fontEPGInfoWindow; - delete fontEPGInfoWindowLarge; - delete fontRssFeed; } cOsd *cNopacityDisplayMenuView::createOsd(void) { - osdLeft = cOsd::OsdLeft(); - osdTop = cOsd::OsdTop(); - osdWidth = cOsd::OsdWidth(); - osdHeight = cOsd::OsdHeight(); - osd = CreateOsd(osdLeft, osdTop, osdWidth, osdHeight); + osd = CreateOsd(geoManager->osdLeft, geoManager->osdTop, geoManager->osdWidth, geoManager->osdHeight); return osd; } -void cNopacityDisplayMenuView::SetGeometry(void) { - spaceMenu = 5; - widthScrollbar = 20; - dateWidth = osdWidth * 0.3; - headerHeight = osdHeight * config.headerHeight / 100; - footerHeight = osdHeight * config.footerHeight / 100; - rssFeedHeight = (config.displayRSSFeed)?(osdHeight * config.rssFeedHeight / 100):0; - contentHeight = osdHeight - headerHeight - footerHeight - rssFeedHeight; - contentWidthMain = osdWidth * config.menuWidthMain / 100; - contentWidthSchedules = osdWidth * config.menuWidthSchedules / 100; - contentWidthChannels = osdWidth * config.menuWidthChannels / 100; - contentWidthTimers = osdWidth * config.menuWidthTimers / 100; - contentWidthRecordings = osdWidth * config.menuWidthRecordings / 100; - contentWidthSetup = osdWidth * config.menuWidthSetup / 100; - contentWidthFull = osdWidth - widthScrollbar - spaceMenu; - contentWidthMinimum = Minimum(contentWidthMain, - contentWidthSchedules, - contentWidthChannels, - contentWidthTimers, - contentWidthRecordings, - contentWidthSetup); - menuItemWidthDefault = contentWidthFull - 4 * spaceMenu; - menuItemWidthMain = contentWidthMain - 4*spaceMenu; - menuItemWidthSchedule = contentWidthSchedules - 4*spaceMenu; - menuItemWidthChannel = contentWidthChannels - 4*spaceMenu; - menuItemWidthTimer = contentWidthTimers - 4*spaceMenu; - menuItemWidthRecording = contentWidthRecordings - 4*spaceMenu; - menuItemWidthSetup = contentWidthSetup - 4*spaceMenu; - menuItemHeightMain = config.iconHeight + 2; - menuItemHeightSchedule = config.menuItemLogoHeight + 2; - menuItemHeightDefault = contentHeight / config.numDefaultMenuItems - spaceMenu; - menuItemHeightRecordings = config.menuRecFolderSize + 2; - diskUsageWidth = diskUsageHeight = osdWidth * config.menuSizeDiskUsage / 100; - timersWidth = osdWidth * config.menuWidthRightItems / 100; - buttonsBorder = footerHeight / 6; - buttonWidth = (osdWidth / 4) - 2 * buttonsBorder; - buttonHeight = footerHeight - 3 * buttonsBorder; - messageWidth = 0.8 * osdWidth; - messageHeight = 0.1 * osdHeight; - SetDescriptionTextWindowSize(); -} - void cNopacityDisplayMenuView::SetDescriptionTextWindowSize(void) { - int xSchedules = (config.menuAdjustLeft) ? (2 * spaceMenu + contentWidthSchedules + widthScrollbar) : (spaceMenu); - int xRecordings = (config.menuAdjustLeft) ? (2 * spaceMenu + contentWidthRecordings + widthScrollbar) : (spaceMenu); - int xChannels = (config.menuAdjustLeft) ? (2 * spaceMenu + contentWidthChannels + widthScrollbar) : (spaceMenu); - - int heightFull = contentHeight - 2*spaceMenu; + int xSchedules, xRecordings, xChannels; + int widthSchedules, widthRecordings, widthChannels; + if (config.menuAdjustLeft) { + xSchedules = 2 * geoManager->menuSpace + + geoManager->menuContentWidthSchedules + + geoManager->menuWidthScrollbar; + xRecordings = 2 * geoManager->menuSpace + + geoManager->menuContentWidthRecordings + + geoManager->menuWidthScrollbar; + xChannels = 2 * geoManager->menuSpace + + geoManager->menuContentWidthChannels + + geoManager->menuWidthScrollbar; + widthSchedules = geoManager->osdWidth - xSchedules - geoManager->menuSpace; + widthRecordings = geoManager->osdWidth - xRecordings - geoManager->menuSpace; + widthChannels = geoManager->osdWidth - xChannels - geoManager->menuSpace; + } else { + xSchedules = geoManager->menuSpace; + xRecordings = geoManager->menuSpace; + xChannels = geoManager->menuSpace; + widthSchedules = geoManager->osdWidth + - geoManager->menuContentWidthSchedules + - geoManager->menuWidthScrollbar + - 2 * geoManager->menuSpace; + widthRecordings = geoManager->osdWidth + - geoManager->menuContentWidthRecordings + - geoManager->menuWidthScrollbar + - 2 * geoManager->menuSpace; + widthChannels = geoManager->osdWidth + - geoManager->menuContentWidthChannels + - geoManager->menuWidthScrollbar + - 2 * geoManager->menuSpace; + } + int heightFull = geoManager->menuContentHeight - 2*geoManager->menuSpace; int height = config.menuHeightInfoWindow * heightFull / 100; - int y = headerHeight + (contentHeight - height - spaceMenu); - int yFullScreen = headerHeight + spaceMenu; + int y = geoManager->menuHeaderHeight + (geoManager->menuContentHeight - height - geoManager->menuSpace); + int yFullScreen = geoManager->menuHeaderHeight + geoManager->menuSpace; - int widthSchedules = (config.menuAdjustLeft) ? (osdWidth - xSchedules - spaceMenu) : (osdWidth - contentWidthSchedules - widthScrollbar - 2 * spaceMenu); - int widthRecordings = (config.menuAdjustLeft) ? (osdWidth - xRecordings - spaceMenu) : (osdWidth - contentWidthRecordings - widthScrollbar - 2 * spaceMenu); - int widthChannels = (config.menuAdjustLeft) ? (osdWidth - xChannels - spaceMenu) : (osdWidth - contentWidthChannels - widthScrollbar - 2 * spaceMenu); if (config.menuSchedulesWindowMode == 0) textWindowSizeSchedules = cRect(xSchedules,y,widthSchedules,height); else @@ -141,66 +100,66 @@ int cNopacityDisplayMenuView::GetContentWidth(eMenuCategory menuCat) { switch (menuCat) { case mcMain: if (config.narrowMainMenu) - return contentWidthMain; + return geoManager->menuContentWidthMain; else - return contentWidthFull; + return geoManager->menuContentWidthFull; case mcSetup: if (config.narrowSetupMenu) - return contentWidthSetup; + return geoManager->menuContentWidthSetup; else - return contentWidthFull; + return geoManager->menuContentWidthFull; case mcSchedule: case mcScheduleNow: case mcScheduleNext: if (config.narrowScheduleMenu) - return contentWidthSchedules; + return geoManager->menuContentWidthSchedules; else - return contentWidthFull; + return geoManager->menuContentWidthFull; case mcChannel: if (config.narrowChannelMenu) - return contentWidthChannels; + return geoManager->menuContentWidthChannels; else - return contentWidthFull; + return geoManager->menuContentWidthFull; case mcTimer: if (config.narrowTimerMenu) - return contentWidthTimers; + return geoManager->menuContentWidthTimers; else - return contentWidthFull; + return geoManager->menuContentWidthFull; case mcRecording: if (config.narrowRecordingMenu) - return contentWidthRecordings; + return geoManager->menuContentWidthRecordings; else - return contentWidthFull; + return geoManager->menuContentWidthFull; default: - return contentWidthFull; + return geoManager->menuContentWidthFull; } - return contentWidthFull; + return geoManager->menuContentWidthFull; } void cNopacityDisplayMenuView::CreatePixmaps(void) { - pixmapHeader = osd->CreatePixmap(1, cRect(0, 0, osdWidth, headerHeight)); - int dateX = (config.menuAdjustLeft) ? (osdWidth - dateWidth) : 0; - pixmapDate = osd->CreatePixmap(2, cRect(dateX, 0, dateWidth, headerHeight)); - int logoX = (config.menuAdjustLeft) ? 0 : (osdWidth - config.menuHeaderLogoWidth); + pixmapHeader = osd->CreatePixmap(1, cRect(0, 0, geoManager->osdWidth, geoManager->menuHeaderHeight)); + int dateX = (config.menuAdjustLeft) ? (geoManager->osdWidth - geoManager->menuDateWidth) : 0; + pixmapDate = osd->CreatePixmap(2, cRect(dateX, 0, geoManager->menuDateWidth, geoManager->menuHeaderHeight)); + int logoX = (config.menuAdjustLeft) ? 0 : (geoManager->osdWidth - config.menuHeaderLogoWidth); pixmapHeaderLogo = osd->CreatePixmap(-1, cRect(logoX, 0, config.menuHeaderLogoWidth, config.menuHeaderLogoHeight)); - int labelX = (config.menuAdjustLeft) ? 0 : dateWidth; - pixmapHeaderLabel = osd->CreatePixmap(2, cRect(labelX, 0, osdWidth - dateWidth, headerHeight)); - pixmapFooter = osd->CreatePixmap(1, cRect(0, osdHeight - rssFeedHeight - footerHeight, osdWidth, footerHeight)); - int drawPortWidth = osdWidth + contentWidthFull - contentWidthMinimum; - pixmapContent = osd->CreatePixmap(1, cRect(0, headerHeight, osdWidth, contentHeight), - cRect(0, 0, drawPortWidth, contentHeight)); - int diskUsageX = (config.menuAdjustLeft) ? (osdWidth - diskUsageWidth - 10) : 10; - pixmapDiskUsage = osd->CreatePixmap(2, cRect(diskUsageX, headerHeight + spaceMenu, diskUsageWidth, diskUsageHeight)); - pixmapDiskUsageIcon = osd->CreatePixmap(3, cRect(diskUsageX + 2, headerHeight + spaceMenu + 2, diskUsageWidth - 4, diskUsageHeight - 4)); - pixmapDiskUsageLabel = osd->CreatePixmap(4, cRect(diskUsageX + 2, headerHeight + spaceMenu + 2, diskUsageWidth - 4, diskUsageHeight - 4)); - int scrollbarX = (config.menuAdjustLeft) ? contentWidthMain : (osdWidth - contentWidthMain); - pixmapScrollbar = osd->CreatePixmap(2, cRect(scrollbarX, headerHeight + spaceMenu, widthScrollbar, contentHeight - 2 * spaceMenu)); + int labelX = (config.menuAdjustLeft) ? 0 : geoManager->menuDateWidth; + pixmapHeaderLabel = osd->CreatePixmap(2, cRect(labelX, 0, geoManager->osdWidth - geoManager->menuDateWidth, geoManager->menuHeaderHeight)); + pixmapFooter = osd->CreatePixmap(1, cRect(0, geoManager->osdHeight - geoManager->menuRssFeedHeight - geoManager->menuFooterHeight, geoManager->osdWidth, geoManager->menuFooterHeight)); + int drawPortWidth = geoManager->osdWidth + geoManager->menuContentWidthFull - geoManager->menuContentWidthMinimum; + pixmapContent = osd->CreatePixmap(1, cRect(0, geoManager->menuHeaderHeight, geoManager->osdWidth, geoManager->menuContentHeight), + cRect(0, 0, drawPortWidth, geoManager->menuContentHeight)); + int diskUsageX = (config.menuAdjustLeft) ? (geoManager->osdWidth - geoManager->menuDiskUsageWidth - 10) : 10; + pixmapDiskUsage = osd->CreatePixmap(2, cRect(diskUsageX, geoManager->menuHeaderHeight + geoManager->menuSpace, geoManager->menuDiskUsageWidth, geoManager->menuDiskUsageHeight)); + pixmapDiskUsageIcon = osd->CreatePixmap(3, cRect(diskUsageX + 2, geoManager->menuHeaderHeight + geoManager->menuSpace + 2, geoManager->menuDiskUsageWidth - 4, geoManager->menuDiskUsageHeight - 4)); + pixmapDiskUsageLabel = osd->CreatePixmap(4, cRect(diskUsageX + 2, geoManager->menuHeaderHeight + geoManager->menuSpace + 2, geoManager->menuDiskUsageWidth - 4, geoManager->menuDiskUsageHeight - 4)); + int scrollbarX = (config.menuAdjustLeft) ? geoManager->menuContentWidthMain : (geoManager->osdWidth - geoManager->menuContentWidthMain); + pixmapScrollbar = osd->CreatePixmap(2, cRect(scrollbarX, geoManager->menuHeaderHeight + geoManager->menuSpace, geoManager->menuWidthScrollbar, geoManager->menuContentHeight - 2 * geoManager->menuSpace)); if (config.displayRSSFeed) { - pixmapRssFeedBackground = osd->CreatePixmap(1, cRect(0, headerHeight + contentHeight + footerHeight, osdWidth, rssFeedHeight)); - pixmapRssFeed = osd->CreatePixmap(2, cRect(0, headerHeight + contentHeight + footerHeight, osdWidth, rssFeedHeight)); - pixmapRssFeedIcon = osd->CreatePixmap(3, cRect(0, headerHeight + contentHeight + footerHeight, rssFeedHeight, rssFeedHeight)); + pixmapRssFeedBackground = osd->CreatePixmap(1, cRect(0, geoManager->menuHeaderHeight + geoManager->menuContentHeight + geoManager->menuFooterHeight, geoManager->osdWidth, geoManager->menuRssFeedHeight)); + pixmapRssFeed = osd->CreatePixmap(2, cRect(0, geoManager->menuHeaderHeight + geoManager->menuContentHeight + geoManager->menuFooterHeight, geoManager->osdWidth, geoManager->menuRssFeedHeight)); + pixmapRssFeedIcon = osd->CreatePixmap(3, cRect(0, geoManager->menuHeaderHeight + geoManager->menuContentHeight + geoManager->menuFooterHeight, geoManager->menuRssFeedHeight, geoManager->menuRssFeedHeight)); } else { pixmapRssFeedBackground = NULL; pixmapRssFeed = NULL; @@ -238,112 +197,43 @@ void cNopacityDisplayMenuView::SetPixmapAlpha(int Alpha) { pixmapDiskUsageLabel->SetAlpha(Alpha); } -void cNopacityDisplayMenuView::CreateFonts(void) { - fontHeader = cFont::CreateFont(config.fontName, headerHeight / 2 + config.fontHeader); - fontDate = cFont::CreateFont(config.fontName, headerHeight / 2 + config.fontDate); - fontMenuitemLarge = cFont::CreateFont(config.fontName, menuItemHeightMain/3 + 4 + config.fontMenuitemLarge); - fontMenuitemSchedule = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 4 + 5 + config.fontMenuitemSchedule); - fontMenuitemScheduleSmall = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 4 - 5 + config.fontMenuitemScheduleSmall); - fontMenuitemChannel = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 3 + config.fontMenuitemChannel); - fontMenuitemChannelSmall = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 5 - 2 + config.fontMenuitemChannelSmall); - fontMenuitemRecordings = cFont::CreateFont(config.fontName, menuItemHeightRecordings / 2 - 14 + config.fontMenuitemRecordings); - fontMenuitemRecordingsSmall = cFont::CreateFont(config.fontName, menuItemHeightRecordings / 4 - 3 + config.fontMenuitemRecordingsSmall); - fontMenuitemTimers = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 3 + config.fontMenuitemTimers); - fontMenuitemTimersSmall = cFont::CreateFont(config.fontName, menuItemHeightSchedule / 4 - 3 + config.fontMenuitemTimersSmall); - fontMenuitemDefault = cFont::CreateFont(config.fontName, menuItemHeightDefault * 2 / 3 + config.fontMenuitemDefault); - fontDiskUsage = cFont::CreateFont(config.fontName, diskUsageHeight/6 - 2 + config.fontDiskUsage); - fontDiskUsagePercent = cFont::CreateFont(config.fontName, diskUsageHeight/5 - 4 + config.fontDiskUsagePercent); - fontTimersHead = cFont::CreateFont(config.fontName, (contentHeight - 3*spaceMenu - diskUsageHeight) / 25 + config.fontTimersHead); - fontTimers = cFont::CreateFont(config.fontName, (contentHeight - 3*spaceMenu - diskUsageHeight) / 25 - 6 + config.fontTimers); - fontButtons = cFont::CreateFont(config.fontName, buttonHeight*0.8 + config.fontButtons); - fontMessage = cFont::CreateFont(config.fontName, messageHeight / 3 + config.fontMessageMenu); - fontEPGInfoWindow = cFont::CreateFont(config.fontName, contentHeight / 30 + config.fontEPGInfoWindow); - fontEPGInfoWindowLarge = cFont::CreateFont(config.fontName, contentHeight / 20 + config.fontEPGInfoWindowLarge); - fontRssFeed = cFont::CreateFont(config.fontName, (rssFeedHeight / 2) + 3 + config.fontRssFeed); -} - -cFont *cNopacityDisplayMenuView::GetMenuItemFont(eMenuCategory menuCat) { - switch (menuCat) { - case mcUnknown: - return fontMenuitemDefault; - case mcMain: - case mcSetup: - return fontMenuitemLarge; - case mcSchedule: - return fontMenuitemSchedule; - case mcChannel: - return fontMenuitemChannel; - case mcTimer: - return fontMenuitemTimers; - case mcRecording: - return fontMenuitemRecordings; - default: - return fontMenuitemDefault; - } - return fontMenuitemDefault; -} - -cFont *cNopacityDisplayMenuView::GetMenuItemFontSmall(eMenuCategory menuCat) { - switch (menuCat) { - case mcSchedule: - return fontMenuitemScheduleSmall; - case mcChannel: - return fontMenuitemChannelSmall; - case mcTimer: - return fontMenuitemTimersSmall; - case mcRecording: - return fontMenuitemRecordingsSmall; - default: - return fontMenuitemScheduleSmall; - } - return fontMenuitemScheduleSmall; -} - -cFont *cNopacityDisplayMenuView::GetEPGWindowFont(void) { - return fontEPGInfoWindow; -} - -cFont *cNopacityDisplayMenuView::GetEPGWindowFontLarge(void) { - return fontEPGInfoWindowLarge; -} - void cNopacityDisplayMenuView::GetMenuItemSize(eMenuCategory menuCat, cPoint *itemSize) { int itemWidth = 0; int itemHeight = 0; switch (menuCat) { case mcUnknown: - itemWidth = menuItemWidthDefault; - itemHeight = menuItemHeightDefault; + itemWidth = geoManager->menuItemWidthDefault; + itemHeight = geoManager->menuItemHeightDefault; break; case mcMain: - itemWidth = menuItemWidthMain; - itemHeight = menuItemHeightMain; + itemWidth = geoManager->menuItemWidthMain; + itemHeight = geoManager->menuItemHeightMain; break; case mcSetup: - itemWidth = menuItemWidthSetup; - itemHeight = menuItemHeightMain; + itemWidth = geoManager->menuItemWidthSetup; + itemHeight = geoManager->menuItemHeightMain; break; case mcSchedule: case mcScheduleNow: case mcScheduleNext: - itemWidth = menuItemWidthSchedule; - itemHeight = menuItemHeightSchedule; + itemWidth = geoManager->menuItemWidthSchedule; + itemHeight = geoManager->menuItemHeightSchedule; break; case mcChannel: - itemWidth = menuItemWidthChannel; - itemHeight = menuItemHeightSchedule; + itemWidth = geoManager->menuItemWidthChannel; + itemHeight = geoManager->menuItemHeightSchedule; break; case mcTimer: - itemWidth = menuItemWidthTimer; - itemHeight = menuItemHeightSchedule; + itemWidth = geoManager->menuItemWidthTimer; + itemHeight = geoManager->menuItemHeightSchedule; break; case mcRecording: - itemWidth = menuItemWidthRecording; - itemHeight = menuItemHeightRecordings; + itemWidth = geoManager->menuItemWidthRecording; + itemHeight = geoManager->menuItemHeightRecordings; break; default: - itemWidth = menuItemWidthDefault; - itemHeight = menuItemHeightDefault; + itemWidth = geoManager->menuItemWidthDefault; + itemHeight = geoManager->menuItemHeightDefault; break; } itemSize->Set(itemWidth, itemHeight); @@ -354,17 +244,17 @@ int cNopacityDisplayMenuView::GetMaxItems(eMenuCategory menuCat) { switch (menuCat) { case mcMain: case mcSetup: - maxItems = contentHeight / (menuItemHeightMain + spaceMenu); + maxItems = geoManager->menuContentHeight / (geoManager->menuItemHeightMain + geoManager->menuSpace); break; case mcSchedule: case mcScheduleNow: case mcScheduleNext: case mcChannel: case mcTimer: - maxItems = contentHeight / (menuItemHeightSchedule + spaceMenu); + maxItems = geoManager->menuContentHeight / (geoManager->menuItemHeightSchedule + geoManager->menuSpace); break; case mcRecording: - maxItems = contentHeight / (menuItemHeightRecordings + spaceMenu); + maxItems = geoManager->menuContentHeight / (geoManager->menuItemHeightRecordings + geoManager->menuSpace); break; default: maxItems = config.numDefaultMenuItems; @@ -373,18 +263,18 @@ int cNopacityDisplayMenuView::GetMaxItems(eMenuCategory menuCat) { } int cNopacityDisplayMenuView::GetMenuTop(int numItems, int itemHeight) { - return headerHeight + (contentHeight - numItems*(itemHeight + spaceMenu))/2; + return geoManager->menuHeaderHeight + (geoManager->menuContentHeight - numItems*(itemHeight + geoManager->menuSpace))/2; } int cNopacityDisplayMenuView::GetMenuItemLeft(int itemWidth) { - int menuLeft = spaceMenu; + int menuLeft = geoManager->menuSpace; if (!config.menuAdjustLeft) - menuLeft = osdWidth - itemWidth - spaceMenu; + menuLeft = geoManager->osdWidth - itemWidth - geoManager->menuSpace; return menuLeft; } void cNopacityDisplayMenuView::SetAvrgFontWidth(void) { - avrgFontWidth = fontMenuitemDefault->Width("x")+3; + avrgFontWidth = fontManager->menuItemDefault->Width("x")+3; } void cNopacityDisplayMenuView::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5) { @@ -403,80 +293,22 @@ void cNopacityDisplayMenuView::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, i } int cNopacityDisplayMenuView::GetEditableWidth(void) { - return contentWidthFull*0.5; + return geoManager->menuContentWidthFull*0.5; } int cNopacityDisplayMenuView::GetTextAreaWidth(void) { - return contentWidthFull - 2*spaceMenu; + return geoManager->menuContentWidthFull - 2*geoManager->menuSpace; } const cFont *cNopacityDisplayMenuView::GetTextAreaFont(bool FixedFont) { - return cFont::CreateFont(config.fontName, contentHeight / 25 + config.fontDetailView); -} - -void cNopacityDisplayMenuView::CreateBackgroundImages(int *handleBackgrounds, int *handleButtons) { - if (!config.doBlending) - return; - cImageLoader imgLoader; - //Default Menus - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), menuItemWidthDefault-2, menuItemHeightDefault-2); - handleBackgrounds[0] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), menuItemWidthDefault-2, menuItemHeightDefault-2); - handleBackgrounds[1] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Main Menu - cPoint itemSize; - GetMenuItemSize(mcMain, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[2] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[3] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Schedules Menu - GetMenuItemSize(mcSchedule, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[4] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[5] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Channels Menu - GetMenuItemSize(mcChannel, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[6] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[7] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Recordings Menu - GetMenuItemSize(mcRecording, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[8] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[9] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Timers Menu - GetMenuItemSize(mcTimer, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[10] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[11] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Setup Menu - GetMenuItemSize(mcSetup, &itemSize); - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[12] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), itemSize.X()-2, itemSize.Y()-2); - handleBackgrounds[13] = cOsdProvider::StoreImage(imgLoader.GetImage()); - //Color Buttons - imgLoader.DrawBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonRed), buttonWidth-4, buttonHeight-4); - handleButtons[0] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonGreen), buttonWidth-4, buttonHeight-4); - handleButtons[1] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonYellow), buttonWidth-4, buttonHeight-4); - handleButtons[2] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonBlue), buttonWidth-4, buttonHeight-4); - handleButtons[3] = cOsdProvider::StoreImage(imgLoader.GetImage()); + return cFont::CreateFont(config.fontName, geoManager->menuContentHeight / 25 + config.fontDetailView); } void cNopacityDisplayMenuView::DrawBorderDecoration() { if (config.doBlending) { - cImageLoader imgLoader; - bool mirrorHeader = (config.menuAdjustLeft) ? false : true; - imgLoader.DrawBackground(Theme.Color(clrMenuHeaderBlend), Theme.Color(clrMenuHeader), osdWidth, headerHeight, mirrorHeader); - pixmapHeader->DrawImage(cPoint(0,0), imgLoader.GetImage()); + cImage *headerImage = imgCache->GetBackground(btMenuHeader); + if (headerImage) + pixmapHeader->DrawImage(cPoint(0, 0), *headerImage); } else pixmapHeader->Fill(Theme.Color(clrMenuBack)); pixmapFooter->Fill(Theme.Color(clrMenuBack)); @@ -488,43 +320,43 @@ void cNopacityDisplayMenuView::DrawBorderDecoration() { if (config.menuAdjustLeft) { //Background - pixmapContent->DrawRectangle(cRect(0, 0, contentWidthFull - radius, contentHeight), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(0, 0, geoManager->menuContentWidthFull - radius, geoManager->menuContentHeight), Theme.Color(clrMenuBack)); //Upper and lower Corner Square - pixmapContent->DrawRectangle(cRect(contentWidthFull - radius, 0, radius, radius), Theme.Color(clrMenuBack)); - pixmapContent->DrawRectangle(cRect(contentWidthFull - radius, contentHeight - radius, radius, radius), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(geoManager->menuContentWidthFull - radius, 0, radius, radius), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(geoManager->menuContentWidthFull - radius, geoManager->menuContentHeight - radius, radius, radius), Theme.Color(clrMenuBack)); //Upper line - pixmapContent->DrawRectangle(cRect(contentWidthFull, 0, osdWidth - contentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(geoManager->menuContentWidthFull, 0, geoManager->osdWidth - geoManager->menuContentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); //Lower Line - pixmapContent->DrawRectangle(cRect(contentWidthFull, contentHeight - borderWidth, osdWidth - contentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(geoManager->menuContentWidthFull, geoManager->menuContentHeight - borderWidth, geoManager->osdWidth - geoManager->menuContentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); //Vertical line - pixmapContent->DrawRectangle(cRect(contentWidthFull-radius, radius, borderWidth, contentHeight - 2*radius), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(geoManager->menuContentWidthFull-radius, radius, borderWidth, geoManager->menuContentHeight - 2*radius), Theme.Color(clrMenuBorder)); if (radius-borderWidth > 2) { //Upper Ellipse - pixmapContent->DrawEllipse(cRect(contentWidthFull - radius, 0, radius, radius), Theme.Color(clrMenuBorder),2); - pixmapContent->DrawEllipse(cRect(contentWidthFull - radius + borderWidth, borderWidth, radius-borderWidth, radius-borderWidth), clrTransparent, 2); + pixmapContent->DrawEllipse(cRect(geoManager->menuContentWidthFull - radius, 0, radius, radius), Theme.Color(clrMenuBorder),2); + pixmapContent->DrawEllipse(cRect(geoManager->menuContentWidthFull - radius + borderWidth, borderWidth, radius-borderWidth, radius-borderWidth), clrTransparent, 2); //Lower Ellipse - pixmapContent->DrawEllipse(cRect(contentWidthFull - radius, contentHeight - radius, radius, radius), Theme.Color(clrMenuBorder),3); - pixmapContent->DrawEllipse(cRect(contentWidthFull - radius + borderWidth, contentHeight - radius, radius-borderWidth, radius-borderWidth), clrTransparent, 3); + pixmapContent->DrawEllipse(cRect(geoManager->menuContentWidthFull - radius, geoManager->menuContentHeight - radius, radius, radius), Theme.Color(clrMenuBorder),3); + pixmapContent->DrawEllipse(cRect(geoManager->menuContentWidthFull - radius + borderWidth, geoManager->menuContentHeight - radius, radius-borderWidth, radius-borderWidth), clrTransparent, 3); } } else { //Background - pixmapContent->DrawRectangle(cRect(osdWidth - contentWidthMinimum + radius, 0, contentWidthFull - radius, contentHeight), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum + radius, 0, geoManager->menuContentWidthFull - radius, geoManager->menuContentHeight), Theme.Color(clrMenuBack)); //Upper and lower Corner Square - pixmapContent->DrawRectangle(cRect(osdWidth - contentWidthMinimum, 0, radius, radius), Theme.Color(clrMenuBack)); - pixmapContent->DrawRectangle(cRect(osdWidth - contentWidthMinimum, contentHeight - radius, radius, radius), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, 0, radius, radius), Theme.Color(clrMenuBack)); + pixmapContent->DrawRectangle(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, geoManager->menuContentHeight - radius, radius, radius), Theme.Color(clrMenuBack)); //Upper line - pixmapContent->DrawRectangle(cRect(0, 0, osdWidth - contentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(0, 0, geoManager->osdWidth - geoManager->menuContentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); //Lower Line - pixmapContent->DrawRectangle(cRect(0, contentHeight - borderWidth, osdWidth - contentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(0, geoManager->menuContentHeight - borderWidth, geoManager->osdWidth - geoManager->menuContentWidthMinimum, borderWidth), Theme.Color(clrMenuBorder)); //Vertical line - pixmapContent->DrawRectangle(cRect(osdWidth - contentWidthMinimum + radius - borderWidth, radius, borderWidth, contentHeight - 2*radius), Theme.Color(clrMenuBorder)); + pixmapContent->DrawRectangle(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum + radius - borderWidth, radius, borderWidth, geoManager->menuContentHeight - 2*radius), Theme.Color(clrMenuBorder)); if (radius-borderWidth > 2) { //Upper Ellipse - pixmapContent->DrawEllipse(cRect(osdWidth - contentWidthMinimum, 0, radius, radius), Theme.Color(clrMenuBorder),1); - pixmapContent->DrawEllipse(cRect(osdWidth - contentWidthMinimum, borderWidth, radius-borderWidth, radius-borderWidth), clrTransparent, 1); + pixmapContent->DrawEllipse(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, 0, radius, radius), Theme.Color(clrMenuBorder),1); + pixmapContent->DrawEllipse(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, borderWidth, radius-borderWidth, radius-borderWidth), clrTransparent, 1); //Lower Ellipse - pixmapContent->DrawEllipse(cRect(osdWidth - contentWidthMinimum, contentHeight - radius, radius, radius), Theme.Color(clrMenuBorder),4); - pixmapContent->DrawEllipse(cRect(osdWidth - contentWidthMinimum, contentHeight - radius, radius-borderWidth, radius-borderWidth), clrTransparent, 4); + pixmapContent->DrawEllipse(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, geoManager->menuContentHeight - radius, radius, radius), Theme.Color(clrMenuBorder),4); + pixmapContent->DrawEllipse(cRect(geoManager->osdWidth - geoManager->menuContentWidthMinimum, geoManager->menuContentHeight - radius, radius-borderWidth, radius-borderWidth), clrTransparent, 4); } } } @@ -534,40 +366,39 @@ void cNopacityDisplayMenuView::AdjustContentBackground(eMenuCategory menuCat, eM int contentWidthLast = GetContentWidth(menuCatLast); int drawportX; if ((contentWidth != contentWidthLast)||(menuCatLast == mcUndefined)) { - if (contentWidth == contentWidthFull) { - drawportX = (config.menuAdjustLeft)?0:(contentWidthMinimum - contentWidthFull); + if (contentWidth == geoManager->menuContentWidthFull) { + drawportX = (config.menuAdjustLeft)?0:(geoManager->menuContentWidthMinimum - geoManager->menuContentWidthFull); pixmapContent->SetDrawPortPoint(cPoint(drawportX, 0)); if (config.scalePicture) { // ask output device to restore full size vidWin = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null); } } else { - drawportX = (config.menuAdjustLeft)?(contentWidth - contentWidthFull):(contentWidthMinimum - contentWidth); + drawportX = (config.menuAdjustLeft)?(contentWidth - geoManager->menuContentWidthFull):(geoManager->menuContentWidthMinimum - contentWidth); pixmapContent->SetDrawPortPoint(cPoint(drawportX, 0)); if (config.scalePicture) { // ask output device to scale down - int windowX = (config.menuAdjustLeft)?(osdLeft + contentWidth + widthScrollbar + 2 * spaceMenu) - :(osdLeft + 2 * spaceMenu); + int windowX = (config.menuAdjustLeft)?(geoManager->osdLeft + contentWidth + geoManager->menuWidthScrollbar + 2 * geoManager->menuSpace) + :(geoManager->osdLeft + 2 * geoManager->menuSpace); cRect availableRect( windowX, - osdTop + headerHeight, - contentWidthFull - osdLeft - contentWidth - widthScrollbar - 4 * spaceMenu, - contentHeight); + geoManager->osdTop + geoManager->menuHeaderHeight, + geoManager->menuContentWidthFull - geoManager->osdLeft - contentWidth - geoManager->menuWidthScrollbar - 4 * geoManager->menuSpace, + geoManager->menuContentHeight); vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect); } } } osd->DestroyPixmap(pixmapScrollbar); - int scrollbarX = (config.menuAdjustLeft)?(contentWidth):(osdWidth - contentWidth - widthScrollbar); - pixmapScrollbar = osd->CreatePixmap(2, cRect(scrollbarX , headerHeight + spaceMenu, widthScrollbar, contentHeight - 2*spaceMenu)); + int scrollbarX = (config.menuAdjustLeft)?(contentWidth):(geoManager->osdWidth - contentWidth - geoManager->menuWidthScrollbar); + pixmapScrollbar = osd->CreatePixmap(2, cRect(scrollbarX , geoManager->menuHeaderHeight + geoManager->menuSpace, geoManager->menuWidthScrollbar, geoManager->menuContentHeight - 2*geoManager->menuSpace)); pixmapScrollbar->Fill(clrTransparent); } void cNopacityDisplayMenuView::DrawHeaderLogo(void) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/vdrlogo", config.menuHeaderLogoWidth, config.menuHeaderLogoHeight)) { - pixmapHeaderLogo->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/vdrlogo"); + if (imgIcon) + pixmapHeaderLogo->DrawImage(cPoint(0,0), *imgIcon); } int cNopacityDisplayMenuView::ShowHeaderLogo(bool show) { @@ -576,7 +407,7 @@ int cNopacityDisplayMenuView::ShowHeaderLogo(bool show) { } else { pixmapHeaderLogo->SetLayer(-1); } - return config.menuHeaderLogoWidth + spaceMenu; + return config.menuHeaderLogoWidth + geoManager->menuSpace; } int cNopacityDisplayMenuView::DrawHeaderIcon(eMenuCategory menuCat) { @@ -608,13 +439,13 @@ int cNopacityDisplayMenuView::DrawHeaderIcon(eMenuCategory menuCat) { int left = 0; if (drawIcon) { - int iconX = (config.menuAdjustLeft) ? 0 : (osdWidth - config.headerIconHeight); + int iconX = (config.menuAdjustLeft) ? 0 : (geoManager->osdWidth - config.headerIconHeight); pixmapHeaderIcon = osd->CreatePixmap(2, cRect(iconX, 0, config.headerIconHeight, config.headerIconHeight)); pixmapHeaderIcon->Fill(clrTransparent); - cImageLoader imgLoader; - if (imgLoader.LoadIcon(*icon, config.headerIconHeight)) { - pixmapHeaderIcon->DrawImage(cPoint(0,0), imgLoader.GetImage()); - left = config.headerIconHeight + spaceMenu; + cImage *imgIcon = imgCache->GetSkinIcon(*icon); + if (imgIcon) { + pixmapHeaderIcon->DrawImage(cPoint(0,0), *imgIcon); + left = config.headerIconHeight + geoManager->menuSpace; } } return left; @@ -622,7 +453,7 @@ int cNopacityDisplayMenuView::DrawHeaderIcon(eMenuCategory menuCat) { int cNopacityDisplayMenuView::ShowHeaderIconChannelLogo(const char *Title) { int left = 0; - int iconX = (config.menuAdjustLeft) ? 0 : (osdWidth - config.menuItemLogoWidth); + int iconX = (config.menuAdjustLeft) ? 0 : (geoManager->osdWidth - config.menuItemLogoWidth); pixmapHeaderIcon = osd->CreatePixmap(2, cRect(iconX, 0, config.menuItemLogoWidth, config.menuItemLogoHeight)); pixmapHeaderIcon->Fill(clrTransparent); std::string channel = Title; @@ -636,7 +467,7 @@ int cNopacityDisplayMenuView::ShowHeaderIconChannelLogo(const char *Title) { cImageLoader imgLoader; if (imgLoader.LoadLogo(channel.c_str(), config.menuItemLogoWidth, config.menuItemLogoHeight)) { pixmapHeaderIcon->DrawImage(cPoint(0, 0), imgLoader.GetImage()); - left = config.menuItemLogoWidth + spaceMenu; + left = config.menuItemLogoWidth + geoManager->menuSpace; } return left; } @@ -650,38 +481,35 @@ void cNopacityDisplayMenuView::DestroyHeaderIcon(void) { void cNopacityDisplayMenuView::DrawHeaderLabel(int left, cString label) { pixmapHeaderLabel->Fill(clrTransparent); - int labelW = fontHeader->Width(label); - int labelX = (config.menuAdjustLeft) ? (left) : (osdWidth - dateWidth - labelW - left - 2*spaceMenu); - pixmapHeaderLabel->DrawText(cPoint(labelX, ((headerHeight - 10) - fontHeader->Height()) / 2), *label, Theme.Color(clrMenuFontHeader), clrTransparent, fontHeader); + int labelW = fontManager->menuHeader->Width(label); + int labelX = (config.menuAdjustLeft) ? (left) : (geoManager->osdWidth - geoManager->menuDateWidth - labelW - left - 2*geoManager->menuSpace); + pixmapHeaderLabel->DrawText(cPoint(labelX, ((geoManager->menuHeaderHeight - 10) - fontManager->menuHeader->Height()) / 2), *label, Theme.Color(clrMenuFontHeader), clrTransparent, fontManager->menuHeader); } void cNopacityDisplayMenuView::DrawDate(bool initial) { cString date = DayDateTime(); if (initial || strcmp(date, lastDate)) { pixmapDate->Fill(clrTransparent); - int dateW = fontDate->Width(date); - int dateX = (config.menuAdjustLeft) ? (dateWidth - dateW - 2*spaceMenu) : (spaceMenu); - pixmapDate->DrawText(cPoint(dateX, (headerHeight - fontDate->Height()) / 2), date, Theme.Color(clrMenuFontDate), clrTransparent, fontDate); + int dateW = fontManager->menuDate->Width(date); + int dateX = (config.menuAdjustLeft) ? (geoManager->menuDateWidth - dateW - 2*geoManager->menuSpace) : (geoManager->menuSpace); + pixmapDate->DrawText(cPoint(dateX, (geoManager->menuHeaderHeight - fontManager->menuDate->Height()) / 2), date, Theme.Color(clrMenuFontDate), clrTransparent, fontManager->menuDate); lastDate = date; } } void cNopacityDisplayMenuView::DrawDiskUsage(void) { - int iconWidth = diskUsageWidth * 3/4; + int iconWidth = geoManager->menuDiskUsageWidth * 3/4; int DiskUsage = cVideoDiskUsage::UsedPercent(); bool DiskAlert = DiskUsage > diskUsageAlert; tColor bgColor = DiskAlert ? Theme.Color(clrDiskAlert) : Theme.Color(clrMenuBack); pixmapDiskUsage->Fill(Theme.Color(clrMenuBorder)); - pixmapDiskUsage->DrawRectangle(cRect(2,2,diskUsageWidth-4, diskUsageHeight-4), bgColor); - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/DiskUsage", iconWidth)) { - cImage icon = imgLoader.GetImage(); - pixmapDiskUsageIcon->DrawImage(cPoint((diskUsageWidth - iconWidth)/2,0), icon); - } - if (imgLoader.LoadIcon("skinIcons/discpercent", diskUsageWidth - 4, diskUsageHeight/5, false)) { - cImage icon = imgLoader.GetImage(); - pixmapDiskUsageIcon->DrawImage(cPoint(0,4*diskUsageHeight/5), icon); - } + pixmapDiskUsage->DrawRectangle(cRect(2,2,geoManager->menuDiskUsageWidth-4, geoManager->menuDiskUsageHeight-4), bgColor); + cImage *imgDisc = imgCache->GetSkinIcon("skinIcons/DiskUsage"); + if (imgDisc) + pixmapDiskUsageIcon->DrawImage(cPoint((geoManager->menuDiskUsageWidth - iconWidth)/2,0), *imgDisc); + cImage *imgDiscPerc = imgCache->GetSkinIcon("skinIcons/discpercent"); + if (imgDiscPerc) + pixmapDiskUsageIcon->DrawImage(cPoint(0,4*geoManager->menuDiskUsageHeight/5), *imgDiscPerc); pixmapDiskUsageLabel->Fill(clrTransparent); cString usage = cString::sprintf("%d%%", DiskUsage); cString rest; @@ -689,9 +517,9 @@ void cNopacityDisplayMenuView::DrawDiskUsage(void) { rest = cString::sprintf("%02d:%02dh %s", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60, tr("free")); else rest = cString::sprintf("%d GB %s", cVideoDiskUsage::FreeMB() / 1024, tr("free")); - pixmapDiskUsageLabel->DrawRectangle(cRect((diskUsageWidth - 4)*DiskUsage/100,4*diskUsageHeight/5, (diskUsageWidth - 4) - (diskUsageWidth - 4)*DiskUsage/100, diskUsageHeight/5), 0xDD000000); - pixmapDiskUsageLabel->DrawText(cPoint((diskUsageWidth - fontDiskUsagePercent->Width(*usage))/2, 4*diskUsageHeight/5), *usage, Theme.Color(clrMenuFontDiscUsage), clrTransparent, fontDiskUsagePercent); - pixmapDiskUsageLabel->DrawText(cPoint((diskUsageWidth - fontDiskUsage->Width(*rest))/2, (diskUsageHeight - fontDiskUsage->Height())/2), *rest, Theme.Color(clrMenuFontDiscUsage), clrTransparent, fontDiskUsage); + pixmapDiskUsageLabel->DrawRectangle(cRect((geoManager->menuDiskUsageWidth - 4)*DiskUsage/100,4*geoManager->menuDiskUsageHeight/5, (geoManager->menuDiskUsageWidth - 4) - (geoManager->menuDiskUsageWidth - 4)*DiskUsage/100, geoManager->menuDiskUsageHeight/5), 0xDD000000); + pixmapDiskUsageLabel->DrawText(cPoint((geoManager->menuDiskUsageWidth - fontManager->menuDiskUsagePercent->Width(*usage))/2, 4*geoManager->menuDiskUsageHeight/5), *usage, Theme.Color(clrMenuFontDiscUsage), clrTransparent, fontManager->menuDiskUsagePercent); + pixmapDiskUsageLabel->DrawText(cPoint((geoManager->menuDiskUsageWidth - fontManager->menuDiskUsage->Width(*rest))/2, (geoManager->menuDiskUsageHeight - fontManager->menuDiskUsage->Height())/2), *rest, Theme.Color(clrMenuFontDiscUsage), clrTransparent, fontManager->menuDiskUsage); pixmapDiskUsage->SetLayer(2); pixmapDiskUsageIcon->SetLayer(3); @@ -710,16 +538,18 @@ void cNopacityDisplayMenuView::ShowDiskUsage(bool show) { } } -void cNopacityDisplayMenuView::DrawButton(const char *text, int handleImage, tColor buttonColor, tColor borderColor, tColor fontColor, int num) { +void cNopacityDisplayMenuView::DrawButton(const char *text, eBackgroundType bgButton, tColor buttonColor, tColor borderColor, tColor fontColor, int num) { if (num < 0) return; - int top = 2*buttonsBorder; - int left = num * buttonWidth + (2*num + 1) * buttonsBorder; + int top = 2*geoManager->menuButtonsBorder; + int left = num * geoManager->menuButtonWidth + (2*num + 1) * geoManager->menuButtonsBorder; if (config.doBlending) { - pixmapFooter->DrawRectangle(cRect(left, top, buttonWidth, buttonHeight), borderColor); - pixmapFooter->DrawImage(cPoint(left+2, top+2), handleImage); + pixmapFooter->DrawRectangle(cRect(left, top, geoManager->menuButtonWidth, geoManager->menuButtonHeight), borderColor); + cImage *back = imgCache->GetBackground(bgButton); + if (back) + pixmapFooter->DrawImage(cPoint(left+2, top+2), *back); } else { - pixmapFooter->DrawRectangle(cRect(left, top, buttonWidth, buttonHeight), buttonColor); + pixmapFooter->DrawRectangle(cRect(left, top, geoManager->menuButtonWidth, geoManager->menuButtonHeight), buttonColor); } if (config.roundedCorners) { int radius = config.cornerRadius; @@ -727,60 +557,60 @@ void cNopacityDisplayMenuView::DrawButton(const char *text, int handleImage, tCo pixmapFooter->DrawEllipse(cRect(left,top,radius,radius), borderColor, -2); pixmapFooter->DrawEllipse(cRect(left-2,top-2,radius,radius), Theme.Color(clrMenuBack), -2); - pixmapFooter->DrawEllipse(cRect(left + buttonWidth -radius, top,radius,radius), borderColor, -1); - pixmapFooter->DrawEllipse(cRect(left + buttonWidth -radius+2,top-2,radius,radius), Theme.Color(clrMenuBack), -1); + pixmapFooter->DrawEllipse(cRect(left + geoManager->menuButtonWidth -radius, top,radius,radius), borderColor, -1); + pixmapFooter->DrawEllipse(cRect(left + geoManager->menuButtonWidth -radius+2,top-2,radius,radius), Theme.Color(clrMenuBack), -1); - pixmapFooter->DrawEllipse(cRect(left,top + buttonHeight -radius,radius,radius), borderColor, -3); - pixmapFooter->DrawEllipse(cRect(left - 2, top + buttonHeight - radius + 2,radius,radius), Theme.Color(clrMenuBack), -3); + pixmapFooter->DrawEllipse(cRect(left,top + geoManager->menuButtonHeight -radius,radius,radius), borderColor, -3); + pixmapFooter->DrawEllipse(cRect(left - 2, top + geoManager->menuButtonHeight - radius + 2,radius,radius), Theme.Color(clrMenuBack), -3); - pixmapFooter->DrawEllipse(cRect(left + buttonWidth -radius, top + buttonHeight -radius,radius,radius), borderColor, -4); - pixmapFooter->DrawEllipse(cRect(left + buttonWidth -radius + 2, top + buttonHeight -radius + 2,radius,radius), Theme.Color(clrMenuBack), -4); + pixmapFooter->DrawEllipse(cRect(left + geoManager->menuButtonWidth -radius, top + geoManager->menuButtonHeight -radius,radius,radius), borderColor, -4); + pixmapFooter->DrawEllipse(cRect(left + geoManager->menuButtonWidth -radius + 2, top + geoManager->menuButtonHeight -radius + 2,radius,radius), Theme.Color(clrMenuBack), -4); } } - int textWidth = fontButtons->Width(text); - int textHeight = fontButtons->Height(); + int textWidth = fontManager->menuButtons->Width(text); + int textHeight = fontManager->menuButtons->Height(); tColor clrFontBack = (config.doBlending)?(clrTransparent):buttonColor; - pixmapFooter->DrawText(cPoint(left + (buttonWidth-textWidth)/2, top + (buttonHeight-textHeight)/2), text, fontColor, clrFontBack, fontButtons); + pixmapFooter->DrawText(cPoint(left + (geoManager->menuButtonWidth-textWidth)/2, top + (geoManager->menuButtonHeight-textHeight)/2), text, fontColor, clrFontBack, fontManager->menuButtons); } void cNopacityDisplayMenuView::ClearButton(int num) { if (num < 0) return; - int top = 2*buttonsBorder; - int left = num * buttonWidth + (2*num + 1) * buttonsBorder; - pixmapFooter->DrawRectangle(cRect(left, top, buttonWidth, buttonHeight), Theme.Color(clrMenuBack)); + int top = 2*geoManager->menuButtonsBorder; + int left = num * geoManager->menuButtonWidth + (2*num + 1) * geoManager->menuButtonsBorder; + pixmapFooter->DrawRectangle(cRect(left, top, geoManager->menuButtonWidth, geoManager->menuButtonHeight), Theme.Color(clrMenuBack)); } int cNopacityDisplayMenuView::GetTimersInitHeight(void) { - int initHeight = headerHeight + 2*spaceMenu; + int initHeight = geoManager->menuHeaderHeight + 2*geoManager->menuSpace; if (config.showDiscUsage) - initHeight += diskUsageHeight; + initHeight += geoManager->menuDiskUsageHeight; return initHeight; } int cNopacityDisplayMenuView::GetTimersMaxHeight(void) { - return headerHeight + contentHeight; + return geoManager->menuHeaderHeight + geoManager->menuContentHeight; } cNopacityTimer *cNopacityDisplayMenuView::DrawTimerConflict(int numConflicts, int y) { - cNopacityTimer *t = new cNopacityTimer(osd, numConflicts, fontTimers, fontTimersHead); - t->SetGeometry(timersWidth, y); + cNopacityTimer *t = new cNopacityTimer(osd, imgCache, numConflicts, fontManager->menuTimers, fontManager->menuTimersHead); + t->SetGeometry(geoManager->menuTimersWidth, y); t->CreateConflictText(); - t->CalculateHeight(spaceMenu); - int timerX = (config.menuAdjustLeft) ? (osdWidth - timersWidth - 10) : 10; + t->CalculateHeight(geoManager->menuSpace); + int timerX = (config.menuAdjustLeft) ? (geoManager->osdWidth - geoManager->menuTimersWidth - 10) : 10; t->CreatePixmaps(timerX); t->Render(); return t; } cNopacityTimer *cNopacityDisplayMenuView::DrawTimer(const cTimer *Timer, int y) { - cNopacityTimer *t = new cNopacityTimer(osd, Timer, fontTimers, fontTimersHead); - t->SetGeometry(timersWidth, y); + cNopacityTimer *t = new cNopacityTimer(osd, imgCache, Timer, fontManager->menuTimers, fontManager->menuTimersHead); + t->SetGeometry(geoManager->menuTimersWidth, y); t->CreateDate(); t->CreateShowName(); - t->CalculateHeight(spaceMenu); - int timerX = (config.menuAdjustLeft) ? (osdWidth - timersWidth - 10) : 10; + t->CalculateHeight(geoManager->menuSpace); + int timerX = (config.menuAdjustLeft) ? (geoManager->osdWidth - geoManager->menuTimersWidth - 10) : 10; t->CreatePixmaps(timerX); t->Render(); return t; @@ -791,8 +621,8 @@ void cNopacityDisplayMenuView::DrawScrollbar(double Height, double Offset) { int height = Height * totalHeight; int offset = Offset * totalHeight; pixmapScrollbar->Fill(Theme.Color(clrMenuScrollBar)); - pixmapScrollbar->DrawRectangle(cRect(2,2,widthScrollbar-4,totalHeight+2), Theme.Color(clrMenuScrollBarBack)); - pixmapScrollbar->DrawRectangle(cRect(3,3 + offset,widthScrollbar-6,height), Theme.Color(clrMenuScrollBar)); + pixmapScrollbar->DrawRectangle(cRect(2,2,geoManager->menuWidthScrollbar-4,totalHeight+2), Theme.Color(clrMenuScrollBarBack)); + pixmapScrollbar->DrawRectangle(cRect(3,3 + offset,geoManager->menuWidthScrollbar-6,height), Theme.Color(clrMenuScrollBar)); } void cNopacityDisplayMenuView::ClearScrollbar(void) { @@ -824,19 +654,18 @@ void cNopacityDisplayMenuView::DrawMessage(eMessageType Type, const char *Text) if (pixmapStatus) { ClearMessage(); } - pixmapStatus = osd->CreatePixmap(7, cRect(0.1*osdWidth, 0.8*osdHeight, messageWidth, messageHeight)); + pixmapStatus = osd->CreatePixmap(7, cRect(0.1*geoManager->osdWidth, 0.8*geoManager->osdHeight, geoManager->menuMessageWidth, geoManager->menuMessageHeight)); pixmapStatus->Fill(col); if (config.doBlending) { - cImageLoader imgLoader; - imgLoader.DrawBackground2(Theme.Color(clrMenuBack), col, messageWidth-2, messageHeight-2); - pixmapStatus->DrawImage(cPoint(1, 1), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrMenuBack), col, geoManager->menuMessageWidth-2, geoManager->menuMessageHeight-2, true); + pixmapStatus->DrawImage(cPoint(1, 1), imgBack); } if (config.roundedCorners) { - DrawRoundedCornersWithBorder(pixmapStatus, col, config.cornerRadius, messageWidth, messageHeight); + DrawRoundedCornersWithBorder(pixmapStatus, col, config.cornerRadius, geoManager->menuMessageWidth, geoManager->menuMessageHeight); } - int textWidth = fontMessage->Width(Text); + int textWidth = fontManager->menuMessage->Width(Text); tColor clrFontBack = (config.doBlending)?(clrTransparent):col; - pixmapStatus->DrawText(cPoint((messageWidth - textWidth) / 2, (messageHeight - fontMessage->Height()) / 2), Text, colFont, clrFontBack, fontMessage); + pixmapStatus->DrawText(cPoint((geoManager->menuMessageWidth - textWidth) / 2, (geoManager->menuMessageHeight - fontManager->menuMessage->Height()) / 2), Text, colFont, clrFontBack, fontManager->menuMessage); } void cNopacityDisplayMenuView::ClearMessage(void) { @@ -847,7 +676,7 @@ void cNopacityDisplayMenuView::ClearMessage(void) { } void cNopacityDisplayMenuView::SetDetailViewSize(eDetailViewType detailViewType, cNopacityMenuDetailView *detailView) { - int x = (config.menuAdjustLeft) ? 0 : osdWidth - contentWidthFull + 2*spaceMenu; + int x = (config.menuAdjustLeft) ? 0 : geoManager->osdWidth - geoManager->menuContentWidthFull + 2*geoManager->menuSpace; int width = 0; int height = 0; int top = 0; @@ -869,45 +698,42 @@ void cNopacityDisplayMenuView::SetDetailViewSize(eDetailViewType detailViewType, default: break; } - width = contentWidthFull - 2*spaceMenu; - height = contentHeight; - top = headerHeight; + width = geoManager->menuContentWidthFull - 2*geoManager->menuSpace; + height = geoManager->menuContentHeight; + top = geoManager->menuHeaderHeight; detailView->SetGeometry(x, width, height, top, contentBorder, detailHeaderHeight); } void cNopacityDisplayMenuView::DrawRssFeed(std::string feedName) { pixmapRssFeedBackground->Fill(clrBlack); pixmapRssFeed->Fill(clrTransparent); - feedNameLength = fontRssFeed->Width(feedName.c_str()); - int labelWidth = 2 + rssFeedHeight + 2 + feedNameLength + 6; + feedNameLength = fontManager->menuRssFeed->Width(feedName.c_str()); + int labelWidth = 2 + geoManager->menuRssFeedHeight + 2 + feedNameLength + 6; pixmapRssFeed->Fill(Theme.Color(clrRSSFeedBorder)); - cImageLoader imgLoader; if (config.doBlending) { - imgLoader.DrawBackground(Theme.Color(clrRSSFeedHeaderBack), Theme.Color(clrRSSFeedHeaderBackBlend), labelWidth, rssFeedHeight - 4); - pixmapRssFeed->DrawImage(cPoint(2,2), imgLoader.GetImage()); - - imgLoader.DrawBackground(Theme.Color(clrRSSFeedBack), Theme.Color(clrRSSFeedBackBlend), osdWidth - labelWidth - 2, rssFeedHeight - 4); - pixmapRssFeed->DrawImage(cPoint(labelWidth,2), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrRSSFeedHeaderBack), Theme.Color(clrRSSFeedHeaderBackBlend), labelWidth, geoManager->menuRssFeedHeight - 4); + pixmapRssFeed->DrawImage(cPoint(2,2), imgBack); + cImage imgBack2 = imgCache->GetBackground(Theme.Color(clrRSSFeedBack), Theme.Color(clrRSSFeedBackBlend), geoManager->osdWidth - labelWidth - 2, geoManager->menuRssFeedHeight - 4); + pixmapRssFeed->DrawImage(cPoint(labelWidth,2), imgBack2); } else { - pixmapRssFeed->DrawRectangle(cRect(2, 2, labelWidth, rssFeedHeight - 4), Theme.Color(clrRSSFeedHeaderBack)); - pixmapRssFeed->DrawRectangle(cRect(labelWidth, 2, osdWidth - labelWidth - 2, rssFeedHeight - 4), Theme.Color(clrRSSFeedBack)); + pixmapRssFeed->DrawRectangle(cRect(2, 2, labelWidth, geoManager->menuRssFeedHeight - 4), Theme.Color(clrRSSFeedHeaderBack)); + pixmapRssFeed->DrawRectangle(cRect(labelWidth, 2, geoManager->osdWidth - labelWidth - 2, geoManager->menuRssFeedHeight - 4), Theme.Color(clrRSSFeedBack)); } - pixmapRssFeed->DrawText(cPoint(rssFeedHeight + 2, (rssFeedHeight - fontRssFeed->Height()) / 2), feedName.c_str(), Theme.Color(clrRSSFeedHeaderText), clrTransparent, fontRssFeed); + pixmapRssFeed->DrawText(cPoint(geoManager->menuRssFeedHeight + 2, (geoManager->menuRssFeedHeight - fontManager->menuRssFeed->Height()) / 2), feedName.c_str(), Theme.Color(clrRSSFeedHeaderText), clrTransparent, fontManager->menuRssFeed); pixmapRssFeedIcon->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/rss", rssFeedHeight-4)) { - cImage icon = imgLoader.GetImage(); - pixmapRssFeedIcon->DrawImage(cPoint(2,2), icon); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/rss"); + if (imgIcon) + pixmapRssFeedIcon->DrawImage(cPoint(2,2), *imgIcon); } cPoint cNopacityDisplayMenuView::GetRssFeedPosition(void) { - int x = rssFeedHeight + feedNameLength + 10; - int y = osdHeight - rssFeedHeight + 2; + int x = geoManager->menuRssFeedHeight + feedNameLength + 10; + int y = geoManager->osdHeight - geoManager->menuRssFeedHeight + 2; return cPoint(x, y); } cPoint cNopacityDisplayMenuView::GetRssFeedSize(void) { - int width = osdWidth - (rssFeedHeight + feedNameLength + 12); - int height = rssFeedHeight - 4; + int width = geoManager->osdWidth - (geoManager->menuRssFeedHeight + feedNameLength + 12); + int height = geoManager->menuRssFeedHeight - 4; return cPoint(width, height); } diff --git a/displaymenuview.h b/displaymenuview.h index 139404e..4c7ea16 100644 --- a/displaymenuview.h +++ b/displaymenuview.h @@ -6,6 +6,7 @@ enum eDetailViewType {dvEvent = 0, dvRecording, dvText}; class cNopacityDisplayMenuView { private: cOsd *osd; + cImageCache *imgCache; cString lastDate; int diskUsageAlert; cPixmap *pixmapHeader; @@ -23,70 +24,19 @@ class cNopacityDisplayMenuView { cPixmap *pixmapRssFeed; cPixmap *pixmapRssFeedBackground; cPixmap *pixmapRssFeedIcon; - cFont *fontHeader; - cFont *fontDate; - cFont *fontMenuitemLarge; - cFont *fontMenuitemSchedule; - cFont *fontMenuitemScheduleSmall; - cFont *fontMenuitemChannel; - cFont *fontMenuitemChannelSmall; - cFont *fontMenuitemRecordings; - cFont *fontMenuitemRecordingsSmall; - cFont *fontMenuitemTimers; - cFont *fontMenuitemTimersSmall; - cFont *fontMenuitemDefault; - cFont *fontDiskUsage; - cFont *fontDiskUsagePercent; - cFont *fontTimers; - cFont *fontTimersHead; - cFont *fontButtons; - cFont *fontMessage; - cFont *fontEPGInfoWindow; - cFont *fontEPGInfoWindowLarge; - cFont *fontRssFeed; - int osdWidth, osdHeight; - int osdLeft, osdTop; - int widthScrollbar; - int dateWidth; - int headerHeight, footerHeight, rssFeedHeight, contentHeight; - int contentWidthFull; - int contentWidthMain; - int contentWidthSchedules; - int contentWidthChannels; - int contentWidthTimers; - int contentWidthRecordings; - int contentWidthSetup; - int contentWidthMinimum; - int menuItemWidthDefault, menuItemHeightDefault; - int menuItemWidthMain, menuItemHeightMain; - int menuItemWidthSchedule, menuItemHeightSchedule; - int menuItemWidthChannel; - int menuItemWidthTimer; - int menuItemWidthRecording, menuItemHeightRecordings; - int menuItemWidthSetup; - int diskUsageWidth, diskUsageHeight; - int timersWidth; - int buttonsBorder, buttonWidth, buttonHeight; - int messageWidth, messageHeight; int feedNameLength; int avrgFontWidth; cRect textWindowSizeSchedules; cRect textWindowSizeRecordings; cRect textWindowSizeChannels; - void SetDescriptionTextWindowSize(void); int GetContentWidth(eMenuCategory menuCat); public: - cNopacityDisplayMenuView(); + cNopacityDisplayMenuView(cImageCache *imgCache); virtual ~cNopacityDisplayMenuView(void); cOsd *createOsd(void); - void SetGeometry(void); + void SetDescriptionTextWindowSize(void); void CreatePixmaps(void); void SetPixmapAlpha(int Alpha); - void CreateFonts(void); - cFont *GetMenuItemFont(eMenuCategory menuCat); - cFont *GetMenuItemFontSmall(eMenuCategory menuCat); - cFont *GetEPGWindowFont(void); - cFont *GetEPGWindowFontLarge(void); void GetMenuItemSize(eMenuCategory menuCat, cPoint *itemSize); int GetMaxItems(eMenuCategory menuCat); int GetMenuTop(int numItems, int itemHeight); @@ -95,11 +45,10 @@ class cNopacityDisplayMenuView { int mytabs[cSkinDisplayMenu::MaxTabs]; void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0); int GetEditableWidth(void); - int GetWidthDefaultMenu(void) {return menuItemWidthDefault;}; + int GetWidthDefaultMenu(void) {return geoManager->menuItemWidthDefault;}; int GetTextAreaWidth(void); const cFont *GetTextAreaFont(bool FixedFont); cRect *GetDescriptionTextWindowSize(eMenuCategory menuCat); - void CreateBackgroundImages(int *handleBackgrounds, int *handleButtons); void AdjustContentBackground(eMenuCategory menuCat, eMenuCategory menuCatLast, cRect & vidWin); void DrawBorderDecoration(void); int ShowHeaderLogo(bool show); @@ -111,7 +60,7 @@ class cNopacityDisplayMenuView { void DrawDate(bool initial); void DrawDiskUsage(void); void ShowDiskUsage(bool show); - void DrawButton(const char *text, int handleImage, tColor buttonColor, tColor borderColor, tColor fontColor, int num); + void DrawButton(const char *text, eBackgroundType bgButton, tColor buttonColor, tColor borderColor, tColor fontColor, int num); void ClearButton(int num); int GetTimersInitHeight(void); int GetTimersMaxHeight(void); @@ -123,10 +72,8 @@ class cNopacityDisplayMenuView { void ClearMessage(void); void SetDetailViewSize(eDetailViewType detailViewType, cNopacityMenuDetailView *detailView); void DrawRssFeed(std::string feedName); - cFont *GetRssFeedFont(void) {return fontRssFeed;}; cPoint GetRssFeedPosition(void); cPoint GetRssFeedSize(void); - int spaceMenu; }; diff --git a/displaymessage.c b/displaymessage.c index 894d8d8..b512a44 100644 --- a/displaymessage.c +++ b/displaymessage.c @@ -1,19 +1,17 @@ #include "displaymessage.h" -cNopacityDisplayMessage::cNopacityDisplayMessage(void) { +cNopacityDisplayMessage::cNopacityDisplayMessage(cImageCache *imgCache) { + this->imgCache = imgCache; config.setDynamicValues(); - height = cOsd::OsdHeight() * config.messageHeight / 100; - int top = cOsd::OsdTop() + cOsd::OsdHeight() - height - config.messageBorderBottom; - width = cOsd::OsdWidth() * config.messageWidth / 100; - int left = (cOsd::OsdLeft() + cOsd::OsdWidth() - width) / 2; - osd = CreateOsd(left, top, width, height); - pixmap = osd->CreatePixmap(2, cRect(0, 0, width, height)); - pixmapBackground = osd->CreatePixmap(1, cRect(0, 0, width, height)); + int top = geoManager->osdTop + geoManager->osdHeight - geoManager->messageHeight - config.messageBorderBottom; + int left = (geoManager->osdLeft + geoManager->osdWidth - geoManager->messageWidth) / 2; + osd = CreateOsd(left, top, geoManager->messageWidth, geoManager->messageHeight); + pixmap = osd->CreatePixmap(2, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight)); + pixmapBackground = osd->CreatePixmap(1, cRect(0, 0, geoManager->messageWidth, geoManager->messageHeight)); if (config.messageFadeTime) { pixmap->SetAlpha(0); pixmapBackground->SetAlpha(0); } - font = cFont::CreateFont(config.fontName, height / 4 + 15 + config.fontMessage); FrameTime = config.messageFrameTime; FadeTime = config.messageFadeTime; } @@ -24,7 +22,6 @@ cNopacityDisplayMessage::~cNopacityDisplayMessage() { cCondWait::SleepMs(10); osd->DestroyPixmap(pixmap); osd->DestroyPixmap(pixmapBackground); - delete font; delete osd; } @@ -52,15 +49,14 @@ void cNopacityDisplayMessage::SetMessage(eMessageType Type, const char *Text) { pixmapBackground->Fill(clrBlack); pixmap->Fill(col); if (config.doBlending) { - cImageLoader imgLoader; - imgLoader.DrawBackground2(Theme.Color(clrMessageBlend), col, width-2, height-2); - pixmap->DrawImage(cPoint(1, 1), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrMessageBlend), col, geoManager->messageWidth-2, geoManager->messageHeight-2, true); + pixmap->DrawImage(cPoint(1, 1), imgBack); } if (config.roundedCorners) { - DrawRoundedCornersWithBorder(pixmap, col, config.cornerRadius, width, height, pixmapBackground); + DrawRoundedCornersWithBorder(pixmap, col, config.cornerRadius, geoManager->messageWidth, geoManager->messageHeight, pixmapBackground); } - int textWidth = font->Width(Text); - pixmap->DrawText(cPoint((width - textWidth) / 2, (height - font->Height()) / 2), Text, colFont, (config.doBlending)?clrTransparent:col, font); + int textWidth = fontManager->messageText->Width(Text); + pixmap->DrawText(cPoint((geoManager->messageWidth - textWidth) / 2, (geoManager->messageHeight - fontManager->messageText->Height()) / 2), Text, colFont, (config.doBlending)?clrTransparent:col, fontManager->messageText); if (config.messageFadeTime) Start(); } diff --git a/displaymessage.h b/displaymessage.h index d1ff5af..dc53d5f 100644 --- a/displaymessage.h +++ b/displaymessage.h @@ -3,16 +3,14 @@ class cNopacityDisplayMessage : public cSkinDisplayMessage , cThread { private: cOsd *osd; - int width; - int height; + cImageCache *imgCache; cPixmap *pixmap; cPixmap *pixmapBackground; - cFont *font; int FrameTime; int FadeTime; virtual void Action(void); public: - cNopacityDisplayMessage(void); + cNopacityDisplayMessage(cImageCache *imgCache); virtual ~cNopacityDisplayMessage(); virtual void SetMessage(eMessageType Type, const char *Text); virtual void Flush(void); diff --git a/displayreplay.c b/displayreplay.c index 70bc930..3b08de0 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -1,17 +1,16 @@ #include "displayreplay.h" -cNopacityDisplayReplay::cNopacityDisplayReplay(bool ModeOnly) { +cNopacityDisplayReplay::cNopacityDisplayReplay(cImageCache *imgCache, bool ModeOnly) { + this->imgCache = imgCache; config.setDynamicValues(); initial = true; modeOnly = ModeOnly; lastDate = ""; FrameTime = config.replayFrameTime; FadeTime = config.replayFadeTime; - - SetGeometry(); + createOSD(); CreatePixmaps(); DrawBackground(); - CreateFonts(); } cNopacityDisplayReplay::~cNopacityDisplayReplay() { @@ -36,68 +35,43 @@ cNopacityDisplayReplay::~cNopacityDisplayReplay() { osd->DestroyPixmap(pixmapPause); osd->DestroyPixmap(pixmapPlay); osd->DestroyPixmap(pixmapFwd); - delete fontReplayHeader; - delete fontReplay; delete osd; } -void cNopacityDisplayReplay::SetGeometry(void) { - height = cOsd::OsdHeight() * config.replayHeight / 100; - width = cOsd::OsdWidth() - 2 * config.replayBorderVertical; - int top = cOsd::OsdTop() + cOsd::OsdHeight() - height - config.replayBorderBottom; - osd = CreateOsd(cOsd::OsdLeft() + config.replayBorderVertical, top, width, height); - headerHeight = height * 0.2; - if (headerHeight%2 != 0) - headerHeight++; - footerHeight = headerHeight; - resolutionX = 10; - resolutionY = 5; - info2Height = max(headerHeight,config.resolutionIconSize+resolutionY*2-headerHeight); - progressBarHeight = 0.1 * height; - if (progressBarHeight%2 != 0) - progressBarHeight++; - currentHeight = progressBarHeight + config.fontReplay; - controlsHeight = height - headerHeight - info2Height - footerHeight - progressBarHeight; - if (controlsHeight < 11) - controlsHeight = 11; - infoWidth = 0.75 * width - config.resolutionIconSize - 10; - dateWidth = width - infoWidth; - - jumpX = (width - 4 * controlsHeight)/2 + 5*controlsHeight; - jumpY = headerHeight + info2Height + progressBarHeight; - jumpWidth = width - jumpX; - jumpHeight = controlsHeight; +void cNopacityDisplayReplay::createOSD(void) { + int top = geoManager->osdTop + geoManager->osdHeight - geoManager->replayHeight - config.replayBorderBottom; + osd = CreateOsd(geoManager->osdLeft + config.replayBorderVertical, top, geoManager->replayWidth, geoManager->replayHeight); } void cNopacityDisplayReplay::CreatePixmaps(void) { if (!modeOnly) { - pixmapHeader = osd->CreatePixmap(1, cRect(0, 0, width, headerHeight)); - pixmapBackground = osd->CreatePixmap(1, cRect(0, headerHeight, width, info2Height + progressBarHeight + controlsHeight)); - pixmapFooter = osd->CreatePixmap(1, cRect(0, headerHeight + info2Height + progressBarHeight + controlsHeight, width, footerHeight)); - pixmapInfo = osd->CreatePixmap(2, cRect(config.resolutionIconSize + 10, 0, infoWidth, headerHeight)); - pixmapDate = osd->CreatePixmap(2, cRect(infoWidth, 0, dateWidth, headerHeight)); - pixmapInfo2 = osd->CreatePixmap(2, cRect(config.resolutionIconSize + 10, headerHeight, infoWidth, info2Height)); - pixmapProgressBar = osd->CreatePixmap(2, cRect(0, headerHeight + info2Height, width, progressBarHeight)); - pixmapCurrent = osd->CreatePixmap(3, cRect(0, headerHeight + info2Height + progressBarHeight, width/5, currentHeight)); - pixmapTotal = osd->CreatePixmap(3, cRect(4*width/5, headerHeight + info2Height + progressBarHeight, width/5, currentHeight)); - pixmapScreenResolution = osd->CreatePixmap(5, cRect(resolutionX, resolutionY, config.resolutionIconSize, config.resolutionIconSize)); - pixmapJump = osd->CreatePixmap(4, cRect(jumpX, jumpY, jumpWidth, jumpHeight)); + pixmapHeader = osd->CreatePixmap(1, cRect(0, 0, geoManager->replayWidth, geoManager->replayHeaderHeight)); + pixmapBackground = osd->CreatePixmap(1, cRect(0, geoManager->replayHeaderHeight, geoManager->replayWidth, geoManager->replayInfo2Height + geoManager->replayProgressBarHeight + geoManager->replayControlsHeight)); + pixmapFooter = osd->CreatePixmap(1, cRect(0, geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight + geoManager->replayControlsHeight, geoManager->replayWidth, geoManager->replayFooterHeight)); + pixmapInfo = osd->CreatePixmap(2, cRect(config.resolutionIconSize + 10, 0, geoManager->replayInfoWidth, geoManager->replayHeaderHeight)); + pixmapDate = osd->CreatePixmap(2, cRect(geoManager->replayInfoWidth, 0, geoManager->replayDateWidth, geoManager->replayHeaderHeight)); + pixmapInfo2 = osd->CreatePixmap(2, cRect(config.resolutionIconSize + 10, geoManager->replayHeaderHeight, geoManager->replayInfoWidth, geoManager->replayInfo2Height)); + pixmapProgressBar = osd->CreatePixmap(2, cRect(0, geoManager->replayHeaderHeight + geoManager->replayInfo2Height, geoManager->replayWidth, geoManager->replayProgressBarHeight)); + pixmapCurrent = osd->CreatePixmap(3, cRect(0, geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight, geoManager->replayWidth/5, geoManager->replayCurrentHeight)); + pixmapTotal = osd->CreatePixmap(3, cRect(4*geoManager->replayWidth/5, geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight, geoManager->replayWidth/5, geoManager->replayCurrentHeight)); + pixmapScreenResolution = osd->CreatePixmap(5, cRect(geoManager->replayResolutionX, geoManager->replayResolutionY, config.resolutionIconSize, config.resolutionIconSize)); + pixmapJump = osd->CreatePixmap(4, cRect(geoManager->replayJumpX, geoManager->replayJumpY, geoManager->replayJumpWidth, geoManager->replayJumpHeight)); } - int controlY = headerHeight + info2Height + progressBarHeight; - iconBorder = 5; - iconSize = min(controlsHeight - 2*iconBorder, 128); + int controlY = geoManager->replayHeaderHeight + geoManager->replayInfo2Height + geoManager->replayProgressBarHeight; + int iconBorder = geoManager->replayIconBorder; + int iconSize = geoManager->replayIconSize; int backgroundWidth = 2 * iconBorder + iconSize; if (!modeOnly) { - pixmapControls = osd->CreatePixmap(2, cRect(0, controlY, width, controlsHeight)); + pixmapControls = osd->CreatePixmap(2, cRect(0, controlY, geoManager->replayWidth, geoManager->replayControlsHeight)); } else { - pixmapControls = osd->CreatePixmap(2, cRect( (width - (5 * backgroundWidth))/2, controlY - 10, 5 * backgroundWidth, controlsHeight + 20)); + pixmapControls = osd->CreatePixmap(2, cRect( (geoManager->replayWidth - (5 * backgroundWidth))/2, controlY - 10, 5 * backgroundWidth, geoManager->replayControlsHeight + 20)); } - pixmapRew = osd->CreatePixmap(4, cRect((width - 4 * backgroundWidth)/2 + iconBorder, controlY + iconBorder, iconSize, iconSize)); - pixmapPause = osd->CreatePixmap(4, cRect((width - 4 * backgroundWidth)/2 + (iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); - pixmapPlay = osd->CreatePixmap(4, cRect((width - 4 * backgroundWidth)/2 + 2*(iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); - pixmapFwd = osd->CreatePixmap(4, cRect((width - 4 * backgroundWidth)/2 + 3*(iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); + pixmapRew = osd->CreatePixmap(4, cRect((geoManager->replayWidth - 4 * backgroundWidth)/2 + iconBorder, controlY + iconBorder, iconSize, iconSize)); + pixmapPause = osd->CreatePixmap(4, cRect((geoManager->replayWidth - 4 * backgroundWidth)/2 + (iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); + pixmapPlay = osd->CreatePixmap(4, cRect((geoManager->replayWidth - 4 * backgroundWidth)/2 + 2*(iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); + pixmapFwd = osd->CreatePixmap(4, cRect((geoManager->replayWidth - 4 * backgroundWidth)/2 + 3*(iconSize + 2*iconBorder) + iconBorder, controlY + iconBorder, iconSize, iconSize)); if (config.replayFadeTime) { if (!modeOnly) { @@ -121,11 +95,6 @@ void cNopacityDisplayReplay::CreatePixmaps(void) { } } -void cNopacityDisplayReplay::CreateFonts(void) { - fontReplayHeader = cFont::CreateFont(config.fontName, headerHeight - 8 + config.fontReplayHeader); - fontReplay = cFont::CreateFont(config.fontName, currentHeight); -} - void cNopacityDisplayReplay::DrawBackground(void) { if (!modeOnly) { if (config.doBlending && (Theme.Color(clrReplayBackground) != Theme.Color(clrReplayBackBlend))) { @@ -136,13 +105,13 @@ void cNopacityDisplayReplay::DrawBackground(void) { pixmapFooter->Fill(Theme.Color(clrReplayBackground)); } if (config.roundedCornersChannel) { - int cornerTopSize = headerHeight/2; - int cornerBottomSize = footerHeight/2; + int cornerTopSize = geoManager->replayHeaderHeight/2; + int cornerBottomSize = geoManager->replayFooterHeight/2; if ((cornerTopSize > 2)&&(cornerBottomSize > 2)) { pixmapHeader->DrawEllipse(cRect(0,0, cornerTopSize, cornerTopSize), clrTransparent, -2); - pixmapHeader->DrawEllipse(cRect(width - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); + pixmapHeader->DrawEllipse(cRect(geoManager->replayWidth - cornerTopSize, 0, cornerTopSize, cornerTopSize), clrTransparent, -1); pixmapFooter->DrawEllipse(cRect(0, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -3); - pixmapFooter->DrawEllipse(cRect(width - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); + pixmapFooter->DrawEllipse(cRect(geoManager->replayWidth - cornerBottomSize, cornerBottomSize, cornerBottomSize, cornerBottomSize), clrTransparent, -4); } } pixmapBackground->Fill(Theme.Color(clrReplayBackground)); @@ -157,37 +126,35 @@ void cNopacityDisplayReplay::DrawBackground(void) { } void cNopacityDisplayReplay::LoadControlIcons(void) { - pixmapRew->Fill(clrTransparent); pixmapPause->Fill(clrTransparent); pixmapPlay->Fill(clrTransparent); pixmapFwd->Fill(clrTransparent); - - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/rewInactive", iconSize)) { - pixmapRew->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } - if (imgLoader.LoadIcon("skinIcons/pauseInactive", iconSize)) { - pixmapPause->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } - if (imgLoader.LoadIcon("skinIcons/playInactive", iconSize)) { - pixmapPlay->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } - if (imgLoader.LoadIcon("skinIcons/fwdInactive", iconSize)) { - pixmapFwd->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + int iconSize = geoManager->replayIconSize; + cImage *imgRew = imgCache->GetSkinIcon("skinIcons/rewInactive", iconSize, iconSize); + if (imgRew) + pixmapRew->DrawImage(cPoint(0,0), *imgRew); + cImage *imgPause = imgCache->GetSkinIcon("skinIcons/pauseInactive", iconSize, iconSize); + if (imgPause) + pixmapPause->DrawImage(cPoint(0,0), *imgPause); + cImage *imgPlay = imgCache->GetSkinIcon("skinIcons/playInactive", iconSize, iconSize); + if (imgPlay) + pixmapPlay->DrawImage(cPoint(0,0), *imgPlay); + cImage *imgFwd = imgCache->GetSkinIcon("skinIcons/fwdInactive", iconSize, iconSize); + if (imgFwd) + pixmapFwd->DrawImage(cPoint(0,0), *imgFwd); } void cNopacityDisplayReplay::DrawDate(void) { cString curDate = DayDateTime(); if (initial || strcmp(curDate, lastDate)) { - int strDateWidth = fontReplay->Width(curDate); - int strDateHeight = fontReplay->Height(); - int x = dateWidth - strDateWidth - headerHeight/2; - int y = (headerHeight - strDateHeight) / 2; + int strDateWidth = fontManager->replayText->Width(curDate); + int strDateHeight = fontManager->replayText->Height(); + int x = geoManager->replayDateWidth - strDateWidth - geoManager->replayHeaderHeight/2; + int y = (geoManager->replayHeaderHeight - strDateHeight) / 2; pixmapDate->Fill(clrTransparent); - pixmapDate->DrawText(cPoint(x, y), curDate, Theme.Color(clrReplayHead), clrTransparent, fontReplay); + pixmapDate->DrawText(cPoint(x, y), curDate, Theme.Color(clrReplayHead), clrTransparent, fontManager->replayText); lastDate = curDate; } } @@ -216,10 +183,9 @@ void cNopacityDisplayReplay::DrawScreenResolution(void) { iconName = "skinIcons/sd576i"; break; } - cImageLoader imgLoader; - if (imgLoader.LoadIcon(*iconName, config.resolutionIconSize)) { - pixmapScreenResolution->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgRes = imgCache->GetSkinIcon(*iconName, config.resolutionIconSize, config.resolutionIconSize); + if (imgRes) + pixmapScreenResolution->DrawImage(cPoint(0,0), *imgRes); } void cNopacityDisplayReplay::SetRecording(const cRecording *Recording) { @@ -232,91 +198,95 @@ void cNopacityDisplayReplay::SetRecording(const cRecording *Recording) { info2 = cString::sprintf("%s %s", *ShortDateString(Recording->Start()), *TimeString(Recording->Start())); pixmapInfo2->Fill(clrTransparent); - pixmapInfo2->DrawText(cPoint(headerHeight/2, max( (info2Height - fontReplay->Height())/2 - 10,0 )), *info2, Theme.Color(clrReplayDescription), clrTransparent, fontReplay); + pixmapInfo2->DrawText(cPoint(geoManager->replayHeaderHeight/2, max( (geoManager->replayInfo2Height - fontManager->replayText->Height())/2 - 10,0 )), *info2, Theme.Color(clrReplayDescription), clrTransparent, fontManager->replayText); DrawScreenResolution(); } void cNopacityDisplayReplay::SetTitle(const char *Title) { pixmapInfo->Fill(clrTransparent); - pixmapInfo->DrawText(cPoint(headerHeight/2, 0), Title, Theme.Color(clrReplayHead), clrTransparent, fontReplayHeader); + pixmapInfo->DrawText(cPoint(geoManager->replayHeaderHeight/2, 0), Title, Theme.Color(clrReplayHead), clrTransparent, fontManager->replayHeader); } void cNopacityDisplayReplay::SetMode(bool Play, bool Forward, int Speed) { LoadControlIcons(); - cImageLoader imgLoader; + int iconSize = geoManager->replayIconSize; if (Speed == -1) { if (Play) { pixmapPlay->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/play", iconSize)) { - pixmapPlay->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/play", iconSize, iconSize); + if (imgIcon) + pixmapPlay->DrawImage(cPoint(0,0), *imgIcon); } else { pixmapPause->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/pause", iconSize)) { - pixmapPause->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize); + if (imgIcon) + pixmapPause->DrawImage(cPoint(0,0), *imgIcon); } } else if (Forward) { if (!Play) { pixmapPause->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/pause", iconSize)) { - pixmapPause->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize); + if (imgIcon) + pixmapPause->DrawImage(cPoint(0,0), *imgIcon); } pixmapFwd->Fill(clrTransparent); if (Speed > 0) { cString trickIcon = cString::sprintf("skinIcons/fwdx%d", Speed); - if (imgLoader.LoadIcon(*trickIcon, iconSize)) { - pixmapFwd->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } - } else if (imgLoader.LoadIcon("skinIcons/fwd", iconSize)) { - pixmapFwd->DrawImage(cPoint(0,0), imgLoader.GetImage()); + cImage *imgIcon = imgCache->GetSkinIcon(*trickIcon, iconSize, iconSize); + if (imgIcon) + pixmapFwd->DrawImage(cPoint(0,0), *imgIcon); + } else { + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/fwd", iconSize, iconSize); + if (imgIcon) + pixmapFwd->DrawImage(cPoint(0,0), *imgIcon); } } else { if (!Play) { pixmapPause->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/pause", iconSize)) { - pixmapPause->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/pause", iconSize, iconSize); + if (imgIcon) + pixmapPause->DrawImage(cPoint(0,0), *imgIcon); } pixmapRew->Fill(clrTransparent); if (Speed > 0) { cString trickIcon = cString::sprintf("skinIcons/rewx%d", Speed); - if (imgLoader.LoadIcon(*trickIcon, iconSize)) { - pixmapRew->DrawImage(cPoint(0,0), imgLoader.GetImage()); - } - } else if (imgLoader.LoadIcon("skinIcons/rew", iconSize)) { - pixmapRew->DrawImage(cPoint(0,0), imgLoader.GetImage()); + cImage *imgIcon = imgCache->GetSkinIcon(*trickIcon, iconSize, iconSize); + if (imgIcon) + pixmapRew->DrawImage(cPoint(0,0), *imgIcon); + } else { + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/rew", iconSize, iconSize); + if (imgIcon) + pixmapRew->DrawImage(cPoint(0,0), *imgIcon); } } } void cNopacityDisplayReplay::SetProgress(int Current, int Total) { - if (progressBarHeight < 5) + if (geoManager->replayProgressBarHeight < 5) return; - int barWidth = width - 2*progressBarHeight; - cProgressBar pb(barWidth, progressBarHeight-2, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent)); - pixmapProgressBar->DrawEllipse(cRect(progressBarHeight/2, 0, progressBarHeight, progressBarHeight), Theme.Color(clrProgressBarBack)); - pixmapProgressBar->DrawEllipse(cRect(barWidth + progressBarHeight/2, 0, progressBarHeight, progressBarHeight), Theme.Color(clrReplayProgressRest)); - pixmapProgressBar->DrawRectangle(cRect( progressBarHeight, 0, barWidth, progressBarHeight), Theme.Color(clrProgressBarBack)); - pixmapProgressBar->DrawEllipse(cRect(progressBarHeight/2+1, 1, progressBarHeight-1, progressBarHeight-2), Theme.Color(clrReplayProgressSeen)); - pixmapProgressBar->DrawBitmap(cPoint(progressBarHeight, 1), pb); + int barWidth = geoManager->replayWidth - 2*geoManager->replayProgressBarHeight; + cProgressBar pb(barWidth, geoManager->replayProgressBarHeight-2, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent)); + pixmapProgressBar->DrawEllipse(cRect(geoManager->replayProgressBarHeight/2, 0, geoManager->replayProgressBarHeight, geoManager->replayProgressBarHeight), Theme.Color(clrProgressBarBack)); + pixmapProgressBar->DrawEllipse(cRect(barWidth + geoManager->replayProgressBarHeight/2, 0, geoManager->replayProgressBarHeight, geoManager->replayProgressBarHeight), Theme.Color(clrReplayProgressRest)); + pixmapProgressBar->DrawRectangle(cRect( geoManager->replayProgressBarHeight, 0, barWidth, geoManager->replayProgressBarHeight), Theme.Color(clrProgressBarBack)); + pixmapProgressBar->DrawEllipse(cRect(geoManager->replayProgressBarHeight/2+1, 1, geoManager->replayProgressBarHeight-1, geoManager->replayProgressBarHeight-2), Theme.Color(clrReplayProgressSeen)); + pixmapProgressBar->DrawBitmap(cPoint(geoManager->replayProgressBarHeight, 1), pb); } void cNopacityDisplayReplay::SetCurrent(const char *Current) { pixmapCurrent->Fill(clrTransparent); - pixmapCurrent->DrawText(cPoint(headerHeight/2, 0), Current, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontReplay); + pixmapCurrent->DrawText(cPoint(geoManager->replayHeaderHeight/2, 0), Current, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontManager->replayText); } void cNopacityDisplayReplay::SetTotal(const char *Total) { pixmapTotal->Fill(clrTransparent); - pixmapTotal->DrawText(cPoint(width/5 - (fontReplay->Width(Total) + headerHeight/2), 0), Total, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontReplay); + pixmapTotal->DrawText(cPoint(geoManager->replayWidth/5 - (fontManager->replayText->Width(Total) + geoManager->replayHeaderHeight/2), 0), Total, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontManager->replayText); } void cNopacityDisplayReplay::SetJump(const char *Jump) { pixmapJump->Fill(clrTransparent); if (Jump) { - pixmapJump->DrawText(cPoint(0, (jumpHeight - fontReplayHeader->Height())/2), Jump, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontReplayHeader); + pixmapJump->DrawText(cPoint(0, (geoManager->replayJumpHeight - fontManager->replayHeader->Height())/2), Jump, Theme.Color(clrReplayCurrentTotal), clrTransparent, fontManager->replayHeader); } } diff --git a/displayreplay.h b/displayreplay.h index 2ed0a41..4dbfe6b 100644 --- a/displayreplay.h +++ b/displayreplay.h @@ -4,23 +4,10 @@ class cNopacityDisplayReplay : public cSkinDisplayReplay , cThread{ private: cOsd *osd; + cImageCache *imgCache; bool initial; bool modeOnly; cString lastDate; - int width; - int height; - int headerHeight; - int info2Height; - int progressBarHeight; - int currentHeight; - int controlsHeight; - int footerHeight; - int infoWidth; - int dateWidth; - int iconSize, iconBorder; - int resolutionX, resolutionY; - int jumpX, jumpY; - int jumpWidth, jumpHeight; int FrameTime; int FadeTime; cPixmap *pixmapHeader; @@ -39,18 +26,15 @@ private: cPixmap *pixmapFwd; cPixmap *pixmapJump; cPixmap *pixmapFooter; - cFont *fontReplayHeader; - cFont *fontReplay; virtual void Action(void); - void SetGeometry(void); + void createOSD(void); void CreatePixmaps(void); - void CreateFonts(void); void DrawBackground(void); void DrawDate(void); void LoadControlIcons(void); void DrawScreenResolution(void); public: - cNopacityDisplayReplay(bool ModeOnly); + cNopacityDisplayReplay(cImageCache *imgCache, bool ModeOnly); virtual ~cNopacityDisplayReplay(); virtual void SetRecording(const cRecording *Recording); virtual void SetTitle(const char *Title); diff --git a/displaytracks.c b/displaytracks.c index b9c7f7e..d79418c 100644 --- a/displaytracks.c +++ b/displaytracks.c @@ -1,6 +1,7 @@ #include "displaytracks.h" -cNopacityDisplayTracks::cNopacityDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) { +cNopacityDisplayTracks::cNopacityDisplayTracks(cImageCache *imgCache, const char *Title, int NumTracks, const char * const *Tracks) { + this->imgCache = imgCache; config.setDynamicValues(); initial = true; currentIndex = -1; @@ -10,8 +11,6 @@ cNopacityDisplayTracks::cNopacityDisplayTracks(const char *Title, int NumTracks, FadeTime = config.tracksFadeTime; SetGeometry(); CreatePixmaps(); - CreateFonts(); - CreateBackgroundImages(); DrawHeader(Title); for (int i = 0; i < NumTracks; i++) SetItem(Tracks[i], i, false); @@ -25,21 +24,15 @@ cNopacityDisplayTracks::~cNopacityDisplayTracks() { osd->DestroyPixmap(pixmapHeader); osd->DestroyPixmap(pixmapHeaderAudio); menuItems.Clear(); - if (config.doBlending) { - for (int i=0; i<2; i++) - cOsdProvider::DropImage(handleBackgrounds[i]); - } - delete font; - delete fontHeader; delete osd; } void cNopacityDisplayTracks::SetGeometry(void) { - width = cOsd::OsdWidth() * config.tracksWidth / 100; + width = geoManager->trackWidth; height = (config.tracksItemHeight +4) * (numTracks+1); - menuItemWidth = width - 4; - menuItemHeight = config.tracksItemHeight; + menuItemWidth = geoManager->menuItemWidthTracks; + menuItemHeight = geoManager->menuItemHeightTracks; int top, left; switch(config.tracksPosition) { @@ -94,48 +87,34 @@ void cNopacityDisplayTracks::CreatePixmaps(void) { } } -void cNopacityDisplayTracks::CreateFonts(void) { - font = cFont::CreateFont(config.fontName, menuItemHeight/3 + config.fontTracks); - fontHeader = cFont::CreateFont(config.fontName, menuItemHeight/2 + config.fontTracksHeader); -} - -void cNopacityDisplayTracks::CreateBackgroundImages(void) { - if (!config.doBlending) - return; - cImageLoader imgLoader; - imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), menuItemWidth-2, menuItemHeight-2); - handleBackgrounds[0] = cOsdProvider::StoreImage(imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), menuItemWidth-2, menuItemHeight-2); - handleBackgrounds[1] = cOsdProvider::StoreImage(imgLoader.GetImage()); -} - void cNopacityDisplayTracks::DrawHeader(const char *Title) { pixmapContainer->Fill(Theme.Color(clrMenuBorder)); pixmapContainer->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrMenuBack)); pixmapHeader->Fill(Theme.Color(clrMenuItem)); if (config.doBlending) { - pixmapHeader->DrawImage(cPoint(1, 1), handleBackgrounds[0]); + cImage *back = imgCache->GetBackground(btTracks); + if (back) + pixmapHeader->DrawImage(cPoint(1, 1), *back); } else { pixmapHeader->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrMenuItemHigh)); } pixmapIcon = osd->CreatePixmap(3, cRect(2, 2, menuItemHeight-2, menuItemHeight-2)); pixmapIcon->Fill(clrTransparent); - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/tracks", menuItemHeight-6)) { - pixmapIcon->DrawImage(cPoint(3, 3), imgLoader.GetImage()); - } + + cImage *imgTracks = imgCache->GetSkinIcon("skinIcons/tracks", menuItemHeight-6, menuItemHeight-6); + if (imgTracks) + pixmapIcon->DrawImage(cPoint(3,3), *imgTracks); int clrFontBack = (config.doBlending)?clrTransparent:Theme.Color(clrMenuItemHigh); - pixmapHeader->DrawText(cPoint((width - fontHeader->Width(Title)) / 2, (menuItemHeight - fontHeader->Height()) / 2), Title, Theme.Color(clrTracksFontHead), clrFontBack, fontHeader); + pixmapHeader->DrawText(cPoint((width - fontManager->trackHeader->Width(Title)) / 2, (menuItemHeight - fontManager->trackHeader->Height()) / 2), Title, Theme.Color(clrTracksFontHead), clrFontBack, fontManager->trackHeader); } void cNopacityDisplayTracks::SetItem(const char *Text, int Index, bool Current) { cNopacityMenuItem *item; - item = new cNopacityTrackMenuItem(osd, Text); + item = new cNopacityTrackMenuItem(osd, imgCache, Text); item->SetCurrent(Current); - item->SetFont(font); + item->SetFont(fontManager->trackText); item->SetGeometry(Index, menuItemHeight+4, 2, menuItemWidth, menuItemHeight, 4); item->CreatePixmap(); - item->SetBackgrounds(handleBackgrounds); menuItems.Add(item); item->Render(); } @@ -169,10 +148,10 @@ void cNopacityDisplayTracks::SetAudioChannel(int AudioChannel) { icon = "skinIcons/stereo"; break; } - cImageLoader imgLoader; - if (imgLoader.LoadIcon(icon, menuItemHeight-2)) { - pixmapHeaderAudio->DrawImage(cPoint(1, 1), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon(*icon, menuItemHeight-2, menuItemHeight-2); + if (imgIcon) + pixmapHeaderAudio->DrawImage(cPoint(1,1), *imgIcon); + } } diff --git a/displaytracks.h b/displaytracks.h index 171b808..1f9ad1e 100644 --- a/displaytracks.h +++ b/displaytracks.h @@ -4,6 +4,7 @@ class cNopacityDisplayTracks : public cSkinDisplayTracks, cThread { private: cOsd *osd; + cImageCache *imgCache; int FrameTime; int FadeTime; int width, height; @@ -18,18 +19,13 @@ private: cPixmap *pixmapHeaderAudio; cPixmap *pixmapIcon; cList<cNopacityMenuItem> menuItems; - int handleBackgrounds[2]; - cFont *font; - cFont *fontHeader; virtual void Action(void); void SetItem(const char *Text, int Index, bool Current); void SetGeometry(void); void CreatePixmaps(void); - void CreateFonts(void); - void CreateBackgroundImages(void); void DrawHeader(const char *Title); public: - cNopacityDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); + cNopacityDisplayTracks(cImageCache *imgCache, const char *Title, int NumTracks, const char * const *Tracks); virtual ~cNopacityDisplayTracks(); virtual void SetTrack(int Index, const char * const *Tracks); virtual void SetAudioChannel(int AudioChannel); diff --git a/displayvolume.c b/displayvolume.c index 03dc4eb..390c339 100644 --- a/displayvolume.c +++ b/displayvolume.c @@ -8,16 +8,12 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) { FrameTime = config.volumeFrameTime; FadeTime = config.volumeFadeTime; - width = cOsd::OsdWidth() * config.volumeWidth / 100; - height = cOsd::OsdHeight() * config.volumeHeight / 100; + int top = (geoManager->osdHeight - geoManager->volumeHeight) - config.volumeBorderBottom; + int left = (geoManager->osdWidth - geoManager->volumeWidth) / 2; + osd = CreateOsd(left, top, geoManager->volumeWidth, geoManager->volumeHeight); - int top = (cOsd::OsdHeight() - height) - config.volumeBorderBottom; - int left = (cOsd::OsdWidth() - width) / 2; - - osd = CreateOsd(left, top, width, height); - - pixmapBackgroundTop = osd->CreatePixmap(1, cRect(0, 0, width, height/2)); - pixmapBackgroundBottom = osd->CreatePixmap(1, cRect(0, height/2, width, height/2)); + pixmapBackgroundTop = osd->CreatePixmap(1, cRect(0, 0, geoManager->volumeWidth, geoManager->volumeHeight/2)); + pixmapBackgroundBottom = osd->CreatePixmap(1, cRect(0, geoManager->volumeHeight/2, geoManager->volumeWidth, geoManager->volumeHeight/2)); if (config.doBlending) { DrawBlendedBackground(pixmapBackgroundTop, Theme.Color(clrChannelBackground), Theme.Color(clrChannelBackBlend), true); DrawBlendedBackground(pixmapBackgroundBottom, Theme.Color(clrChannelBackground), Theme.Color(clrChannelBackBlend), false); @@ -25,20 +21,16 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) { pixmapBackgroundTop->Fill(Theme.Color(clrChannelBackground)); pixmapBackgroundBottom->Fill(Theme.Color(clrChannelBackground)); } - int cornerSize = height/4; + int cornerSize = geoManager->volumeHeight/4; if (cornerSize > 2) { pixmapBackgroundTop->DrawEllipse(cRect(0, 0, cornerSize, cornerSize), clrTransparent, -2); - pixmapBackgroundTop->DrawEllipse(cRect(width - cornerSize, 0, cornerSize, cornerSize), clrTransparent, -1); + pixmapBackgroundTop->DrawEllipse(cRect(geoManager->volumeWidth - cornerSize, 0, cornerSize, cornerSize), clrTransparent, -1); pixmapBackgroundBottom->DrawEllipse(cRect(0, cornerSize, cornerSize, cornerSize), clrTransparent, -3); - pixmapBackgroundBottom->DrawEllipse(cRect(width - cornerSize, cornerSize, cornerSize, cornerSize), clrTransparent, -4); + pixmapBackgroundBottom->DrawEllipse(cRect(geoManager->volumeWidth - cornerSize, cornerSize, cornerSize, cornerSize), clrTransparent, -4); } - labelHeight = height/3; - pixmapLabel = osd->CreatePixmap(2, cRect(0, 5, width, labelHeight)); - progressBarWidth = 0.9 * width; - progressBarHeight = 0.3 * height; - if (progressBarHeight%2 != 0) - progressBarHeight++; - pixmapProgressBar = osd->CreatePixmap(2, cRect((width - progressBarWidth) / 2, (height - progressBarHeight)*2/3, progressBarWidth, progressBarHeight)); + + pixmapLabel = osd->CreatePixmap(2, cRect(0, 5, geoManager->volumeWidth, geoManager->volumeLabelHeight)); + pixmapProgressBar = osd->CreatePixmap(2, cRect((geoManager->volumeWidth - geoManager->volumeProgressBarWidth) / 2, (geoManager->volumeHeight - geoManager->volumeProgressBarHeight)*2/3, geoManager->volumeProgressBarWidth, geoManager->volumeProgressBarHeight)); if (config.volumeFadeTime) { pixmapBackgroundTop->SetAlpha(0); @@ -46,7 +38,6 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) { pixmapProgressBar->SetAlpha(0); pixmapLabel->SetAlpha(0); } - font = cFont::CreateFont(config.fontName, labelHeight - 6 + config.fontVolume); } cNopacityDisplayVolume::~cNopacityDisplayVolume() { @@ -57,36 +48,35 @@ cNopacityDisplayVolume::~cNopacityDisplayVolume() { osd->DestroyPixmap(pixmapBackgroundBottom); osd->DestroyPixmap(pixmapLabel); osd->DestroyPixmap(pixmapProgressBar); - delete font; delete osd; } void cNopacityDisplayVolume::SetVolume(int Current, int Total, bool Mute) { pixmapLabel->Fill(clrTransparent); cString label = cString::sprintf("%s: %d", tr("Volume"), Current); - pixmapLabel->DrawText(cPoint((width - font->Width(*label)) / 2, (labelHeight - font->Height()) / 2), *label, Theme.Color(clrVolumeFont), clrTransparent, font); + pixmapLabel->DrawText(cPoint((geoManager->volumeWidth - fontManager->volumeText->Width(*label)) / 2, (geoManager->volumeLabelHeight - fontManager->volumeText->Height()) / 2), *label, Theme.Color(clrVolumeFont), clrTransparent, fontManager->volumeText); if (Mute) { cBitmap bmMute(mute_xpm); - pixmapLabel->DrawBitmap(cPoint(width - 2*bmMute.Width(), (labelHeight - bmMute.Height()) / 2), bmMute, Theme.Color(clrDiskAlert), clrTransparent); + pixmapLabel->DrawBitmap(cPoint(geoManager->volumeWidth - 2*bmMute.Width(), (geoManager->volumeLabelHeight - bmMute.Height()) / 2), bmMute, Theme.Color(clrDiskAlert), clrTransparent); } DrawProgressBar(Current, Total); } void cNopacityDisplayVolume::DrawProgressBar(int Current, int Total) { pixmapProgressBar->Fill(clrTransparent); - if (progressBarHeight < 5) + if (geoManager->volumeProgressBarHeight < 5) return; double percent = ((double)Current) / (double)Total; - int barWidth = progressBarWidth - progressBarHeight; + int barWidth = geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight; if ((Current > 0) || (Total > 0)) { - pixmapProgressBar->DrawEllipse(cRect(0, 0, progressBarHeight, progressBarHeight), Theme.Color(clrProgressBarBack)); - pixmapProgressBar->DrawEllipse(cRect(progressBarWidth - progressBarHeight, 0, progressBarHeight, progressBarHeight), Theme.Color(clrProgressBarBack)); - pixmapProgressBar->DrawRectangle(cRect(progressBarHeight/2, 0, progressBarWidth - progressBarHeight, progressBarHeight), Theme.Color(clrProgressBarBack)); + pixmapProgressBar->DrawEllipse(cRect(0, 0, geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack)); + pixmapProgressBar->DrawEllipse(cRect(geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight, 0, geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack)); + pixmapProgressBar->DrawRectangle(cRect(geoManager->volumeProgressBarHeight/2, 0, geoManager->volumeProgressBarWidth - geoManager->volumeProgressBarHeight, geoManager->volumeProgressBarHeight), Theme.Color(clrProgressBarBack)); - pixmapProgressBar->DrawEllipse(cRect(1, 1, progressBarHeight-2, progressBarHeight-2), Theme.Color(clrProgressBarBlend)); + pixmapProgressBar->DrawEllipse(cRect(1, 1, geoManager->volumeProgressBarHeight-2, geoManager->volumeProgressBarHeight-2), Theme.Color(clrProgressBarBlend)); if (Current > 0) { - tColor colAct = DrawProgressbarBackground(progressBarHeight / 2 - 1, 1, barWidth * percent - 2, progressBarHeight - 2); - pixmapProgressBar->DrawEllipse(cRect(barWidth * percent, 1, progressBarHeight-2, progressBarHeight-2), colAct); + tColor colAct = DrawProgressbarBackground(geoManager->volumeProgressBarHeight / 2 - 1, 1, barWidth * percent - 2, geoManager->volumeProgressBarHeight - 2); + pixmapProgressBar->DrawEllipse(cRect(barWidth * percent, 1, geoManager->volumeProgressBarHeight-2, geoManager->volumeProgressBarHeight-2), colAct); } } } diff --git a/displayvolume.h b/displayvolume.h index 707bca3..30a4db2 100644 --- a/displayvolume.h +++ b/displayvolume.h @@ -7,15 +7,11 @@ private: int FadeTime; bool initial; bool muted; - int width, height; - int labelHeight; - int progressBarWidth, progressBarHeight; cOsd *osd; cPixmap *pixmapBackgroundTop; cPixmap *pixmapBackgroundBottom; cPixmap *pixmapProgressBar; cPixmap *pixmapLabel; - cFont *font; virtual void Action(void); void DrawProgressBar(int Current, int Total); tColor DrawProgressbarBackground(int left, int top, int width, int height); diff --git a/fontmanager.c b/fontmanager.c new file mode 100644 index 0000000..8b42b66 --- /dev/null +++ b/fontmanager.c @@ -0,0 +1,132 @@ +#include "fontmanager.h" + +cFontManager::cFontManager() { +} + +cFontManager::~cFontManager() { + DeleteFonts(); +} + +void cFontManager::SetFonts() { + SetFontsMenu(); + SetFontsChannel(); + SetFontsReplay(); + SetFontsMessage(); + SetFontsTrack(); + SetFontsVolume(); +} + +void cFontManager::DeleteFonts() { + DeleteFontsMenu(); + DeleteFontsChannel(); + DeleteFontsReplay(); + DeleteFontsMessage(); + DeleteFontsTrack(); + DeleteFontsVolume(); +} + +cFont *cFontManager::CreateFont(int size) { + return cFont::CreateFont(config.fontName, size); +} + +void cFontManager::SetFontsMenu(void) { + menuHeader = CreateFont(geoManager->menuHeaderHeight / 2 + config.fontHeader); + menuDate = CreateFont(geoManager->menuHeaderHeight / 2 + config.fontDate); + menuItemLarge = CreateFont(geoManager->menuItemHeightMain/3 + 4 + config.fontMenuitemLarge); + menuItemSchedule = CreateFont(geoManager->menuItemHeightSchedule / 4 + 5 + config.fontMenuitemSchedule); + menuItemScheduleSmall = CreateFont(geoManager->menuItemHeightSchedule / 4 - 5 + config.fontMenuitemScheduleSmall); + menuItemChannel = CreateFont(geoManager->menuItemHeightSchedule / 3 + config.fontMenuitemChannel); + menuItemChannelSmall = CreateFont(geoManager->menuItemHeightSchedule / 5 - 2 + config.fontMenuitemChannelSmall); + menuItemRecordings = CreateFont(geoManager->menuItemHeightRecordings / 2 - 14 + config.fontMenuitemRecordings); + menuItemRecordingsSmall = CreateFont(geoManager->menuItemHeightRecordings / 4 - 3 + config.fontMenuitemRecordingsSmall); + menuItemTimers = CreateFont(geoManager->menuItemHeightSchedule / 3 + config.fontMenuitemTimers); + menuItemTimersSmall = CreateFont(geoManager->menuItemHeightSchedule / 4 - 3 + config.fontMenuitemTimersSmall); + menuItemDefault = CreateFont(geoManager->menuItemHeightDefault * 2 / 3 + config.fontMenuitemDefault); + menuDiskUsage = CreateFont(geoManager->menuDiskUsageHeight/6 - 2 + config.fontDiskUsage); + menuDiskUsagePercent = CreateFont(geoManager->menuDiskUsageHeight/5 - 4 + config.fontDiskUsagePercent); + menuTimersHead = CreateFont((geoManager->menuContentHeight - 3*geoManager->menuSpace - geoManager->menuDiskUsageHeight) / 25 + config.fontTimersHead); + menuTimers = CreateFont((geoManager->menuContentHeight - 3*geoManager->menuSpace - geoManager->menuDiskUsageHeight) / 25 - 6 + config.fontTimers); + menuButtons = CreateFont(geoManager->menuButtonHeight*0.8 + config.fontButtons); + menuMessage = CreateFont(geoManager->menuMessageHeight / 3 + config.fontMessageMenu); + menuEPGInfoWindow = CreateFont(geoManager->menuContentHeight / 30 + config.fontEPGInfoWindow); + menuEPGInfoWindowLarge = CreateFont(geoManager->menuContentHeight / 20 + config.fontEPGInfoWindowLarge); + menuRssFeed = CreateFont((geoManager->menuRssFeedHeight / 2) + 3 + config.fontRssFeed); +} + +void cFontManager::DeleteFontsMenu(void) { + delete menuHeader; + delete menuDate; + delete menuItemLarge; + delete menuItemSchedule; + delete menuItemScheduleSmall; + delete menuItemChannel; + delete menuItemChannelSmall; + delete menuItemRecordings; + delete menuItemRecordingsSmall; + delete menuItemTimers; + delete menuItemTimersSmall; + delete menuItemDefault; + delete menuDiskUsage; + delete menuDiskUsagePercent; + delete menuTimers; + delete menuTimersHead; + delete menuButtons; + delete menuMessage; + delete menuEPGInfoWindow; + delete menuEPGInfoWindowLarge; + delete menuRssFeed; +} + +void cFontManager::SetFontsChannel(void) { + channelHeader = CreateFont(geoManager->channelInfoHeight - 8 + config.fontChannelHeaderSize); + channelDate = CreateFont(geoManager->channelInfoHeight/2 + config.fontChannelDateSize); + channelEPG = CreateFont(geoManager->channelEpgInfoLineHeight + config.fontEPGSize); + channelEPGSmall = CreateFont(geoManager->channelEpgInfoLineHeight - 6 + config.fontEPGSmallSize); + channelChannelGroup = CreateFont(geoManager->channelEpgInfoHeight/3 + config.fontChannelGroupSize); + channelChannelGroupSmall = CreateFont(geoManager->channelEpgInfoHeight/3 - 5 + config.fontChannelGroupSmallSize); +} + +void cFontManager::DeleteFontsChannel(void) { + delete channelHeader; + delete channelDate; + delete channelEPG; + delete channelEPGSmall; + delete channelChannelGroup; + delete channelChannelGroupSmall; +} + +void cFontManager::SetFontsReplay(void) { + replayHeader = CreateFont(geoManager->replayHeaderHeight - 8 + config.fontReplayHeader); + replayText = CreateFont(geoManager->replayCurrentHeight); +} + +void cFontManager::DeleteFontsReplay(void) { + delete replayHeader; + delete replayText; +} + +void cFontManager::SetFontsMessage(void) { + messageText = CreateFont(geoManager->messageHeight / 4 + 15 + config.fontMessage); +} + +void cFontManager::DeleteFontsMessage(void) { + delete messageText; +} + +void cFontManager::SetFontsTrack(void) { + trackText = CreateFont(geoManager->menuItemHeightTracks/3 + config.fontTracks); + trackHeader = CreateFont(geoManager->menuItemHeightTracks/2 + config.fontTracksHeader); +} + +void cFontManager::DeleteFontsTrack(void) { + delete trackText; + delete trackHeader; +} + +void cFontManager::SetFontsVolume(void) { + volumeText = CreateFont(geoManager->volumeLabelHeight - 6 + config.fontVolume); +} + +void cFontManager::DeleteFontsVolume(void) { + delete volumeText; +}
\ No newline at end of file diff --git a/fontmanager.h b/fontmanager.h new file mode 100644 index 0000000..6728ace --- /dev/null +++ b/fontmanager.h @@ -0,0 +1,65 @@ +#ifndef __NOPACITY_FONTMANAGER_H +#define __NOPACITY_FONTMANAGER_H + +class cFontManager { + private: + void SetFontsMenu(void); + void DeleteFontsMenu(void); + void SetFontsChannel(void); + void DeleteFontsChannel(void); + void SetFontsReplay(void); + void DeleteFontsReplay(void); + void SetFontsMessage(void); + void DeleteFontsMessage(void); + void SetFontsTrack(void); + void DeleteFontsTrack(void); + void SetFontsVolume(void); + void DeleteFontsVolume(void); + public: + cFontManager(); + ~cFontManager(); + cFont *CreateFont(int size); + void SetFonts(void); + void DeleteFonts(void); + //Fonts DisplayMenu + cFont *menuHeader; + cFont *menuDate; + cFont *menuItemLarge; + cFont *menuItemSchedule; + cFont *menuItemScheduleSmall; + cFont *menuItemChannel; + cFont *menuItemChannelSmall; + cFont *menuItemRecordings; + cFont *menuItemRecordingsSmall; + cFont *menuItemTimers; + cFont *menuItemTimersSmall; + cFont *menuItemDefault; + cFont *menuDiskUsage; + cFont *menuDiskUsagePercent; + cFont *menuTimers; + cFont *menuTimersHead; + cFont *menuButtons; + cFont *menuMessage; + cFont *menuEPGInfoWindow; + cFont *menuEPGInfoWindowLarge; + cFont *menuRssFeed; + //Fonts DisplayChannel + cFont *channelHeader; + cFont *channelDate; + cFont *channelEPG; + cFont *channelEPGSmall; + cFont *channelChannelGroup; + cFont *channelChannelGroupSmall; + //Fonts DisplayReplay + cFont *replayHeader; + cFont *replayText; + //Fonts DisplayMessage + cFont *messageText; + //Fonts DisplayTracks + cFont *trackText; + cFont *trackHeader; + //Fonts DisplayVolume + cFont *volumeText; +}; + +#endif //__NOPACITY_FONTMANAGER_H
\ No newline at end of file diff --git a/geometrymanager.c b/geometrymanager.c new file mode 100644 index 0000000..549da73 --- /dev/null +++ b/geometrymanager.c @@ -0,0 +1,168 @@ +#include "geometrymanager.h" + +cGeometryManager::cGeometryManager() { + SetOSDSize(); +} + +cGeometryManager::~cGeometryManager() { +} + +void cGeometryManager::SetOSDSize(void) { + osdWidth = cOsd::OsdWidth(); + osdHeight = cOsd::OsdHeight(); + osdLeft = cOsd::OsdLeft(); + osdTop = cOsd::OsdTop(); +} + +void cGeometryManager::SetGeometry(void) { + SetDisplayMenuSizes(); + SetDisplayChannelSizes(); + SetDisplayReplaySizes(); + SetDisplayMessageSizes(); + SetDisplayTrackSizes(); + SetDisplayVolumeSizes(); +} + +bool cGeometryManager::GeometryChanged(void) { + if ((osdWidth != cOsd::OsdWidth()) || + (osdHeight != cOsd::OsdHeight()) || + (osdLeft != cOsd::OsdLeft()) || + (osdTop != cOsd::OsdTop())) { + dsyslog("nopacity: osd Size changed"); + dsyslog("nopacity: old osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight); + SetOSDSize(); + dsyslog("nopacity: new osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight); + return true; + } + return false; +} + +void cGeometryManager::SetDisplayMenuSizes() { + menuSpace = config.spaceMenu; + + menuWidthScrollbar = config.widthScrollbar; + menuDateWidth = osdWidth * 0.3; + + menuHeaderHeight = osdHeight * config.headerHeight / 100; + menuFooterHeight = osdHeight * config.footerHeight / 100; + menuRssFeedHeight = (config.displayRSSFeed)?(osdHeight * config.rssFeedHeight / 100):0; + menuContentHeight = osdHeight - menuHeaderHeight - menuFooterHeight - menuRssFeedHeight; + + menuContentWidthMain = osdWidth * config.menuWidthMain / 100; + menuContentWidthSchedules = osdWidth * config.menuWidthSchedules / 100; + menuContentWidthChannels = osdWidth * config.menuWidthChannels / 100; + menuContentWidthTimers = osdWidth * config.menuWidthTimers / 100; + menuContentWidthRecordings = osdWidth * config.menuWidthRecordings / 100; + menuContentWidthSetup = osdWidth * config.menuWidthSetup / 100; + menuContentWidthFull = osdWidth - config.widthScrollbar - config.spaceMenu; + menuContentWidthMinimum = Minimum(menuContentWidthMain, + menuContentWidthSchedules, + menuContentWidthChannels, + menuContentWidthTimers, + menuContentWidthRecordings, + menuContentWidthSetup); + + menuItemWidthDefault = menuContentWidthFull - 4 * config.spaceMenu; + menuItemWidthMain = menuContentWidthMain - 4 * config.spaceMenu; + menuItemWidthSchedule = menuContentWidthSchedules - 4 * config.spaceMenu; + menuItemWidthChannel = menuContentWidthChannels - 4 * config.spaceMenu; + menuItemWidthTimer = menuContentWidthTimers - 4 * config.spaceMenu; + menuItemWidthRecording = menuContentWidthRecordings - 4 * config.spaceMenu; + menuItemWidthSetup = menuContentWidthSetup - 4 * config.spaceMenu; + menuItemWidthTracks = osdWidth * config.tracksWidth / 100 - 4; + menuItemHeightMain = config.iconHeight + 2; + menuItemHeightSchedule = config.menuItemLogoHeight + 2; + menuItemHeightDefault = menuContentHeight / config.numDefaultMenuItems - config.spaceMenu; + menuItemHeightRecordings = config.menuRecFolderSize + 2; + menuItemHeightTracks = config.tracksItemHeight; + + menuButtonsBorder = menuFooterHeight / 6; + menuButtonWidth = (osdWidth / 4) - 2 * menuButtonsBorder; + menuButtonHeight = menuFooterHeight - 3 * menuButtonsBorder; + + menuDiskUsageWidth = menuDiskUsageHeight = osdWidth * config.menuSizeDiskUsage / 100; + menuTimersWidth = osdWidth * config.menuWidthRightItems / 100; + menuMessageWidth = 0.8 * osdWidth; + menuMessageHeight = 0.1 * osdHeight; +} + +void cGeometryManager::SetDisplayChannelSizes(void) { + channelHeight = osdHeight * config.channelHeight / 100; + channelTop = osdTop + osdHeight - channelHeight - config.channelBorderBottom; + switch (config.logoPosition) { + case lpLeft: + channelWidth = osdWidth - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder); + channelX = config.logoWidth + config.channelBorderVertical + config.logoBorder; + break; + case lpRight: + channelWidth = osdWidth - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder); + channelX = config.channelBorderVertical; + break; + case lpNone: + channelWidth = osdWidth - 2 * config.channelBorderVertical; + channelX = config.channelBorderVertical; + break; + } + channelInfoWidth = channelWidth * 0.7; + channelDateWidth = channelWidth - channelInfoWidth; + channelInfoHeight = channelHeight * 0.2; + if (channelInfoHeight%2 != 0) + channelInfoHeight++; + channelProgressBarHeight = channelHeight * 0.1; + channelStreamInfoHeight = channelHeight * 0.2; + if (channelStreamInfoHeight%2 != 0) + channelStreamInfoHeight++; + channelEpgInfoHeight = channelHeight - channelInfoHeight - channelStreamInfoHeight - channelProgressBarHeight; + channelEpgInfoLineHeight = channelEpgInfoHeight / 4; + channelStreamInfoY = channelInfoHeight + channelProgressBarHeight + channelEpgInfoHeight; + channelIconSize = config.statusIconSize; + channelIconsWidth = 5*channelIconSize; +} + +void cGeometryManager::SetDisplayReplaySizes(void) { + replayHeight = osdHeight * config.replayHeight / 100; + replayWidth = osdWidth - 2 * config.replayBorderVertical; + replayHeaderHeight = replayHeight * 0.2; + if (replayHeaderHeight%2 != 0) + replayHeaderHeight++; + replayFooterHeight = replayHeaderHeight; + replayResolutionX = 10; + replayResolutionY = 5; + replayInfo2Height = max(replayHeaderHeight,config.resolutionIconSize+replayResolutionY*2-replayHeaderHeight); + replayProgressBarHeight = 0.1 * replayHeight; + if (replayProgressBarHeight%2 != 0) + replayProgressBarHeight++; + replayCurrentHeight = replayProgressBarHeight + config.fontReplay; + replayControlsHeight = replayHeight - replayHeaderHeight - replayInfo2Height - replayFooterHeight - replayProgressBarHeight; + if (replayControlsHeight < 11) + replayControlsHeight = 11; + replayInfoWidth = 0.75 * replayWidth - config.resolutionIconSize - 10; + replayDateWidth = replayWidth - replayInfoWidth; + + replayJumpX = (replayWidth - 4 * replayControlsHeight)/2 + 5*replayControlsHeight; + replayJumpY = replayHeaderHeight + replayInfo2Height + replayProgressBarHeight; + replayJumpWidth = replayWidth - replayJumpX; + replayJumpHeight = replayControlsHeight; + + replayIconBorder = 5; + replayIconSize = min(replayControlsHeight - 2*replayIconBorder, 128); +} + +void cGeometryManager::SetDisplayMessageSizes(void) { + messageWidth = osdWidth * config.messageWidth / 100; + messageHeight = osdHeight * config.messageHeight / 100; +} + +void cGeometryManager::SetDisplayTrackSizes(void) { + trackWidth = osdWidth * config.tracksWidth / 100; +} + +void cGeometryManager::SetDisplayVolumeSizes(void) { + volumeWidth = osdWidth * config.volumeWidth / 100; + volumeHeight = osdHeight * config.volumeHeight / 100; + volumeLabelHeight = volumeHeight/3; + volumeProgressBarWidth = 0.9 * volumeWidth; + volumeProgressBarHeight = 0.3 * volumeWidth; + if (volumeProgressBarHeight%2 != 0) + volumeProgressBarHeight++; +} diff --git a/geometrymanager.h b/geometrymanager.h new file mode 100644 index 0000000..03f4f44 --- /dev/null +++ b/geometrymanager.h @@ -0,0 +1,104 @@ +#ifndef __NOPACITY_GEOMETRYMANAGER_H +#define __NOPACITY_GEOMETRYMANAGER_H + +enum eLogoPosition {lpNone = 0, lpLeft, lpRight}; + +class cGeometryManager { + private: + void SetOSDSize(void); + void SetDisplayMenuSizes(void); + void SetDisplayChannelSizes(void); + void SetDisplayReplaySizes(void); + void SetDisplayMessageSizes(void); + void SetDisplayTrackSizes(void); + void SetDisplayVolumeSizes(void); + public: + cGeometryManager(); + ~cGeometryManager(); + void SetGeometry(void); + bool GeometryChanged(void); + int osdWidth; + int osdHeight; + int osdLeft; + int osdTop; + //DisplayMenu Sizes + int menuSpace; + int menuWidthScrollbar; + int menuDateWidth; + int menuHeaderHeight; + int menuFooterHeight; + int menuRssFeedHeight; + int menuContentHeight; + int menuContentWidthMain; + int menuContentWidthSchedules; + int menuContentWidthChannels; + int menuContentWidthTimers; + int menuContentWidthRecordings; + int menuContentWidthSetup; + int menuContentWidthFull; + int menuContentWidthMinimum; + int menuItemWidthDefault; + int menuItemWidthMain; + int menuItemWidthSchedule; + int menuItemWidthChannel; + int menuItemWidthTimer; + int menuItemWidthRecording; + int menuItemWidthSetup; + int menuItemWidthTracks; + int menuItemHeightMain; + int menuItemHeightSchedule; + int menuItemHeightDefault; + int menuItemHeightRecordings; + int menuItemHeightTracks; + int menuButtonsBorder; + int menuButtonWidth; + int menuButtonHeight; + int menuDiskUsageWidth; + int menuDiskUsageHeight; + int menuTimersWidth; + int menuMessageWidth; + int menuMessageHeight; + //DisplayChannel Sizes + int channelTop, channelHeight; + int channelWidth; + int channelX; + int channelInfoWidth; + int channelInfoHeight; + int channelDateWidth; + int channelProgressBarHeight; + int channelEpgInfoHeight; + int channelEpgInfoLineHeight; + int channelStreamInfoHeight; + int channelStreamInfoY; + int channelIconSize; + int channelIconsWidth; + int channelSignalWidth, channelSignalHeight, channelSignalX; + //DisplayReplay Sizes + int replayWidth; + int replayHeight; + int replayHeaderHeight; + int replayInfo2Height; + int replayProgressBarHeight; + int replayCurrentHeight; + int replayControlsHeight; + int replayFooterHeight; + int replayInfoWidth; + int replayDateWidth; + int replayIconSize, replayIconBorder; + int replayResolutionX, replayResolutionY; + int replayJumpX, replayJumpY; + int replayJumpWidth, replayJumpHeight; + //DisplayMessage Sizes + int messageWidth; + int messageHeight; + //DisplayTracks Sizes + int trackWidth; + //DisplayVolume Sizes + int volumeWidth; + int volumeHeight; + int volumeLabelHeight; + int volumeProgressBarWidth; + int volumeProgressBarHeight; +}; + +#endif //__NOPACITY_GEOMETRYMANAGER_H
\ No newline at end of file @@ -1,5 +1,6 @@ #include <string> #include <sstream> +#include <vector> static cOsd *CreateOsd(int Left, int Top, int Width, int Height) { cOsd *osd = cOsdProvider::NewOsd(Left, Top); @@ -110,6 +111,15 @@ static std::string CutText(std::string text, int width, const cFont *font) { return cuttedText; } +std::string StrToLowerCase(std::string str) { + std::string lowerCase = str; + const int length = lowerCase.length(); + for(int i=0; i < length; ++i) { + lowerCase[i] = std::tolower(lowerCase[i]); + } + return lowerCase; +} + class splitstring : public std::string { std::vector<std::string> flds; public: diff --git a/icons/skinIcons/rssStandalone.png b/icons/skinIcons/rssStandalone.png Binary files differnew file mode 100644 index 0000000..b1c7bbe --- /dev/null +++ b/icons/skinIcons/rssStandalone.png diff --git a/imagecache.c b/imagecache.c new file mode 100644 index 0000000..452a942 --- /dev/null +++ b/imagecache.c @@ -0,0 +1,310 @@ +#include <string> +#include <sstream> +#include <map> +#include "imagecache.h" + +using namespace Magick; + +cImageCache::cImageCache() : cImageMagickWrapper() { + osdTheme = Setup.OSDTheme; +} + +cImageCache::~cImageCache() { + Clear(); +} + +void cImageCache::CreateCache(void) { + //Menu Icons + std::vector<std::pair<std::string, cPoint> > menuIcons = GetMenuIcons(); + for (int i=0; i < menuIcons.size(); i++) { + std::string iconName = menuIcons[i].first; + cPoint iconSize = menuIcons[i].second; + LoadIcon(ctMenuIcon, iconName, iconSize.X(), iconSize.X()); + } + //Skin Icons + std::vector<std::pair<std::string, sImgProperties> > skinIcons = GetSkinIcons(); + for (int i=0; i < skinIcons.size(); i++) { + std::string iconName = skinIcons[i].first; + sImgProperties iconProps = skinIcons[i].second; + LoadIcon(ctSkinIcon, iconName, iconProps.width, iconProps.height, iconProps.preserveAspect); + } +} + +void cImageCache::CreateCache2(void) { + CreateBackgroundImages(); +} + +bool cImageCache::ThemeChanged(void) { + if (osdTheme.compare(Setup.OSDTheme) != 0) { + osdTheme = Setup.OSDTheme; + return true; + } + return false; +} + +void cImageCache::Reload(void) { + Clear(); + CreateCache(); + CreateCache2(); +} + +cImage *cImageCache::GetMenuIcon(std::string name) { + std::map<std::string, cImage*>::iterator hit = menuIconCache.find(name); + if (hit != menuIconCache.end()) { + return (cImage*)hit->second; + } else { + int iconWidth = config.iconHeight; + int iconHeight = config.iconHeight; + bool success = LoadIcon(ctMenuIcon, name, iconWidth, iconHeight); + if (success) { + hit = menuIconCache.find(name); + if (hit != menuIconCache.end()) { + return (cImage*)hit->second; + } + } + } + return NULL; +} + +cImage *cImageCache::GetSkinIcon(std::string name, int width, int height, bool preserveAspect) { + std::map<std::string, cImage*>::iterator hit = skinIconCache.find(name); + if (hit != skinIconCache.end()) { + return (cImage*)hit->second; + } else { + bool success = LoadIcon(ctSkinIcon, name, width, height, preserveAspect); + if (success) { + hit = skinIconCache.find(name); + if (hit != skinIconCache.end()) { + return (cImage*)hit->second; + } + } + } + return NULL; +} + +cImage *cImageCache::GetBackground(eBackgroundType type) { + try { + return backgroundImages[(int)type]; + } catch (...) { + esyslog("nopacity: trying to get undefined Background Image %d", (int)type); + } + return NULL; +} + +cImage cImageCache::GetBackground(tColor back, tColor blend, int width, int height, bool flip) { + if (!flip) + CreateBackground(back, blend, width, height); + else + CreateBackgroundReverse(back, blend, width, height); + return CreateImageCopy(); +} + + +std::vector<std::pair<std::string, cPoint> > cImageCache::GetMenuIcons(void) { + std::vector<std::pair<std::string, cPoint> > menuIcons; + //MainMenuIcons + std::vector<std::string> mainMenuIcons; + mainMenuIcons.push_back("menuIcons/Schedule"); + mainMenuIcons.push_back("menuIcons/Channels"); + mainMenuIcons.push_back("menuIcons/Timers"); + mainMenuIcons.push_back("menuIcons/Recordings"); + mainMenuIcons.push_back("menuIcons/Setup"); + mainMenuIcons.push_back("menuIcons/Commands"); + mainMenuIcons.push_back("menuIcons/OSD"); + mainMenuIcons.push_back("menuIcons/EPG"); + mainMenuIcons.push_back("menuIcons/DVB"); + mainMenuIcons.push_back("menuIcons/LNB"); + mainMenuIcons.push_back("menuIcons/CAM"); + mainMenuIcons.push_back("menuIcons/Recording"); + mainMenuIcons.push_back("menuIcons/Replay"); + mainMenuIcons.push_back("menuIcons/Miscellaneous"); + mainMenuIcons.push_back("menuIcons/Plugins"); + mainMenuIcons.push_back("menuIcons/Restart"); + int mainMenuIconSize = config.iconHeight; + for (int i=0; i<mainMenuIcons.size(); i++) { + menuIcons.push_back(std::pair<std::string, cPoint>(mainMenuIcons[i], cPoint(mainMenuIconSize, mainMenuIconSize))); + } + //Plugin Icons + for (int i = 0; ; i++) { + cPlugin *p = cPluginManager::GetPlugin(i); + if (p) { + std::stringstream iconPlugin; + iconPlugin << "pluginIcons/" << p->Name(); + menuIcons.push_back(std::pair<std::string, cPoint>(iconPlugin.str(), cPoint(mainMenuIconSize, mainMenuIconSize))); + } else + break; + } + return menuIcons; +} + +std::vector<std::pair<std::string, sImgProperties> > cImageCache::GetSkinIcons(void) { + std::vector<std::pair<std::string, sImgProperties> > skinIcons; + //VDR Logo + sImgProperties props; + props.width = config.menuHeaderLogoWidth; + props.height = config.menuHeaderLogoWidth; + props.preserveAspect = true; + skinIcons.push_back(std::pair<std::string, sImgProperties>("skinIcons/vdrlogo", props)); + //DiskUsage + int discUsageSize = geoManager->menuDiskUsageWidth; + props.width = props.height = discUsageSize*3/4; + props.preserveAspect = true; + skinIcons.push_back(std::pair<std::string, sImgProperties>("skinIcons/DiskUsage", props)); + props.width = discUsageSize - 4; + props.height = discUsageSize/5; + props.preserveAspect = false; + skinIcons.push_back(std::pair<std::string, sImgProperties>("skinIcons/discpercent", props)); + //RSS Feed + int rssFeedHeight = geoManager->osdHeight * config.rssFeedHeight / 100; + props.width = props.height = rssFeedHeight - 4; + props.preserveAspect = true; + skinIcons.push_back(std::pair<std::string, sImgProperties>("skinIcons/rss", props)); + //menu header icons + std::vector<std::string> menuHeaderIcons; + menuHeaderIcons.push_back("menuIcons/Schedule"); + menuHeaderIcons.push_back("menuIcons/Channels"); + menuHeaderIcons.push_back("menuIcons/Timers"); + menuHeaderIcons.push_back("menuIcons/Recordings"); + menuHeaderIcons.push_back("menuIcons/Setup"); + menuHeaderIcons.push_back("menuIcons/Commands"); + props.width = config.headerIconHeight; + props.height = config.headerIconHeight; + props.preserveAspect = true; + for (int i=0; i<menuHeaderIcons.size(); i++) { + skinIcons.push_back(std::pair<std::string, sImgProperties>(menuHeaderIcons[i], props)); + } + + //displaychannel Icons + int iconSize = config.statusIconSize; + props.width = iconSize*5; + props.height = iconSize; + props.preserveAspect = false; + skinIcons.push_back(std::pair<std::string, sImgProperties>("skinIcons/channelsymbols", props)); + + return skinIcons; +} + +bool cImageCache::LoadIcon(eCacheType type, std::string name, int width, int height, bool preserveAspect) { + bool success = false; + if (config.iconPathSet) { + cString iconPathTheme = cString::sprintf("%s%s/", *config.iconPath, Setup.OSDTheme); + success = LoadImage(name, *iconPathTheme, "png"); + if (success) { + InsertIntoCache(type, name, width, height, preserveAspect); + } else { + success = LoadImage(name, *config.iconPath, "png"); + if (success) { + InsertIntoCache(type, name, width, height, preserveAspect); + } + } + } else if (!success) { + cString iconPathTheme = cString::sprintf("%s%s/", *config.iconPathDefault, Setup.OSDTheme); + success = LoadImage(name, *iconPathTheme, "png"); + if (success) { + InsertIntoCache(type, name, width, height, preserveAspect); + } else { + success = LoadImage(name, *config.iconPathDefault, "png"); + if (success) { + InsertIntoCache(type, name, width, height, preserveAspect); + } + } + } + return success; +} + +void cImageCache::InsertIntoCache(eCacheType type, std::string name, int width, int height, bool preserveAspect) { + if (preserveAspect) { + buffer.sample(Geometry(width, height)); + } else { + cString geometry = cString::sprintf("%dx%d!", width, height); + buffer.scale(Geometry(*geometry)); + } + cImage *image = CreateImage(); + if (type == ctMenuIcon) + menuIconCache.insert(std::pair<std::string, cImage*>(name, image)); + else if (type == ctSkinIcon) + skinIconCache.insert(std::pair<std::string, cImage*>(name, image)); +} + +void cImageCache::CreateBackgroundImages(void) { + //Default Menus + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthDefault-2, geoManager->menuItemHeightDefault-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthDefault-2, geoManager->menuItemHeightDefault-2); + backgroundImages.push_back(CreateImage()); + + //Main Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthMain-2, geoManager->menuItemHeightMain-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthMain-2, geoManager->menuItemHeightMain-2); + backgroundImages.push_back(CreateImage()); + + //Schedules Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthSchedule-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthSchedule-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + + //Channels Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthChannel-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthChannel-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + + //Recordings Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthRecording-2, geoManager->menuItemHeightRecordings-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthRecording-2, geoManager->menuItemHeightRecordings-2); + backgroundImages.push_back(CreateImage()); + + //Timers Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthTimer-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthTimer-2, geoManager->menuItemHeightSchedule-2); + backgroundImages.push_back(CreateImage()); + + //Setup Menu + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthSetup-2, geoManager->menuItemHeightMain-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthSetup-2, geoManager->menuItemHeightMain-2); + backgroundImages.push_back(CreateImage()); + + //DisplayTracks + CreateBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), geoManager->menuItemWidthTracks-2, geoManager->menuItemHeightTracks-2); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), geoManager->menuItemWidthTracks-2, geoManager->menuItemHeightTracks-2); + backgroundImages.push_back(CreateImage()); + + //Color Buttons + CreateBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonRed), geoManager->menuButtonWidth-4, geoManager->menuButtonHeight-4); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonGreen), geoManager->menuButtonWidth-4, geoManager->menuButtonHeight-4); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonYellow), geoManager->menuButtonWidth-4, geoManager->menuButtonHeight-4); + backgroundImages.push_back(CreateImage()); + CreateBackground(Theme.Color(clrMenuBack), Theme.Color(clrButtonBlue), geoManager->menuButtonWidth-4, geoManager->menuButtonHeight-4); + backgroundImages.push_back(CreateImage()); + + //Menu Header + bool mirrorHeader = (config.menuAdjustLeft) ? false : true; + CreateBackground(Theme.Color(clrMenuHeaderBlend), Theme.Color(clrMenuHeader), geoManager->osdWidth, geoManager->menuHeaderHeight, mirrorHeader); + backgroundImages.push_back(CreateImage()); +} + +void cImageCache::Clear(void) { + for(std::map<std::string, cImage*>::const_iterator it = menuIconCache.begin(); it != menuIconCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + menuIconCache.clear(); + for(std::map<std::string, cImage*>::const_iterator it = skinIconCache.begin(); it != skinIconCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + skinIconCache.clear(); + for(std::vector<cImage*>::const_iterator it = backgroundImages.begin(); it != backgroundImages.end(); it++) { + cImage *img = (cImage*)*it; + delete img; + } + backgroundImages.clear(); +}
\ No newline at end of file diff --git a/imagecache.h b/imagecache.h new file mode 100644 index 0000000..4977c3e --- /dev/null +++ b/imagecache.h @@ -0,0 +1,72 @@ +#ifndef __NOPACITY_IMAGECACHE_H +#define __NOPACITY_IMAGECACHE_H + +#define X_DISPLAY_MISSING + +#include <vdr/osd.h> +#include <vdr/skins.h> +#include <Magick++.h> + +using namespace Magick; + +enum eCacheType { + ctMenuIcon = 0, + ctSkinIcon, +}; +enum eBackgroundType { + btNone = -1, + btDefault = 0, + btDefaultHigh, + btMain, + btMainHigh, + btSchedules, + btSchedulesHigh, + btChannels, + btChannelsHigh, + btRecordings, + btRecordingsHigh, + btTimers, + btTimersHigh, + btSetup, + btSetupHigh, + btTracks, + btTracksHigh, + btButtonRed, + btButtonGreen, + btButtonYellow, + btButtonBlue, + btMenuHeader, +}; + +struct sImgProperties { + int width; + int height; + bool preserveAspect; +}; + +class cImageCache : public cImageMagickWrapper { +public: + cImageCache(); + ~cImageCache(); + void CreateCache(void); + void CreateCache2(void); + void Reload(void); + bool ThemeChanged(void); + cImage *GetMenuIcon(std::string name); + cImage *GetSkinIcon(std::string name, int width=0, int height=0, bool preserveAspect = true); + cImage *GetBackground(eBackgroundType type); + cImage GetBackground(tColor back, tColor blend, int width, int height, bool flip = false); +private: + std::string osdTheme; + std::map<std::string, cImage*> menuIconCache; + std::map<std::string, cImage*> skinIconCache; + std::vector<cImage*> backgroundImages; + std::vector<std::pair<std::string, cPoint> > GetMenuIcons(void); + std::vector<std::pair<std::string, sImgProperties> > GetSkinIcons(void); + bool LoadIcon(eCacheType type, std::string name, int width, int height, bool preserveAspect = true); + void InsertIntoCache(eCacheType type, std::string name, int width, int height, bool preserveAspect = true); + void CreateBackgroundImages(void); + void Clear(void); +}; + +#endif //__NOPACITY_IMAGECACHE_H diff --git a/imageloader.c b/imageloader.c index b59aa9d..3807bbb 100644 --- a/imageloader.c +++ b/imageloader.c @@ -6,32 +6,34 @@ using namespace Magick; -cImageLoader::cImageLoader() { - InitializeMagick(NULL); +cImageLoader::cImageLoader() : cImageMagickWrapper() { } cImageLoader::~cImageLoader() { } +cImage cImageLoader::GetImage() { + return CreateImageCopy(); +} + bool cImageLoader::LoadLogo(const char *logo, int width = config.logoWidth, int height = config.logoHeight) { if ((width == 0)||(height==0)) return false; - std::string logoLower = logo; - toLowerCase(logoLower); + std::string logoLower = StrToLowerCase(logo); bool success = false; if (config.logoPathSet) { //theme dependend logo cString logoPath = cString::sprintf("%s%s/", *config.logoPath, Setup.OSDTheme); - success = LoadImage(logoLower.c_str(), logoPath, config.logoExtension); + success = LoadImage(logoLower.c_str(), *logoPath, *config.logoExtension); if (!success) - success = LoadImage(logoLower.c_str(), config.logoPath, config.logoExtension); + success = LoadImage(logoLower.c_str(), *config.logoPath, *config.logoExtension); } if (!success) { //theme dependend logo cString logoPath = cString::sprintf("%s%s/", *config.logoPathDefault, Setup.OSDTheme); - success = LoadImage(logoLower.c_str(), logoPath, config.logoExtension); + success = LoadImage(logoLower.c_str(), *logoPath, *config.logoExtension); if (!success) - success = LoadImage(logoLower.c_str(), config.logoPathDefault, config.logoExtension); + success = LoadImage(logoLower.c_str(), *config.logoPathDefault, *config.logoExtension); } if (!success) return false; @@ -41,64 +43,6 @@ bool cImageLoader::LoadLogo(const char *logo, int width = config.logoWidth, int return true; } -bool cImageLoader::LoadIcon(const char *cIcon, int size) { - if (size==0) - return false; - bool success = false; - if (config.iconPathSet) { - cString iconThemePath = cString::sprintf("%s%s/", *config.iconPath, Setup.OSDTheme); - success = LoadImage(cString(cIcon), iconThemePath, "png"); - if (!success) { - success = LoadImage(cString(cIcon), config.iconPath, "png"); - } - } - if (!success) { - cString iconThemePath = cString::sprintf("%s%s/", *config.iconPathDefault, Setup.OSDTheme); - success = LoadImage(cString(cIcon), iconThemePath, "png"); - if (!success) { - success = LoadImage(cString(cIcon), config.iconPathDefault, "png"); - } - } - if (!success) - return false; - buffer.sample(Geometry(size, size)); - return true; -} - -bool cImageLoader::LoadIcon(const char *cIcon, int width, int height, bool preserveAspect) { - try { - if ((width == 0)||(height==0)) - return false; - bool success = false; - if (config.iconPathSet) { - cString iconThemePath = cString::sprintf("%s%s/", *config.iconPath, Setup.OSDTheme); - success = LoadImage(cString(cIcon), iconThemePath, "png"); - if (!success) { - success = LoadImage(cString(cIcon), config.iconPath, "png"); - } - } - if (!success) { - cString iconThemePath = cString::sprintf("%s%s/", *config.iconPathDefault, Setup.OSDTheme); - success = LoadImage(cString(cIcon), iconThemePath, "png"); - if (!success) { - success = LoadImage(cString(cIcon), config.iconPathDefault, "png"); - } - } - if (!success) - return false; - if (preserveAspect) { - buffer.sample(Geometry(width, height)); - } else { - cString geometry = cString::sprintf("%dx%d!", width, height); - buffer.scale(Geometry(*geometry)); - } - return true; - } - catch (...) { - return false; - } -} - bool cImageLoader::LoadEPGImage(int eventID) { int width = config.epgImageWidth; int height = config.epgImageHeight; @@ -106,10 +50,10 @@ bool cImageLoader::LoadEPGImage(int eventID) { return false; bool success = false; if (config.epgImagePathSet) { - success = LoadImage(cString::sprintf("%d", eventID), config.epgImagePath, "jpg"); + success = LoadImage(*cString::sprintf("%d", eventID), *config.epgImagePath, "jpg"); } if (!success) { - success = LoadImage(cString::sprintf("%d", eventID), config.epgImagePathDefault, "jpg"); + success = LoadImage(*cString::sprintf("%d", eventID), *config.epgImagePathDefault, "jpg"); } if (!success) return false; @@ -126,10 +70,10 @@ bool cImageLoader::LoadAdditionalEPGImage(cString name) { return false; bool success = false; if (config.epgImagePathSet) { - success = LoadImage(name, config.epgImagePath, "jpg"); + success = LoadImage(*name, *config.epgImagePath, "jpg"); } if (!success) { - success = LoadImage(name, config.epgImagePathDefault, "jpg"); + success = LoadImage(*name, *config.epgImagePathDefault, "jpg"); } if (!success) return false; @@ -147,7 +91,7 @@ bool cImageLoader::LoadRecordingImage(cString Path) { cString recImage(""); if (FirstImageInFolder(Path, "jpg", &recImage)) { recImage = cString::sprintf("/%s", *recImage); - if (!LoadImage(*recImage, Path, "jpg")) + if (!LoadImage(*recImage, *Path, "jpg")) return false; buffer.sample( Geometry(width, height)); return true; @@ -160,7 +104,7 @@ bool cImageLoader::LoadAdditionalRecordingImage(cString path, cString name) { int height = config.epgImageHeightLarge; if ((width == 0)||(height==0)) return false; - if (LoadImage(name, path, "jpg")) { + if (LoadImage(*name, *path, "jpg")) { buffer.sample( Geometry(width, height)); return true; } @@ -175,30 +119,6 @@ bool cImageLoader::LoadPoster(const char *poster, int width, int height) { return false; } -void cImageLoader::DrawBackground(tColor back, tColor blend, int width, int height, bool mirror) { - Color Back = Argb2Color(back); - Color Blend = Argb2Color(blend); - Image tmp(Geometry(width, height), Blend); - double arguments[9] = {0.0,(double)height,0.0,-1*(double)width,0.0,0.0,1.5*(double)width,0.0,1.0}; - tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); - Image tmp2(Geometry(width, height), Back); - tmp.composite(tmp2, 0, 0, OverlayCompositeOp); - if (mirror) - tmp.flop(); - buffer = tmp; -} - -void cImageLoader::DrawBackground2(tColor back, tColor blend, int width, int height) { - Color Back = Argb2Color(back); - Color Blend = Argb2Color(blend); - Image tmp(Geometry(width, height), Blend); - double arguments[9] = {0.0,(double)height,0.0,-0.5*(double)width,0.0,0.0,(double)width,0.0,1.0}; - tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); - Image tmp2(Geometry(width, height), Back); - tmp.composite(tmp2, 0, 0, OverlayCompositeOp); - buffer = tmp; -} - bool cImageLoader::SearchRecordingPoster(cString recPath, cString &found) { cString manualPoster = cString::sprintf("%s/cover_vdr.jpg", *recPath); if (FileSize(*manualPoster) != -1) { @@ -218,64 +138,6 @@ bool cImageLoader::SearchRecordingPoster(cString recPath, cString &found) { return false; } -cImage cImageLoader::GetImage() { - int w, h; - w = buffer.columns(); - h = buffer.rows(); - cImage image (cSize(w, h)); - const PixelPacket *pixels = buffer.getConstPixels(0, 0, w, h); - for (int iy = 0; iy < h; ++iy) { - for (int ix = 0; ix < w; ++ix) { - tColor col = (~int(pixels->opacity * 255 / MaxRGB) << 24) - | (int(pixels->green * 255 / MaxRGB) << 8) - | (int(pixels->red * 255 / MaxRGB) << 16) - | (int(pixels->blue * 255 / MaxRGB) ); - image.SetPixel(cPoint(ix, iy), col); - ++pixels; - } - } - return image; -} - -Color cImageLoader::Argb2Color(tColor col) { - tIndex alpha = (col & 0xFF000000) >> 24; - tIndex red = (col & 0x00FF0000) >> 16; - tIndex green = (col & 0x0000FF00) >> 8; - tIndex blue = (col & 0x000000FF); - Color color(MaxRGB*red/255, MaxRGB*green/255, MaxRGB*blue/255, MaxRGB*(0xFF-alpha)/255); - return color; -} - -void cImageLoader::toLowerCase(std::string &str) { - const int length = str.length(); - for(int i=0; i < length; ++i) { - str[i] = std::tolower(str[i]); - } -} - -bool cImageLoader::LoadImage(cString FileName, cString Path, cString Extension) { - try { - cString File = cString::sprintf("%s%s.%s", *Path, *FileName, *Extension); - dsyslog("nopacity: trying to load: %s", *File); - buffer.read(*File); - dsyslog("nopacity: %s sucessfully loaded", *File); - } catch (...) { - return false; - } - return true; -} - -bool cImageLoader::LoadImage(const char *fullpath) { - try { - dsyslog("nopacity: trying to load: %s", fullpath); - buffer.read(fullpath); - dsyslog("nopacity: %s sucessfully loaded", fullpath); - } catch (...) { - return false; - } - return true; -} - bool cImageLoader::FirstImageInFolder(cString Path, cString Extension, cString *recImage) { DIR *folder; struct dirent *file; diff --git a/imageloader.h b/imageloader.h index 4983539..a0fa864 100644 --- a/imageloader.h +++ b/imageloader.h @@ -9,28 +9,19 @@ using namespace Magick; -class cImageLoader { +class cImageLoader : public cImageMagickWrapper { public: cImageLoader(); ~cImageLoader(); cImage GetImage(); bool LoadLogo(const char *logo, int width, int height); - bool LoadIcon(const char *cIcon, int size); - bool LoadIcon(const char *cIcon, int width, int height, bool preserveAspect = true); bool LoadEPGImage(int eventID); bool LoadAdditionalEPGImage(cString name); bool LoadRecordingImage(cString Path); bool LoadAdditionalRecordingImage(cString path, cString name); bool LoadPoster(const char *poster, int width, int height); - void DrawBackground(tColor back, tColor blend, int width, int height, bool mirror = false); - void DrawBackground2(tColor back, tColor blend, int width, int height); bool SearchRecordingPoster(cString recPath, cString &found); private: - Image buffer; - Color Argb2Color(tColor col); - void toLowerCase(std::string &str); - bool LoadImage(cString FileName, cString Path, cString Extension); - bool LoadImage(const char *fullpath); bool FirstImageInFolder(cString Path, cString Extension, cString *recImage); }; diff --git a/imagemagickwrapper.c b/imagemagickwrapper.c new file mode 100644 index 0000000..3ae1cb0 --- /dev/null +++ b/imagemagickwrapper.c @@ -0,0 +1,107 @@ +#include <string> +#include <sstream> +#include "imagemagickwrapper.h" + +cImageMagickWrapper::cImageMagickWrapper() { + InitializeMagick(NULL); +} + +cImageMagickWrapper::~cImageMagickWrapper() { +} + +cImage *cImageMagickWrapper::CreateImage() { + int w, h; + w = buffer.columns(); + h = buffer.rows(); + cImage *image = new cImage(cSize(w, h)); + const PixelPacket *pixels = buffer.getConstPixels(0, 0, w, h); + for (int iy = 0; iy < h; ++iy) { + for (int ix = 0; ix < w; ++ix) { + tColor col = (~int(pixels->opacity * 255 / MaxRGB) << 24) + | (int(pixels->green * 255 / MaxRGB) << 8) + | (int(pixels->red * 255 / MaxRGB) << 16) + | (int(pixels->blue * 255 / MaxRGB) ); + image->SetPixel(cPoint(ix, iy), col); + ++pixels; + } + } + return image; +} + +cImage cImageMagickWrapper::CreateImageCopy() { + int w, h; + w = buffer.columns(); + h = buffer.rows(); + cImage image (cSize(w, h)); + const PixelPacket *pixels = buffer.getConstPixels(0, 0, w, h); + for (int iy = 0; iy < h; ++iy) { + for (int ix = 0; ix < w; ++ix) { + tColor col = (~int(pixels->opacity * 255 / MaxRGB) << 24) + | (int(pixels->green * 255 / MaxRGB) << 8) + | (int(pixels->red * 255 / MaxRGB) << 16) + | (int(pixels->blue * 255 / MaxRGB) ); + image.SetPixel(cPoint(ix, iy), col); + ++pixels; + } + } + return image; +} + +bool cImageMagickWrapper::LoadImage(std::string FileName, std::string Path, std::string Extension) { + try { + std::stringstream sstrImgFile; + sstrImgFile << Path << FileName << "." << Extension; + std::string imgFile = sstrImgFile.str(); + //dsyslog("nopacity: trying to load: %s", imgFile.c_str()); + buffer.read(imgFile.c_str()); + //dsyslog("nopacity: %s sucessfully loaded", imgFile.c_str()); + } catch (...) { + return false; + } + return true; +} + +bool cImageMagickWrapper::LoadImage(const char *fullpath) { + try { + //dsyslog("nopacity: trying to load: %s", fullpath); + buffer.read(fullpath); + //dsyslog("nopacity: %s sucessfully loaded", fullpath); + } catch (...) { + return false; + } + return true; +} + +Color cImageMagickWrapper::Argb2Color(tColor col) { + tIndex alpha = (col & 0xFF000000) >> 24; + tIndex red = (col & 0x00FF0000) >> 16; + tIndex green = (col & 0x0000FF00) >> 8; + tIndex blue = (col & 0x000000FF); + Color color(MaxRGB*red/255, MaxRGB*green/255, MaxRGB*blue/255, MaxRGB*(0xFF-alpha)/255); + return color; +} + +void cImageMagickWrapper::CreateBackground(tColor back, tColor blend, int width, int height, bool mirror) { + Color Back = Argb2Color(back); + Color Blend = Argb2Color(blend); + Image tmp(Geometry(width, height), Blend); + double arguments[9] = {0.0,(double)height,0.0,-1*(double)width,0.0,0.0,1.5*(double)width,0.0,1.0}; + tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); + Image tmp2(Geometry(width, height), Back); + tmp.composite(tmp2, 0, 0, OverlayCompositeOp); + if (mirror) + tmp.flop(); + buffer = tmp; +} + +void cImageMagickWrapper::CreateBackgroundReverse(tColor back, tColor blend, int width, int height) { + Color Back = Argb2Color(back); + Color Blend = Argb2Color(blend); + Image tmp(Geometry(width, height), Blend); + double arguments[9] = {0.0,(double)height,0.0,-0.5*(double)width,0.0,0.0,(double)width,0.0,1.0}; + tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); + Image tmp2(Geometry(width, height), Back); + tmp.composite(tmp2, 0, 0, OverlayCompositeOp); + buffer = tmp; +} + diff --git a/imagemagickwrapper.h b/imagemagickwrapper.h new file mode 100644 index 0000000..1ec7a56 --- /dev/null +++ b/imagemagickwrapper.h @@ -0,0 +1,25 @@ +#ifndef __NOPACITY_IMAGEMAGICKWRAPPER_H +#define __NOPACITY_IMAGEMAGICKWRAPPER_H + +#define X_DISPLAY_MISSING + +#include <Magick++.h> + +using namespace Magick; + +class cImageMagickWrapper { +public: + cImageMagickWrapper(); + ~cImageMagickWrapper(); +protected: + Image buffer; + Color Argb2Color(tColor col); + cImage *CreateImage(void); + cImage CreateImageCopy(void); + bool LoadImage(std::string FileName, std::string Path, std::string Extension); + bool LoadImage(const char *fullpath); + void CreateBackground(tColor back, tColor blend, int width, int height, bool mirror = false); + void CreateBackgroundReverse(tColor back, tColor blend, int width, int height); +}; + +#endif //__NOPACITY_IMAGEMAGICKWRAPPER_H @@ -7,8 +7,9 @@ // cNopacityMenuItem ------------- -cNopacityMenuItem::cNopacityMenuItem(cOsd *osd, const char *text, bool sel) { +cNopacityMenuItem::cNopacityMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel) { this->osd = osd; + this->imgCache = imgCache; drawn = false; Text = text; selectable = sel; @@ -78,27 +79,25 @@ void cNopacityMenuItem::SetTabs(cString *tabs, int *tabWidths, int numtabs) { numTabs = numtabs; } -void cNopacityMenuItem::SetBackgrounds(int *handleBackgrounds) { - this->handleBackgrounds = handleBackgrounds; -} - -void cNopacityMenuItem::DrawDelimiter(const char *del, const char *icon, int handleBgrd) { +void cNopacityMenuItem::DrawDelimiter(const char *del, const char *icon, eBackgroundType bgType) { pixmap->Fill(Theme.Color(clrSeparatorBorder)); - if (handleBgrd >= 0) - pixmap->DrawImage(cPoint(1, 1), handleBackgrounds[handleBgrd]); - else + if (bgType != btNone) { + cImage *back = imgCache->GetBackground(bgType); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); + } else pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrMenuItem)); if (config.roundedCorners) DrawRoundedCorners(Theme.Color(clrSeparatorBorder)); - cImageLoader imgLoader; if (!drawn) { - if (imgLoader.LoadIcon(icon, config.iconHeight)) { + cImage *imgIcon = imgCache->GetSkinIcon(icon, config.iconHeight, config.iconHeight); + if (imgIcon) { if (pixmapIcon == NULL) { pixmapIcon = osd->CreatePixmap(5, cRect(left, top + index * (height + spaceMenu), config.menuItemLogoWidth, config.menuItemLogoWidth)); pixmapIcon->Fill(clrTransparent); } - pixmapIcon->DrawImage(cPoint(1, (height - config.iconHeight) / 2), imgLoader.GetImage()); + pixmapIcon->DrawImage(cPoint(1, (height - config.iconHeight) / 2), *imgIcon); } drawn = true; } @@ -177,7 +176,7 @@ void cNopacityMenuItem::DrawRoundedCorners(tColor borderColor) { } // cNopacityMainMenuItem ------------- -cNopacityMainMenuItem::cNopacityMainMenuItem(cOsd *osd, const char *text, bool sel, bool setup) : cNopacityMenuItem (osd, text, sel) { +cNopacityMainMenuItem::cNopacityMainMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel, bool setup) : cNopacityMenuItem (osd, imgCache, text, sel) { this->isSetup = setup; } @@ -187,12 +186,14 @@ cNopacityMainMenuItem::~cNopacityMainMenuItem(void) { void cNopacityMainMenuItem::DrawBackground(void) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd; + eBackgroundType type; if (!isSetup) - handleBgrd = (current)?handleBackgrounds[3]:handleBackgrounds[2]; + type = (current)?btMainHigh:btMain; else - handleBgrd = (current)?handleBackgrounds[13]:handleBackgrounds[12]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + type = (current)?btSetupHigh:btSetup; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -334,10 +335,9 @@ void cNopacityMainMenuItem::Render() { if (config.useMenuIcons) { cString cIcon = GetIconName(); if (!drawn) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon(*cIcon, config.iconHeight)) { - pixmapIcon->DrawImage(cPoint(1, 1), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetMenuIcon(*cIcon); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(1,1), *imgIcon); drawn = true; } } @@ -351,14 +351,14 @@ void cNopacityMainMenuItem::Render() { Cancel(-1); } } else { - DrawDelimiter(strEntry.c_str(), "skinIcons/channeldelimiter", (config.doBlending)?-1:(isSetup?12:2)); + DrawDelimiter(strEntry.c_str(), "skinIcons/channeldelimiter", (config.doBlending)?btNone:(isSetup?btSetup:btMain)); } } // cNopacityScheduleMenuItem ------------- -cNopacityScheduleMenuItem::cNopacityScheduleMenuItem(cOsd *osd, const cEvent *Event, const cChannel *Channel, eTimerMatch TimerMatch, bool sel, eMenuCategory category, cRect *vidWin) - : cNopacityMenuItem (osd, "", sel) { +cNopacityScheduleMenuItem::cNopacityScheduleMenuItem(cOsd *osd, cImageCache *imgCache, const cEvent *Event, const cChannel *Channel, eTimerMatch TimerMatch, bool sel, eMenuCategory category, cRect *vidWin) + : cNopacityMenuItem (osd, imgCache, "", sel) { this->category = category; this->Event = Event; this->Channel = Channel; @@ -494,9 +494,9 @@ void cNopacityScheduleMenuItem::Render() { } } else { if (Event) { - DrawDelimiter(Event->Title(), "skinIcons/daydelimiter", (config.doBlending)?4:-1); + DrawDelimiter(Event->Title(), "skinIcons/daydelimiter", (config.doBlending)?btSchedules:btNone); } else if (Channel) { - DrawDelimiter(Channel->Name(), "skinIcons/channeldelimiter", (config.doBlending)?4:-1); + DrawDelimiter(Channel->Name(), "skinIcons/channeldelimiter", (config.doBlending)?btSchedules:btNone); } } } @@ -504,8 +504,10 @@ void cNopacityScheduleMenuItem::Render() { void cNopacityScheduleMenuItem::DrawBackground(int textLeft) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[5]:handleBackgrounds[4]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btSchedulesHigh:btSchedules; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -513,15 +515,14 @@ void cNopacityScheduleMenuItem::DrawBackground(int textLeft) { if (config.roundedCorners) DrawRoundedCorners(Theme.Color(clrMenuBorder)); if (TimerMatch == tmFull) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/activetimer", 64, 64)) { - pixmapIcon->DrawImage(cPoint(width - 66, 2), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/activetimer", 64, 64); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(width - 66, 2), *imgIcon); } else if (TimerMatch == tmPartial) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/activetimersmall", 32, 32)) { - pixmapIcon->DrawImage(cPoint(width - 34, 2), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/activetimersmall", 32, 32); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(width - 34, 2), *imgIcon); + } tColor clrFont = (current)?Theme.Color(clrMenuFontMenuItemHigh):Theme.Color(clrMenuFontMenuItem); tColor clrFontBack = (config.doBlending)?(clrTransparent):((current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem)); @@ -571,7 +572,7 @@ void cNopacityScheduleMenuItem::DrawRemaining(int x, int y, int width) { // cNopacityChannelMenuItem ------------- -cNopacityChannelMenuItem::cNopacityChannelMenuItem(cOsd *osd, const cChannel *Channel, bool sel, cRect *vidWin) : cNopacityMenuItem (osd, "", sel) { +cNopacityChannelMenuItem::cNopacityChannelMenuItem(cOsd *osd, cImageCache *imgCache, const cChannel *Channel, bool sel, cRect *vidWin) : cNopacityMenuItem (osd, imgCache, "", sel) { this->Channel = Channel; this->vidWin = vidWin; strEntry = ""; @@ -687,8 +688,10 @@ void cNopacityChannelMenuItem::SetTextShort(void) { void cNopacityChannelMenuItem::DrawBackground(void) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[7]:handleBackgrounds[6]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btChannelsHigh:btChannels; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -703,9 +706,9 @@ void cNopacityChannelMenuItem::DrawBackground(void) { tColor clrFontBack = (config.doBlending)?(clrTransparent):((current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem)); pixmap->DrawText(cPoint(sourceX, 3*height/4 + (height/4 - fontSmall->Height())/2), *strChannelInfo, clrFont, clrFontBack, fontSmall); if (Channel->Ca()) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/encrypted", encryptedSize)) { - pixmapIcon->DrawImage(cPoint(sourceX, height/2+1), imgLoader.GetImage()); + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/encrypted", encryptedSize, encryptedSize); + if (imgIcon) { + pixmapIcon->DrawImage(cPoint(sourceX, height/2+1), *imgIcon); sourceX += encryptedSize + 10; } } @@ -801,13 +804,13 @@ void cNopacityChannelMenuItem::Render() { infoTextWindow->Start(); } } else { //Channelseparators - DrawDelimiter(Channel->Name(), "skinIcons/channeldelimiter", (config.doBlending)?6:-1); + DrawDelimiter(Channel->Name(), "skinIcons/channeldelimiter", (config.doBlending)?btChannels:btNone); } } // cNopacityTimerMenuItem ------------- -cNopacityTimerMenuItem::cNopacityTimerMenuItem(cOsd *osd, const cTimer *Timer, bool sel) : cNopacityMenuItem (osd, "", sel) { +cNopacityTimerMenuItem::cNopacityTimerMenuItem(cOsd *osd, cImageCache *imgCache, const cTimer *Timer, bool sel) : cNopacityMenuItem (osd, imgCache, "", sel) { this->Timer = Timer; } @@ -884,8 +887,10 @@ void cNopacityTimerMenuItem::SetTextShort(void) { void cNopacityTimerMenuItem::DrawBackground(int textLeft) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[11]:handleBackgrounds[10]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btTimersHigh:btTimers; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -905,10 +910,10 @@ void cNopacityTimerMenuItem::DrawBackground(int textLeft) { else iconName = "skinIcons/timerActive"; - cImageLoader imgLoader; - if (imgLoader.LoadIcon(iconName, iconSize)) { - pixmapIcon->DrawImage(cPoint(textLeft, 0), imgLoader.GetImage()); - } + cImage *imgIcon = imgCache->GetSkinIcon(*iconName, iconSize, iconSize); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(textLeft, 0), *imgIcon); + cString dateTime(""); if (firstDay) dateTime = cString::sprintf("! %s", strDateTime.c_str()); @@ -964,7 +969,7 @@ void cNopacityTimerMenuItem::DrawLogo(int logoWidth, int logoHeight) { } // cNopacityRecordingMenuItem ------------- -cNopacityRecordingMenuItem::cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New, cRect *vidWin) : cNopacityMenuItem (osd, "", sel) { +cNopacityRecordingMenuItem::cNopacityRecordingMenuItem(cOsd *osd, cImageCache *imgCache, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New, cRect *vidWin) : cNopacityMenuItem (osd, imgCache, "", sel) { this->Recording = Recording; this->isFolder = isFolder; this->Level = Level; @@ -1080,8 +1085,10 @@ void cNopacityRecordingMenuItem::SetTextFull(void) { void cNopacityRecordingMenuItem::DrawBackground(void) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[9]:handleBackgrounds[8]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btRecordingsHigh:btRecordings; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -1139,30 +1146,31 @@ void cNopacityRecordingMenuItem::SetTextShortRecording(void) { void cNopacityRecordingMenuItem::DrawRecordingNewIcon(void) { int iconNewSize = height/3; - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/newrecording", iconNewSize)) { + + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/newrecording", iconNewSize, iconNewSize); + if (imgIcon) { int iconX = pixmapIcon->ViewPort().Width() - iconNewSize; int iconY = height/2; - pixmapIcon->DrawImage(cPoint(iconX, iconY), imgLoader.GetImage()); + pixmapIcon->DrawImage(cPoint(iconX, iconY), *imgIcon); } } void cNopacityRecordingMenuItem::DrawRecordingEditedIcon(void) { int iconCutSize = height/3; - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/recordingcutted", iconCutSize)) { + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/recordingcutted", iconCutSize, iconCutSize); + if (imgIcon) { int iconX = pixmapIcon->ViewPort().Width() - iconCutSize; if (Recording->IsNew()) iconX -= iconCutSize; int iconY = height/2; - pixmapIcon->DrawImage(cPoint(iconX, iconY), imgLoader.GetImage()); + pixmapIcon->DrawImage(cPoint(iconX, iconY), *imgIcon); } } void cNopacityRecordingMenuItem::DrawFolderIcon(void) { - cImageLoader imgLoader; - if (imgLoader.LoadIcon("skinIcons/recfolder", posterWidth, posterHeight)) { - pixmapIcon->DrawImage(cPoint(10, 1), imgLoader.GetImage()); + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/recfolder", posterWidth, posterHeight); + if (imgIcon) { + pixmapIcon->DrawImage(cPoint(10, 1), *imgIcon); } } @@ -1213,9 +1221,10 @@ void cNopacityRecordingMenuItem::DrawPoster(void) { pixmapIcon->DrawImage(cPoint(10, 5), imgLoader.GetImage()); } } else { - if (imgLoader.LoadIcon("skinIcons/defaultPoster", posterWidth, posterHeight)) { - pixmapIcon->DrawImage(cPoint(10, 5), imgLoader.GetImage()); - } + + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/defaultPoster", posterWidth, posterHeight); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(10,5), *imgIcon); } } @@ -1275,7 +1284,7 @@ void cNopacityRecordingMenuItem::Render() { // cNopacityDefaultMenuItem ------------- -cNopacityDefaultMenuItem::cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool sel) : cNopacityMenuItem (osd, text, sel) { +cNopacityDefaultMenuItem::cNopacityDefaultMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel) : cNopacityMenuItem (osd, imgCache, text, sel) { scrollCol = -1; } @@ -1295,8 +1304,10 @@ bool cNopacityDefaultMenuItem::CheckProgressBar(const char *text) { void cNopacityDefaultMenuItem::DrawBackground(void) { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btDefaultHigh:btDefault; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -1451,7 +1462,7 @@ void cNopacityDefaultMenuItem::Render() { // cNopacityTrackMenuItem ------------- -cNopacityTrackMenuItem::cNopacityTrackMenuItem(cOsd *osd, const char *text) : cNopacityMenuItem (osd, text, true) { +cNopacityTrackMenuItem::cNopacityTrackMenuItem(cOsd *osd, cImageCache *imgCache, const char *text) : cNopacityMenuItem (osd, imgCache, text, true) { } cNopacityTrackMenuItem::~cNopacityTrackMenuItem(void) { @@ -1460,8 +1471,10 @@ cNopacityTrackMenuItem::~cNopacityTrackMenuItem(void) { void cNopacityTrackMenuItem::Render() { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - int handleBgrd = (current)?handleBackgrounds[1]:handleBackgrounds[0]; - pixmap->DrawImage(cPoint(1, 1), handleBgrd); + eBackgroundType type = (current)?btTracksHigh:btTracks; + cImage *back = imgCache->GetBackground(type); + if (back) + pixmap->DrawImage(cPoint(1, 1), *back); } else { tColor col = (current)?Theme.Color(clrMenuItemHigh):Theme.Color(clrMenuItem); pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), col); @@ -4,10 +4,10 @@ class cNopacityMenuItem : public cListObject, public cThread { protected: cOsd *osd; + cImageCache *imgCache; cPixmap *pixmap; cPixmap *pixmapIcon; cPixmap *pixmapTextScroller; - int *handleBackgrounds; const char *Text; bool selectable; bool current; @@ -30,12 +30,12 @@ protected: cNopacityTextWindow *infoTextWindow; virtual void SetTextFull(void) {}; virtual void SetTextShort(void) {}; - void DrawDelimiter(const char *del, const char *icon, int handleBgrd); + void DrawDelimiter(const char *del, const char *icon, eBackgroundType bgType); void DrawRoundedCorners(tColor borderColor); virtual void Action(void); void DoSleep(int duration); public: - cNopacityMenuItem(cOsd *osd, const char *text, bool sel); + cNopacityMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel); virtual ~cNopacityMenuItem(void); void CreatePixmap(); void CreatePixmapIcon(void); @@ -50,7 +50,6 @@ public: void SetAlphaIcon(int alpha) {if (pixmapIcon) 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); void SetTextWindow(cRect *window) {textWindow = window;}; virtual void CreateText(void) {}; virtual void SetPoster(void) {}; @@ -71,7 +70,7 @@ private: void SetTextFull(void); void SetTextShort(void); public: - cNopacityMainMenuItem(cOsd *osd, const char *text, bool sel, bool setup); + cNopacityMainMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel, bool setup); ~cNopacityMainMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); @@ -100,7 +99,7 @@ private: void SetTextFull(void); void SetTextShort(void); public: - cNopacityScheduleMenuItem(cOsd *osd, const cEvent *Event, const cChannel *Channel, eTimerMatch TimerMatch, bool sel, eMenuCategory category, cRect *vidWin); + cNopacityScheduleMenuItem(cOsd *osd, cImageCache *imgCache, const cEvent *Event, const cChannel *Channel, eTimerMatch TimerMatch, bool sel, eMenuCategory category, cRect *vidWin); ~cNopacityScheduleMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); @@ -125,7 +124,7 @@ private: void readCurrentEPG(void); std::string readEPG(void); public: - cNopacityChannelMenuItem(cOsd *osd, const cChannel *Channel, bool sel, cRect *vidWin); + cNopacityChannelMenuItem(cOsd *osd, cImageCache *imgCache, const cChannel *Channel, bool sel, cRect *vidWin); ~cNopacityChannelMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); @@ -145,7 +144,7 @@ private: void DrawLogo(int logoWidth, int logoHeight); std::string CreateDate(void); public: - cNopacityTimerMenuItem(cOsd *osd, const cTimer *Timer, bool sel); + cNopacityTimerMenuItem(cOsd *osd, cImageCache *imgCache, const cTimer *Timer, bool sel); ~cNopacityTimerMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); @@ -182,7 +181,7 @@ private: int CheckScrollableRecording(void); int CheckScrollableFolder(void); public: - cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New, cRect *vidWin); + cNopacityRecordingMenuItem(cOsd *osd, cImageCache *imgCache, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New, cRect *vidWin); ~cNopacityRecordingMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); @@ -203,7 +202,7 @@ private: void SetTextFull(void); void SetTextShort(void); public: - cNopacityDefaultMenuItem(cOsd *osd, const char *text, bool sel); + cNopacityDefaultMenuItem(cOsd *osd, cImageCache *imgCache, const char *text, bool sel); ~cNopacityDefaultMenuItem(void); int CheckScrollable(bool hasIcon); void Render(); @@ -212,7 +211,7 @@ public: class cNopacityTrackMenuItem : public cNopacityMenuItem { private: public: - cNopacityTrackMenuItem(cOsd *osd, const char *text); + cNopacityTrackMenuItem(cOsd *osd, cImageCache *imgCache, const char *text); ~cNopacityTrackMenuItem(void); void Render(); }; @@ -156,11 +156,17 @@ THEME_CLR(Theme, clrMessageWarning, CLR_MESSAGEWARNING); THEME_CLR(Theme, clrMessageError, CLR_MESSAGEERROR); THEME_CLR(Theme, clrMessageBlend, CLR_TRANSBLACK); +#include "helpers.c" #include "config.c" cNopacityConfig config; -#include "setup.c" +#include "geometrymanager.c" +cGeometryManager *geoManager; +#include "fontmanager.c" +cFontManager *fontManager; +#include "imagemagickwrapper.c" +#include "imagecache.c" #include "imageloader.c" -#include "helpers.c" +#include "setup.c" #include "rssreader.c" #include "nopacity.h" #include "displaychannel.c" @@ -177,11 +183,17 @@ cNopacityConfig config; -cNopacity::cNopacity(void) : cSkin("nOpacity", &::Theme) { +cNopacity::cNopacity(cImageCache *imgCache) : cSkin("nOpacity", &::Theme) { displayMenu = NULL; rssTicker = NULL; config.setDynamicValues(); config.loadRssFeeds(); + geoManager = new cGeometryManager(); + geoManager->SetGeometry(); + fontManager = new cFontManager(); + fontManager->SetFonts(); + this->imgCache = imgCache; + imgCache->CreateCache(); } const char *cNopacity::Description(void) { @@ -189,22 +201,25 @@ const char *cNopacity::Description(void) { } cSkinDisplayChannel *cNopacity::DisplayChannel(bool WithInfo) { - if (rssTicker) { - delete rssTicker; - rssTicker = NULL; - } - return new cNopacityDisplayChannel(WithInfo); + if (rssTicker) { + delete rssTicker; + rssTicker = NULL; + } + ReloadCaches(); + return new cNopacityDisplayChannel(imgCache, WithInfo); } cSkinDisplayMenu *cNopacity::DisplayMenu(void) { - if (rssTicker) { - delete rssTicker; - rssTicker = NULL; - } - cNopacityDisplayMenu *menu = new cNopacityDisplayMenu; - displayMenu = menu; - menuActive = true; - return menu; + if (rssTicker) { + delete rssTicker; + rssTicker = NULL; + } + + ReloadCaches(); + cNopacityDisplayMenu *menu = new cNopacityDisplayMenu(imgCache); + displayMenu = menu; + menuActive = true; + return menu; } cSkinDisplayReplay *cNopacity::DisplayReplay(bool ModeOnly) { @@ -212,7 +227,8 @@ cSkinDisplayReplay *cNopacity::DisplayReplay(bool ModeOnly) { delete rssTicker; rssTicker = NULL; } - return new cNopacityDisplayReplay(ModeOnly); + ReloadCaches(); + return new cNopacityDisplayReplay(imgCache, ModeOnly); } cSkinDisplayVolume *cNopacity::DisplayVolume(void) { @@ -220,6 +236,7 @@ cSkinDisplayVolume *cNopacity::DisplayVolume(void) { delete rssTicker; rssTicker = NULL; } + ReloadCaches(); return new cNopacityDisplayVolume; } @@ -228,7 +245,8 @@ cSkinDisplayTracks *cNopacity::DisplayTracks(const char *Title, int NumTracks, c delete rssTicker; rssTicker = NULL; } - return new cNopacityDisplayTracks(Title, NumTracks, Tracks); + ReloadCaches(); + return new cNopacityDisplayTracks(imgCache, Title, NumTracks, Tracks); } cSkinDisplayMessage *cNopacity::DisplayMessage(void) { @@ -236,7 +254,8 @@ cSkinDisplayMessage *cNopacity::DisplayMessage(void) { delete rssTicker; rssTicker = NULL; } - return new cNopacityDisplayMessage; + ReloadCaches(); + return new cNopacityDisplayMessage(imgCache); } void cNopacity::svdrpSwitchRss(void) { @@ -260,7 +279,7 @@ bool cNopacity::svdrpToggleStandaloneRss(void) { return false; if (!rssTicker) { - rssTicker = new cRssStandaloneTicker(); + rssTicker = new cRssStandaloneTicker(imgCache); rssTicker->SetFeed(config.rssFeeds[config.rssFeed[0]].name); rssTicker->Start(); return true; @@ -270,4 +289,25 @@ bool cNopacity::svdrpToggleStandaloneRss(void) { return false; } return false; -}
\ No newline at end of file +} + +void cNopacity::ReloadCaches(void) { + int start = cTimeMs::Now(); + bool change = false; + bool reloadImgCache = false; + if (geoManager->GeometryChanged()) { + geoManager->SetGeometry(); + fontManager->DeleteFonts(); + fontManager->SetFonts(); + reloadImgCache = true; + change = true; + } + if (imgCache->ThemeChanged()) { + reloadImgCache = true; + change = true; + } + if (reloadImgCache) + imgCache->Reload(); + if (change) + dsyslog("nopacity: Cache reloaded in %d ms", int(cTimeMs::Now()-start)); +} @@ -10,8 +10,10 @@ class cNopacity : public cSkin { private: cNopacityDisplayMenu *displayMenu; cRssStandaloneTicker *rssTicker; + cImageCache *imgCache; + void ReloadCaches(void); public: - cNopacity(void); + cNopacity(cImageCache *imgCache); virtual const char *Description(void); virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo); virtual cSkinDisplayMenu *DisplayMenu(void); diff --git a/rssreader.c b/rssreader.c index dc42452..44a4c5a 100644 --- a/rssreader.c +++ b/rssreader.c @@ -262,7 +262,8 @@ void cRssReader::debugRSS(void) { } -cRssStandaloneTicker::cRssStandaloneTicker(void) { +cRssStandaloneTicker::cRssStandaloneTicker(cImageCache *imgCache) { + this->imgCache = imgCache; osdLeft = cOsd::OsdLeft(); osdWidth = cOsd::OsdWidth(); osdHeight = config.rssFeedHeightStandalone * cOsd::OsdHeight() / 100; @@ -302,23 +303,21 @@ void cRssStandaloneTicker::SetFeed(std::string feedName) { int feedNameLength = font->Width(feedName.c_str()); labelWidth = 2 + osdHeight + 2 + feedNameLength + 6; pixmapFeed->Fill(Theme.Color(clrRSSFeedBorder)); - cImageLoader imgLoader; if (config.doBlending) { - imgLoader.DrawBackground(Theme.Color(clrRSSFeedHeaderBack), Theme.Color(clrRSSFeedHeaderBackBlend), labelWidth, osdHeight - 4); - pixmapFeed->DrawImage(cPoint(2,2), imgLoader.GetImage()); - imgLoader.DrawBackground(Theme.Color(clrRSSFeedBack), Theme.Color(clrRSSFeedBackBlend), osdWidth - labelWidth - 2, osdHeight - 4); - pixmapFeed->DrawImage(cPoint(labelWidth,2), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrRSSFeedHeaderBack), Theme.Color(clrRSSFeedHeaderBackBlend), labelWidth, osdHeight - 4); + pixmapFeed->DrawImage(cPoint(2,2), imgBack); + cImage imgBack2 = imgCache->GetBackground(Theme.Color(clrRSSFeedBack), Theme.Color(clrRSSFeedBackBlend), osdWidth - labelWidth - 2, osdHeight - 4); + pixmapFeed->DrawImage(cPoint(labelWidth,2), imgBack2); } else { pixmapFeed->DrawRectangle(cRect(2, 2, labelWidth, osdHeight - 4), Theme.Color(clrRSSFeedHeaderBack)); pixmapFeed->DrawRectangle(cRect(labelWidth, 2, osdWidth - labelWidth - 2, osdHeight - 4), Theme.Color(clrRSSFeedBack)); } pixmapFeed->DrawText(cPoint(osdHeight + 2, (osdHeight - font->Height()) / 2), feedName.c_str(), Theme.Color(clrRSSFeedHeaderText), clrTransparent, font); pixmapIcon->Fill(clrTransparent); - if (imgLoader.LoadIcon("skinIcons/rss", osdHeight-4)) { - cImage icon = imgLoader.GetImage(); - pixmapIcon->DrawImage(cPoint(2,2), icon); - } + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/rssStandalone", osdHeight-4, osdHeight-4); + if (imgIcon) + pixmapIcon->DrawImage(cPoint(2,2), *imgIcon); osd->Flush(); } diff --git a/rssreader.h b/rssreader.h index 86c7119..868b48f 100644 --- a/rssreader.h +++ b/rssreader.h @@ -58,13 +58,14 @@ private: class cRssStandaloneTicker {
public:
- cRssStandaloneTicker(void);
+ cRssStandaloneTicker(cImageCache *imgCache);
~cRssStandaloneTicker();
void Start(void);
void SetFeed(std::string feedName);
void SwitchNextRssMessage(void);
void SwitchNextRssFeed(void);
private:
+ cImageCache *imgCache;
int osdLeft;
int osdTop;
int osdWidth;
@@ -1,6 +1,7 @@ #include "setup.h" -cNopacitySetup::cNopacitySetup() { +cNopacitySetup::cNopacitySetup(cImageCache *imgCache) { + this->imgCache = imgCache; tmpNopacityConfig = config; cFont::GetAvailableFontNames(&fontNames); fontNames.Insert(strdup(config.fontDefaultName)); @@ -8,6 +9,11 @@ cNopacitySetup::cNopacitySetup() { } cNopacitySetup::~cNopacitySetup() { + config.setDynamicValues(); + geoManager->SetGeometry(); + fontManager->DeleteFonts(); + fontManager->SetFonts(); + imgCache->Reload(); } @@ -225,7 +231,7 @@ void cNopacitySetup::Store(void) { SetupStore("fontRssFeedStandalone", config.fontRssFeedStandalone); SetupStore("rssFeedStandalonePos", config.rssFeedStandalonePos); } - + //------------------------------------------------------------------------------------------------------------------ cMenuSetupSubMenu::cMenuSetupSubMenu(const char* Title, cNopacityConfig* data) : cOsdMenu(Title, 30) { @@ -3,9 +3,10 @@ class cNopacitySetup : public cMenuSetupPage { public: - cNopacitySetup(void); + cNopacitySetup(cImageCache *imgCache); virtual ~cNopacitySetup(); private: + cImageCache *imgCache; cNopacityConfig tmpNopacityConfig; cStringList fontNames; void Setup(void); diff --git a/skinnopacity.c b/skinnopacity.c index 40475f5..602029b 100644 --- a/skinnopacity.c +++ b/skinnopacity.c @@ -15,13 +15,14 @@ #endif -static const char *VERSION = "0.1.4"; +static const char *VERSION = "0.1.4 dev"; static const char *DESCRIPTION = "'nOpacity' Skin"; static const char *MAINMENUENTRY = "nOpacity"; class cPluginNopacity : public cPlugin { private: cNopacity *nopacity; + cImageCache *imgCache; public: cPluginNopacity(void); virtual ~cPluginNopacity(); @@ -62,8 +63,7 @@ const char *cPluginNopacity::CommandLineHelp(void) " -l <LOGOPATH>, --logopath=<LOGOPATH> Set directory where Channel Logos are stored.\n"; } -bool cPluginNopacity::ProcessArgs(int argc, char *argv[]) -{ +bool cPluginNopacity::ProcessArgs(int argc, char *argv[]) { // Implement command line argument processing here if applicable. static const struct option long_options[] = { { "epgimages", required_argument, NULL, 'e' }, @@ -91,66 +91,59 @@ bool cPluginNopacity::ProcessArgs(int argc, char *argv[]) return true; } -bool cPluginNopacity::Initialize(void) -{ +bool cPluginNopacity::Initialize(void) { return true; } -bool cPluginNopacity::Start(void) -{ +bool cPluginNopacity::Start(void) { if (!cOsdProvider::SupportsTrueColor()) { esyslog("nopacity: No TrueColor OSD found! Aborting!"); return false; } else dsyslog("nopacity: TrueColor OSD found"); - nopacity = new cNopacity; - return nopacity; + + imgCache = new cImageCache(); + nopacity = new cNopacity(imgCache); + return nopacity; } -void cPluginNopacity::Stop(void) -{ +void cPluginNopacity::Stop(void) { + delete imgCache; + delete geoManager; + delete fontManager; } -void cPluginNopacity::Housekeeping(void) -{ +void cPluginNopacity::Housekeeping(void) { } -void cPluginNopacity::MainThreadHook(void) -{ +void cPluginNopacity::MainThreadHook(void) { } -cString cPluginNopacity::Active(void) -{ +cString cPluginNopacity::Active(void) { return NULL; } -time_t cPluginNopacity::WakeupTime(void) -{ +time_t cPluginNopacity::WakeupTime(void) { return 0; } -cOsdObject *cPluginNopacity::MainMenuAction(void) -{ +cOsdObject *cPluginNopacity::MainMenuAction(void) { return NULL; } -cMenuSetupPage *cPluginNopacity::SetupMenu(void) -{ - return new cNopacitySetup(); +cMenuSetupPage *cPluginNopacity::SetupMenu(void) { + return new cNopacitySetup(imgCache); } -bool cPluginNopacity::SetupParse(const char *Name, const char *Value) -{ +bool cPluginNopacity::SetupParse(const char *Name, const char *Value) { return config.SetupParse(Name, Value); } -bool cPluginNopacity::Service(const char *Id, void *Data) -{ +bool cPluginNopacity::Service(const char *Id, void *Data) { return false; } -const char **cPluginNopacity::SVDRPHelpPages(void) -{ +const char **cPluginNopacity::SVDRPHelpPages(void) { static const char *HelpPages[] = { "NEXTMESG\n" " Switches to next message in running RSS Feed\n", @@ -1,15 +1,17 @@ #include "timers.h" -cNopacityTimer::cNopacityTimer(cOsd *osd, const cTimer *timer, const cFont *font, const cFont *fontLarge) { +cNopacityTimer::cNopacityTimer(cOsd *osd, cImageCache *imgCache, const cTimer *timer, const cFont *font, const cFont *fontLarge) { this->osd = osd; + this->imgCache = imgCache; this->timer = timer; this->font = font; this->fontLarge = fontLarge; isTimerConflict = false; } -cNopacityTimer::cNopacityTimer(cOsd *osd, int numConflicts, const cFont *font, const cFont *fontLarge) { +cNopacityTimer::cNopacityTimer(cOsd *osd, cImageCache *imgCache, int numConflicts, const cFont *font, const cFont *fontLarge) { this->osd = osd; + this->imgCache = imgCache; this->numConflicts = numConflicts; this->font = font; this->fontLarge = fontLarge; @@ -113,14 +115,13 @@ void cNopacityTimer::CreatePixmaps(int x) { void cNopacityTimer::Render(void) { pixmapBackground->Fill(clrBlack); - cImageLoader imgLoader; tColor clrFontBack = (config.doBlending)?clrTransparent:Theme.Color(clrTimersBack); if (isTimerConflict) { pixmapLogo->Fill(clrTransparent); pixmap->Fill(Theme.Color(clrDiskAlert)); if (config.doBlending) { - imgLoader.DrawBackground(Theme.Color(clrDiskAlert), Theme.Color(clrMenuItemHigh), width-2, height-2); - pixmap->DrawImage(cPoint(1,1), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrDiskAlert), Theme.Color(clrMenuItemHigh), width-2, height-2); + pixmap->DrawImage(cPoint(1,1), imgBack); } else { pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrDiskAlert)); clrFontBack = Theme.Color(clrDiskAlert); @@ -140,8 +141,8 @@ void cNopacityTimer::Render(void) { if (timer->Recording()) { pixmap->Fill(Theme.Color(clrDiskAlert)); if (config.doBlending) { - imgLoader.DrawBackground(Theme.Color(clrDiskAlert), Theme.Color(clrMenuItemHigh), width-2, height-2); - pixmap->DrawImage(cPoint(1,1), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrDiskAlert), Theme.Color(clrMenuItemHigh), width-2, height-2); + pixmap->DrawImage(cPoint(1,1), imgBack); } else { pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrDiskAlert)); clrFontBack = Theme.Color(clrDiskAlert); @@ -149,8 +150,8 @@ void cNopacityTimer::Render(void) { } else { pixmap->Fill(Theme.Color(clrMenuBorder)); if (config.doBlending) { - imgLoader.DrawBackground(Theme.Color(clrTimersBack), Theme.Color(clrTimersBackBlend), width-2, height-2); - pixmap->DrawImage(cPoint(1,1), imgLoader.GetImage()); + cImage imgBack = imgCache->GetBackground(Theme.Color(clrTimersBack), Theme.Color(clrTimersBackBlend), width-2, height-2); + pixmap->DrawImage(cPoint(1,1), imgBack); } else { pixmap->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrTimersBack)); } @@ -4,6 +4,7 @@ class cNopacityTimer : public cListObject {
private:
cOsd *osd;
+ cImageCache *imgCache;
cPixmap *pixmapBackground;
cPixmap *pixmap;
cPixmap *pixmapLogo;
@@ -19,8 +20,8 @@ class cNopacityTimer : public cListObject { cTextWrapper showName;
void DrawLogo(void);
public:
- cNopacityTimer(cOsd *osd, const cTimer *timer, const cFont *font, const cFont *fontLarge);
- cNopacityTimer(cOsd *osd, int numConflicts, const cFont *font, const cFont *fontLarge);
+ cNopacityTimer(cOsd *osd, cImageCache *imgCache, const cTimer *timer, const cFont *font, const cFont *fontLarge);
+ cNopacityTimer(cOsd *osd, cImageCache *imgCache, int numConflicts, const cFont *font, const cFont *fontLarge);
virtual ~cNopacityTimer(void);
void SetGeometry(int width, int y);
void CreateDate(void);
|