mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
Rework positioning of volumebar / mute icon / info clock
- Is required for custom icons
Origin commit data
------------------
Commit: cfd7b4b16b
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-05-10 (Fri, 10 May 2013)
Origin message was:
------------------
* Rework positioning of volumebar / mute icon / info clock
- Is required for custom icons
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
|
||||
#define YOFF 0
|
||||
|
||||
CInfoClock::CInfoClock(bool noVolume)
|
||||
CInfoClock::CInfoClock()
|
||||
{
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
x = y = clock_x = 0;
|
||||
time_height = time_width = thrTimer = 0;
|
||||
Init(noVolume);
|
||||
Init();
|
||||
}
|
||||
|
||||
CInfoClock::~CInfoClock()
|
||||
@@ -32,53 +32,35 @@ CInfoClock::~CInfoClock()
|
||||
thrTimer = 0;
|
||||
}
|
||||
|
||||
void CInfoClock::Init(bool noVolume)
|
||||
void CInfoClock::Init()
|
||||
{
|
||||
static int mute_dx = 0, mute_dy = 0, y_org = 0, spacer = 0;
|
||||
int mute_corrY = 0;
|
||||
if (!noVolume) {
|
||||
CVolumeHelper *vh = CVolumeHelper::getInstance();
|
||||
int dummy;
|
||||
vh->getDimensions(&dummy, &y, &x, &dummy);
|
||||
vh->getMuteIconDimensions(&dummy, &dummy, &mute_dx, &mute_dy);
|
||||
vh->getSpacer(&spacer, &dummy);
|
||||
y_org = y;
|
||||
}
|
||||
else
|
||||
y = y_org;
|
||||
|
||||
digit_offset = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getDigitOffset();
|
||||
digit_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getDigitHeight();
|
||||
int t1 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(widest_number);
|
||||
int t2 = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(":");
|
||||
time_height = digit_h + (int)((float)digit_offset * 1.5);
|
||||
time_width = t1*6 + t2*2;
|
||||
clock_x = x - time_width;
|
||||
if (CNeutrinoApp::getInstance()->isMuted()) {
|
||||
clock_x -= (mute_dx + spacer);
|
||||
if (mute_dy > time_height)
|
||||
y += (mute_dy - time_height) / 2;
|
||||
else
|
||||
mute_corrY = (time_height - mute_dy) / 2;
|
||||
CVolumeHelper::getInstance()->setMuteIconCorrY(mute_corrY);
|
||||
}
|
||||
CVolumeHelper::getInstance()->refresh();
|
||||
CVolumeHelper::getInstance()->getInfoClockDimensions(&clock_x, &y, &time_width, &time_height, &digit_h, &digit_offset);
|
||||
}
|
||||
|
||||
CInfoClock* CInfoClock::getInstance(bool noVolume)
|
||||
CInfoClock* CInfoClock::getInstance()
|
||||
{
|
||||
static CInfoClock* InfoClock = NULL;
|
||||
if(!InfoClock)
|
||||
InfoClock = new CInfoClock(noVolume);
|
||||
InfoClock = new CInfoClock();
|
||||
return InfoClock;
|
||||
}
|
||||
|
||||
void CInfoClock::paintTime( bool show_dot)
|
||||
{
|
||||
char timestr[20];
|
||||
int dummy, mute_dx, h_spacer;
|
||||
time_t tm = time(0);
|
||||
strftime((char*) ×tr, sizeof(timestr), "%H:%M:%S", localtime(&tm));
|
||||
timestr[2] = show_dot ? ':':'.';
|
||||
|
||||
CVolumeHelper *cvh = CVolumeHelper::getInstance();
|
||||
cvh->getInfoClockDimensions(&clock_x, &y, &time_width, &time_height, &digit_h, &digit_offset);
|
||||
cvh->getMuteIconDimensions(&dummy, &dummy, &mute_dx, &dummy);
|
||||
cvh->getSpacer(&h_spacer, &dummy);
|
||||
if (CNeutrinoApp::getInstance()->isMuted())
|
||||
clock_x -= (mute_dx + h_spacer);
|
||||
|
||||
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 + digit_h + digit_offset + ((time_height - digit_h) / 2), time_width, timestr, COL_MENUCONTENT);
|
||||
@@ -104,6 +86,7 @@ void* CInfoClock::TimerProc(void *arg)
|
||||
void CInfoClock::ClearDisplay()
|
||||
{
|
||||
frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height);
|
||||
Init();
|
||||
}
|
||||
|
||||
void CInfoClock::StartClock()
|
||||
|
Reference in New Issue
Block a user