CInfoViewer: rework init and paint of clock

This removes some dimension assignments in start() because of
already existant and usable dimension values that comes directly
from clock object.
This commit is contained in:
2014-12-19 09:11:05 +01:00
committed by svenhoefer
parent 0013e139a5
commit a58bd6c235
2 changed files with 22 additions and 27 deletions

View File

@@ -130,6 +130,7 @@ CInfoViewer::~CInfoViewer()
void CInfoViewer::Init() void CInfoViewer::Init()
{ {
initClock();
BoxStartX = BoxStartY = BoxEndX = BoxEndY = 0; BoxStartX = BoxStartY = BoxEndX = BoxEndY = 0;
recordModeActive = false; recordModeActive = false;
is_visible = false; is_visible = false;
@@ -216,16 +217,9 @@ void CInfoViewer::start ()
ChanNameY = BoxStartY + (ChanHeight / 2) + SHADOW_OFFSET; //oberkante schatten? ChanNameY = BoxStartY + (ChanHeight / 2) + SHADOW_OFFSET; //oberkante schatten?
ChanInfoX = BoxStartX + (ChanWidth / 3); ChanInfoX = BoxStartX + (ChanWidth / 3);
int digit_width = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getMaxDigitWidth(); initClock();
int dot_width = max(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(":"), time_height = clock->getHeight();
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(" ")); time_width = clock->getWidth();
time_width = (digit_width * 4) + dot_width;
time_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getHeight();
if (clock) {
delete clock;
clock = NULL;
}
} }
void CInfoViewer::changePB() void CInfoViewer::changePB()
@@ -244,6 +238,23 @@ void CInfoViewer::changePB()
timescale->setType(CProgressBar::PB_TIMESCALE); timescale->setType(CProgressBar::PB_TIMESCALE);
} }
void CInfoViewer::initClock()
{
if (clock == NULL){
clock = new CComponentsFrmClock();
clock->doPaintBg(false);
}
clock->setColorBody(COL_INFOBAR_PLUS_0);
clock->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
clock->setClockFont(SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME);
clock->setClockAlignment(CC_ALIGN_RIGHT | CC_ALIGN_HOR_CENTER);
clock->refresh();
clock->setPos(BoxEndX - 10 - clock->getWidth(), ChanNameY);
clock->setTextColor(COL_INFOBAR_TEXT);
}
void CInfoViewer::paintTime (bool show_dot) void CInfoViewer::paintTime (bool show_dot)
{ {
if (!gotTime) if (!gotTime)
@@ -252,23 +263,7 @@ void CInfoViewer::paintTime (bool show_dot)
if (!gotTime) if (!gotTime)
return; return;
int clock_w = time_width;
int clock_h = time_height;
int clock_x = BoxEndX - 10 - clock_w;
int clock_y = ChanNameY;
if (clock == NULL){
clock = new CComponentsFrmClock();
clock->doPaintBg(false);
}
clock->setColorBody(COL_INFOBAR_PLUS_0);
clock->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
clock->setDimensionsAll(clock_x, clock_y, clock_w, clock_h);
clock->setClockFont(SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME);
clock->setClockFormat(show_dot ? "%H:%M" : "%H %M"); clock->setClockFormat(show_dot ? "%H:%M" : "%H %M");
clock->setTextColor(COL_INFOBAR_TEXT);
clock->paint(CC_SAVE_SCREEN_NO); clock->paint(CC_SAVE_SCREEN_NO);
} }

View File

@@ -115,8 +115,8 @@ class CInfoViewer
const char *runningStart = NULL, const char *runningRest = NULL, const char *runningStart = NULL, const char *runningRest = NULL,
const char *nextStart = NULL, const char *nextDuration = NULL, const char *nextStart = NULL, const char *nextDuration = NULL,
bool update_current = true, bool update_next = true); bool update_current = true, bool update_next = true);
void initClock();
void paintTime( bool show_dot ); void paintTime( bool show_dot );
void showRecordIcon(const bool show); void showRecordIcon(const bool show);
void showIcon_Tuner() const; void showIcon_Tuner() const;