From 4fa3a245dfe35e34e940bc60404bf4847359ae10 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Tue, 21 Jan 2014 17:24:05 +0100 Subject: [PATCH] CSignalBar: Fix display "value caption" --- src/gui/components/cc_frm_signalbars.cpp | 34 +++++++++++++----------- src/gui/components/cc_frm_signalbars.h | 13 +++------ src/gui/motorcontrol.cpp | 1 - src/gui/scan.cpp | 1 - src/gui/streaminfo2.cpp | 1 - 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index d50bf21e1..df2e1d27d 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -41,6 +41,8 @@ CSignalBar::CSignalBar() { initVarSigBar(); sb_name = "SIG"; + + initDimensions(); initSBItems(); } @@ -54,6 +56,7 @@ CSignalBar::CSignalBar(const int& xpos, const int& ypos, const int& w, const int height = h; sb_name = sbname; + initDimensions(); initSBItems(); } @@ -65,15 +68,14 @@ void CSignalBar::initDimensions() if (sb_scale_height == -1) sb_scale_height = sb_item_height; - //use value in % of signalbox width for scale, rest is reserved for caption - sb_scale_width = width*sb_scale_w_percent/100; + int dx = 0; + int dy = min(sb_item_height, 100); + sb_font = *dy_font->getDynFont(dx, dy, "100% "+sb_name); + dx += dx/10; + sb_scale_width = width - dx; - int dx = width - sb_scale_width; - int dy = sb_item_height; - sb_font = *dy_font->getDynFont(dx, dy); - - //use 15% for value and name label - sb_vlbl_width = sb_lbl_width = dx /2; + sb_vlbl_width = sb_font->getRenderWidth("100% ") + dx/20; + sb_lbl_width = dx - sb_vlbl_width; } void CSignalBar::initSBItems() @@ -87,9 +89,6 @@ void CSignalBar::initSBItems() sb_caption_color = sbx->getTextColor(); } - //reinit dimensions - initDimensions(); - //init items scale, value and name initSBarScale(); initSBarValue(); @@ -105,7 +104,6 @@ void CSignalBar::initVarSigBar() height = SB_MIN_HEIGHT; sb_scale_height = -1; - sb_scale_w_percent = 60; dy_font = CNeutrinoFonts::getInstance(); sb_caption_color= COL_INFOBAR_TEXT; @@ -170,7 +168,7 @@ void CSignalBar::initSBarName() if (sb_lbl == NULL){ sb_lbl = new CComponentsLabel(); sb_lbl->doPaintBg(false); - sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK/* | CTextBox::RIGHT*/, sb_font); + sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font); sb_lbl->forceTextPaint(); sb_lbl->doPaintTextBoxBg(true); } @@ -299,7 +297,6 @@ void CSignalBox::initVarSigBox() sbx_bar_height = height/2; sbx_bar_x = corner_rad; sbx_caption_color = COL_INFOBAR_TEXT; - sbx_scale_w_percent = 60; vertical = true; } @@ -316,17 +313,22 @@ void CSignalBox::initSignalItems() int sbar_x = sbx_bar_x + fr_thickness; int scale_h = sbar_h * 76 / 100; + int sbar_sw = sbar->getScaleWidth(); + int snrbar_sw = snrbar->getScaleWidth(); + if (sbar_sw < snrbar_sw) + snrbar->setScaleWidth(sbar_sw); + else if (snrbar_sw < sbar_sw) + sbar->setScaleWidth(snrbar_sw); + sbar->setDimensionsAll(sbar_x, fr_thickness, sbar_w, sbar_h); sbar->setFrontEnd(sbx_frontend); sbar->setCorner(0); sbar->setScaleHeight(scale_h); - sbar->setScaleWidth(sbx_scale_w_percent); snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : fr_thickness, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setCorner(0); snrbar->setScaleHeight(scale_h); - snrbar->setScaleWidth(sbx_scale_w_percent); } void CSignalBox::paintScale() diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index c18344142..c7474ffa7 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -88,9 +88,6 @@ class CSignalBar : public CComponentsForm int sb_lastsig; ///current signal value uint16_t sb_signal; - - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sb_scale_w_percent; ///initialize all needed basich attributes and objects void initVarSigBar(); @@ -126,7 +123,7 @@ class CSignalBar : public CComponentsForm ///assigns the height of scale virtual void setScaleHeight(const int& scale_height){sb_scale_height = scale_height;}; ///assigns the width of scale - virtual void setScaleWidth(const short & scale_width_percent){sb_scale_w_percent = scale_width_percent;}; + virtual void setScaleWidth(const int & scale_width){sb_scale_width = scale_width;}; ///assigns the name of signal value in the caption object, see also sb_name virtual void setName(const std::string& name){sb_name = name;}; @@ -136,6 +133,8 @@ class CSignalBar : public CComponentsForm virtual CComponentsLabel* getLabelValObject(){return sb_vlbl;}; ///returns the name label object, type = CComponentsLabel* virtual CComponentsLabel* getLabelNameObject(){return sb_lbl;}; + /// return the scale width + virtual int getScaleWidth(){ return sb_scale_width;}; ///paint this items virtual void paint(bool do_save_bg); @@ -256,9 +255,6 @@ class CSignalBox : public CComponentsForm ///property: text color, see also setTextColor() fb_pixel_t sbx_caption_color; - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sbx_scale_w_percent; - // true if vertical arrangement, false if horizontal bool vertical; @@ -283,9 +279,6 @@ class CSignalBox : public CComponentsForm void setTextColor(const fb_pixel_t& caption_color){ sbx_caption_color = caption_color;}; ///get caption color of signalbars, see also property 'sbx_caption_color' fb_pixel_t getTextColor(){return sbx_caption_color;}; - - ///assigns the width of scale in percent related of full width of signal box, the rest is reserved for text - void setScaleWidth(const short & scale_width_percent){sbx_scale_w_percent = scale_width_percent;}; ///paint items void paint(bool do_save_bg); diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index f23aa878f..fbe2581bc 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -582,7 +582,6 @@ void CMotorControl::showSNR () if (signalbox == NULL){ int xpos1 = x + 10; signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 2ed59771f..d0f0493d8 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -552,7 +552,6 @@ void CScanTs::showSNR () if (signalbox == NULL){ CFrontend * frontend = CServiceScan::getInstance()->GetFrontend(); signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 9447241d0..2c61b5819 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -886,7 +886,6 @@ void CStreamInfo2::showSNR () { if (signalbox == NULL){ signalbox = new CSignalBox(x + 10, yypos, 240, 50, frontend); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUHEAD_PLUS_0); signalbox->setTextColor(COL_INFOBAR_TEXT); signalbox->doPaintBg(true);