From 80c9969dcd690b9adddc9df081b23a43a47ab549 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 3 Jan 2010 10:39:40 +0000 Subject: [PATCH] neutrino: consolidate CScale and CProgressBar code Add code for coloured progressbars to CProgressBar class. This allows to deprecate the CScale code completely (is not used anymore) and, in a follow-up step, make the progress bar style runtime configurable. TODO: documentation ;) check if all progressbars still behave the same git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@131 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/697e3c6756e986a36f433f2c300211fd300bad2a Author: Stefan Seyfried Date: 2010-01-03 (Sun, 03 Jan 2010) Origin message was: ------------------ neutrino: consolidate CScale and CProgressBar code Add code for coloured progressbars to CProgressBar class. This allows to deprecate the CScale code completely (is not used anymore) and, in a follow-up step, make the progress bar style runtime configurable. TODO: documentation ;) check if all progressbars still behave the same git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@131 e54a6e83-5905-42d5-8d5c-058d10e6a962 ------------------ This commit was generated by Migit --- src/gui/Makefile.am | 2 +- src/gui/channellist.cpp | 2 +- src/gui/epgview.cpp | 12 +- src/gui/infoviewer.cpp | 78 ++++++------- src/gui/infoviewer.h | 6 +- src/gui/motorcontrol.cpp | 16 +-- src/gui/motorcontrol.h | 5 +- src/gui/moviebrowser.cpp | 20 ++-- src/gui/scan.cpp | 20 ++-- src/gui/scan.h | 5 +- src/gui/streaminfo2.cpp | 23 ++-- src/gui/streaminfo2.h | 7 +- src/gui/timeosd.cpp | 10 +- src/gui/widget/progressbar.cpp | 195 ++++++++++++++++++++++++++++----- src/gui/widget/progressbar.h | 52 ++++++++- src/neutrino.cpp | 10 +- src/neutrino_menue.cpp | 1 - 17 files changed, 325 insertions(+), 139 deletions(-) diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index c41ccff4a..7676f8ea3 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -30,7 +30,7 @@ libneutrino_gui_a_SOURCES = \ plugins.cpp imageinfo.cpp audio_select.cpp moviebrowser.cpp movieinfo.cpp libneutrino_gui2_a_SOURCES = \ - color.cpp alphasetup.cpp motorcontrol.cpp scale.cpp hdd_menu.cpp cam_menu.cpp infoclock.cpp upnpbrowser.cpp + color.cpp alphasetup.cpp motorcontrol.cpp hdd_menu.cpp cam_menu.cpp infoclock.cpp upnpbrowser.cpp libtimerlist_a_SOURCES = \ timerlist.cpp diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 908fb7aa2..109d41cc2 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1497,7 +1497,7 @@ void CChannelList::paintItem(int pos) else l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->name.c_str()); - CProgressBar pb; + CProgressBar pb(false); /* never colored */ int pb_space = prg_offset - title_offset; int pb_max = pb_space - 4; if (!(p_event->description.empty())) { diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 215f576eb..0e15f21c9 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -49,13 +50,11 @@ #include #include #include -#include #include extern CPictureViewer * g_PicViewer; #define PIC_W 52 #define PIC_H 39 -static CScale * timescale; #define ICON_LARGE_WIDTH 26 #define ROUND_RADIUS 9 @@ -120,7 +119,6 @@ CEpgData::CEpgData() { bigFonts = false; frameBuffer = CFrameBuffer::getInstance(); - timescale = new CScale(100, 12, 30, 100, 70, true); } #define MAX_W 540 @@ -628,8 +626,8 @@ int CEpgData::show(const t_channel_id channel_id, unsigned long long a_id, time_ if ( epg_done!= -1 ) { int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - timescale->reset(); - timescale->paint(pbx+2, sy+oy-height+2, epg_done); + CProgressBar pb; + pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 104); } GetPrevNextEPGData( epgData.eventID, &epgData.epg_times.startzeit ); @@ -668,9 +666,9 @@ int CEpgData::show(const t_channel_id channel_id, unsigned long long a_id, time_ if (data == g_InfoViewer->lcdUpdateTimer) { GetEPGData(channel_id, id, &startzeit ); if ( epg_done!= -1 ) { + CProgressBar pb; int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - timescale->reset(); - timescale->paint(pbx+2, sy+oy-height+2, epg_done); + pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 104); } } CNeutrinoApp::getInstance()->handleMsg(msg, data); diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index fe13b3600..e0ada8c76 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -42,7 +42,6 @@ #include -#include #include #include @@ -135,14 +134,16 @@ extern uint32_t shift_timer; extern char act_emu_str[20]; extern std::string ext_channel_name; int m_CA_Status; -static CScale * timescale; -static CScale * hddscale; -static CScale * varscale; extern bool timeset; CInfoViewer::CInfoViewer () { - Init(); + sigscale = NULL; + snrscale = NULL; + hddscale = NULL; + varscale = NULL; + timescale = NULL; + Init(); } void CInfoViewer::Init() @@ -159,11 +160,24 @@ void CInfoViewer::Init() virtual_zap_mode = false; chanready = 1; fileplay = 0; - sigscale = new CScale(BAR_WIDTH, 10, RED_BAR, GREEN_BAR, YELLOW_BAR); - snrscale = new CScale(BAR_WIDTH, 10, RED_BAR, GREEN_BAR, YELLOW_BAR); - hddscale = new CScale(100, 6, 50, GREEN_BAR, 75, true); - varscale = new CScale(100, 6, 50, GREEN_BAR, 75, true); - timescale = new CScale(100, TIME_BAR_HEIGHT, 30, GREEN_BAR, 70, true); + + /* after font size changes, Init() might be called multiple times */ + if (sigscale != NULL) + delete sigscale; + sigscale = new CProgressBar(BAR_WIDTH, 10, PB_COLORED, RED_BAR, GREEN_BAR, YELLOW_BAR); + if (snrscale != NULL) + delete snrscale; + snrscale = new CProgressBar(BAR_WIDTH, 10, PB_COLORED, RED_BAR, GREEN_BAR, YELLOW_BAR); + if (hddscale != NULL) + delete hddscale; + hddscale = new CProgressBar(100, 6, PB_COLORED, 50, GREEN_BAR, 75, true); + if (varscale != NULL) + delete varscale; + varscale = new CProgressBar(100, 6, PB_COLORED, 50, GREEN_BAR, 75, true); + if (timescale != NULL) + delete timescale; + timescale = new CProgressBar(PB_COLORED, 30, GREEN_BAR, 70, true); + channel_id = live_channel_id; lcdUpdateTimer = 0; } @@ -342,8 +356,9 @@ void CInfoViewer::showTitle (const int ChanNum, const std::string & Channel, con fileplay = (ChanNum == 0); newfreq = true; - sigscale->reset(); snrscale->reset(); timescale->reset(); hddscale->reset(); varscale->reset(); + sigscale->reset(); snrscale->reset(); timescale->reset(); hddscale->reset(); varscale->reset(); + lastsig = lastsnr = lasthdd = lastvar = -1; #if 0 InfoHeightY = NUMBER_H * 9 / 8 + 2 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getHeight () + 25; InfoHeightY_Info = 40; @@ -1038,10 +1053,11 @@ void CInfoViewer::showSNR () height = g_SignalFont->getHeight () - 1; ChanNumYPos = BoxStartY + ChanHeight /*+ 4*/ - 2 * height; - if (sigscale->getPercent() != sig) { + if (lastsig != sig) { + lastsig = sig; posx = BoxStartX + 4; posy = ChanNumYPos + 3; - sigscale->paint(posx, posy+4, sig); + sigscale->paintProgressBar(posx, posy+4, BAR_WIDTH, 10, sig, 100); sprintf (percent, "%d%%S", sig); posx = posx + barwidth + 2; @@ -1049,11 +1065,12 @@ void CInfoViewer::showSNR () frameBuffer->paintBoxRel (posx, posy, sw, height, COL_INFOBAR_PLUS_0); g_SignalFont->RenderString (posx, posy + height, sw, percent, COL_INFOBAR); } - if (snrscale->getPercent() != snr) { + if (lastsnr != snr) { + lastsnr = snr; posx = BoxStartX + 4; posy = ChanNumYPos + 3 + height - 2; - snrscale->paint(posx, posy+4, snr); + snrscale->paintProgressBar(posx, posy+4, BAR_WIDTH, 10, snr, 100); sprintf (percent, "%d%%Q", snr); posx = posx + barwidth + 2; @@ -1071,8 +1088,8 @@ void CInfoViewer::showSNR () /* center the scales in the button bar. BBarY + InfoHeightY_Info / 2 is middle, scales are 6 pixels high, icons are 16 pixels, so keep 4 pixels free between the scales */ - varscale->paint(BoxEndX - (2*ICON_LARGE_WIDTH + 2*ICON_SMALL_WIDTH + 4*2) - 102, - BBarY + InfoHeightY_Info / 2 - 2 - 6, per); + varscale->paintProgressBar(BoxEndX - (2*ICON_LARGE_WIDTH + 2*ICON_SMALL_WIDTH + 4*2) - 102, + BBarY + InfoHeightY_Info / 2 - 2 - 6, 100, 6, per, 100); per = 0; //HD info if (::statfs(g_settings.network_nfs_recordingdir, &s) == 0) { @@ -1094,8 +1111,8 @@ void CInfoViewer::showSNR () } } - hddscale->paint(BoxEndX - (2*ICON_LARGE_WIDTH + 2*ICON_SMALL_WIDTH + 4*2) - 102, - BBarY + InfoHeightY_Info / 2 + 2, per); + hddscale->paintProgressBar(BoxEndX - (2*ICON_LARGE_WIDTH + 2*ICON_SMALL_WIDTH + 4*2) - 102, + BBarY + InfoHeightY_Info / 2 + 2, 100, 6, per, 100); } void CInfoViewer::display_Info(const char *current, const char *next, @@ -1127,21 +1144,6 @@ void CInfoViewer::display_Info(const char *current, const char *next, else xStart = InfoX; -#ifndef NO_BLINKENLIGHTS - int posy = BoxStartY + 16; - int height2 = 20; - if (pb_pos > -1) - { - if (timescale->getPercent() != pb_pos) { - frameBuffer->paintBoxRel(BoxEndX - 104, posy + 6, 108, 14, COL_INFOBAR_SHADOW_PLUS_0, 1); - frameBuffer->paintBoxRel(BoxEndX - 108, posy + 2, 108, 14, COL_INFOBAR_PLUS_0, 1); - } - timescale->paint(BoxEndX - 102, posy + 2, pb_pos); - } else { - timescale->reset(); - frameBuffer->paintBackgroundBoxRel(BoxEndX - 108, posy, 112, height2); - } -#else if (pb_pos > -1) { int pb_w = 112; @@ -1149,11 +1151,9 @@ void CInfoViewer::display_Info(const char *current, const char *next, int pb_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() - 4; if (pb_p > pb_w) pb_p = pb_w; - CProgressBar pb; - pb.paintProgressBar(BoxEndX - pb_w - SHADOW_OFFSET, BoxStartY + 12, pb_w, pb_h, pb_p, pb_w, - 0, 0, COL_INFOBAR_PLUS_0, COL_INFOBAR_SHADOW_PLUS_0, "", COL_INFOBAR); + timescale->paintProgressBar(BoxEndX - pb_w - SHADOW_OFFSET, BoxStartY + 12, pb_w, pb_h, pb_p, pb_w, + 0, 0, COL_INFOBAR_PLUS_0, COL_INFOBAR_SHADOW_PLUS_0, "", COL_INFOBAR); } -#endif int currTimeW = 0; int nextTimeW = 0; @@ -1220,7 +1220,7 @@ void CInfoViewer::show_Data (bool calledFromEvent) frameBuffer->paintBoxRel (b112+4, posy + 2, 98, 14, COL_INFOBAR_PLUS_0); oldrunningPercent = file_prozent; } - timescale->paint(b112+4, posy + 2, runningPercent); + timescale->paintProgressBar2(b112+4, posy + 2, runningPercent); int xStart = BoxStartX + ChanWidth; int ChanInfoY = BoxStartY + ChanHeight + 15; //+10 diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 42390b001..e0bbb1b55 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -40,7 +40,7 @@ #include #include #include "widget/menue.h" -#include +#include #include class CInfoViewer @@ -90,6 +90,9 @@ class CInfoViewer CChannelEventList evtlist; CChannelEventList::iterator eli; + int lastsnr, lastsig, lasthdd, lastvar, lasttime; + CProgressBar *snrscale, *sigscale, *hddscale, *varscale, *timescale; + void paintBackground(int col_Numbox); void show_Data( bool calledFromEvent = false ); void display_Info(const char *current, const char *next, bool UTF8 = true, @@ -115,7 +118,6 @@ class CInfoViewer void showMotorMoving(int duration); void showLcdPercentOver(); void showSNR(); - CScale * snrscale, * sigscale; public: bool chanready; diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index c5e7b80a0..513a395aa 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -90,8 +89,8 @@ void CMotorControl::Init(void) motorPosition = 1; satellitePosition = 0; stepDelay = 10; - sigscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); - snrscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); + sigscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); + snrscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); } int CMotorControl::exec(CMenuTarget* parent, const std::string &) @@ -109,6 +108,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) sigscale->reset(); snrscale->reset(); + lastsnr = lastsig = -1; bool istheend = false; int lim_cmd; @@ -680,23 +680,25 @@ void CMotorControl::showSNR() bheight = mheight - 5; posy = y + height - mheight - 5; - if(sigscale->getPercent() != sig) { + if (lastsig != sig) { + lastsig = sig; posx = x + 10; sprintf(percent, "%d%% SIG", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SIG"); - sigscale->paint(posx-1, posy, sig); + sigscale->paintProgressBar2(posx-1, posy, sig); 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); } - if(snrscale->getPercent() != snr) { + if (lastsnr != snr) { + lastsnr = snr; posx = x + 10 + 210; sprintf(percent, "%d%% SNR", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SNR"); - snrscale->paint(posx-1, posy, snr); + snrscale->paintProgressBar2(posx-1, posy, snr); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h index 5d88e5a03..7270fb5c6 100644 --- a/src/gui/motorcontrol.h +++ b/src/gui/motorcontrol.h @@ -34,8 +34,8 @@ #define __motorcontrol__ #include +#include #include -#include #include @@ -65,7 +65,8 @@ class CMotorControl : public CMenuTarget uint8_t motorPosition; int32_t satellitePosition; int satfindpid; - CScale * snrscale, * sigscale; + int lastsnr, lastsig; + CProgressBar *snrscale, *sigscale; void paint(); void paintMenu(void); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index deeab59ed..f3733a2d1 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -64,14 +64,14 @@ #include #include #include -#include +#include #include #include extern CPictureViewer * g_PicViewer; #define PIC_W 52 #define PIC_H 39 -static CScale * timescale; +static CProgressBar *timescale; #define ROUND_RADIUS 9 #define my_scandir scandir64 @@ -3893,13 +3893,13 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) } CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); - if(!timescale) - timescale = new CScale(200, 15, 0, 100, 0); + if (! timescale) + timescale = new CProgressBar(200, 15, PB_COLORED, 0, 100, 0); 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->paint(x + 41, y + 12, percent); + timescale->paintProgressBar2(x + 41, y + 12, percent); int len = minfo->length; off64_t size = minfo->file.Size; //off64_t secsize = len ? size/len/60 : 511040; @@ -4041,7 +4041,7 @@ if(buf[0] != 0x47) printf("cut: buffer not aligned at %lld\n", sdone); sdone += r; spos += r - wptr; percent = (int) ((float)(spos)/(float)(newsize)*100.); - timescale->paint(x + 41, y + 12, percent); + timescale->paintProgressBar2(x + 41, y + 12, percent); #if REAL_CUT int wr = write(dstfd, &buf[wptr], r-wptr); if(wr < (r-wptr)) { @@ -4147,13 +4147,13 @@ static off64_t copy_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi printf("copy: len %d minute %lld second %lld\n", len, len ? size/len : 511040*60, secsize); CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); - if(!timescale) - timescale = new CScale(200, 15, 0, 100, 0); + if (! timescale) + timescale = new CProgressBar(200, 15, PB_COLORED, 0, 100, 0); 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->paint(x + 41, y + 12, percent); + timescale->paintProgressBar2(x + 41, y + 12, percent); newsize = 0; for(int book_nr = 0; book_nr < MI_MOVIE_BOOK_USER_MAX; book_nr++) { @@ -4269,7 +4269,7 @@ if(buf[0] != 0x47) printf("copy: buffer not aligned at %lld\n", sdone); spos += r - wptr; btotal += r; percent = (int) ((float)(btotal)/(float)(newsize)*100.); - timescale->paint(x + 41, y + 12, percent); + timescale->paintProgressBar2(x + 41, y + 12, percent); #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 00f6b09fd..99bdd92cd 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include @@ -47,6 +46,7 @@ #include #include +#include #include @@ -66,9 +66,6 @@ extern CFrontend * frontend; #define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" TP_params TP; -#define RED_BAR 40 -#define YELLOW_BAR 70 -#define GREEN_BAR 100 #define BAR_BORDER 2 #define BAR_WIDTH 150 #define BAR_HEIGHT 16//(13 + BAR_BORDER*2) @@ -82,8 +79,8 @@ CScanTs::CScanTs() total = done = 0; freqready = 0; - sigscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); - snrscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); + sigscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); + snrscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); } @@ -119,6 +116,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) sigscale->reset(); snrscale->reset(); + lastsig = lastsnr = -1; if (!frameBuffer->getActive()) return menu_return::RETURN_EXIT_ALL; @@ -479,23 +477,25 @@ void CScanTs::showSNR () posy = y + height - mheight - 5; - if(sigscale->getPercent() != sig) { + if (lastsig != sig) { + lastsig = sig; posx = x + 20; sprintf(percent, "%d%% SIG", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SIG"); - sigscale->paint(posx - 1, posy+2, sig); + sigscale->paintProgressBar2(posx - 1, posy+2, sig); posx = posx + barwidth + 3; sw = x + 247 - posx; frameBuffer->paintBoxRel(posx, posy - 2, sw, mheight, COL_MENUCONTENT_PLUS_0); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx+2, posy + mheight, sw, percent, COL_MENUCONTENT); } - if(snrscale->getPercent() != snr) { + if (lastsnr != snr) { + lastsnr = snr; posx = x + 20 + 260; sprintf(percent, "%d%% SNR", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SNR"); - snrscale->paint(posx - 1, posy+2, snr); + snrscale->paintProgressBar2(posx - 1, posy+2, snr); posx = posx + barwidth + 3; sw = x + width - posx; diff --git a/src/gui/scan.h b/src/gui/scan.h index 05a90d8b7..ff832efc1 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -33,9 +33,9 @@ #define __scants__ #include +#include #include #include -#include #include @@ -64,7 +64,8 @@ class CScanTs : public CMenuTarget bool istheend; uint32_t total; uint32_t done; - CScale * snrscale, * sigscale; + int lastsnr, lastsig; + CProgressBar *snrscale, *sigscale; void paint(bool fortest = false); void paintLineLocale(int x, int * y, int width, const neutrino_locale_t l); diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 8923e4795..c24121443 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -135,14 +135,10 @@ int CStreamInfo2::exec (CMenuTarget * parent, const std::string &) int CStreamInfo2::doSignalStrengthLoop () { -#define RED_BAR 40 -#define YELLOW_BAR 70 -#define GREEN_BAR 100 #define BAR_WIDTH 150 #define BAR_HEIGHT 12 - - sigscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); - snrscale = new CScale(BAR_WIDTH, BAR_HEIGHT, RED_BAR, GREEN_BAR, YELLOW_BAR); + sigscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); + snrscale = new CProgressBar(BAR_WIDTH, BAR_HEIGHT); neutrino_msg_t msg; unsigned long long maxb, minb, lastb, tmp_rate; @@ -246,6 +242,7 @@ int CStreamInfo2::doSignalStrengthLoop () sigscale->reset(); if(snrscale) snrscale->reset(); + lastsnr = lastsig = -1; paint_mode = ++paint_mode % 2; paint (paint_mode); continue; @@ -788,23 +785,25 @@ void CStreamInfo2::showSNR () sig = (signal.sig & 0xFFFF) * 100 / 65535; int mheight = g_Font[font_info]->getHeight(); - if(sigscale->getPercent() != sig) { - posy = yypos + (mheight/2); + if (lastsig != sig) { + lastsig = sig; + posy = yypos + (mheight/2); posx = x + 10; sprintf(percent, "%d%% SIG", sig); sw = g_Font[font_info]->getRenderWidth (percent); - sigscale->paint(posx - 1, posy, sig); + sigscale->paintProgressBar2(posx - 1, posy, sig); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy -1, sw, mheight-8, COL_MENUHEAD_PLUS_0); g_Font[font_info]->RenderString (posx+2, posy + mheight-5, sw, percent, COL_MENUCONTENTDARK); } - if(snrscale->getPercent() != snr) { - posy = yypos + mheight + 4; + if (lastsnr != snr) { + lastsnr = snr; + posy = yypos + mheight + 4; posx = x + 10; sprintf(percent, "%d%% SNR", snr); sw = g_Font[font_info]->getRenderWidth (percent); - snrscale->paint(posx - 1, posy+2, snr); + 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 e85706659..99896fa7a 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -27,7 +27,7 @@ #include #include -#include +#include class CStreamInfo2 : public CMenuTarget @@ -91,8 +91,9 @@ class CStreamInfo2 : public CMenuTarget void paint_signal_fe(struct bitrate rate, struct feSignal s); int y_signal_fe(unsigned long value, unsigned long max_range, int max_y); void SignalRenderStr (unsigned int value, int x, int y); - CScale *sigscale; - CScale *snrscale; + CProgressBar *sigscale; + CProgressBar *snrscale; + int lastsig, lastsnr; void showSNR (); public: diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index 6f2e3c814..11a90ac0a 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -29,9 +29,9 @@ #include #include #include -#include +#include -static CScale * timescale; +static CProgressBar *timescale; #define TIMEOSD_FONT SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME #define TIMEBARH 38 @@ -42,8 +42,8 @@ CTimeOSD::CTimeOSD() visible=false; m_mode=MODE_ASC; GetDimensions(); - if(!timescale) - timescale = new CScale(200, 32, 40, 100, 70, true); + if (! timescale) + timescale = new CProgressBar(200, 32, PB_COLORED, 40, 100, 70, true); } CTimeOSD::~CTimeOSD() @@ -121,7 +121,7 @@ void CTimeOSD::update(time_t time_show) void CTimeOSD::updatePos(short runningPercent) { - timescale->paint(m_xstart, m_y, runningPercent); + timescale->paintProgressBar2(m_xstart, m_y, runningPercent); } void CTimeOSD::hide() diff --git a/src/gui/widget/progressbar.cpp b/src/gui/widget/progressbar.cpp index d699bb591..fbd9e7f04 100644 --- a/src/gui/widget/progressbar.cpp +++ b/src/gui/widget/progressbar.cpp @@ -26,19 +26,53 @@ #include "icons.h" #include "progressbar.h" +#define ITEMW 4 +#define POINT 2 -CProgressBar::CProgressBar() +#define RED 0xFF0000 +#define GREEN 0x00FF00 +#define YELLOW 0xFFFF00 + + +CProgressBar::CProgressBar(const bool bl, 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 = height = -1; +} + +CProgressBar::CProgressBar(const int w, const int h, + const bool bl, 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; } CProgressBar::~CProgressBar() { } +inline unsigned int make16color(__u32 rgb) +{ + return 0xFF000000 | rgb; +} + void CProgressBar::paintProgressBar ( const int pos_x, const int pos_y, const int pb_width, @@ -53,6 +87,41 @@ void CProgressBar::paintProgressBar ( const int pos_x, 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 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) { // set colors fb_pixel_t active_col = activebar_col != 0 ? activebar_col : COL_INFOBAR_PLUS_7; @@ -63,9 +132,8 @@ void CProgressBar::paintProgressBar ( const int pos_x, const int c_rad = 0; /* if the bar is too small, do not draw the borders around it */ - if (pb_height / 2 <= frame_widht) + if (height / 2 <= frame_widht || blink) frame_widht = 0; - // get icon size int icon_w = 0, icon_h = 0; icon_w = iconfile != NULL ? frameBuffer->getIconWidth(iconfile) : 0; @@ -78,33 +146,111 @@ void CProgressBar::paintProgressBar ( const int pos_x, // width active bar for current value int active_pb_width; if (max_value) - active_pb_width = (pb_width - icon_w - 2 * frame_widht) * value / 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 ? (pb_width - 2*frame_widht) - icon_w - frame_widht : pb_width - 2*frame_widht; + 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 > pb_height ? icon_h + 2* frame_widht : pb_height; + int pb_max_height = icon_h > height ? icon_h + 2* frame_widht : height; - // max height of active/passive bar - int bar_height = pb_max_height - 2*frame_widht; + if (! blink) + { + // 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; + 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, pb_width, pb_max_height, shadowbar_col, c_rad); // shadow + // 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+pb_width-10,pos_y, 10, pb_max_height, backgroundbar_col, c_rad, CORNER_RIGHT); - frameBuffer->paintBoxRel(pos_x+10,pos_y, pb_width-20, frame_widht, backgroundbar_col); - frameBuffer->paintBoxRel(pos_x+10,pos_y+pb_max_height-frame_widht, pb_width-20, frame_widht, backgroundbar_col); + // 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 + { + /* 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 hcnt = height / ITEMW; /* how many POINTs is the bar high */ + int maxi = active_pb_width / ITEMW; /* how many POINTs is the active bar */ + int total = width / ITEMW; /* total number of POINTs */ + + int i, j; + uint32_t rgb; + fb_pixel_t color; + int b = 0; + + 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 step; + if (active_pb_width > last_width) { + step = 255 / rd; + for (i = 0; (i < rd) && (i < maxi); i++) { + if (invert) + rgb = GREEN + ((unsigned char)(step * i) << 16); // adding red + else + rgb = RED + ((unsigned char)(step * i) << 8); // adding green + color = make16color(rgb); + for(j = 0; j <= hcnt; j++) + frameBuffer->paintBoxRel(pos_x + i * ITEMW, pos_y + j * ITEMW, + POINT, POINT, color); + } + step = 255 / yw / 2; + for (; (i < yw) && (i < maxi); i++) { + if (invert) + rgb = YELLOW - ((unsigned char)(step * (b++)) << 8); // removing green + else + rgb = YELLOW - ((unsigned char)(step * (b++)) << 16); // removing red + color = make16color(rgb); + for(j = 0; j <= hcnt; j++) + frameBuffer->paintBoxRel(pos_x + i * ITEMW, pos_y + j * ITEMW, + POINT, POINT, color); + } + step = 255 / gn; + for (; (i < gn) && (i < maxi); i++) { + if (invert) + rgb = YELLOW - ((unsigned char) (step * (b++)) << 8); // removing green + else + rgb = YELLOW - ((unsigned char) (step * (b++)) << 16); // removing red + color = make16color(rgb); + for(j = 0; j <= hcnt; j++) + frameBuffer->paintBoxRel(pos_x + i * ITEMW, pos_y + j * ITEMW, + POINT, POINT, color); + } + } + for(i = maxi; i < total; i++) { + for(j = 0; j <= hcnt; j++) + frameBuffer->paintBoxRel(pos_x + i * ITEMW, pos_y + j * ITEMW, + POINT, POINT, COL_INFOBAR_PLUS_3);//fill passive + } + last_width = active_pb_width; + } } // paint icon if present @@ -118,17 +264,12 @@ void CProgressBar::paintProgressBar ( const int pos_x, if (upper_labeltext != NULL) { g_Font[font_pbar]->RenderString(start_x +2, upper_labeltext_y, - pb_width, + width, upper_labeltext, uppertext_col != 0 ? uppertext_col : COL_INFOBAR, - pb_height, + height, true); // UTF8 } - - 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+pb_width-3, pos_y+pb_height-3, active_col); // zero line } diff --git a/src/gui/widget/progressbar.h b/src/gui/widget/progressbar.h index 4c54fe23d..be683bb06 100644 --- a/src/gui/widget/progressbar.h +++ b/src/gui/widget/progressbar.h @@ -21,12 +21,17 @@ #ifndef __gui_widget_progressbar_h__ #define __gui_widget_progressbar_h__ - +#include "config.h" #include #include #include #include +#ifdef NO_BLINKENLIGHTS +#define PB_COLORED false +#else +#define PB_COLORED true +#endif #include class CProgressBar @@ -35,9 +40,32 @@ class CProgressBar CFrameBuffer * frameBuffer; int font_pbar; int frame_widht; - + int last_width; + int red, green, yellow; + bool blink, invert; + 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: - CProgressBar(); + CProgressBar(const bool blinkenlights = PB_COLORED, + const int r = 40, + const int g = 100, + const int b =70, const bool inv = false); + CProgressBar(const int w, const int h, + const bool blinkenlights = PB_COLORED, + const int r = 40, + const int g = 100, + const int b =70, const bool inv = false); ~CProgressBar(); /// void paintProgressBar(...) @@ -81,14 +109,28 @@ class CProgressBar 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 */ }; #endif /* __gui_widget_progressbar_h__ */ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index eeee71694..5de913bb8 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -79,6 +79,7 @@ #include "gui/widget/icons.h" #include "gui/widget/lcdcontroler.h" #include "gui/widget/vfdcontroler.h" +#include "gui/widget/progressbar.h" #include "gui/widget/rgbcsynccontroler.h" #include "gui/widget/keychooser.h" #include "gui/widget/stringinput.h" @@ -112,7 +113,6 @@ #include "gui/pictureviewer.h" #include "gui/motorcontrol.h" #include "gui/filebrowser.h" -#include "gui/scale.h" #include "gui/cam_menu.h" #include "gui/hdd_menu.h" #include "gui/upnpbrowser.h" @@ -171,7 +171,7 @@ int dvbsub_pause(); //char current_volume; extern int list_changed; -static CScale * g_volscale; +static CProgressBar *g_volscale; //NEW static pthread_t timer_thread; void * timerd_main_thread(void *data); @@ -2376,7 +2376,7 @@ int CNeutrinoApp::run(int argc, char **argv) g_EpgData = new CEpgData; g_InfoViewer = new CInfoViewer; g_EventList = new EventList; - g_volscale = new CScale(200, 15, 50, 100, 80, true); + g_volscale = new CProgressBar(200, 15, PB_COLORED, 50, 100, 80, true); g_CamHandler = new CCAMMenuHandler(); g_CamHandler->init(); @@ -3624,7 +3624,7 @@ void CNeutrinoApp::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool frameBuffer->paintIcon("volume.raw",x,y, 0, COL_INFOBAR); frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); g_volscale->reset(); - g_volscale->paint(x + 41, y + 12, g_settings.current_volume); + g_volscale->paintProgressBar2(x + 41, y + 12, g_settings.current_volume); } neutrino_msg_data_t data; @@ -3668,7 +3668,7 @@ void CNeutrinoApp::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool if (bDoPaint) { if(vol != g_settings.current_volume) { vol = g_settings.current_volume; - g_volscale->paint(x + 41, y + 12, g_settings.current_volume); + g_volscale->paintProgressBar2(x + 41, y + 12, g_settings.current_volume); } } diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 4b81b4cdf..b4906cf07 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -110,7 +110,6 @@ #include "gui/pictureviewer.h" #include "gui/motorcontrol.h" #include "gui/filebrowser.h" -#include "gui/scale.h" #include "gui/upnpbrowser.h" #include