infoviewer_bb: use OFFSET defines; ...

height of ca-bar now depends on height of ca-icons
cleanup from commented code


Origin commit data
------------------
Branch: ni/coolstream
Commit: 866a2c3a4a
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-28 (Tue, 28 Nov 2017)

Origin message was:
------------------
- infoviewer_bb: use OFFSET defines; ...

height of ca-bar now depends on height of ca-icons
cleanup from commented code


------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2017-11-28 14:41:42 +01:00
parent 2a29fa67eb
commit eb616062fa
2 changed files with 39 additions and 60 deletions

View File

@@ -130,6 +130,7 @@ void CInfoViewerBB::Init()
CComponentsFooter footer; CComponentsFooter footer;
InfoHeightY_Info = footer.getHeight(); InfoHeightY_Info = footer.getHeight();
ca_h = 0;
initBBOffset(); initBBOffset();
changePB(); changePB();
@@ -309,8 +310,8 @@ void CInfoViewerBB::getBBButtonInfo()
if (text == g_Locale->getText(LOCALE_MPKEY_AUDIO) && !g_settings.infobar_buttons_usertitle) if (text == g_Locale->getText(LOCALE_MPKEY_AUDIO) && !g_settings.infobar_buttons_usertitle)
text = CMoviePlayerGui::getInstance(false).CurrentAudioName(); // use instance_mp text = CMoviePlayerGui::getInstance(false).CurrentAudioName(); // use instance_mp
} }
bbButtonInfo[i].w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(text) + w + 10; bbButtonInfo[i].w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(text) + w + OFFSET_INNER_MID;
bbButtonInfo[i].cx = w + 5; bbButtonInfo[i].cx = w + OFFSET_INNER_SMALL;
bbButtonInfo[i].h = h; bbButtonInfo[i].h = h;
bbButtonInfo[i].text = text; bbButtonInfo[i].text = text;
bbButtonInfo[i].icon = icon; bbButtonInfo[i].icon = icon;
@@ -320,21 +321,12 @@ void CInfoViewerBB::getBBButtonInfo()
} }
// Calculate position/size of buttons // Calculate position/size of buttons
minX = std::min(bbIconMinX, g_InfoViewer->ChanInfoX + (((g_InfoViewer->BoxEndX - g_InfoViewer->ChanInfoX) * 75) / 100)); minX = std::min(bbIconMinX, g_InfoViewer->ChanInfoX + (((g_InfoViewer->BoxEndX - g_InfoViewer->ChanInfoX) * 75) / 100));
int MaxBr = minX - (g_InfoViewer->ChanInfoX + 10); int MaxBr = minX - (g_InfoViewer->ChanInfoX + OFFSET_INNER_MID);
bbButtonMaxX = g_InfoViewer->ChanInfoX + 10; bbButtonMaxX = g_InfoViewer->ChanInfoX + OFFSET_INNER_MID;
int br = 0, count = 0; int br = 0, count = 0;
for (int i = 0; i < CInfoViewerBB::BUTTON_MAX; i++) { for (int i = 0; i < CInfoViewerBB::BUTTON_MAX; i++) {
#if 0
if ((i == CInfoViewerBB::BUTTON_YELLOW) && (g_RemoteControl->subChannels.empty())) { // no subchannels
bbButtonInfo[i].paint = false;
// bbButtonInfo[i].x = -1;
// continue;
}
else
#else
if (!bbButtonInfo[i].active) if (!bbButtonInfo[i].active)
bbButtonInfo[i].paint = false; bbButtonInfo[i].paint = false;
#endif
else else
{ {
count++; count++;
@@ -347,35 +339,7 @@ void CInfoViewerBB::getBBButtonInfo()
} }
if (br > MaxBr) if (br > MaxBr)
printf("[infoviewer_bb:%s#%d] width br (%d) > MaxBr (%d) count %d\n", __func__, __LINE__, br, MaxBr, count); printf("[infoviewer_bb:%s#%d] width br (%d) > MaxBr (%d) count %d\n", __func__, __LINE__, br, MaxBr, count);
#if 0 bbButtonMaxX = g_InfoViewer->ChanInfoX + OFFSET_INNER_MID;
int Btns = 0;
// counting buttons
for (int i = 0; i < CInfoViewerBB::BUTTON_MAX; i++) {
if (bbButtonInfo[i].x != -1) {
Btns++;
}
}
bbButtonMaxX = g_InfoViewer->ChanInfoX + 10;
bbButtonInfo[CInfoViewerBB::BUTTON_RED].x = bbButtonMaxX;
bbButtonInfo[CInfoViewerBB::BUTTON_BLUE].x = minX - bbButtonInfo[CInfoViewerBB::BUTTON_BLUE].w;
int x1 = bbButtonInfo[CInfoViewerBB::BUTTON_RED].x + bbButtonInfo[CInfoViewerBB::BUTTON_RED].w;
int rest = bbButtonInfo[CInfoViewerBB::BUTTON_BLUE].x - x1;
if (Btns < 4) {
rest -= bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].w;
bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].x = x1 + rest / 2;
}
else {
rest -= bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].w + bbButtonInfo[CInfoViewerBB::BUTTON_YELLOW].w;
rest = rest / 3;
bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].x = x1 + rest;
bbButtonInfo[CInfoViewerBB::BUTTON_YELLOW].x = bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].x +
bbButtonInfo[CInfoViewerBB::BUTTON_GREEN].w + rest;
}
#endif
bbButtonMaxX = g_InfoViewer->ChanInfoX + 10;
int step = MaxBr / 4; int step = MaxBr / 4;
if (count > 0) { /* avoid div-by-zero :-) */ if (count > 0) { /* avoid div-by-zero :-) */
step = MaxBr / count; step = MaxBr / count;
@@ -421,7 +385,7 @@ void CInfoViewerBB::showBBButtons(bool paintFooter)
if (paint) { if (paint) {
fb_pixel_t *pixbuf = NULL; fb_pixel_t *pixbuf = NULL;
int buf_x = bbIconMinX - 5; int buf_x = bbIconMinX - OFFSET_INNER_SMALL;
int buf_y = BBarY; int buf_y = BBarY;
int buf_w = g_InfoViewer->BoxEndX-buf_x; int buf_w = g_InfoViewer->BoxEndX-buf_x;
int buf_h = InfoHeightY_Info; int buf_h = InfoHeightY_Info;
@@ -615,7 +579,7 @@ void CInfoViewerBB::showIcon_Resolution()
switch (yres) { switch (yres) {
case 2160: case 2160:
icon_name = NEUTRINO_ICON_RESOLUTION_2160; icon_name = NEUTRINO_ICON_RESOLUTION_2160;
break; break;
case 1920: case 1920:
icon_name = NEUTRINO_ICON_RESOLUTION_1920; icon_name = NEUTRINO_ICON_RESOLUTION_1920;
break; break;
@@ -739,7 +703,7 @@ void CInfoViewerBB::showBarSys(int percent)
if (is_visible){ if (is_visible){
sysscale->reset(); sysscale->reset();
sysscale->doPaintBg(false); sysscale->doPaintBg(false);
sysscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6); sysscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info/2 - OFFSET_INNER_MIN - InfoHeightY_Info/4, hddwidth, InfoHeightY_Info/4);
sysscale->setValues(percent, 100); sysscale->setValues(percent, 100);
sysscale->paint(); sysscale->paint();
} }
@@ -751,11 +715,11 @@ void CInfoViewerBB::showBarHdd(int percent)
hddscale->reset(); hddscale->reset();
hddscale->doPaintBg(false); hddscale->doPaintBg(false);
if (percent >= 0){ if (percent >= 0){
hddscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6); hddscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info/2 + OFFSET_INNER_MIN, hddwidth, InfoHeightY_Info/4);
hddscale->setValues(percent, 100); hddscale->setValues(percent, 100);
hddscale->paint(); hddscale->paint();
}else { }else {
frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, COL_INFOBAR_BUTTONS_BACKGROUND); frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info/2 + OFFSET_INNER_MIN, hddwidth, InfoHeightY_Info/4, COL_INFOBAR_BUTTONS_BACKGROUND);
} }
} }
} }
@@ -763,11 +727,11 @@ void CInfoViewerBB::showBarHdd(int percent)
void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_offset) void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_offset)
{ {
char buf[20]; char buf[20];
int endx = g_InfoViewer->BoxEndX - (g_settings.infobar_casystem_frame ? 20 : 10); int endx = g_InfoViewer->BoxEndX - OFFSET_INNER_MID - (g_settings.infobar_casystem_frame ? FRAME_WIDTH_MIN + OFFSET_INNER_SMALL : 0);
int py = g_InfoViewer->BoxEndY + (g_settings.infobar_casystem_frame ? 4 : 2); /* hand-crafted, should be automatic */ int py = g_InfoViewer->BoxEndY + OFFSET_INNER_SMALL;
int px = 0; int px = 0;
static std::map<int, std::pair<int,const char*> > icon_map; static std::map<int, std::pair<int,const char*> > icon_map;
const int icon_space = 10, icon_number = 11; //NI const int icon_space = OFFSET_INNER_SMALL, icon_number = 11; //NI
static int icon_offset[icon_number] = {0,0,0,0,0,0,0,0,0,0,0}; //NI static int icon_offset[icon_number] = {0,0,0,0,0,0,0,0,0,0,0}; //NI
static int icon_sizeW [icon_number] = {0,0,0,0,0,0,0,0,0,0,0}; //NI static int icon_sizeW [icon_number] = {0,0,0,0,0,0,0,0,0,0,0}; //NI
@@ -816,7 +780,7 @@ void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_o
if (px) { if (px) {
snprintf(buf, sizeof(buf), "%s_%s", icon_map[caid].second, icon); snprintf(buf, sizeof(buf), "%s_%s", icon_map[caid].second, icon);
if ((px >= (endx-8)) || (px <= 0)) if ((px >= (endx-OFFSET_INNER_MID)) || (px <= 0))
printf("#####[%s:%d] Error paint icon %s, px: %d, py: %d, endx: %d, icon_offset: %d\n", printf("#####[%s:%d] Error paint icon %s, px: %d, py: %d, endx: %d, icon_offset: %d\n",
__FUNCTION__, __LINE__, buf, px, py, endx, icon_offset[icon_map[caid].first]); __FUNCTION__, __LINE__, buf, px, py, endx, icon_offset[icon_map[caid].first]);
else if (strstr(buf,"dec_white") == 0) //NI else if (strstr(buf,"dec_white") == 0) //NI
@@ -925,12 +889,14 @@ void CInfoViewerBB::showIcon_CA_Status(int notfirst)
void CInfoViewerBB::paint_ca_bar() void CInfoViewerBB::paint_ca_bar()
{ {
initBBOffset(); initBBOffset();
int ca_width = g_InfoViewer->BoxEndX - g_InfoViewer->ChanInfoX; int ca_x = g_InfoViewer->ChanInfoX + OFFSET_INNER_MID;
int ca_y = g_InfoViewer->BoxEndY;
int ca_w = g_InfoViewer->BoxEndX - g_InfoViewer->ChanInfoX - 2*OFFSET_INNER_MID;
if (g_settings.infobar_casystem_frame) if (g_settings.infobar_casystem_frame)
{ {
if (ca_bar == NULL) if (ca_bar == NULL)
ca_bar = new CComponentsShapeSquare(g_InfoViewer->ChanInfoX + OFFSET_INNER_MID, g_InfoViewer->BoxEndY, ca_width - 2*OFFSET_INNER_MID, bottom_bar_offset - 10, NULL, CC_SHADOW_ON, COL_INFOBAR_CASYSTEM_PLUS_2, COL_INFOBAR_CASYSTEM_PLUS_0); //NI ca_bar = new CComponentsShapeSquare(ca_x, ca_y, ca_w, ca_h, NULL, CC_SHADOW_ON, COL_INFOBAR_CASYSTEM_PLUS_2, COL_INFOBAR_CASYSTEM_PLUS_0); //NI
ca_bar->enableShadow(CC_SHADOW_ON, OFFSET_SHADOW/2, true); ca_bar->enableShadow(CC_SHADOW_ON, OFFSET_SHADOW/2, true);
ca_bar->setFrameThickness(FRAME_WIDTH_MIN); ca_bar->setFrameThickness(FRAME_WIDTH_MIN);
ca_bar->setCorner(RADIUS_SMALL, CORNER_ALL); ca_bar->setCorner(RADIUS_SMALL, CORNER_ALL);
@@ -938,7 +904,7 @@ void CInfoViewerBB::paint_ca_bar()
} }
else else
{ {
paintBoxRel(g_InfoViewer->ChanInfoX, g_InfoViewer->BoxEndY, ca_width , bottom_bar_offset, COL_INFOBAR_CASYSTEM_PLUS_0); paintBoxRel(g_InfoViewer->ChanInfoX, g_InfoViewer->BoxEndY, g_InfoViewer->BoxEndX - g_InfoViewer->ChanInfoX, bottom_bar_offset, COL_INFOBAR_CASYSTEM_PLUS_0);
} }
//NI //NI
#if 0 #if 0
@@ -960,7 +926,8 @@ void CInfoViewerBB::paint_ca_bar()
void CInfoViewerBB::changePB() void CInfoViewerBB::changePB()
{ {
hddwidth = frameBuffer->getScreenWidth(true) * ((g_settings.screen_preset == 1) ? 10 : 8) / 128; /* 80(CRT)/100(LCD) pix if screen is 1280 wide */ hddwidth = frameBuffer->getScreenWidth(true) / 100 * 10; // 10 percent of screen width
if (!hddscale) { if (!hddscale) {
hddscale = new CProgressBar(); hddscale = new CProgressBar();
hddscale->setType(CProgressBar::PB_REDRIGHT); hddscale->setType(CProgressBar::PB_REDRIGHT);
@@ -997,7 +964,18 @@ void CInfoViewerBB::ResetModules()
void CInfoViewerBB::initBBOffset() void CInfoViewerBB::initBBOffset()
{ {
bottom_bar_offset = (g_settings.infobar_casystem_display < 2) ? (g_settings.infobar_casystem_frame ? 38 : 24) : 0; //NI int icon_w = 0, icon_h = 0;
frameBuffer->getIconSize("nagra_white", &icon_w, &icon_h); // take any ca icon to get its height
ca_h = icon_h + 2*OFFSET_INNER_SMALL;
bottom_bar_offset = 0;
if (g_settings.infobar_casystem_display < 2)
{
if (g_settings.infobar_casystem_frame)
bottom_bar_offset = ca_h + OFFSET_SHADOW/2 + OFFSET_INNER_SMALL;
else
bottom_bar_offset = ca_h;
}
} }
void* CInfoViewerBB::scrambledThread(void *arg) void* CInfoViewerBB::scrambledThread(void *arg)
@@ -1035,10 +1013,10 @@ void CInfoViewerBB::scrambledCheck(bool force)
void CInfoViewerBB::paint_cam_icons() void CInfoViewerBB::paint_cam_icons()
{ {
std::ostringstream buf; std::ostringstream buf;
int emu_pic_startx = g_InfoViewer->ChanInfoX + (g_settings.infobar_casystem_frame ? 20 : 10); int emu_pic_startx = g_InfoViewer->ChanInfoX + OFFSET_INNER_MID + (g_settings.infobar_casystem_frame ? FRAME_WIDTH_MIN + OFFSET_INNER_SMALL : 0);
int py = g_InfoViewer->BoxEndY + (g_settings.infobar_casystem_frame ? 4 : 2); int py = g_InfoViewer->BoxEndY + OFFSET_INNER_SMALL;
const char *icon_name[] = {"mgcamd","doscam","ncam","oscam","osemu","newcs","gbox"}; const char *icon_name[] = {"mgcamd","doscam","ncam","oscam","osemu","newcs","gbox"};
static int icon_space[] = {10,10,10,10,10,10,10}; const int icon_space = OFFSET_INNER_SMALL;
int icon_sizeH = 0; int icon_sizeH = 0;
int icon_sizeW = 0; int icon_sizeW = 0;
bool useCI = CCamManager::getInstance()->getUseCI(); bool useCI = CCamManager::getInstance()->getUseCI();
@@ -1056,7 +1034,7 @@ void CInfoViewerBB::paint_cam_icons()
} }
frameBuffer->paintIcon(buf.str().c_str(), emu_pic_startx, py ); frameBuffer->paintIcon(buf.str().c_str(), emu_pic_startx, py );
frameBuffer->getIconSize(buf.str().c_str(), &icon_sizeW, &icon_sizeH); frameBuffer->getIconSize(buf.str().c_str(), &icon_sizeW, &icon_sizeH);
emu_pic_startx += icon_space[i]; emu_pic_startx += icon_space;
emu_pic_startx += icon_sizeW; emu_pic_startx += icon_sizeW;
} }
} }

View File

@@ -115,6 +115,7 @@ class CInfoViewerBB
CProgressBar *hddscale, *sysscale; CProgressBar *hddscale, *sysscale;
CComponentsShapeSquare *foot, *ca_bar; CComponentsShapeSquare *foot, *ca_bar;
int ca_h;
void paintFoot(int w = 0); void paintFoot(int w = 0);
void showBBIcons(const int modus, const std::string & icon); void showBBIcons(const int modus, const std::string & icon);
void getBBIconInfo(void); void getBBIconInfo(void);