From 860be9a412125cf84a0b78e4a62633cda5d10941 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 1 Apr 2013 22:01:55 +0200 Subject: [PATCH] CComponents: add progressbar class to cc-items CProgressbar moved into components sub directory and adapt includes. Progressbar objects are now usable as cc-item TODO: -some color and size corrections -found some dub codes for sig and snr-bars, needs rework --- src/driver/volume.cpp | 11 +- src/gui/channellist.cpp | 35 +-- src/gui/components/Makefile.am | 1 + src/gui/components/cc.h | 4 +- src/gui/components/cc_base.cpp | 2 +- src/gui/components/cc_item_progressbar.cpp | 273 +++++++++++++++++ src/gui/components/cc_item_progressbar.h | 162 +++++++++++ src/gui/components/cc_types.h | 1 + src/gui/dboxinfo.cpp | 9 +- src/gui/epgview.cpp | 18 +- src/gui/infoviewer.cpp | 60 ++-- src/gui/infoviewer.h | 1 - src/gui/infoviewer_bb.cpp | 30 +- src/gui/infoviewer_bb.h | 2 +- src/gui/motorcontrol.cpp | 33 ++- src/gui/motorcontrol.h | 2 +- src/gui/moviebrowser.cpp | 35 ++- src/gui/scan.cpp | 19 +- src/gui/scan.h | 4 +- src/gui/streaminfo2.cpp | 13 +- src/gui/streaminfo2.h | 2 +- src/gui/timeosd.cpp | 8 +- src/gui/timeosd.h | 2 +- src/gui/widget/Makefile.am | 1 - src/gui/widget/progressbar.cpp | 323 --------------------- src/gui/widget/progressbar.h | 142 --------- src/neutrino.cpp | 4 - src/system/settings.h | 9 + 28 files changed, 616 insertions(+), 590 deletions(-) create mode 100644 src/gui/components/cc_item_progressbar.cpp create mode 100644 src/gui/components/cc_item_progressbar.h delete mode 100644 src/gui/widget/progressbar.cpp delete mode 100644 src/gui/widget/progressbar.h diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp index d2b3e65fa..d0c556f60 100644 --- a/src/driver/volume.cpp +++ b/src/driver/volume.cpp @@ -40,7 +40,7 @@ #include #if HAVE_COOL_HARDWARE -#include +#include #endif extern CRemoteControl * g_RemoteControl; @@ -111,7 +111,7 @@ void CVolume::Init() } if (volscale) delete volscale; - volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true); + volscale = new CProgressBar(progress_x, progress_y, progress_w, progress_h, colFrame, colBar, colShadow, COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1, true); // mute icon mute_icon_dx = 0; @@ -250,8 +250,6 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa frameBuffer->paintBoxRel(x+ShadowOffset , y+ShadowOffset , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colShadow, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); // volumebar frameBuffer->paintBoxRel(x , y , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colBar, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); - // frame for progress - frameBuffer->paintBoxRel(progress_x-pB, progress_y-pB, progress_w+pB*2, progress_h+pB*2, colFrame); // volume icon frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar); @@ -343,8 +341,6 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa void CVolume::refreshVolumebar(int current_volume) { - // progressbar - volscale->paintProgressBar2(progress_x, progress_y, current_volume); if (paintDigits) { // shadow for erase digits if (paintShadow) @@ -356,6 +352,9 @@ void CVolume::refreshVolumebar(int current_volume) snprintf(buff, 4, "%3d", current_volume); g_Font[VolumeFont]->RenderString(digit_x, digit_y, digit_w, buff, colContent); } + // progressbar + volscale->setValues(current_volume, 100); + volscale->paint(); } bool CVolume::changeNotify(const neutrino_locale_t OptionName, void * data) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index ed422e7f1..6d2b251c6 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include @@ -1903,8 +1903,8 @@ void CChannelList::paintItem(int pos) else l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->getName().c_str()); - CProgressBar pb(false); /* never colored */ int pb_space = prg_offset - title_offset; + CProgressBar pb(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2); /* never colored */ int pb_max = pb_space - 4; if (!(p_event->description.empty())) { snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l,g_settings.channellist_epgtext_align_right ? " ":" - "); @@ -1945,15 +1945,12 @@ void CChannelList::paintItem(int pos) runningPercent = pb_max; // later on which can be fatal... } - int pb_activeCol , pb_passiveCol; - if (liststart + pos != selected) { - pb_activeCol = COL_MENUCONTENT_PLUS_3; - pb_passiveCol = COL_MENUCONTENT_PLUS_1; - } else { - pb_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; - pb_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; - } - pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, runningPercent, pb_max, pb_activeCol, pb_passiveCol, pb_activeCol); + if (liststart + pos != selected) + pb.setStatusColors(COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1); + else + pb.setStatusColors(COL_MENUCONTENTSELECTED_PLUS_2, COL_MENUCONTENTSELECTED_PLUS_0); + pb.setValues(runningPercent, pb_max); + pb.paint(); } } @@ -1969,15 +1966,13 @@ void CChannelList::paintItem(int pos) } else { if(g_settings.channellist_extended) { - int pbz_activeCol, pbz_passiveCol; - if (liststart + pos != selected) { - pbz_activeCol = COL_MENUCONTENT_PLUS_1; - pbz_passiveCol = COL_MENUCONTENT_PLUS_0; - } else { - pbz_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; - pbz_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; - } - pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, 0, pb_max, pbz_activeCol, pbz_passiveCol, pbz_activeCol, 0, NULL, 0, NULL, true); + if (liststart + pos != selected) + pb.setStatusColors(COL_MENUCONTENT_PLUS_2, COL_MENUCONTENT_PLUS_1); + else + pb.setStatusColors(COL_MENUCONTENTSELECTED_PLUS_2, COL_MENUCONTENTSELECTED_PLUS_0); + pb.setValues(0, pb_max); + pb.setZeroLine(); + pb.paint(); } //name g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10+prg_offset, ypos+ fheight, width- numwidth- 40- 15-prg_offset, nameAndDescription, color, 0, true); // UTF-8 diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 8e839e16b..1a6caf7d0 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -27,6 +27,7 @@ libneutrino_gui_components_a_SOURCES = \ cc_item_box.cpp \ cc_item_infobox.cpp \ cc_item_picture.cpp \ + cc_item_progressbar.cpp \ cc_item_shapes.cpp \ cc_item_text.cpp \ cc_item_tvpic.cpp diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index f8eaa5e9f..17dd0ca49 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -32,7 +32,7 @@ #include #include -// #define DEBUG_CC + #define DEBUG_CC class CComponents { @@ -46,7 +46,7 @@ class CComponents void initVarBasic(); void paintFbItems(bool do_save_bg = true); - fb_pixel_t* getScreen(int ax, int ay, int dx, int dy); + virtual fb_pixel_t* getScreen(int ax, int ay, int dx, int dy); comp_screen_data_t saved_screen; void clearSavedScreen(); diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index 7655019b9..313c29635 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -42,7 +42,7 @@ CComponents::CComponents() CComponents::~CComponents() { - hide(); + hide(); clearSavedScreen(); clear(); } diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp new file mode 100644 index 000000000..d12f68a1e --- /dev/null +++ b/src/gui/components/cc_item_progressbar.cpp @@ -0,0 +1,273 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + (C) 2008, 2013 by Thilo Graf + (C) 2009,2010,2013 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "cc_item_progressbar.h" + +#define ITEMW 4 +#define POINT 2 + +#define RED 0xFF0000 +#define GREEN 0x00FF00 +#define YELLOW 0xFFFF00 + +CProgressBar::CProgressBar() +{ + initVarProgressbar(); +} + +CProgressBar::CProgressBar( const int x_pos, const int y_pos, const int w, const int h, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow, + const fb_pixel_t active_col, const fb_pixel_t passive_col, + const bool blinkenlights, + const int r, const int g, const int b, + const bool inv) +{ + initVarProgressbar(); + + //CComponents + x = x_pos; + y = y_pos; + width = w; + height = h; + + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + pb_blink = blinkenlights; + pb_invert = inv; + pb_red = r; + pb_green = g; + pb_yellow = b; + pb_active_col = active_col; + pb_passive_col = passive_col; +} + + +void CProgressBar::initVarProgressbar() +{ + //CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_PROGRESSBAR; + fr_thickness = 2; + + //CProgressBar + pb_blink = false; + pb_invert = false; + pb_bl_changed = g_settings.progressbar_color; + pb_last_width = -1; + pb_red = 40; + pb_green = 100; + pb_yellow = 70; + pb_active_col = COL_INFOBAR_PLUS_7; + pb_passive_col = COL_INFOBAR_PLUS_3; + pb_value = 0; + pb_max_value = 0; + pb_paint_zero = false; + + // init start positions x/y active bar + pb_x = x + fr_thickness; + pb_y = y + fr_thickness; + pb_active_width = 0; + pb_max_width = width - 2*fr_thickness; + pb_height = 0; + pb_start_x_passive = 0; + pb_passive_width = width; +} + +//calculate bar dimensions +void CProgressBar::initDimensions() +{ + //prevent stupid callers, can give invalid values like "-1"... + if (pb_value < 0) + pb_value = 0; + if (pb_value > pb_max_value) + pb_max_value = pb_value; + + // start positions x/y active bar + pb_x = x + fr_thickness; + pb_y = y + fr_thickness; + + // width for active bar with current value + pb_active_width = max(0, pb_last_width); + if (pb_max_value) + pb_active_width = (width - 2*fr_thickness) * pb_value / pb_max_value; + + // max width active/passive bar + pb_max_width = width - 2*fr_thickness; + + // max height of active/passive bar + pb_height = height - 2*fr_thickness; + + pb_start_x_passive = pb_x + pb_active_width; + + pb_passive_width = pb_max_width - pb_active_width; + + // background = frame + if ( col_frame == 0 ) + col_frame = pb_active_col; +} + + +void CProgressBar::paintSimple() +{ + // progress value + if (pb_active_width != pb_last_width){ + frameBuffer->paintBoxRel(pb_x, pb_y, pb_active_width, pb_height, pb_active_col); // active bar + frameBuffer->paintBoxRel(pb_start_x_passive, pb_y, pb_passive_width, pb_height, pb_passive_col); // passive bar + } + + if (pb_paint_zero && pb_value == 0) + frameBuffer->paintLine(x+fr_thickness , y+fr_thickness, x+width-3, y+height-3, pb_active_col); // zero line +} + +void CProgressBar::paintAdvanced() +{ + int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT; + if(g_settings.progressbar_color){ + switch ((pb_color_t)g_settings.progressbar_design){ + default: + case PB_MATRIX: // ::::: matrix + break; + case PB_LINES_V: // ||||| vert. lines + itemh = pb_height; + pointy = pb_height; + break; + case PB_LINES_H: // ===== horiz. lines + itemw = POINT; + break; + case PB_COLOR: // filled color + itemw = POINT; + itemh = pb_height; + pointy = pb_height; + break; + } + } + + const int spc = itemh - pointy; /* space between horizontal lines / points */ + int hcnt = (pb_height + spc) / itemh; /* how many POINTs is the bar high */ + int yoff = (pb_height + spc - itemh * hcnt) / 2; + + //printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc); + /* red, yellow, green are given in percent */ + int rd = pb_red * pb_max_width / (100 * itemw); /* how many POINTs red */ + int yw = pb_yellow * pb_max_width / (100 * itemw); /* how many POINTs yellow */ + int gn = pb_green * pb_max_width / (100 * itemw); /* how many POINTs green */ + + int maxi = pb_active_width / itemw; /* how many POINTs is the active bar */ + int total = pb_max_width / itemw; /* total number of POINTs */ + + uint32_t rgb; + fb_pixel_t color; + + if (pb_active_width != pb_last_width) { + int i, j; + const int py = pb_y + yoff; + if (pb_active_width > pb_last_width) { + int step, off; + int b = 0; + uint8_t diff = 0; + for (i = 0; (i < rd) && (i < maxi); i++) { + diff = i * 255 / rd; + if (pb_invert) + rgb = GREEN + (diff << 16); // adding red + else + rgb = RED + (diff << 8); // adding green + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + step = yw - rd - 1; + if (step < 1) + step = 1; + for (; (i < yw) && (i < maxi); i++) { + diff = b++ * 255 / step / 2; + if (pb_invert) + rgb = YELLOW - (diff << 8); // removing green + else + rgb = YELLOW - (diff << 16); // removing red + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + off = diff; + b = 0; + step = gn - yw - 1; + if (step < 1) + step = 1; + for (; (i < gn) && (i < maxi); i++) { + diff = b++ * 255 / step / 2 + off; + if (pb_invert) + rgb = YELLOW - (diff << 8); // removing green + else + rgb = YELLOW - (diff << 16); // removing red + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + } + for(i = maxi; i < total; i++) { + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, pb_passive_col); //fill passive + } + } +} + + +void CProgressBar::paintProgress(bool do_save_bg) +{ + if(pb_bl_changed != g_settings.progressbar_color) { + pb_bl_changed = g_settings.progressbar_color; + reset(); + } + + initDimensions(); + + //body + if (pb_last_width == -1 && col_body != 0) /* first paint */ + paintInit(do_save_bg); + + //progress + if (!pb_blink || !g_settings.progressbar_color) + paintSimple(); + else + paintAdvanced(); + + if (is_painted) + pb_last_width = pb_active_width; +} + + +void CProgressBar::paint(bool do_save_bg) +{ + paintProgress(do_save_bg); +} diff --git a/src/gui/components/cc_item_progressbar.h b/src/gui/components/cc_item_progressbar.h new file mode 100644 index 000000000..a7c0d5796 --- /dev/null +++ b/src/gui/components/cc_item_progressbar.h @@ -0,0 +1,162 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + (C) 2008, 2013 by Thilo Graf + (C) 2009,2010,2013 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +/// +/*! + description of parameters: + + position of progressbar: + x_pos > start position on screen x + y_pos > start position on screen y + pb_width > with of progressbar + pb_height > height of progressbar + + definitions of values: + value > value, you will display + max_value > maximal value that you will display + + appearance: + activebar_col > color of inner bar that shows the current value + passivebar_col > color of passive bar + frame_col > general frame color of progressbar, set 0 for no frame + shadowbar_col color > shadow behind progressbar, set 0 for no shadow + + paintZero > optional, if set to true and value = 0, then paints a diagonal line instead of active bar as symbolic for a zero value +*/ + +#ifndef __CC_PROGRESSBAR_H__ +#define __CC_PROGRESSBAR_H__ + +#include "config.h" +#include +#include + +class CProgressBar : public CComponentsItem +{ + protected: + void initVarProgressbar(); + + private: + ///colors of active and passive bar area, active means the displayed value, passive the neutral area + fb_pixel_t pb_active_col, pb_passive_col; + + int pb_last_width; + + ///width of progress + int pb_active_width, pb_passive_width; + + ///maximal width,heigth of progress + int pb_max_width, pb_height; + + ///start position of bars + int pb_start_x_passive; + + ///color values + int pb_red, pb_green, pb_yellow; + + ///start position of activ/passiv area + int pb_x, pb_y; + + bool pb_blink, pb_invert, pb_bl_changed; + + ///causes a diagonal line as a sign for 0 value instead of an empty bar + bool pb_paint_zero; + + ///to evaluate values, these will be convert to the graph + int pb_value, pb_max_value; + + ///paint simple version of progressbar with simple color modifications + void paintSimple(); + ///paint version of progressbar with color and advanced display modifications + void paintAdvanced(); + + void initDimensions(); + + ///paints graph + void paintProgress(bool do_save_bg = CC_SAVE_SCREEN_NO); + + static inline unsigned int make16color(__u32 rgb){return 0xFF000000 | rgb;}; + + public: + ///parameters: + ///x_pos, y_pos, w, h: position and dimension in pixel + ///blinkenlights: true if you want code to follow progressbar_color. needed, no default. + ///w, h: width / height of bar. Can later be set with paintProgressbar. + ///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true. + ///inv: false => red on the left side, true: red on right side. + ///active_col, passive_col: sets colors for displayed values, activ_col means the the displayed progress + ///color_frame, color_body, color_shadow: colores of progressbar for frame, body and shadow, Note: color of frame is ineffective on fr_thickness = 0 + CProgressBar(); + CProgressBar( const int x_pos, const int y_pos, + const int w = -1, const int h = -1, + fb_pixel_t color_frame = 0, fb_pixel_t color_body = COL_INFOBAR_PLUS_3, fb_pixel_t color_shadow = COL_INFOBAR_PLUS_7, + const fb_pixel_t active_col = COL_INFOBAR_PLUS_7, const fb_pixel_t passive_col = COL_INFOBAR_PLUS_3, + const bool blinkenlights = false, + const int r = 40, const int g = 100, const int b =70, + const bool inv = false ); + + + ///set up to display available values + void setValue(const int val){ pb_value = val;}; + void setMaxValue(const int max_val){pb_max_value = max_val;}; + ///set up booth values to display at once + void setValues(const int val, const int max_val){pb_value = val; pb_max_value = max_val;}; + + ///causes painting a diagonal line if value = 0, Note: ineffective in colored mode + void setZeroLine(bool paint_zero_line = true){pb_paint_zero = paint_zero_line;}; + + ///setters for status colors + void setActiveColor(fb_pixel_t active_color) {pb_active_col = active_color;}; + void setPassiveColor(fb_pixel_t passive_color) {pb_passive_col = passive_color;}; + ///set up booth status colors at once + void setStatusColors(fb_pixel_t active_color, fb_pixel_t passive_color) {pb_passive_col = passive_color; pb_active_col = active_color;}; + + ///invert: false => red on the left side, true: red on right side. + void setInvert(bool inverted = true){pb_invert = inverted;}; + + ///blinkenlights: true (default) if you want code to follow progressbar_color. + void setBlink(bool blinkenlights = true){pb_blink = blinkenlights;}; + ///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true. + void setRgb(const int r, const int g, const int b){pb_red = r; pb_green = g; pb_yellow = b;}; + + ///x, y, width, height, value, max_value: set most wanted parameters at once + void setProgress(const int x_pos, const int y_pos, + const int w, const int h, + const int val, const int max_val){x=x_pos; y=y_pos; width=w; height=h; pb_value=val; pb_max_value=max_val;}; + + ///force update on next paint + void reset() { pb_last_width = -1; } + void paint(bool do_save_bg = CC_SAVE_SCREEN_NO); + + enum pb_color_t { + PB_MATRIX = 0, /* 0 */ + PB_LINES_V, /* 1 */ + PB_LINES_H, /* 2 */ + PB_COLOR /* 3 */ + }; + +}; + +#endif /* __CC_PROGRESSBAR_H__ */ diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 85f09144e..3ba4d1c14 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -44,6 +44,7 @@ typedef enum CC_ITEMTYPE_FRM_ICONFORM, CC_ITEMTYPE_FRM_WINDOW, CC_ITEMTYPE_LABEL, + CC_ITEMTYPE_PROGRESSBAR, CC_ITEMTYPES }CC_ITEMTYPES_T; diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index e00db49e7..1e48bc29e 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -442,8 +442,11 @@ void CDBoxInfoWidget::paint() //fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw); if (pbw > 8) /* smaller progressbar is not useful ;) */ { - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - pb.paintProgressBarDefault(x+offsetw, ypos+3, pbw, mheight-10, percent_used, 100); + CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); + pb.setFrameThickness(0); + pb.setBlink(); + pb.setValues(percent_used, 100); + pb.paint(false); } ypos+= mheight; } diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 16f7dd77e..f4a4a17b3 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -641,8 +641,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if ( epg_done!= -1 ) { int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 100); + CProgressBar pb(pbx, sy+oy-height, 104, height-6); + pb.setFrameThickness(0); + pb.setBlink(); + pb.setValues(epg_done, 100); + pb.paint(false); } GetPrevNextEPGData( epgData.eventID, &epgData.epg_times.startzeit ); @@ -683,9 +686,12 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if (data == g_InfoViewer->getUpdateTimer()) { GetEPGData(channel_id, id, &startzeit, false); if ( epg_done!= -1 ) { - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 100); + int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); + CProgressBar pb(pbx, sy+oy-height, 104, height-6); + pb.setFrameThickness(0); + pb.setBlink(); + pb.setValues(epg_done, 100); + pb.paint(false); } } if(data == fader.GetTimer()) { diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index de51eddb8..91b798378 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -216,19 +216,22 @@ void CInfoViewer::start () void CInfoViewer::changePB() { - const short red_bar = 40; - const short yellow_bar = 70; - const short green_bar = 100; - - if (sigscale != NULL) + if (sigscale) delete sigscale; - sigscale = new CProgressBar(true, bar_width, 10, red_bar, green_bar, yellow_bar); - if (snrscale != NULL) + sigscale = new CProgressBar(); + sigscale->setBlink(); + sigscale->setFrameThickness(0); + + if (snrscale) delete snrscale; - snrscale = new CProgressBar(true, bar_width, 10, red_bar, green_bar, yellow_bar); - if (timescale != NULL) + snrscale = new CProgressBar(); + snrscale->setBlink(); + snrscale->setFrameThickness(0); + + if (timescale) delete timescale; - timescale = new CProgressBar(true, -1, -1, 30, green_bar, yellow_bar, true); + timescale = new CProgressBar(); + timescale->setBlink(); } void CInfoViewer::paintTime (bool show_dot, bool firstPaint) @@ -1390,7 +1393,10 @@ void CInfoViewer::showSNR () lastsig = sig; posx = BoxStartX + (ChanWidth - (bar_width + 2 + (g_SignalFont->getWidth() * 4))) / 2; posy = freqStartY; - sigscale->paintProgressBar(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100, sig, 100); + sigscale->setDimensionsAll(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100); + sigscale->setColorBody(COL_INFOBAR_PLUS_0); + sigscale->setValues(sig, 100); + sigscale->paint(); snprintf (percent, sizeof(percent), "%d%%S", sig); posx = posx + bar_width + 2; sw = BoxStartX + ChanWidth - posx; @@ -1401,7 +1407,10 @@ void CInfoViewer::showSNR () lastsnr = snr; posx = BoxStartX + (ChanWidth - (bar_width + 2 + (g_SignalFont->getWidth() * 4))) / 2; posy = freqStartY + height - (2 * g_settings.screen_yres / 100); - snrscale->paintProgressBar(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100, snr, 100); + snrscale->setDimensionsAll(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100); + snrscale->setColorBody(COL_INFOBAR_PLUS_0); + snrscale->setValues(snr, 100); + snrscale->paint(); snprintf (percent, sizeof(percent), "%d%%Q", snr); posx = posx + bar_width + 2; sw = BoxStartX + ChanWidth - posx -4; @@ -1443,12 +1452,12 @@ void CInfoViewer::display_Info(const char *current, const char *next, int pb_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() - 4; switch(g_settings.infobar_progressbar) { - case 1: - case 2: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL: CurrInfoY += (pb_h/3); NextInfoY += (pb_h/3); break; - case 3: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS: CurrInfoY -= (pb_h/3); NextInfoY += (pb_h/3); break; @@ -1462,26 +1471,27 @@ void CInfoViewer::display_Info(const char *current, const char *next, int pb_startx = BoxEndX - pb_w - SHADOW_OFFSET; int pb_starty = ChanNameY - (pb_h + 10); int pb_shadow = COL_INFOBAR_SHADOW_PLUS_0; + timescale->setShadowOnOff(true); int pb_color = g_settings.progressbar_color ? COL_INFOBAR_SHADOW_PLUS_0 : COL_INFOBAR_PLUS_0; if(g_settings.infobar_progressbar){ pb_startx = xStart; pb_w = BoxEndX - 10 - xStart; pb_shadow = 0; + timescale->setShadowOnOff(false); } - switch(g_settings.infobar_progressbar) + switch(g_settings.infobar_progressbar) //set progressbar position { - case 1: - + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME: pb_starty = CurrInfoY - ((pb_h * 2) + (pb_h / 6)) ; pb_h = (pb_h/3); - pb_color = 0; +// pb_color = 0; break; - case 2: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL: pb_starty = CurrInfoY - ((pb_h * 2) + (pb_h / 5)) ; pb_h = (pb_h/5); - pb_color = 0; +// pb_color = 0; break; - case 3: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS: pb_starty = CurrInfoY + ((pb_h / 3)-(pb_h/5)) ; pb_h = (pb_h/5); break; @@ -1493,8 +1503,10 @@ void CInfoViewer::display_Info(const char *current, const char *next, if (pb_p > pb_w) pb_p = pb_w; - timescale->paintProgressBar(pb_startx, pb_starty, pb_w, pb_h, pb_p, pb_w, - 0, 0, pb_color, pb_shadow, "", COL_INFOBAR); + timescale->setDimensionsAll(pb_startx, pb_starty, pb_w, pb_h); + timescale->setColorAll(pb_color, pb_color, pb_shadow); + timescale->setValues(pb_p, pb_w); + timescale->paint(); //printf("paintProgressBar(%d, %d, %d, %d)\n", BoxEndX - pb_w - SHADOW_OFFSET, ChanNameY - (pb_h + 10) , pb_w, pb_h); } diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 9a0831132..206d76a96 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -42,7 +42,6 @@ #include #include "widget/menue.h" #include -#include #include #include diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 131c0a506..7bf733ecd 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -642,17 +642,22 @@ void* CInfoViewerBB::hddperThread(void *arg) } void CInfoViewerBB::showBarSys(int percent) -{ - if (is_visible) - sysscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6, percent, 100); +{ + if (is_visible){ + sysscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6); + sysscale->setValues(percent, 100); + sysscale->paint(); + } } void CInfoViewerBB::showBarHdd(int percent) { if (is_visible) { - if (percent >= 0) - hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); - else { + if (percent >= 0){ + hddscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6); + hddscale->setValues(percent, 100); + hddscale->paint(); + }else { frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, COL_INFOBAR_BUTTONS_BACKGROUND); hddscale->reset(); } @@ -811,12 +816,17 @@ void CInfoViewerBB::paintCA_bar(int left, int right) void CInfoViewerBB::changePB() { hddwidth = frameBuffer->getScreenWidth(true) * ((g_settings.screen_preset == 1) ? 10 : 8) / 128; /* 80(CRT)/100(LCD) pix if screen is 1280 wide */ - if (hddscale != NULL) + if (hddscale) delete hddscale; - hddscale = new CProgressBar(true, hddwidth, 6, 50, 100, 75, true); - if (sysscale != NULL) + hddscale = new CProgressBar(); + hddscale->setFrameThickness(0); + hddscale->setBlink(); + + if (sysscale) delete sysscale; - sysscale = new CProgressBar(true, hddwidth, 6, 50, 100, 75, true); + sysscale = new CProgressBar(); + sysscale->setFrameThickness(0); + sysscale->setBlink(); } void CInfoViewerBB::reset_allScala() diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index d5f4230c5..d47e64409 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -41,7 +41,7 @@ #include #include #include "widget/menue.h" -#include +#include #include class CInfoViewerBB diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 627535772..508282fe7 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -99,8 +99,10 @@ void CMotorControl::Init(void) motorPosition = 1; satellitePosition = 0; stepDelay = 10; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); + sigscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + sigscale->setBlink(); + snrscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + snrscale->setBlink(); } int CMotorControl::exec(CMenuTarget* parent, const std::string &) @@ -717,7 +719,7 @@ void CMotorControl::showSNR() int barwidth = 100; uint16_t ssig, ssnr; int sig, snr; - int posx, posy; + int posx_sig, posx_snr, posy; int sw; @@ -732,29 +734,32 @@ void CMotorControl::showSNR() g_snr = snr; posy = y + height - mheight - 5; - + //TODO: move sig/snr display into its own class, similar or same code also to find in scan.cpp if (lastsig != sig) { lastsig = sig; - posx = x + 10; + posx_sig = x + 10; sprintf(percent, "%d%% SIG", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SIG"); - sigscale->paintProgressBar2(posx-1, posy, sig); + sigscale->setProgress(posx_sig-1, posy, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); - posx = posx + barwidth + 3; - frameBuffer->paintBoxRel(posx, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx+2, posy + mheight, sw, percent, COL_MENUCONTENT); + posx_sig += barwidth + 3; + frameBuffer->paintBoxRel(posx_sig, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx_sig+2, posy + mheight, sw, percent, COL_MENUCONTENT); } if (lastsnr != snr) { lastsnr = snr; - posx = x + 10 + 210; + posx_snr = x + 10 + 210; sprintf(percent, "%d%% SNR", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SNR"); - snrscale->paintProgressBar2(posx-1, posy, snr); + + snrscale->setProgress(posx_snr-1, posy, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); - posx = posx + barwidth + 3; - frameBuffer->paintBoxRel(posx, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx+2, posy + mheight, sw, percent, COL_MENUCONTENT); + posx_snr += barwidth + 3; + frameBuffer->paintBoxRel(posx_snr, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx_snr+2, posy + mheight, sw, percent, COL_MENUCONTENT); } } diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h index 7ef402417..b69ad427f 100644 --- a/src/gui/motorcontrol.h +++ b/src/gui/motorcontrol.h @@ -34,7 +34,7 @@ #define __motorcontrol__ #include -#include +#include #include #include #include diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index ccbef2f65..e91dd8429 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include @@ -1283,10 +1283,13 @@ void CMovieBrowser::info_hdd_level(bool paint_hdd) if(tmp_blocks_percent_used != blocks_percent_used || paint_hdd){ tmp_blocks_percent_used = blocks_percent_used; - CProgressBar pb(true, -1, -1, 30, 100, 70, true); const short pbw = 100; const short border = m_cBoxFrameTitleRel.iHeight/4; - pb.paintProgressBarDefault(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2, blocks_percent_used, 100); + CProgressBar pb(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2); + pb.setBlink(); + pb.setInvert(); + pb.setValues( blocks_percent_used, 100); + pb.paint(false); } } @@ -4006,12 +4009,14 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); if (! timescale) - timescale = new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale = new CProgressBar();//new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale->setBlink(); int dx = 256; int x = (((g_settings.screen_EndX- g_settings.screen_StartX)- dx) / 2) + g_settings.screen_StartX; int y = g_settings.screen_EndY - 50; - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); - timescale->paintProgressBar2(x + 41, y + 12, percent); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); int len = minfo->length; off64_t size = minfo->file.Size; //off64_t secsize = len ? size/len/60 : 511040; @@ -4131,7 +4136,7 @@ printf("\ncut: reading from %" PRId64 " to %" PRId64 " (%" PRId64 ") want gop %d } if(msg) { timescale->reset(); - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints } size_t toread = (until-sdone) > BUF_SIZE ? BUF_SIZE : until - sdone; #if REAL_CUT @@ -4157,7 +4162,8 @@ if(buf[0] != 0x47) printf("cut: buffer not aligned at %" PRId64 "\n", sdone); sdone += r; spos += r - wptr; percent = (int) ((float)(spos)/(float)(newsize)*100.); - timescale->paintProgressBar2(x + 41, y + 12, percent); + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); #if REAL_CUT int wr = write(dstfd, &buf[wptr], r-wptr); if(wr < (r-wptr)) { @@ -4263,12 +4269,14 @@ printf("copy: len %d minute %" PRId64 " second %" PRId64 "\n", len, len ? size/l CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); if (! timescale) - timescale = new CProgressBar(true, 200, 15, 0, 100, 0); + timescale = new CProgressBar();//new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale->setBlink(); int dx = 256; int x = (((g_settings.screen_EndX- g_settings.screen_StartX)- dx) / 2) + g_settings.screen_StartX; int y = g_settings.screen_EndY - 50; - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); - timescale->paintProgressBar2(x + 41, y + 12, percent); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); //TODO: remove unneeded box paints + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); newsize = 0; for(int book_nr = 0; book_nr < MI_MOVIE_BOOK_USER_MAX; book_nr++) { @@ -4358,7 +4366,7 @@ printf("copy: read from %" PRId64 " to %" PRId64 " read size %d want gop %d\n", goto ret_err; } if(msg) { - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints timescale->reset(); } #if REAL_CUT @@ -4386,7 +4394,8 @@ if(buf[0] != 0x47) printf("copy: buffer not aligned at %" PRId64 "\n", sdone); spos += r - wptr; btotal += r; percent = (int) ((float)(btotal)/(float)(newsize)*100.); - timescale->paintProgressBar2(x + 41, y + 12, percent); + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); #if REAL_CUT int wr = write(dstfd, &buf[wptr], r-wptr); if(wr < (r-wptr)) { diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 58510e924..28838244c 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include @@ -81,8 +81,11 @@ CScanTs::CScanTs() total = done = 0; freqready = 0; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); + sigscale = new CProgressBar(); + sigscale->setBlink(); + + snrscale = new CProgressBar(); + snrscale->setBlink(); } void CScanTs::prev_next_TP( bool up) @@ -555,13 +558,14 @@ void CScanTs::showSNR () sig = (ssig & 0xFFFF) * 100 / 65535; posy = y + height - mheight - 5; - - if (lastsig != sig) { + //TODO: move sig/snr display into its own class, similar or same code also to find in motorcontrol + if (lastsig != sig) { lastsig = sig; posx = x + 20; sprintf(percent, "%d%%", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100%"); - sigscale->paintProgressBar2(posx - 1, posy+2, sig); + sigscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy -1, sw, mheight-8, COL_MENUCONTENT_PLUS_0); @@ -576,7 +580,8 @@ void CScanTs::showSNR () posx = x + 20 + (20 * fw); sprintf(percent, "%d%%", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100%"); - snrscale->paintProgressBar2(posx - 1, posy+2, snr); + snrscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy - 1, sw, mheight-8, COL_MENUCONTENT_PLUS_0, 0, true); diff --git a/src/gui/scan.h b/src/gui/scan.h index db871bcc0..4464f6441 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -33,11 +33,11 @@ #define __scants__ #include -#include +#include #include #include #include - +#include class CScanTs : public CMenuTarget { diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 242c479d5..d025c81fe 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -120,8 +120,10 @@ int CStreamInfo2::doSignalStrengthLoop () #define BAR_WIDTH 150 #define BAR_HEIGHT 12 int res = menu_return::RETURN_REPAINT; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); + sigscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + sigscale->setBlink(); + snrscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + snrscale->setBlink(); lastsnr = lastsig = -1; neutrino_msg_t msg; @@ -910,7 +912,8 @@ void CStreamInfo2::showSNR () posy = yypos + (mheight/2)-5; posx = x + 10; sprintf(percent, "%d%%", sig); - sigscale->paintProgressBar2(posx - 1, posy, sig); + sigscale->setProgress(posx - 1, posy, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy -1, sw, mheight-8, COL_MENUHEAD_PLUS_0); @@ -922,7 +925,9 @@ void CStreamInfo2::showSNR () posy = yypos + mheight + 5; posx = x + 10; sprintf(percent, "%d%% SNR", snr); - snrscale->paintProgressBar2(posx - 1, posy+2, snr); + snrscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); +// snrscale->paintProgressBar2(posx - 1, posy+2, snr); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy - 1, sw, mheight-8, COL_MENUHEAD_PLUS_0, 0, true); diff --git a/src/gui/streaminfo2.h b/src/gui/streaminfo2.h index e6a8f2359..2a3757ce9 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index 0d80900c2..42daf0d77 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -31,7 +31,7 @@ #include #include -//static CProgressBar *timescale = 0; +static CProgressBar *timescale = 0; #define TIMEOSD_FONT SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME #define BARLEN 200 @@ -44,7 +44,7 @@ CTimeOSD::CTimeOSD() visible=false; m_mode=MODE_ASC; GetDimensions(); - timescale = new CProgressBar(true, BARLEN, m_height -5, 40, 100, 70, true); + timescale = new CProgressBar(); m_time_show = 0; } @@ -118,7 +118,9 @@ void CTimeOSD::updatePos(short runningPercent) if(runningPercent > 100 || runningPercent < 0) runningPercent = 0; - timescale->paintProgressBar2(m_xstart, m_y, runningPercent); + timescale->setProgress(m_xstart, m_y, BARLEN, m_height -5, runningPercent, 100); + timescale->setBlink(); + timescale->paint(); } void CTimeOSD::update(int position, int duration) diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index 66ed1fdda..078b723b7 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -27,7 +27,7 @@ #include #include -#include +#include class CTimeOSD { diff --git a/src/gui/widget/Makefile.am b/src/gui/widget/Makefile.am index 6cdfee1fe..0818dff09 100644 --- a/src/gui/widget/Makefile.am +++ b/src/gui/widget/Makefile.am @@ -33,7 +33,6 @@ libneutrino_gui_widget_a_SOURCES = \ messagebox.cpp \ mountchooser.cpp \ msgbox.cpp \ - progressbar.cpp \ stringinput.cpp \ stringinput_ext.cpp \ textbox.cpp diff --git a/src/gui/widget/progressbar.cpp b/src/gui/widget/progressbar.cpp deleted file mode 100644 index 355eb0fbd..000000000 --- a/src/gui/widget/progressbar.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * (C) 2008 by dbt - * (C) 2009-2010, 2012-2013 Stefan Seyfried - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "icons.h" -#include "progressbar.h" - -#define ITEMW 4 -#define POINT 2 - -#define RED 0xFF0000 -#define GREEN 0x00FF00 -#define YELLOW 0xFFFF00 - -CProgressBar::CProgressBar(const bool bl, const int w, const int h, - const int r, const int g, const int b, const bool inv) -{ - frameBuffer = CFrameBuffer::getInstance(); - font_pbar = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL; - // frame width around active bar - frame_widht = 2; - blink = bl; - invert = inv; - red = r; - green = g; - yellow = b; - width = w; - height = h; - last_width = -1; - bl_changed = g_settings.progressbar_color; -} - -CProgressBar::~CProgressBar() -{ -} - -static inline unsigned int make16color(__u32 rgb) -{ - return 0xFF000000 | rgb; -} - -void CProgressBar::paintProgressBar ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero) -{ - width = pb_width; - height = pb_height; - realpaint(pos_x, pos_y, value, max_value, - activebar_col, passivebar_col, backgroundbar_col, shadowbar_col, - upper_labeltext, uppertext_col, iconfile, paintZero); -} - -void CProgressBar::paintProgressBar2(const int pos_x, - const int pos_y, - const int value, - const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t frame_col, - const fb_pixel_t shadowbar_col, - const char * upper_labeltext, - const uint8_t uppertext_col, - const char * iconfile, - bool paintZero) -{ - if (height < 0 || width < 0) - { - fprintf(stderr, "CProgressBar::paintProgressBar2 height or width not set!\n"); - return; - } - realpaint(pos_x, pos_y, value, max_value, - activebar_col, passivebar_col, frame_col, shadowbar_col, - upper_labeltext, uppertext_col, iconfile, paintZero); -} - -void CProgressBar::realpaint(const int pos_x, const int pos_y, - const int val, const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero) -{ - if(bl_changed != g_settings.progressbar_color) { - bl_changed = g_settings.progressbar_color; - reset(); - } - - /* stupid callers give invalid values like "-1"... */ - int value = val; - if (value < 0) - value = 0; - if (value > max_value) - value = max_value; - - // set colors - fb_pixel_t active_col = activebar_col != 0 ? activebar_col : COL_INFOBAR_PLUS_7; - fb_pixel_t passive_col = passivebar_col != 0 ? passivebar_col : COL_INFOBAR_PLUS_3; - - /* radius is 0 for now, since the rounded corner code is sufficiently - different from tuxbox.org's so that everything else looks 'strange' */ - const int c_rad = 0; - - /* if the bar is too small, do not draw the borders around it */ - if (height / 2 <= frame_widht || (blink && g_settings.progressbar_color) || backgroundbar_col == 0) - frame_widht = 0; - // get icon size - int icon_w = 0, icon_h = 0; - if(iconfile != NULL) - frameBuffer->getIconSize(iconfile, &icon_w, &icon_h); - - // start positions x/y active bar - int start_x = icon_w != 0 ? pos_x + icon_w + 2*frame_widht : pos_x + frame_widht; - int start_y = pos_y + frame_widht; - - // width active bar for current value - int active_pb_width; - if (max_value) - active_pb_width = (width - icon_w - 2 * frame_widht) * value / max_value; - else - active_pb_width = 0; - - // max width active/passive bar - int pb_max_width = icon_w != 0 ? (width - 2*frame_widht) - icon_w - frame_widht : width - 2*frame_widht; - - // max height progressbar bar, if icon height larger than pb_height then get height from icon - int pb_max_height = icon_h > height ? icon_h + 2* frame_widht : height; - - if (!blink || !g_settings.progressbar_color) - { - // max height of active/passive bar - int bar_height = pb_max_height - 2*frame_widht; - - int start_x_passive_bar = start_x + active_pb_width; - int width_passive_bar = pb_max_width - active_pb_width; - - // shadow - if (shadowbar_col != 0) - frameBuffer->paintBoxRel(pos_x + SHADOW_OFFSET, pos_y + SHADOW_OFFSET, - width, pb_max_height, shadowbar_col, c_rad); // shadow - - // background = frame - if (backgroundbar_col != 0) { - // we must paint background as frame, because of flicker effects at screen on fast changing values - frameBuffer->paintBoxRel(pos_x, pos_y, 10, pb_max_height, backgroundbar_col, c_rad, CORNER_LEFT); - frameBuffer->paintBoxRel(pos_x + width - 10, pos_y, 10, pb_max_height, backgroundbar_col, c_rad, CORNER_RIGHT); - frameBuffer->paintBoxRel(pos_x + 10, pos_y, width - 20, frame_widht, backgroundbar_col); - frameBuffer->paintBoxRel(pos_x + 10, pos_y + pb_max_height - frame_widht, width - 20, frame_widht, backgroundbar_col); - } - - frameBuffer->paintBoxRel(start_x, start_y, active_pb_width, bar_height, active_col); // active bar - frameBuffer->paintBoxRel(start_x_passive_bar, start_y, width_passive_bar, bar_height, passive_col); // passive bar - if (paintZero && value == 0) - frameBuffer->paintLine(pos_x+2 , pos_y+2, pos_x+width-3, pos_y+height-3, active_col); // zero line - } - else - { - int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT; - if(g_settings.progressbar_color){ - switch ((pb_color_t)g_settings.progressbar_design){ - default: - case PB_MATRIX: /* matrix */ - break; - case PB_LINES_V: /* vert. lines */ - itemh = height; - pointy = height; - break; - case PB_LINES_H: /* horiz. lines */ - itemw = POINT; - break; - case PB_COLOR: /* filled color */ - itemw = POINT; - itemh = height; - pointy = height; - break; - } - } - const int spc = itemh - pointy; /* space between horizontal lines / points */ - int hcnt = (height + spc) / itemh; /* how many POINTs is the bar high */ - int yoff = (height + spc - itemh * hcnt) / 2; - //printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc); - /* red, yellow, green are given in percent */ - int rd = red * width / (100 * itemw); /* how many POINTs red */ - int yw = yellow * width / (100 * itemw); /* how many POINTs yellow */ - int gn = green * width / (100 * itemw); /* how many POINTs green */ - - int maxi = active_pb_width / itemw; /* how many POINTs is the active bar */ - int total = width / itemw; /* total number of POINTs */ - - uint32_t rgb; - fb_pixel_t color; - - if (last_width == -1 && backgroundbar_col != 0) /* first paint */ - { - frameBuffer->paintBoxRel(pos_x, pos_y, width, pb_max_height, backgroundbar_col); - if (shadowbar_col != 0) - frameBuffer->paintBoxRel(pos_x + SHADOW_OFFSET, pos_y + SHADOW_OFFSET, - width, pb_max_height, shadowbar_col, c_rad); // shadow - } - - if (active_pb_width != last_width) { - int i, j; - const int py = pos_y + yoff; - if (active_pb_width > last_width) { - int step, off; - int b = 0; - uint8_t diff = 0; - for (i = 0; (i < rd) && (i < maxi); i++) { - diff = i * 255 / rd; - if (invert) - rgb = GREEN + (diff << 16); // adding red - else - rgb = RED + (diff << 8); // adding green - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - step = yw - rd - 1; - if (step < 1) - step = 1; - for (; (i < yw) && (i < maxi); i++) { - diff = b++ * 255 / step / 2; - if (invert) - rgb = YELLOW - (diff << 8); // removing green - else - rgb = YELLOW - (diff << 16); // removing red - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - off = diff; - b = 0; - step = gn - yw - 1; - if (step < 1) - step = 1; - for (; (i < gn) && (i < maxi); i++) { - diff = b++ * 255 / step / 2 + off; - if (invert) - rgb = YELLOW - (diff << 8); // removing green - else - rgb = YELLOW - (diff << 16); // removing red - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - } - for(i = maxi; i < total; i++) { - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, COL_INFOBAR_PLUS_3);//fill passive - } - last_width = active_pb_width; - } - } - - // paint icon if present - if (iconfile != NULL){ - int icon_y = pos_y + pb_max_height / 2 - icon_h / 2; - frameBuffer->paintIcon(iconfile, pos_x + frame_widht, icon_y); - } - - // upper text - int upper_labeltext_y = start_y - frame_widht; - if (upper_labeltext != NULL) { - g_Font[font_pbar]->RenderString(start_x +2, - upper_labeltext_y, - width, - upper_labeltext, - uppertext_col != 0 ? uppertext_col : COL_INFOBAR, - height, - true); // UTF8 - } -} - - -void CProgressBar::paintProgressBarDefault( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value) -{ - paintProgressBar (pos_x, pos_y, pb_width, pb_height, value, max_value, 0, 0, COL_INFOBAR_SHADOW_PLUS_1, 0, "", 0); -} diff --git a/src/gui/widget/progressbar.h b/src/gui/widget/progressbar.h deleted file mode 100644 index 1d2b6bf2e..000000000 --- a/src/gui/widget/progressbar.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (C) 2008 by dbt - * (C) 2009,2010,2013 Stefan Seyfried - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef __gui_widget_progressbar_h__ -#define __gui_widget_progressbar_h__ -#include "config.h" -#include -#include -#include -#include - -#include - -class CProgressBar -{ - private: - CFrameBuffer * frameBuffer; - int font_pbar; - int frame_widht; - int last_width; - int red, green, yellow; - bool blink, invert, bl_changed; - int width, height; - void realpaint(const int pos_x, const int pos_y, - const int value, const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero); - - - public: - /* parameters: - blinkenligts: true if you want code to follow progressbar_color. needed, no default. - w, h: width / height of bar. Can later be set with paintProgressbar. - paintProgressBar2 can oly be used if w and h are set. - r, g, b: percentage of the bar where red/green/yellow is used. - only used if blinkenlights == true. - inv: false => red on the left side, true: red on right side. */ - CProgressBar(const bool blinkenlights, - const int w = -1, - const int h = -1, - const int r = 40, - const int g = 100, - const int b =70, - const bool inv = false); - ~CProgressBar(); - -/// void paintProgressBar(...) -/*! - description of parameters: - - position of progressbar: - pos_x > start position on screen x - pos_y > start position on screen y - pb_width > with of progressbar - pb_height > height of progressbar - - definitions of values: - value > value, you will display - max_value > maximal value that you will display - - appearance: - activebar_col > color of inner bar that shows the current value - passivebar_col > color of passive bar - frame_col > general frame color of progressbar, set 0 for no frame - shadowbar_col color > shadow behind progressbar, set 0 for no shadow - - upper_labeltext > optional, label text, will be painted upper/left the progressbar - uppertext_col > optional, but necessary with label text, color of label text - iconfile > optional, name of iconfile - paintZero > optional, if set to true and value = 0, then paints a diagonal line instead of active bar as symbolic for a zero value -*/ - void paintProgressBar ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value, - const fb_pixel_t activebar_col = 0, - const fb_pixel_t passivebar_col = 0, - const fb_pixel_t frame_col = 0, - const fb_pixel_t shadowbar_col = 0, - const char * upper_labeltext = NULL, - const uint8_t uppertext_col = 0, - const char * iconfile = NULL, - bool paintZero = false); - - void paintProgressBar2 (const int pos_x, - const int pos_y, - const int value, - const int max_value = 100, - const fb_pixel_t activebar_col = 0, - const fb_pixel_t passivebar_col = 0, - const fb_pixel_t frame_col = 0, - const fb_pixel_t shadowbar_col = 0, - const char * upper_labeltext = NULL, - const uint8_t uppertext_col = 0, - const char * iconfile = NULL, - bool paintZero = false); - - void paintProgressBarDefault ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value); - - void reset() { last_width = -1; } /* force update on next paint */ - - void hide(); - - enum pb_color_t { - PB_MATRIX = 0, /* 0 */ - PB_LINES_V, /* 1 */ - PB_LINES_H, /* 2 */ - PB_COLOR /* 3 */ - }; -}; - -#endif /* __gui_widget_progressbar_h__ */ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f41464214..d22776f76 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -86,10 +86,6 @@ #include "gui/widget/messagebox.h" #include "gui/infoclock.h" -#if HAVE_COOL_HARDWARE -#include "gui/widget/progressbar.h" -#endif - #include #include #include diff --git a/src/system/settings.h b/src/system/settings.h index e5aced076..6e1856b26 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -601,6 +601,15 @@ struct SNeutrinoSettings std::string usermenu_text[BUTTON_MAX]; int usermenu[BUTTON_MAX][ITEM_MAX]; // (USER_ITEM) [button][position in Menue] = feature item + //progressbar arrangement for infobar + typedef enum + { + INFOBAR_PROGRESSBAR_ARRANGEMENT_DEFAULT = 0, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME = 1, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL = 2, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS = 3 + }INFOBAR_PROGRESSBAR_ARRANGEMENT_TYPES; + }; /* some default Values */