diff --git a/src/gui/imageinfo_ni.cpp b/src/gui/imageinfo_ni.cpp index 50d8c421c..f93dc79b6 100644 --- a/src/gui/imageinfo_ni.cpp +++ b/src/gui/imageinfo_ni.cpp @@ -2,7 +2,7 @@ imageinfo_ni (C) 2009-2016 NG-Team - (C) 2016 NI-Team + (C) 2016,2017 NI-Team License: GPL @@ -58,8 +58,6 @@ #include -extern cVideo * videoDecoder; - extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ #include @@ -81,17 +79,19 @@ CImageInfoNI::CImageInfoNI() Init(); } -static const neutrino_locale_t info_items[8] = +static const neutrino_locale_t info_items[] = { LOCALE_IMAGEINFO_IMAGE, - LOCALE_IMAGEINFO_DATE, LOCALE_IMAGEINFO_VERSION, + /* Commit: */ + LOCALE_IMAGEINFO_KERNEL, + /* Lua-API: */ + /* yWeb: */ + LOCALE_IMAGEINFO_DATE, LOCALE_IMAGEINFO_CREATOR, - LOCALE_IMAGEINFO_HOMEPAGE, - LOCALE_IMAGEINFO_DOKUMENTATION, - LOCALE_IMAGEINFO_FORUM, - LOCALE_IMAGEINFO_LICENSE + LOCALE_IMAGEINFO_HOMEPAGE }; +int info_items_count = sizeof(info_items)/sizeof(info_items[0]); void CImageInfoNI::Init(void) { @@ -109,30 +109,34 @@ void CImageInfoNI::Init(void) max_width = frameBuffer->getScreenWidth(true); max_height = frameBuffer->getScreenHeight(true); - width = frameBuffer->getScreenWidth() - 10; - height = frameBuffer->getScreenHeight() - 10; - x = getScreenStartX( width ); - y = getScreenStartY( height ); + width = frameBuffer->getScreenWidth() - 2*OFFSET_INNER_MID; + height = frameBuffer->getScreenHeight() - 2*OFFSET_INNER_MID; + x = getScreenStartX(width); + y = getScreenStartY(height); + + // This single correction saves many offsets in code below + x += OFFSET_INNER_MID; + width -= OFFSET_INNER_MID; systemfs = 0; + revision = cs_get_revision(); old_x = 0; old_y = 0; InfoThread = 0; read_old = 0; write_old = 0; net_best = 0; - xcpu = width - width/3 - 10; - ycpu = y + 10 + (height/3 /* pig-box height */) + (2 * iheight); - max_text_width = xcpu - x - 2*10; + xcpu = x + width - width/3 - OFFSET_INNER_MID; + ycpu = y + OFFSET_INNER_MID + (height/3 /* pig-box height */) + (2 * iheight); + max_text_width = xcpu - x - OFFSET_INNER_MID; offset = 0; - for (int i = 0; i < 8; i++) { - int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText (info_items[i])); - if (tmpoffset > offset) { + for (int i = 0; i < info_items_count; i++) { + int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText(info_items[i])); + if (tmpoffset > offset) offset = tmpoffset; - } } - offset = offset + 15; + offset = offset + OFFSET_INNER_MID; netIfName = "eth0"; netMaxBit = 104857600; @@ -141,7 +145,6 @@ void CImageInfoNI::Init(void) CImageInfoNI::~CImageInfoNI() { StopInfoThread(); - videoDecoder->Pig(-1, -1, -1, -1); } int CImageInfoNI::exec(CMenuTarget* parent, const std::string &) @@ -165,7 +168,7 @@ int CImageInfoNI::exec(CMenuTarget* parent, const std::string &) fader.StartFadeIn(); bool fadeout = false; paint(); - paint_pig(xcpu, y + 10, width/3, height/3); + paint_pic(xcpu, y + OFFSET_INNER_MID, width/3, height/3); StartInfoThread(); while (1) @@ -241,12 +244,11 @@ int CImageInfoNI::exec(CMenuTarget* parent, const std::string &) void CImageInfoNI::hide() { frameBuffer->paintBackground(); - videoDecoder->Pig(-1, -1, -1, -1); } -void CImageInfoNI::paint_pig(int px, int py, int w, int h) +void CImageInfoNI::paint_pic(int px, int py, int w, int h) { - frameBuffer->paintBoxRel(px-10,py-10,w+20,h+20, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(px - OFFSET_INNER_MID, py - OFFSET_INNER_MID, w + 2*OFFSET_INNER_MID, h + 2*OFFSET_INNER_MID, COL_INFOBAR_PLUS_0); g_PicViewer->DisplayImage(ICONSDIR "/start.jpg", px, py, w, h, frameBuffer->TM_NONE); } @@ -258,22 +260,24 @@ void CImageInfoNI::paintLine(int xpos, int font, std::string text) void CImageInfoNI::clearLine(int xpos, int font) { int font_height = g_Font[font]->getHeight(); - frameBuffer->paintBoxRel(xpos, ypos - font_height, max_text_width , font_height, COL_BLUE/*INFOBAR_PLUS_0*/); + frameBuffer->paintBoxRel(xpos, ypos - font_height, max_text_width, font_height, COL_BLUE/*INFOBAR_PLUS_0*/); } void CImageInfoNI::paint() { - const char * head_string; - int xpos = x+10; - + int xpos = x; ypos = y; + const char * head_string; head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string); //background frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_INFOBAR_PLUS_0); + // just for visual debug + //frameBuffer->paintBoxRel(xpos, ypos, width, height, COL_INFOBAR_PLUS_1); + ypos += hheight; g_Font[font_head]->RenderString(xpos, ypos, max_text_width, head_string, COL_MENUHEAD_TEXT); @@ -315,7 +319,7 @@ void CImageInfoNI::paint() struct utsname uts_info; ypos += iheight; - paintLine(xpos, font_info, "Kernel:"); + paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_KERNEL)); paintLine(xpos+offset, font_info, uname(&uts_info) < 0 ? "n/a" : uts_info.release); #ifdef ENABLE_LUA @@ -341,15 +345,13 @@ void CImageInfoNI::paint() paintLine(xpos+offset, font_info, homepage); ypos += iheight; - ypos += sheight; #ifndef HAVE_GENERIC_HARDWARE get_MTD_Info(); //paint_MTD_Info(xpos); - //ypos+= sheight; + //ypos += sheight; paint_DF_Info(xpos); - ypos+= sheight; #endif @@ -364,8 +366,8 @@ void* CImageInfoNI::InfoProc(void *arg) CImageInfoNI *imageInfo = (CImageInfoNI*) arg; while(1) { - imageInfo->paint_MEM_Info(imageInfo->x+10, imageInfo->ypos); - imageInfo->paint_NET_Info(imageInfo->x+10, imageInfo->ypos); + imageInfo->paint_MEM_Info(imageInfo->x, imageInfo->ypos); + imageInfo->paint_NET_Info(imageInfo->x, imageInfo->ypos); sleep(1); } return 0; @@ -374,7 +376,7 @@ void* CImageInfoNI::InfoProc(void *arg) void CImageInfoNI::StartInfoThread() { if(!InfoThread) { - printf("CImageInfoNI::StartInfoThrea\n"); + printf("CImageInfoNI::StartInfoThread\n"); pthread_create (&InfoThread, NULL, InfoProc, (void*) this) ; pthread_detach(InfoThread); } @@ -529,7 +531,7 @@ int CImageInfoNI::CPU_Percent(_stat *cpu) void CImageInfoNI::paint_Stat_Info_Box(int InfoB_x, int InfoB_y, int InfoB_w, int InfoB_h) { - frameBuffer->paintBoxRel(InfoB_x-10,InfoB_y-10,InfoB_w+20,InfoB_h+20, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(InfoB_x - OFFSET_INNER_MID, InfoB_y - OFFSET_INNER_MID, InfoB_w + 2*OFFSET_INNER_MID, InfoB_h + 2*OFFSET_INNER_MID, COL_INFOBAR_PLUS_0); g_Font[font_info]->RenderString(InfoB_x, InfoB_y, InfoB_w, "CPU-Load", COL_INFOBAR_TEXT); sigBox_x = InfoB_x; @@ -613,15 +615,17 @@ void CImageInfoNI::get_DF_Info() void CImageInfoNI::paint_DF_Info(int posx) { + ypos += sheight/2; + std::ostringstream buf; - int boxH = sheight-4; + int boxH = sheight - 2*OFFSET_INNER_MIN; int boxW = swidth*8; - int boxX = posx+width/3-boxW; - int boxY = ypos-sheight+2; + int boxX = posx + width/3 - boxW; + int boxY = ypos - sheight + OFFSET_INNER_MIN; get_DF_Info(); - buf << "Imagesize (" << image_size.percent << " Percent):"; + buf << "Imagesize (" << image_size.percent << "%):"; paintLine(posx, font_small, buf.str()); CProgressBar pb(boxX, boxY, boxW, boxH); @@ -711,18 +715,18 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy) posy += sheight/2; - int boxH = sheight-4; + int boxH = sheight - 2*OFFSET_INNER_MIN; int boxW = swidth*8; - int boxX = posx+width/3-boxW; - int boxY = posy-sheight+2; + int boxX = posx + width/3 - boxW; + int boxY = posy - sheight + OFFSET_INNER_MIN ; get_MEM_Info(); int mem_percent = get_MEM_Percent(mem_info.total, mem_info.used); - buf << "Memory (" << mem_percent << " Percent):"; + buf << "Memory (" << mem_percent << "%):"; // progressbar ist in same line - so we not can use max_text_width - frameBuffer->paintBoxRel(posx-10,posy-sheight,boxX-posx+10,sheight, COL_INFOBAR_PLUS_0); - g_Font[font_small]->RenderString(posx, posy, boxX-posx, buf.str().c_str(), COL_INFOBAR_TEXT); + frameBuffer->paintBoxRel(posx, posy - sheight, boxX - posx, sheight, COL_INFOBAR_PLUS_0); + g_Font[font_small]->RenderString(posx, posy, boxX - posx, buf.str().c_str(), COL_INFOBAR_TEXT); CProgressBar pb(boxX, boxY, boxW, boxH); pb.setFrameThickness(0); @@ -735,7 +739,7 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy) buf.str(""); buf.precision(2); buf << fixed << "Total: " << (mem_info.total/1024.0) << " MB Used: " << (mem_info.used/1024.0) << " MB"; - frameBuffer->paintBoxRel(posx-10,posy-sheight,max_text_width+10,sheight, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(posx, posy - sheight, max_text_width, sheight, COL_INFOBAR_PLUS_0); g_Font[font_small]->RenderString(posx, posy, max_text_width, buf.str().c_str(), COL_INFOBAR_TEXT); posy+= sheight; @@ -747,7 +751,7 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy) << "Cached: " << (mem_info.cached < 1024 ? mem_info.cached : (mem_info.cached/1024.0)) << (mem_info.cached < 1024?" KB":" MB)"); - frameBuffer->paintBoxRel(posx-10,posy-sheight,max_text_width+10,sheight, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(posx, posy - sheight, max_text_width, sheight, COL_INFOBAR_PLUS_0); g_Font[font_small]->RenderString(posx, posy, max_text_width, buf.str().c_str(), COL_INFOBAR_TEXT); } @@ -814,10 +818,10 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy) posy += sheight/2; posy += 3*sheight + sheight/2; //height meminfo above that - int boxH = sheight-4; + int boxH = sheight - 2*OFFSET_INNER_MIN; int boxW = swidth*8; - int boxX = posx+width/3-boxW; - int boxY = posy-sheight+2; + int boxX = posx + width/3 - boxW; + int boxY = posy - sheight + OFFSET_INNER_MIN ; /* * write testing: @@ -859,7 +863,7 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy) #else # ifdef BOXMODEL_CS_HD2 int max_bit = 104857600; /* Shiner, Kronos */ - if (cs_get_revision() == 9) + if (revision == 9) max_bit = 1073741824; /* Apollo */ # else ifdef int max_bit = 104857600; @@ -884,8 +888,8 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy) sprintf(temp_string,"Interface %s (%d%%):", netIfName.c_str(), percent); // progressbar ist in same line - so we not can use max_text_width - frameBuffer->paintBoxRel(posx-10,posy-sheight,boxX-posx+10,sheight, COL_INFOBAR_PLUS_0); - g_Font[font_small]->RenderString(posx, posy, boxX-posx, temp_string, COL_INFOBAR_TEXT); + frameBuffer->paintBoxRel(posx, posy - sheight, boxX - posx, sheight, COL_INFOBAR_PLUS_0); + g_Font[font_small]->RenderString(posx, posy, boxX - posx, temp_string, COL_INFOBAR_TEXT); CProgressBar pb(boxX, boxY, boxW, boxH); pb.setFrameThickness(0); @@ -897,13 +901,13 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy) posy+= sheight; sprintf(temp_string,"Receive: %llu bit/s Transmit: %llu bit/s",(long long unsigned int)rbit_s,(long long unsigned int)wbit_s); - frameBuffer->paintBoxRel(posx-10,posy-sheight,max_text_width+10,sheight, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(posx, posy - sheight, max_text_width, sheight, COL_INFOBAR_PLUS_0); g_Font[font_small]->RenderString(posx, posy, max_text_width, temp_string, COL_INFOBAR_TEXT); posy+= sheight; sprintf(temp_string,"Maximal: %llu bit/s - %.2f MB/s (%d%%)",(long long unsigned int)net_best,net_best/(8.0*1024.0*1024.0),(int)((net_best*100)/max_bit)); - frameBuffer->paintBoxRel(posx-10,posy-sheight,max_text_width+10,sheight, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel(posx, posy - sheight, max_text_width, sheight, COL_INFOBAR_PLUS_0); g_Font[font_small]->RenderString(posx, posy, max_text_width, temp_string, COL_INFOBAR_TEXT); last_tv.tv_sec = tv.tv_sec; diff --git a/src/gui/imageinfo_ni.h b/src/gui/imageinfo_ni.h index 0b19cca63..d0e28a037 100644 --- a/src/gui/imageinfo_ni.h +++ b/src/gui/imageinfo_ni.h @@ -61,7 +61,7 @@ class CImageInfoNI : public CMenuTarget int netMaxBit; void paint(); - void paint_pig(int x, int y, int w, int h); + void paint_pic(int x, int y, int w, int h); void paintLine(int xpos, int font, std::string text); void clearLine(int xpos, int font); @@ -111,6 +111,7 @@ class CImageInfoNI : public CMenuTarget void StopInfoThread(); int systemfs; + int revision; int old_x; int old_y;