imageinfo_ni: small offset corrections and cleanups

Origin commit data
------------------
Branch: ni/coolstream
Commit: 47b98e5879
Author: vanhofen <vanhofen@gmx.de>
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
This commit is contained in:
vanhofen
2017-03-03 23:33:41 +01:00
parent f1241ccd6d
commit df7c99fcc7
2 changed files with 30 additions and 24 deletions

View File

@@ -114,6 +114,10 @@ void CImageInfoNI::Init(void)
x = getScreenStartX(width); x = getScreenStartX(width);
y = getScreenStartY(height); y = getScreenStartY(height);
// This single correction saves many offsets in code below
x += OFFSET_INNER_MID;
width -= OFFSET_INNER_MID;
systemfs = 0; systemfs = 0;
revision = cs_get_revision(); revision = cs_get_revision();
old_x = 0; old_x = 0;
@@ -122,9 +126,9 @@ void CImageInfoNI::Init(void)
read_old = 0; read_old = 0;
write_old = 0; write_old = 0;
net_best = 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); 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; offset = 0;
for (int i = 0; i < info_items_count; i++) { for (int i = 0; i < info_items_count; i++) {
@@ -161,7 +165,7 @@ int CImageInfoNI::exec(CMenuTarget* parent, const std::string &)
fader.StartFadeIn(); fader.StartFadeIn();
bool fadeout = false; bool fadeout = false;
paint(); paint();
paint_pig(xcpu, y + OFFSET_INNER_MID, width/3, height/3); paint_pic(xcpu, y + OFFSET_INNER_MID, width/3, height/3);
StartInfoThread(); StartInfoThread();
while (1) while (1)
@@ -239,7 +243,7 @@ void CImageInfoNI::hide()
frameBuffer->paintBackground(); 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); 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); 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) void CImageInfoNI::clearLine(int xpos, int font)
{ {
int font_height = g_Font[font]->getHeight(); 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() void CImageInfoNI::paint()
{ {
const char * head_string; int xpos = x;
int xpos = x + OFFSET_INNER_MID;
ypos = y; ypos = y;
const char * head_string;
head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD); head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD);
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string);
//background //background
frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_INFOBAR_PLUS_0); 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; ypos += hheight;
g_Font[font_head]->RenderString(xpos, ypos, max_text_width, head_string, COL_MENUHEAD_TEXT); 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); paintLine(xpos+offset, font_info, homepage);
ypos += iheight; ypos += iheight;
ypos += sheight;
get_MTD_Info(); get_MTD_Info();
//paint_MTD_Info(xpos); //paint_MTD_Info(xpos);
//ypos+= sheight; //ypos += sheight;
paint_DF_Info(xpos); paint_DF_Info(xpos);
ypos+= sheight; ypos+= sheight;
paint_Stat_Info_Box(xcpu, ycpu, width/3, height/3); paint_Stat_Info_Box(xcpu, ycpu, width/3, height/3);
@@ -357,8 +361,8 @@ void* CImageInfoNI::InfoProc(void *arg)
CImageInfoNI *imageInfo = (CImageInfoNI*) arg; CImageInfoNI *imageInfo = (CImageInfoNI*) arg;
while(1) { while(1) {
imageInfo->paint_MEM_Info(imageInfo->x + OFFSET_INNER_MID, imageInfo->ypos); imageInfo->paint_MEM_Info(imageInfo->x, imageInfo->ypos);
imageInfo->paint_NET_Info(imageInfo->x + OFFSET_INNER_MID, imageInfo->ypos); imageInfo->paint_NET_Info(imageInfo->x, imageInfo->ypos);
sleep(1); sleep(1);
} }
return 0; return 0;
@@ -606,6 +610,8 @@ void CImageInfoNI::get_DF_Info()
void CImageInfoNI::paint_DF_Info(int posx) void CImageInfoNI::paint_DF_Info(int posx)
{ {
ypos += sheight/2;
std::ostringstream buf; std::ostringstream buf;
int boxH = sheight - 2*OFFSET_INNER_MIN; int boxH = sheight - 2*OFFSET_INNER_MIN;
int boxW = swidth*8; int boxW = swidth*8;
@@ -614,7 +620,7 @@ void CImageInfoNI::paint_DF_Info(int posx)
get_DF_Info(); get_DF_Info();
buf << "Imagesize (" << image_size.percent << " Percent):"; buf << "Imagesize (" << image_size.percent << "%):";
paintLine(posx, font_small, buf.str()); paintLine(posx, font_small, buf.str());
CProgressBar pb(boxX, boxY, boxW, boxH); CProgressBar pb(boxX, boxY, boxW, boxH);
@@ -712,10 +718,10 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy)
get_MEM_Info(); get_MEM_Info();
int mem_percent = get_MEM_Percent(mem_info.total, mem_info.used); 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 // 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); 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); g_Font[font_small]->RenderString(posx, posy, boxX - posx, buf.str().c_str(), COL_INFOBAR_TEXT);
CProgressBar pb(boxX, boxY, boxW, boxH); CProgressBar pb(boxX, boxY, boxW, boxH);
pb.setFrameThickness(0); pb.setFrameThickness(0);
@@ -728,7 +734,7 @@ void CImageInfoNI::paint_MEM_Info(int posx, int posy)
buf.str(""); buf.str("");
buf.precision(2); buf.precision(2);
buf << fixed << "Total: " << (mem_info.total/1024.0) << " MB Used: " << (mem_info.used/1024.0) << " MB"; 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); g_Font[font_small]->RenderString(posx, posy, max_text_width, buf.str().c_str(), COL_INFOBAR_TEXT);
posy+= sheight; 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)) << "Cached: " << (mem_info.cached < 1024 ? mem_info.cached : (mem_info.cached/1024.0))
<< (mem_info.cached < 1024?" KB":" MB)"); << (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); 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); sprintf(temp_string,"Interface eth0 (%d%%):",percent);
// progressbar ist in same line - so we not can use max_text_width // 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); 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); g_Font[font_small]->RenderString(posx, posy, boxX - posx, temp_string, COL_INFOBAR_TEXT);
CProgressBar pb(boxX, boxY, boxW, boxH); CProgressBar pb(boxX, boxY, boxW, boxH);
pb.setFrameThickness(0); pb.setFrameThickness(0);
@@ -882,13 +888,13 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy)
posy+= sheight; 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); 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); g_Font[font_small]->RenderString(posx, posy, max_text_width, temp_string, COL_INFOBAR_TEXT);
posy+= sheight; 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)); 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); g_Font[font_small]->RenderString(posx, posy, max_text_width, temp_string, COL_INFOBAR_TEXT);
last_tv.tv_sec = tv.tv_sec; last_tv.tv_sec = tv.tv_sec;

View File

@@ -59,7 +59,7 @@ class CImageInfoNI : public CMenuTarget
int font_small; int font_small;
void paint(); 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 paintLine(int xpos, int font, std::string text);
void clearLine(int xpos, int font); void clearLine(int xpos, int font);