2013-12-07 15:51:50 +01:00
|
|
|
#include <string>
|
|
|
|
#include "imageloader.h"
|
|
|
|
#include "tools.h"
|
2013-01-17 13:16:44 +01:00
|
|
|
#include "footer.h"
|
|
|
|
|
2013-05-31 13:58:22 +02:00
|
|
|
cFooter::cFooter(cChannelGroups *channelGroups) {
|
|
|
|
this->channelGroups = channelGroups;
|
|
|
|
currentGroup = -1;
|
2013-12-21 11:25:03 +01:00
|
|
|
buttonY = (geoManager.footerHeight - geoManager.buttonHeight)/2;
|
2013-07-19 15:42:16 +02:00
|
|
|
SetButtonPositions();
|
2013-12-21 11:25:03 +01:00
|
|
|
footer = osdManager.requestPixmap(2, cRect( 0,
|
2013-12-27 16:31:49 +01:00
|
|
|
geoManager.footerY,
|
2013-12-21 11:25:03 +01:00
|
|
|
geoManager.osdWidth,
|
|
|
|
geoManager.footerHeight),
|
2013-05-20 11:37:37 +02:00
|
|
|
cRect::Null);
|
2013-01-17 14:33:53 +01:00
|
|
|
footer->Fill(clrTransparent);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cFooter::~cFooter(void) {
|
2013-05-20 11:37:37 +02:00
|
|
|
osdManager.releasePixmap(footer);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cFooter::drawRedButton() {
|
2013-07-09 00:17:42 +02:00
|
|
|
cString text(tr("Search & Rec"));
|
2013-12-21 11:25:03 +01:00
|
|
|
DrawButton(*text, theme.Color(clrButtonRed), theme.Color(clrButtonRedBorder), oeButtonRed, positionButtons[0]);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cFooter::drawGreenButton() {
|
2013-01-17 14:33:53 +01:00
|
|
|
cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels back"));
|
2013-12-21 11:25:03 +01:00
|
|
|
DrawButton(*text, theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
2013-05-31 13:58:22 +02:00
|
|
|
void cFooter::drawGreenButton(const char *text) {
|
2013-12-21 11:25:03 +01:00
|
|
|
std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton);
|
|
|
|
DrawButton(cuttedText.c_str(), theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]);
|
2013-05-31 13:58:22 +02:00
|
|
|
}
|
|
|
|
|
2013-01-17 13:16:44 +01:00
|
|
|
void cFooter::drawYellowButton() {
|
2013-01-17 14:33:53 +01:00
|
|
|
cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels forward"));
|
2013-12-21 11:25:03 +01:00
|
|
|
DrawButton(*text, theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
2013-05-31 13:58:22 +02:00
|
|
|
void cFooter::drawYellowButton(const char *text) {
|
2013-12-21 11:25:03 +01:00
|
|
|
std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton);
|
|
|
|
DrawButton(cuttedText.c_str(), theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]);
|
2013-05-31 13:58:22 +02:00
|
|
|
}
|
|
|
|
|
2014-01-14 18:00:32 +01:00
|
|
|
void cFooter::drawBlueButton(bool detailedEPG) {
|
2013-06-01 11:08:17 +02:00
|
|
|
cString text;
|
2014-01-14 18:00:32 +01:00
|
|
|
if (tvguideConfig.blueKeyMode == eBlueKeySwitch)
|
2013-06-01 11:08:17 +02:00
|
|
|
text = tr("Switch to Channel");
|
2014-01-14 18:00:32 +01:00
|
|
|
else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) {
|
|
|
|
if (!detailedEPG)
|
|
|
|
text = tr("Detailed EPG");
|
|
|
|
else
|
|
|
|
text = tr("Close detailed EPG");
|
|
|
|
} else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) {
|
|
|
|
if (!detailedEPG)
|
|
|
|
text = tr("Favorites");
|
|
|
|
else
|
|
|
|
text = tr("Switch to Channel");
|
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
DrawButton(*text, theme.Color(clrButtonBlue), theme.Color(clrButtonBlueBorder), oeButtonBlue, positionButtons[3]);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
2013-01-17 14:33:53 +01:00
|
|
|
|
2014-01-11 16:53:23 +01:00
|
|
|
void cFooter::UpdateGroupButtons(const cChannel *channel, bool force) {
|
|
|
|
if (!channel)
|
|
|
|
return;
|
2013-05-31 13:58:22 +02:00
|
|
|
int group = channelGroups->GetGroup(channel);
|
2014-01-11 16:53:23 +01:00
|
|
|
if ((group != currentGroup) || force) {
|
2013-05-31 13:58:22 +02:00
|
|
|
currentGroup = group;
|
|
|
|
drawGreenButton(channelGroups->GetPrev(group));
|
|
|
|
drawYellowButton(channelGroups->GetNext(group));
|
2013-05-26 17:04:57 +02:00
|
|
|
}
|
2013-07-09 00:17:42 +02:00
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
|
2014-01-11 16:53:23 +01:00
|
|
|
void cFooter::SetDetailedViewMode(void) {
|
|
|
|
ClearButton(positionButtons[1]);
|
|
|
|
ClearButton(positionButtons[2]);
|
2014-01-14 18:00:32 +01:00
|
|
|
if (tvguideConfig.blueKeyMode != eBlueKeySwitch) {
|
|
|
|
ClearButton(positionButtons[3]);
|
|
|
|
drawBlueButton(true);
|
|
|
|
}
|
2014-01-11 16:53:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cFooter::LeaveDetailedViewMode(const cChannel *channel) {
|
|
|
|
if (tvguideConfig.channelJumpMode == eNumJump) {
|
|
|
|
drawGreenButton();
|
|
|
|
drawYellowButton();
|
2014-01-15 17:30:06 +01:00
|
|
|
drawBlueButton();
|
2014-01-11 16:53:23 +01:00
|
|
|
} else {
|
|
|
|
UpdateGroupButtons(channel, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 11:25:03 +01:00
|
|
|
void cFooter::SetButtonPositions(void) {
|
|
|
|
for (int i=0; i < 4; i++) {
|
|
|
|
positionButtons[i] = -1;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
red button = 0
|
|
|
|
green button = 1
|
|
|
|
yellow button = 2
|
|
|
|
blue button = 3
|
|
|
|
*/
|
|
|
|
for (int button=0; button<4; button++) {
|
|
|
|
if (Setup.ColorKey0 == button) {
|
|
|
|
positionButtons[button] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Setup.ColorKey1 == button) {
|
|
|
|
positionButtons[button] = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Setup.ColorKey2 == button) {
|
|
|
|
positionButtons[button] = 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Setup.ColorKey3 == button) {
|
|
|
|
positionButtons[button] = 3;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cFooter::DrawButton(const char *text, tColor color, tColor borderColor, eOsdElementType buttonType, int num) {
|
|
|
|
tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent;
|
|
|
|
int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder;
|
|
|
|
|
|
|
|
if ((tvguideConfig.style == eStyleBlendingMagick) || (tvguideConfig.style == eStyleBlendingDefault)) {
|
|
|
|
cImageLoader imgLoader;
|
|
|
|
imgLoader.DrawBackground(theme.Color(clrButtonBlend), color, geoManager.buttonWidth-4, geoManager.buttonHeight-4);
|
|
|
|
footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor);
|
|
|
|
footer->DrawImage(cPoint(left+2, buttonY+2), imgLoader.GetImage());
|
2013-12-27 17:06:49 +01:00
|
|
|
if (tvguideConfig.roundedCorners) {
|
|
|
|
int borderRadius = 12;
|
|
|
|
int borderWidth = 2;
|
|
|
|
DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor);
|
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
} else if (tvguideConfig.style == eStyleGraphical) {
|
|
|
|
cImage *button = imgCache.GetOsdElement(buttonType);
|
|
|
|
if (button) {
|
|
|
|
footer->DrawImage(cPoint(left, buttonY), *button);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor);
|
2013-12-27 17:06:49 +01:00
|
|
|
footer->DrawRectangle(cRect(left+1, buttonY+1, geoManager.buttonWidth-2, geoManager.buttonHeight-2), color);
|
|
|
|
if (tvguideConfig.roundedCorners) {
|
|
|
|
int borderRadius = 12;
|
|
|
|
int borderWidth = 1;
|
|
|
|
DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor);
|
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int textWidth = fontManager.FontButton->Width(text);
|
|
|
|
int textHeight = fontManager.FontButton->Height();
|
|
|
|
footer->DrawText(cPoint(left + (geoManager.buttonWidth-textWidth)/2, buttonY + (geoManager.buttonHeight-textHeight)/2), text, theme.Color(clrFontButtons), colorTextBack, fontManager.FontButton);
|
2014-01-11 16:53:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cFooter::ClearButton(int num) {
|
|
|
|
int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder;
|
|
|
|
footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), clrTransparent);
|
2013-12-21 11:25:03 +01:00
|
|
|
}
|