mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
* Rework positioning of volumebar / mute icon / info clock
- Is required for custom icons
This commit is contained in:
@@ -39,6 +39,7 @@ CAudioMute::CAudioMute()
|
||||
mute_dx = 0;
|
||||
mute_dy = 0;
|
||||
mute_ay_old = -1;
|
||||
CVolumeHelper::getInstance()->refresh();
|
||||
CVolumeHelper::getInstance()->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy);
|
||||
mIcon = new CComponentsPicture(mute_ax, mute_ay, mute_dx, mute_dy, NEUTRINO_ICON_BUTTON_MUTE);
|
||||
}
|
||||
@@ -74,7 +75,7 @@ void CAudioMute::AudioMute(int newValue, bool isEvent)
|
||||
mute_ay_old = mute_ay;
|
||||
}
|
||||
if ((g_settings.mode_clock) && (doInit))
|
||||
CInfoClock::getInstance(true)->ClearDisplay();
|
||||
CInfoClock::getInstance()->ClearDisplay();
|
||||
|
||||
if (newValue)
|
||||
mIcon->paint();
|
||||
@@ -82,6 +83,6 @@ void CAudioMute::AudioMute(int newValue, bool isEvent)
|
||||
mIcon->hide();
|
||||
|
||||
if (doInit)
|
||||
CInfoClock::getInstance(true)->Init(true);
|
||||
CVolumeHelper::getInstance()->refresh();
|
||||
}
|
||||
}
|
||||
|
@@ -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()
|
||||
|
@@ -20,15 +20,15 @@ class CInfoClock
|
||||
void paintTime( bool show_dot);
|
||||
int time_offset, digit_offset, digit_h;
|
||||
int x, y, clock_x;
|
||||
void Init();
|
||||
static void CleanUpProc(void* arg);
|
||||
static void* TimerProc(void *arg);
|
||||
|
||||
public:
|
||||
CInfoClock(bool noVolume=false);
|
||||
CInfoClock();
|
||||
~CInfoClock();
|
||||
static CInfoClock* getInstance(bool noVolume=false);
|
||||
static CInfoClock* getInstance();
|
||||
|
||||
void Init(bool noVolume=false);
|
||||
void StartClock();
|
||||
void StopClock();
|
||||
void ClearDisplay();
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "gui/volumebar.h"
|
||||
|
||||
#include <global.h>
|
||||
@@ -37,6 +36,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
//default vol_height
|
||||
#define VOL_HEIGHT 36
|
||||
|
||||
CVolumeBar::CVolumeBar()
|
||||
{
|
||||
initVarVolumeBar();
|
||||
@@ -47,7 +49,6 @@ void CVolumeBar::initVarVolumeBar()
|
||||
//init inherited variables
|
||||
initVarForm();
|
||||
col_body = COL_MENUCONTENT_PLUS_0;
|
||||
height = 36; //default height
|
||||
|
||||
//init variables this
|
||||
|
||||
@@ -57,12 +58,6 @@ void CVolumeBar::initVarVolumeBar()
|
||||
//items
|
||||
//icon object
|
||||
vb_icon = NULL;
|
||||
// icon whith / height
|
||||
int tmp_h = 0;
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_w, &tmp_h);
|
||||
icon_w += 12;
|
||||
tmp_h += 4;
|
||||
height = max(height, tmp_h);
|
||||
|
||||
//progressbar object
|
||||
vb_pb = NULL;
|
||||
@@ -87,16 +82,14 @@ void CVolumeBar::initVarVolumeBar()
|
||||
//calculates size referred for possible activated clock or/and mute icon
|
||||
void CVolumeBar::initVolumeBarSize()
|
||||
{
|
||||
int tmp_h = height;
|
||||
|
||||
// digit whith / height
|
||||
if (g_settings.volume_digits) {
|
||||
tmp_h = g_Font[VolumeFont]->getDigitHeight() + (g_Font[VolumeFont]->getDigitOffset() * 18) / 10;
|
||||
height = max(height, tmp_h);
|
||||
// digit whith
|
||||
if (g_settings.volume_digits)
|
||||
digit_w = g_Font[VolumeFont]->getRenderWidth("100 ");
|
||||
}
|
||||
else
|
||||
digit_w = 0;
|
||||
int dummy = 0;
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_w, &dummy);
|
||||
icon_w += 12;
|
||||
|
||||
//adapt x-pos
|
||||
icon_x = corner_rad + 2;
|
||||
@@ -112,30 +105,19 @@ void CVolumeBar::initVolumeBarSize()
|
||||
CVolumeHelper *cvh = CVolumeHelper::getInstance();
|
||||
cvh->getSpacer(&h_spacer, &v_spacer);
|
||||
cvh->getDimensions(&x, &y, &sw, &sh);
|
||||
cvh->getVolBarDimensions(&y, &height);
|
||||
|
||||
// mute icon
|
||||
cvh->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy);
|
||||
|
||||
clock_height = 0;
|
||||
int clock_width = 0;
|
||||
// info clock
|
||||
cvh->getInfoClockDimensions(&dummy, &clock_y, &clock_width, &clock_height, &dummy, &dummy);
|
||||
int mute_corrY = 0;
|
||||
if ((g_settings.mode_clock) && (g_settings.volume_pos == 0)) {
|
||||
// Clock and MuteIcon in a line.
|
||||
clock_height = CInfoClock::getInstance(true)->time_height;
|
||||
clock_width = CInfoClock::getInstance(true)->time_width;
|
||||
mute_corrY = (clock_height - mute_dy) / 2;
|
||||
}
|
||||
else {
|
||||
// Volume level and MuteIcon in a line.
|
||||
if (mute_dy > height)
|
||||
y += (mute_dy - height) / 2;
|
||||
else
|
||||
mute_corrY = (height - mute_dy) / 2;
|
||||
}
|
||||
if (mute_dy < height)
|
||||
mute_corrY = (height - mute_dy) / 2;
|
||||
cvh->setMuteIconCorrY(mute_corrY);
|
||||
|
||||
if ((g_settings.mode_clock) && (!CNeutrinoApp::getInstance()->isMuted()))
|
||||
frameBuffer->paintBackgroundBoxRel(sw - clock_width, y, clock_width, clock_height);
|
||||
CInfoClock::getInstance()->ClearDisplay();
|
||||
|
||||
vb_pbh = height-8;
|
||||
vb_pby = height/2-vb_pbh/2;
|
||||
@@ -154,7 +136,7 @@ void CVolumeBar::initVolumeBarPosition()
|
||||
if ((neutrino->isMuted()) && (!g_settings.mode_clock))
|
||||
x_corr = mute_dx + h_spacer;
|
||||
if (g_settings.mode_clock)
|
||||
y += clock_height + v_spacer / 2;
|
||||
y += max(clock_y + clock_height, mute_ay + mute_dy) /*+ v_spacer / 2*/;
|
||||
}
|
||||
x = sw - width - x_corr;
|
||||
break;
|
||||
@@ -290,22 +272,75 @@ CVolumeHelper::CVolumeHelper()
|
||||
h_spacer = 11;
|
||||
v_spacer = 6;
|
||||
|
||||
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
|
||||
x = frameBuffer->getScreenX() + h_spacer;
|
||||
y = frameBuffer->getScreenY() + v_spacer;
|
||||
sw = g_settings.screen_EndX - h_spacer;
|
||||
sh = frameBuffer->getScreenHeight();
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
|
||||
int mute_icon_dx = 0;
|
||||
int mute_icon_dy = 0;
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE, &mute_icon_dx, &mute_icon_dy);
|
||||
mute_dx = mute_icon_dx;
|
||||
mute_dy = mute_icon_dy;
|
||||
mute_dx += mute_icon_dx / 4;
|
||||
mute_dy += mute_icon_dx / 4;
|
||||
Init();
|
||||
}
|
||||
|
||||
void CVolumeHelper::Init()
|
||||
{
|
||||
|
||||
x = frameBuffer->getScreenX() + h_spacer;
|
||||
y = frameBuffer->getScreenY() + v_spacer;
|
||||
sw = g_settings.screen_EndX - h_spacer;
|
||||
sh = frameBuffer->getScreenHeight();
|
||||
|
||||
initVolBarHeight();
|
||||
initMuteIcon();
|
||||
initInfoClock();
|
||||
}
|
||||
|
||||
void CVolumeHelper::initInfoClock()
|
||||
{
|
||||
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(":");
|
||||
clock_dy = digit_h + (int)((float)digit_offset * 1.5);
|
||||
clock_dx = t1*6 + t2*2;
|
||||
clock_ax = sw - clock_dx;
|
||||
clock_ay = y;
|
||||
vol_ay = y;
|
||||
mute_corrY = 0;
|
||||
|
||||
if (g_settings.mode_clock) {
|
||||
if (mute_dy > clock_dy)
|
||||
clock_ay += (mute_dy - clock_dy) / 2;
|
||||
else
|
||||
mute_corrY = (clock_dy - mute_dy) / 2;
|
||||
}
|
||||
else {
|
||||
if (mute_dy > vol_height)
|
||||
vol_ay += (mute_dy - vol_height) / 2;
|
||||
else
|
||||
mute_corrY = (vol_height - mute_dy) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeHelper::initMuteIcon()
|
||||
{
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE, &mute_dx, &mute_dy);
|
||||
mute_ax = sw - mute_dx;
|
||||
mute_ay = y;
|
||||
mute_corrY = 0;
|
||||
}
|
||||
|
||||
void CVolumeHelper::initVolBarHeight()
|
||||
{
|
||||
vol_height = VOL_HEIGHT;
|
||||
int tmp_h = 0;
|
||||
int dummy = 0;
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &dummy, &tmp_h);
|
||||
tmp_h += 4;
|
||||
vol_height = max(vol_height, tmp_h);
|
||||
if (g_settings.volume_digits) {
|
||||
tmp_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getDigitHeight() + (g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getDigitOffset() * 18) / 10;
|
||||
vol_height = max(vol_height, tmp_h);
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeHelper::refresh()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
CVolumeHelper* CVolumeHelper::getInstance()
|
||||
|
@@ -44,7 +44,7 @@ class CVolumeBar : public CComponentsForm
|
||||
int h_spacer, v_spacer;
|
||||
|
||||
//clock
|
||||
int clock_height;
|
||||
int clock_y, clock_width, clock_height;
|
||||
|
||||
//volume value
|
||||
char *vb_vol;
|
||||
@@ -82,7 +82,15 @@ class CVolumeHelper
|
||||
private:
|
||||
int x, y, sw, sh;
|
||||
int mute_ax, mute_ay, mute_dx, mute_dy, mute_corrY;
|
||||
int clock_ax, clock_ay, clock_dx, clock_dy, digit_h, digit_offset;
|
||||
int h_spacer, v_spacer;
|
||||
int vol_ay, vol_height;
|
||||
CFrameBuffer *frameBuffer;
|
||||
|
||||
void Init();
|
||||
void initVolBarHeight();
|
||||
void initMuteIcon();
|
||||
void initInfoClock();
|
||||
|
||||
public:
|
||||
|
||||
@@ -92,7 +100,10 @@ class CVolumeHelper
|
||||
void getSpacer(int *h, int *v) { *h = h_spacer; *v = v_spacer; }
|
||||
void getDimensions(int *_x, int *_y, int *_sw, int *_sh) { *_x = x; *_y = y; *_sw = sw; *_sh = sh; }
|
||||
void getMuteIconDimensions(int *_x, int *_y, int *w, int *h) { *_x = mute_ax; *_y = mute_ay+mute_corrY; *w = mute_dx; *h = mute_dy; }
|
||||
void getInfoClockDimensions(int *_x, int *_y, int *w, int *h, int *d_h, int *d_o) { *_x = clock_ax; *_y = clock_ay; *w = clock_dx; *h = clock_dy, *d_h = digit_h, *d_o = digit_offset; }
|
||||
void getVolBarDimensions(int *_y, int *_dy) { *_y = vol_ay; *_dy = vol_height; }
|
||||
void setMuteIconCorrY(int corr) { mute_corrY = corr; }
|
||||
void refresh();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -243,8 +243,8 @@ bool CFontSizeNotifier::changeNotify(const neutrino_locale_t, void *)
|
||||
CNeutrinoApp::getInstance()->SetupFonts();
|
||||
|
||||
hintBox.hide();
|
||||
/* recalculate infoclock */
|
||||
CInfoClock::getInstance()->Init();
|
||||
/* recalculate infoclock/muteicon/volumebar */
|
||||
CVolumeHelper::getInstance()->refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user