- streaminfo2: some position fixes; mosty on the right side

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2019-03-16 21:15:46 +01:00
committed by Thilo Graf
parent 2a833fbfc1
commit 255c4ded31
2 changed files with 69 additions and 79 deletions

View File

@@ -406,7 +406,7 @@ int CStreamInfo2::exec (CMenuTarget * parent, const std::string &)
frontend = mp ? NULL : CFEManager::getInstance()->getLiveFE(); frontend = mp ? NULL : CFEManager::getInstance()->getLiveFE();
fader.StartFadeIn(); fader.StartFadeIn();
paint (paint_mode); paint(paint_mode);
int res = doSignalStrengthLoop (); int res = doSignalStrengthLoop ();
hide (); hide ();
fader.StopFade(); fader.StopFade();
@@ -415,8 +415,6 @@ int CStreamInfo2::exec (CMenuTarget * parent, const std::string &)
int CStreamInfo2::doSignalStrengthLoop () int CStreamInfo2::doSignalStrengthLoop ()
{ {
#define BAR_WIDTH 150
#define BAR_HEIGHT 12
int res = menu_return::RETURN_REPAINT; int res = menu_return::RETURN_REPAINT;
bool fadeout = false; bool fadeout = false;
@@ -428,7 +426,7 @@ int CStreamInfo2::doSignalStrengthLoop ()
char tmp_str[150]; char tmp_str[150];
int delay_counter = 0; int delay_counter = 0;
const int delay = 15; const int delay = 15;
int sw = 3 * g_FixedFont[font_small]->getRenderWidth(" ") + 8 * g_FixedFont[font_small]->getMaxDigitWidth(); int sw = 2*g_FixedFont[font_info]->getRenderWidth(".") + 8*g_FixedFont[font_info]->getMaxDigitWidth();
maxb = minb = lastb = tmp_rate = 0; maxb = minb = lastb = tmp_rate = 0;
bool repaint_bitrate = true; bool repaint_bitrate = true;
ts_setup (); ts_setup ();
@@ -483,17 +481,10 @@ int CStreamInfo2::doSignalStrengthLoop ()
repaint_bitrate = false; repaint_bitrate = false;
} }
frameBuffer->paintBoxRel (dx1 + spaceoffset, average_bitrate_pos - iheight, sw, iheight, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel(dx1 + spaceoffset, average_bitrate_pos - iheight, sw, iheight, COL_MENUCONTENT_PLUS_0);
char currate[140]; char currate[140];
snprintf(currate, sizeof(currate), "%10u", rate.short_average); snprintf(currate, sizeof(currate), "%u.%03u.%03u", (rate.short_average / 1000 / 1000) % 1000, (rate.short_average / 1000) % 1000, rate.short_average % 1000);
currate[0] = currate[2]; g_FixedFont[font_info]->RenderString(dx1 + spaceoffset, average_bitrate_pos, sw, currate, COL_MENUCONTENT_TEXT);
currate[1] = currate[3];
currate[2] = ' ';
currate[3] = currate[4];
currate[4] = currate[5];
currate[5] = currate[6];
currate[6] = ' ';
g_FixedFont[font_info]->RenderString (dx1 + spaceoffset, average_bitrate_pos, sw, currate, COL_MENUCONTENT_TEXT);
lastb = bit_s; lastb = bit_s;
} }
if ((!mp && pmt_version != current_pmt_version && delay_counter > delay) || probed) if ((!mp && pmt_version != current_pmt_version && delay_counter > delay) || probed)
@@ -565,7 +556,7 @@ int CStreamInfo2::doSignalStrengthLoop ()
{ {
hide (); hide ();
paint_mode = !paint_mode; paint_mode = !paint_mode;
paint (paint_mode); paint(paint_mode);
repaint_bitrate = true; repaint_bitrate = true;
continue; continue;
} }
@@ -610,7 +601,7 @@ int CStreamInfo2::doSignalStrengthLoop ()
void CStreamInfo2::hide () void CStreamInfo2::hide ()
{ {
pip->hide(); pip->hide();
frameBuffer->paintBackgroundBoxRel (0, 0, max_width, max_height); frameBuffer->paintBackgroundBoxRel(0, 0, max_width, max_height);
frameBuffer->blit(); frameBuffer->blit();
} }
@@ -628,57 +619,48 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
else else
tname += to_string(1 + frontend->getNumber()) + ": " + frontend->getName(); tname += to_string(1 + frontend->getNumber()) + ": " + frontend->getName();
g_FixedFont[font_small]->RenderString(_x, _y + iheight, width - _x - OFFSET_INNER_MID, tname /*tuner_name.c_str()*/, COL_MENUCONTENT_TEXT); g_FixedFont[font_small]->RenderString(_x, _y + sheight, w, tname, COL_MENUCONTENT_TEXT);
sigBox_x = _x; sigBox_x = _x;
sigBox_y = _y + iheight + OFFSET_INNER_MID; sigBox_y = _y + sheight + OFFSET_INNER_SMALL;
sigBox_w = w; sigBox_w = w;
sigBox_h = h - iheight - OFFSET_INNER_MID; sigBox_h = h - sheight - OFFSET_INNER_SMALL;
frameBuffer->paintBoxRel(sigBox_x, sigBox_y, sigBox_w, sigBox_h, COL_BLACK); frameBuffer->paintBoxRel(sigBox_x, sigBox_y, sigBox_w, sigBox_h, COL_BLACK);
sig_text_y = sigBox_y + sigBox_h + OFFSET_INNER_SMALL;
int y1 = sig_text_y + sheight + OFFSET_INNER_SMALL; sig_text_y = _y + h + OFFSET_INNER_MID;
sig_text_w = w/5;
int y1 = sig_text_y + sheight;
int fw = g_FixedFont[font_small]->getWidth(); int fw = g_FixedFont[font_small]->getWidth();
int maxmin_x; // x-position of min and max int col = 1;
int fontW = g_FixedFont[font_small]->getWidth(); std::string str;
int xd;
int col = 0;
if (paint_mode == 0)
{
maxmin_x = _x;
xd = (w - 5 * fontW)/4;
_x += 5 * fontW;
}
else
{
maxmin_x = _x + 40;
xd = (w - 5 * fontW + 40)/5;
col = 1;
}
g_FixedFont[font_small]->RenderString(maxmin_x, y1 + (sheight * 1) +OFFSET_INNER_SMALL, fw*3, "max", COL_MENUCONTENT_TEXT);
g_FixedFont[font_small]->RenderString(maxmin_x, y1 + (sheight * 2) +OFFSET_INNER_SMALL, fw*3, "now", COL_MENUCONTENT_TEXT);
g_FixedFont[font_small]->RenderString(maxmin_x, y1 + (sheight * 3) +OFFSET_INNER_SMALL, fw*3, "min", COL_MENUCONTENT_TEXT);
if (!mp) if (!mp)
{ {
g_FixedFont[font_small]->RenderString(_x+xd*col, y1, fw*8, "BER [%]", COL_RED); sig_text_ber_x = _x + sig_text_w*col;
sig_text_ber_x = _x + OFFSET_INNER_SMALL + xd * col; SignalRenderHead("BER [%]", sig_text_ber_x, y1, COL_RED);
col++; col++;
g_FixedFont[font_small]->RenderString(_x+xd*col, y1, fw*8, "SNR [%]", COL_LIGHT_BLUE); sig_text_snr_x = _x + sig_text_w*col;
sig_text_snr_x = _x + OFFSET_INNER_SMALL + xd * col; SignalRenderHead("SNR [%]", sig_text_snr_x, y1, COL_LIGHT_BLUE);
col++; col++;
g_FixedFont[font_small]->RenderString(_x+xd*col, y1, fw*8, "SIG [%]", COL_GREEN); sig_text_sig_x = _x + sig_text_w*col;
sig_text_sig_x = _x + OFFSET_INNER_SMALL + xd * col; SignalRenderHead("SIG [%]", sig_text_sig_x, y1, COL_GREEN);
col++; col++;
} }
else
col = 4;
g_FixedFont[font_small]->RenderString(_x+xd*col, y1, fw*10, "BR [kbps]", COL_YELLOW); sig_text_rate_x = _x + sig_text_w*col;
sig_text_rate_x = _x + OFFSET_INNER_SMALL + xd * col; SignalRenderHead("BR [kbps]", sig_text_rate_x, y1, COL_YELLOW);
y1 += OFFSET_INNER_SMALL;
g_FixedFont[font_small]->RenderString(_x, y1 + (sheight * 1), fw*3, "max", COL_MENUCONTENT_TEXT);
g_FixedFont[font_small]->RenderString(_x, y1 + (sheight * 2), fw*3, "now", COL_MENUCONTENT_TEXT);
g_FixedFont[font_small]->RenderString(_x, y1 + (sheight * 3), fw*3, "min", COL_MENUCONTENT_TEXT);
sigBox_pos = 0; sigBox_pos = 0;
@@ -690,7 +672,7 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s) void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
{ {
int x_now = sigBox_pos; int x_now = sigBox_pos;
int yt = sig_text_y + (sheight *2) + OFFSET_INNER_SMALL; int yt = sig_text_y + OFFSET_INNER_SMALL + (sheight*2);
int yd; int yd;
static int old_x=0, old_y=0; static int old_x=0, old_y=0;
sigBox_pos++; sigBox_pos++;
@@ -777,14 +759,19 @@ int CStreamInfo2::y_signal_fe(unsigned long value, unsigned long max_value, int
return (int) l; return (int) l;
} }
void CStreamInfo2::SignalRenderHead(std::string head, int _x, int _y, fb_pixel_t color)
{
frameBuffer->paintBoxRel(_x, _y - sheight, sig_text_w, sheight, COL_MENUCONTENT_PLUS_0);
int tw = g_FixedFont[font_small]->getRenderWidth(head);
g_FixedFont[font_small]->RenderString(_x + (sig_text_w - tw)/2, _y, tw, head, color);
}
void CStreamInfo2::SignalRenderStr(unsigned int value, int _x, int _y) void CStreamInfo2::SignalRenderStr(unsigned int value, int _x, int _y)
{ {
char str[30]; frameBuffer->paintBoxRel(_x, _y - sheight, sig_text_w, sheight, COL_MENUCONTENT_PLUS_0);
int fw = g_FixedFont[font_small]->getWidth(); std::string val = to_string(value);
fw *=(fw>17)?5:6; int tw = g_FixedFont[font_small]->getRenderWidth(val);
frameBuffer->paintBoxRel(_x, _y - sheight + OFFSET_INNER_SMALL, fw, sheight -1, COL_MENUCONTENT_PLUS_0); g_FixedFont[font_small]->RenderString(_x + (sig_text_w - tw)/2, _y, tw, val, COL_MENUCONTENT_TEXT);
sprintf(str,"%6u",value);
g_FixedFont[font_small]->RenderString(_x, _y + OFFSET_INNER_SMALL, fw, str, COL_MENUCONTENT_TEXT);
} }
void CStreamInfo2::paint (int /*mode*/) void CStreamInfo2::paint (int /*mode*/)
@@ -798,39 +785,37 @@ void CStreamInfo2::paint (int /*mode*/)
int ypos = y + OFFSET_INNER_SMALL; int ypos = y + OFFSET_INNER_SMALL;
int xpos = x + OFFSET_INNER_MID; int xpos = x + OFFSET_INNER_MID;
// paint backround
frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0);
if (paint_mode == 0) if (paint_mode == 0)
{ {
// -- tech Infos, PIG, small signal graph // tech infos, pip, signal graph
head_string = g_Locale->getText (LOCALE_STREAMINFO_HEAD); head_string = g_Locale->getText(LOCALE_STREAMINFO_HEAD);
CVFD::getInstance ()->setMode (CVFD::MODE_MENU_UTF8, head_string); CVFD::getInstance ()->setMode(CVFD::MODE_MENU_UTF8, head_string);
// paint backround, title pig, etc. g_FixedFont[font_head]->RenderString(xpos, ypos + hheight, width, head_string, COL_MENUHEAD_TEXT);
frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0);
g_FixedFont[font_head]->RenderString (xpos, ypos + hheight, width, head_string, COL_MENUHEAD_TEXT);
ypos += hheight + iheight;
if (pip == NULL) if (pip == NULL)
pip = new CComponentsPIP(width - width/3 - OFFSET_INNER_MID, y + OFFSET_INNER_MID, 33); pip = new CComponentsPIP(width - width/3 - OFFSET_INNER_MID, ypos, 33);
pip->paint(CC_SAVE_SCREEN_NO); pip->paint(CC_SAVE_SCREEN_NO);
paint_signal_fe_box(pip->getXPos(), pip->getYPos() + pip->getHeight() + OFFSET_INNER_MID, pip->getWidth(), pip->getHeight());
ypos += hheight + iheight;
techinfo_xpos = xpos; techinfo_xpos = xpos;
techinfo_ypos = ypos; techinfo_ypos = ypos;
paint_techinfo (xpos, ypos); paint_techinfo(xpos, ypos);
paint_signal_fe_box (width - width/3 - OFFSET_INNER_MID, (y + OFFSET_INNER_MID + height/3 + hheight), pip->getWidth(), height/3 + hheight);
} }
else else
{ {
delete signalbox; delete signalbox;
signalbox = NULL; signalbox = NULL;
// -- small PIG, small signal graph // large signal graph
// -- paint backround, title pig, etc. paint_signal_fe_box(x, y, width, height - OFFSET_INNER_SMALL - 4*iheight);
frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0);
// -- paint large signal graph
paint_signal_fe_box (x, y, width, height-100);
} }
} }
@@ -852,11 +837,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
int xres = 0, yres = 0, aspectRatio = 0, framerate = -1, i = 0; int xres = 0, yres = 0, aspectRatio = 0, framerate = -1, i = 0;
// paint labels // paint labels
int ypos1 = ypos; int ypos1 = ypos;
box_width = width*2/3 - OFFSET_INNER_MID - xpos; box_width = width/3*2 - 2*OFFSET_INNER_MID - xpos;
yypos = ypos; yypos = ypos;
if (box_h > 0) if (box_h > 0)
frameBuffer->paintBoxRel (0, ypos, box_width, box_h, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel(0, ypos, box_width, box_h, COL_MENUCONTENT_PLUS_0);
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if (!channel && !mp) if (!channel && !mp)
@@ -959,6 +944,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.col = COL_MENUCONTENT_TEXT; r.col = COL_MENUCONTENT_TEXT;
v.push_back(r); v.push_back(r);
// empty line
r.key = r.val = ""; r.key = r.val = "";
v.push_back(r); v.push_back(r);
@@ -1116,6 +1102,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
} }
} }
// empty line
r.key = r.val = ""; r.key = r.val = "";
v.push_back(r); v.push_back(r);
@@ -1162,6 +1149,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
} }
} }
// empty line
r.key = r.val = ""; r.key = r.val = "";
v.push_back(r); v.push_back(r);
@@ -1230,9 +1218,9 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
for (std::vector<row>::iterator it = v.begin(); it != v.end(); ++it) for (std::vector<row>::iterator it = v.begin(); it != v.end(); ++it)
{ {
it->f->RenderString (xpos, ypos, spaceoffset, it->key, COL_MENUCONTENT_TEXT); it->f->RenderString(xpos, ypos, spaceoffset, it->key, COL_MENUCONTENT_TEXT);
std::string text = it->val.c_str(); std::string text = it->val.c_str();
it->f->RenderString (xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col); it->f->RenderString(xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col);
if (it < v.end() - 1) if (it < v.end() - 1)
ypos += it->f->getHeight(); ypos += it->f->getHeight();
} }

View File

@@ -65,6 +65,7 @@ class CStreamInfo2 : public CMenuTarget
int sigBox_h; int sigBox_h;
int sigBox_pos; int sigBox_pos;
int sig_text_y; int sig_text_y;
int sig_text_w;
int sig_text_ber_x; int sig_text_ber_x;
int sig_text_sig_x; int sig_text_sig_x;
int sig_text_snr_x; int sig_text_snr_x;
@@ -119,7 +120,8 @@ class CStreamInfo2 : public CMenuTarget
void paint_signal_fe_box(int x, int y, int w, int h); void paint_signal_fe_box(int x, int y, int w, int h);
void paint_signal_fe(struct bitrate rate, struct feSignal s); void paint_signal_fe(struct bitrate rate, struct feSignal s);
int y_signal_fe(unsigned long value, unsigned long max_range, int max_y); int y_signal_fe(unsigned long value, unsigned long max_range, int max_y);
void SignalRenderStr (unsigned int value, int x, int y); void SignalRenderHead(std::string head, int x, int y, fb_pixel_t color);
void SignalRenderStr(unsigned int value, int x, int y);
CSignalBox *signalbox; CSignalBox *signalbox;
void showSNR (); void showSNR ();