CInfoViewer: show time with CComponentsFrmClock object

This replaces old code that displayed time in infobar.
This commit is contained in:
2013-11-26 11:56:23 +01:00
parent c83263d5cd
commit ef374d7f8d
2 changed files with 22 additions and 28 deletions

View File

@@ -56,7 +56,6 @@
#include <gui/pictureviewer.h>
#include <gui/movieplayer.h>
#include <gui/infoclock.h>
#include <gui/components/cc.h>
#include <system/helpers.h>
@@ -94,6 +93,7 @@ CInfoViewer::CInfoViewer ()
sigscale = NULL;
snrscale = NULL;
timescale = NULL;
clock = NULL;
frameBuffer = CFrameBuffer::getInstance();
infoViewerBB = CInfoViewerBB::getInstance();
InfoHeightY = 0;
@@ -128,6 +128,7 @@ CInfoViewer::~CInfoViewer()
delete timescale;
delete infoViewerBB;
delete infobar_txt;
delete clock;
}
void CInfoViewer::Init()
@@ -243,35 +244,26 @@ void CInfoViewer::changePB()
timescale->setRgb(0, 100, 70);
}
void CInfoViewer::paintTime (bool show_dot, bool firstPaint)
void CInfoViewer::paintTime (bool show_dot)
{
if (! gotTime)
return;
char timestr[10];
time_t rawtime = time(NULL);
strftime ((char *) &timestr, sizeof(timestr), "%H:%M", localtime(&rawtime));
int clock_x = BoxEndX - time_width - LEFT_OFFSET;
int clock_y = ChanNameY;
int clock_w = time_width + LEFT_OFFSET;
int clock_h = time_height;
if ((!firstPaint) && (strcmp (timestr, old_timestr) == 0)) {
if (show_dot)
frameBuffer->paintBoxRel (BoxEndX - time_width + time_left_width - LEFT_OFFSET, ChanNameY, time_dot_width, time_height / 2 + 2, COL_INFOBAR_PLUS_0);
else
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString (BoxEndX - time_width + time_left_width - LEFT_OFFSET, ChanNameY + time_height, time_dot_width, ":", COL_INFOBAR_TEXT);
strcpy (old_timestr, timestr);
} else {
strcpy (old_timestr, timestr);
if (!firstPaint) {
frameBuffer->paintBoxRel(BoxEndX - time_width - LEFT_OFFSET, ChanNameY, time_width + LEFT_OFFSET, time_height, COL_INFOBAR_PLUS_0, RADIUS_SMALL, CORNER_TOP);
}
timestr[2] = 0;
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString (BoxEndX - time_width - LEFT_OFFSET, ChanNameY + time_height, time_left_width, timestr, COL_INFOBAR_TEXT);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString (BoxEndX - time_left_width - LEFT_OFFSET, ChanNameY + time_height, time_left_width, &timestr[3], COL_INFOBAR_TEXT);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString (BoxEndX - time_width + time_left_width - LEFT_OFFSET, ChanNameY + time_height, time_dot_width, ":", COL_INFOBAR_TEXT);
if (show_dot)
frameBuffer->paintBoxRel (BoxEndX - time_left_width - time_dot_width - LEFT_OFFSET, ChanNameY, time_dot_width, time_height / 2 + 2, COL_INFOBAR_PLUS_0);
if (clock == NULL){
clock = new CComponentsFrmClock();
clock->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
clock->doPaintBg(false);
}
clock->setDimensionsAll(clock_x, clock_y, clock_w, clock_h);
clock->setClockFont(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]);
clock->setClockFormat(show_dot ? "%H:%M" : "%H.%M");
clock->paint(CC_SAVE_SCREEN_NO);
}
void CInfoViewer::showRecordIcon (const bool show)
@@ -516,7 +508,7 @@ void CInfoViewer::showMovieTitle(const int playState, const t_channel_id &Channe
paintBackground(COL_INFOBAR_PLUS_0);
bool show_dot = true;
paintTime (show_dot, true);
paintTime (show_dot);
showRecordIcon (show_dot);
show_dot = !show_dot;
@@ -686,7 +678,7 @@ void CInfoViewer::showTitle (const int ChanNum, const std::string & Channel, con
paintBackground(col_NumBox);
bool show_dot = true;
paintTime (show_dot, true);
paintTime (show_dot);
showRecordIcon (show_dot);
show_dot = !show_dot;
@@ -878,7 +870,7 @@ void CInfoViewer::loop(bool show_dot)
res = messages_return::cancel_info;
} else if ((msg == NeutrinoMessages::EVT_TIMER) && (data == sec_timer_id)) {
showSNR ();
paintTime (show_dot, false);
paintTime (show_dot);
showRecordIcon (show_dot);
show_dot = !show_dot;
showInfoFile();

View File

@@ -44,6 +44,7 @@
#include <gui/infoviewer_bb.h>
#include <string>
#include <zapit/channel.h>
#include <gui/components/cc.h>
class CInfoViewer
{
@@ -51,6 +52,7 @@ class CInfoViewer
CFrameBuffer * frameBuffer;
CInfoViewerBB* infoViewerBB;
CComponentsFrmClock *clock;
bool gotTime;
bool recordModeActive;
@@ -116,7 +118,7 @@ class CInfoViewer
const char *runningStart = NULL, const char *runningRest = NULL,
const char *nextStart = NULL, const char *nextDuration = NULL,
bool update_current = true, bool update_next = true);
void paintTime( bool show_dot, bool firstPaint );
void paintTime( bool show_dot );
void showRecordIcon(const bool show);
void showIcon_Tuner() const;