From 32baf72e169a5f08f3b6227787efbb6e7771de8c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 26 Nov 2013 11:56:23 +0100 Subject: [PATCH] CInfoViewer: show time with CComponentsFrmClock object This replaces old code that displayed time in infobar. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/ef374d7f8d5966a59225abf201c9a556befc560a Author: Thilo Graf Date: 2013-11-26 (Tue, 26 Nov 2013) --- src/gui/infoviewer.cpp | 46 +++++++++++++++++------------------------- src/gui/infoviewer.h | 4 +++- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index da32cc8c5..1e5f31946 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -56,7 +56,6 @@ #include #include #include -#include #include @@ -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 *) ×tr, 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, ×tr[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(); diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 367d609c3..e842f18eb 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -44,6 +44,7 @@ #include #include #include +#include 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;