From df7c99fcc703ec7c3faad3914ba7e4200b7899a5 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 3 Mar 2017 23:33:41 +0100 Subject: [PATCH] imageinfo_ni: small offset corrections and cleanups Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/47b98e5879404b572706c090429d34f21e8d2131 Author: vanhofen Date: 2017-03-03 (Fri, 03 Mar 2017) Origin message was: ------------------ - imageinfo_ni: small offset corrections and cleanups ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/imageinfo_ni.cpp | 52 ++++++++++++++++++++++------------------ src/gui/imageinfo_ni.h | 2 +- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/gui/imageinfo_ni.cpp b/src/gui/imageinfo_ni.cpp index f45f6b19b..018b234fe 100644 --- a/src/gui/imageinfo_ni.cpp +++ b/src/gui/imageinfo_ni.cpp @@ -114,6 +114,10 @@ void CImageInfoNI::Init(void) 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; @@ -122,9 +126,9 @@ void CImageInfoNI::Init(void) read_old = 0; write_old = 0; net_best = 0; - xcpu = width - width/3 - OFFSET_INNER_MID; + 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 - 2*OFFSET_INNER_MID; + max_text_width = xcpu - x - OFFSET_INNER_MID; offset = 0; for (int i = 0; i < info_items_count; i++) { @@ -161,7 +165,7 @@ int CImageInfoNI::exec(CMenuTarget* parent, const std::string &) fader.StartFadeIn(); bool fadeout = false; paint(); - paint_pig(xcpu, y + OFFSET_INNER_MID, width/3, height/3); + paint_pic(xcpu, y + OFFSET_INNER_MID, width/3, height/3); StartInfoThread(); while (1) @@ -239,7 +243,7 @@ void CImageInfoNI::hide() frameBuffer->paintBackground(); } -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 - 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); @@ -253,22 +257,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 + OFFSET_INNER_MID; - + 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); @@ -336,14 +342,12 @@ void CImageInfoNI::paint() paintLine(xpos+offset, font_info, homepage); ypos += iheight; - ypos += sheight; get_MTD_Info(); //paint_MTD_Info(xpos); - //ypos+= sheight; + //ypos += sheight; paint_DF_Info(xpos); - ypos+= sheight; paint_Stat_Info_Box(xcpu, ycpu, width/3, height/3); @@ -357,8 +361,8 @@ void* CImageInfoNI::InfoProc(void *arg) CImageInfoNI *imageInfo = (CImageInfoNI*) arg; while(1) { - imageInfo->paint_MEM_Info(imageInfo->x + OFFSET_INNER_MID, imageInfo->ypos); - imageInfo->paint_NET_Info(imageInfo->x + OFFSET_INNER_MID, imageInfo->ypos); + imageInfo->paint_MEM_Info(imageInfo->x, imageInfo->ypos); + imageInfo->paint_NET_Info(imageInfo->x, imageInfo->ypos); sleep(1); } return 0; @@ -606,6 +610,8 @@ void CImageInfoNI::get_DF_Info() void CImageInfoNI::paint_DF_Info(int posx) { + ypos += sheight/2; + std::ostringstream buf; int boxH = sheight - 2*OFFSET_INNER_MIN; int boxW = swidth*8; @@ -614,7 +620,7 @@ void CImageInfoNI::paint_DF_Info(int posx) 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); @@ -712,10 +718,10 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy) 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 - OFFSET_INNER_MID, posy - sheight, boxX - posx + OFFSET_INNER_MID, 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); @@ -728,7 +734,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 - OFFSET_INNER_MID, posy - sheight, max_text_width + OFFSET_INNER_MID, 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; @@ -740,7 +746,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 - OFFSET_INNER_MID, posy - sheight, max_text_width + OFFSET_INNER_MID, 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); } @@ -869,8 +875,8 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy) sprintf(temp_string,"Interface eth0 (%d%%):",percent); // progressbar ist in same line - so we not can use max_text_width - frameBuffer->paintBoxRel(posx - OFFSET_INNER_MID, posy - sheight, boxX - posx + OFFSET_INNER_MID, 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); @@ -882,13 +888,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 - OFFSET_INNER_MID, posy - sheight, max_text_width + OFFSET_INNER_MID, 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 - OFFSET_INNER_MID, posy - sheight, max_text_width + OFFSET_INNER_MID, 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 2ecd32cca..5a4259bc9 100644 --- a/src/gui/imageinfo_ni.h +++ b/src/gui/imageinfo_ni.h @@ -59,7 +59,7 @@ class CImageInfoNI : public CMenuTarget int font_small; 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);