diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 7c71a13f9..cef4dbf32 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -16,15 +16,10 @@ CInfoClock::CInfoClock() { - frameBuffer = CFrameBuffer::getInstance(); - x = frameBuffer->getScreenWidth(); - y = frameBuffer->getScreenY(); - - time_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getHeight(); - int t1 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(widest_number); - int t2 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(":"); - time_width = t1*6 + t2*2; - thrTimer = 0; + frameBuffer = CFrameBuffer::getInstance(); + x = y = clock_x = 0; + time_height = time_width = thrTimer = 0; + Init(); } CInfoClock::~CInfoClock() @@ -34,6 +29,25 @@ CInfoClock::~CInfoClock() thrTimer = 0; } +void CInfoClock::Init() +{ + //TOTO Give me a framebuffer->getScreenEndX (); + x = frameBuffer->getScreenWidth() + frameBuffer->getScreenX(); + y = frameBuffer->getScreenY(); + + time_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getHeight(); + int t1 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(widest_number); + int t2 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(":"); + time_width = t1*6 + t2*2; + + int dvx, dummy; + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE,&dvx,&dummy); + dvx += (dvx/4); + + x -= dvx; + clock_x = x - time_width - 10; +} + void CInfoClock::paintTime( bool show_dot) { char timestr[20]; @@ -41,8 +55,9 @@ void CInfoClock::paintTime( bool show_dot) strftime((char*) ×tr, sizeof(timestr), "%H:%M:%S", localtime(&tm)); timestr[2] = show_dot ? ':':'.'; - frameBuffer->paintBoxRel(x - time_width - 10, y, time_width, time_height, COL_MENUCONTENT_PLUS_0, RADIUS_SMALL); - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString(x - time_width- 5, y+ time_height, time_width, timestr, COL_MENUCONTENT); + int x_diff = (time_width - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(timestr)) / 2; + frameBuffer->paintBoxRel(clock_x, y, time_width, time_height, COL_MENUCONTENT_PLUS_0, RADIUS_SMALL); + g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString(clock_x + x_diff, y + time_height, time_width, timestr, COL_MENUCONTENT); } void* CInfoClock::TimerProc(void *arg) @@ -52,8 +67,7 @@ void* CInfoClock::TimerProc(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); - CInfoClock *InfoClock = (CInfoClock*) arg; - + CInfoClock *InfoClock = static_cast(arg); InfoClock->paintTime(show_dot); while(1) { sleep(1); @@ -65,6 +79,8 @@ void* CInfoClock::TimerProc(void *arg) void CInfoClock::StartClock() { + Init(); + if(!thrTimer) { pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ; pthread_detach(thrTimer); @@ -76,6 +92,6 @@ void CInfoClock::StopClock() if(thrTimer) { pthread_cancel(thrTimer); thrTimer = 0; - frameBuffer->paintBackgroundBoxRel(x - time_width - 10, y, time_width, time_height); + frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height); } } diff --git a/src/gui/infoclock.h b/src/gui/infoclock.h index 3f7541985..f7b5f12c2 100644 --- a/src/gui/infoclock.h +++ b/src/gui/infoclock.h @@ -17,8 +17,10 @@ class CInfoClock CFrameBuffer * frameBuffer; pthread_t thrTimer; + void Init(); int time_width; int time_height; + int clock_x; void paintTime( bool show_dot); int y,x; static void CleanUpProc(void* arg);