Infoclock: correct position on the screen (Patch by snafed)

- Optimized code


git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1965 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Commit: 6840e8f434
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2011-12-12 (Mon, 12 Dec 2011)

Origin message was:
------------------
* Infoclock: correct position on the screen (Patch by snafed)
- Optimized code


git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1965 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
Michael Liebmann
2011-12-12 01:45:35 +00:00
parent 63aec64d7c
commit 3ffcd3c7b6
2 changed files with 32 additions and 14 deletions

View File

@@ -16,15 +16,10 @@
CInfoClock::CInfoClock() CInfoClock::CInfoClock()
{ {
frameBuffer = CFrameBuffer::getInstance(); frameBuffer = CFrameBuffer::getInstance();
x = frameBuffer->getScreenWidth(); x = y = clock_x = 0;
y = frameBuffer->getScreenY(); time_height = time_width = thrTimer = 0;
Init();
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;
} }
CInfoClock::~CInfoClock() CInfoClock::~CInfoClock()
@@ -34,6 +29,25 @@ CInfoClock::~CInfoClock()
thrTimer = 0; 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) void CInfoClock::paintTime( bool show_dot)
{ {
char timestr[20]; char timestr[20];
@@ -41,8 +55,9 @@ void CInfoClock::paintTime( bool show_dot)
strftime((char*) &timestr, sizeof(timestr), "%H:%M:%S", localtime(&tm)); strftime((char*) &timestr, sizeof(timestr), "%H:%M:%S", localtime(&tm));
timestr[2] = show_dot ? ':':'.'; timestr[2] = show_dot ? ':':'.';
frameBuffer->paintBoxRel(x - time_width - 10, y, time_width, time_height, COL_MENUCONTENT_PLUS_0, RADIUS_SMALL); int x_diff = (time_width - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(timestr)) / 2;
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString(x - time_width- 5, y+ time_height, time_width, timestr, COL_MENUCONTENT); 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) void* CInfoClock::TimerProc(void *arg)
@@ -52,8 +67,7 @@ void* CInfoClock::TimerProc(void *arg)
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0);
CInfoClock *InfoClock = (CInfoClock*) arg; CInfoClock *InfoClock = static_cast<CInfoClock*>(arg);
InfoClock->paintTime(show_dot); InfoClock->paintTime(show_dot);
while(1) { while(1) {
sleep(1); sleep(1);
@@ -65,6 +79,8 @@ void* CInfoClock::TimerProc(void *arg)
void CInfoClock::StartClock() void CInfoClock::StartClock()
{ {
Init();
if(!thrTimer) { if(!thrTimer) {
pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ; pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ;
pthread_detach(thrTimer); pthread_detach(thrTimer);
@@ -76,6 +92,6 @@ void CInfoClock::StopClock()
if(thrTimer) { if(thrTimer) {
pthread_cancel(thrTimer); pthread_cancel(thrTimer);
thrTimer = 0; thrTimer = 0;
frameBuffer->paintBackgroundBoxRel(x - time_width - 10, y, time_width, time_height); frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height);
} }
} }

View File

@@ -17,8 +17,10 @@ class CInfoClock
CFrameBuffer * frameBuffer; CFrameBuffer * frameBuffer;
pthread_t thrTimer; pthread_t thrTimer;
void Init();
int time_width; int time_width;
int time_height; int time_height;
int clock_x;
void paintTime( bool show_dot); void paintTime( bool show_dot);
int y,x; int y,x;
static void CleanUpProc(void* arg); static void CleanUpProc(void* arg);