*CVolume: move static g_volscale to volscale

- Is only needed in this class, not global.
- move scope of variable x_corr. (style) scope of the variable x_corr
  can be limited
- move declaration of framebuffer into header file
This commit is contained in:
2012-07-29 22:31:24 +02:00
committed by micha-bbg
parent ec7ed403a1
commit f3ac0b9fd9
2 changed files with 16 additions and 12 deletions

View File

@@ -36,7 +36,6 @@
#include <audio_cs.h> #include <audio_cs.h>
#include <system/settings.h> #include <system/settings.h>
#include <daemonc/remotecontrol.h> #include <daemonc/remotecontrol.h>
#include <driver/framebuffer.h>
#include <driver/volume.h> #include <driver/volume.h>
#include <zapit/zapit.h> #include <zapit/zapit.h>
@@ -44,14 +43,13 @@
#include <gui/widget/progressbar.h> #include <gui/widget/progressbar.h>
#endif #endif
CFrameBuffer * frameBuffer;
extern CRemoteControl * g_RemoteControl; extern CRemoteControl * g_RemoteControl;
extern cAudio * audioDecoder; extern cAudio * audioDecoder;
static CProgressBar *g_volscale = NULL;
CVolume::CVolume() CVolume::CVolume()
{ {
frameBuffer = CFrameBuffer::getInstance(); frameBuffer = CFrameBuffer::getInstance();
volscale = NULL;
#if 0 #if 0
g_Zapit = new CZapitClient; g_Zapit = new CZapitClient;
g_RCInput = new CRCInput; g_RCInput = new CRCInput;
@@ -71,8 +69,7 @@ CVolume::CVolume()
CVolume::~CVolume() CVolume::~CVolume()
{ {
if (g_volscale) delete volscale;
delete g_volscale;
} }
void CVolume::Init() void CVolume::Init()
@@ -82,7 +79,7 @@ void CVolume::Init()
int faktor_h = 18; // scale * 10 int faktor_h = 18; // scale * 10
int clock_height= 0; int clock_height= 0;
int clock_width = 0; int clock_width = 0;
int x_corr = 0;
pB = 2; // progress border pB = 2; // progress border
spacer = 8; spacer = 8;
@@ -108,8 +105,9 @@ void CVolume::Init()
progress_h = std::max(icon_h, digit_h) - 2*pB; progress_h = std::max(icon_h, digit_h) - 2*pB;
vbar_w += digit_w; vbar_w += digit_w;
} }
delete g_volscale; if (volscale)
g_volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true); delete volscale;
volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true);
// mute icon // mute icon
mute_icon_dx = 0; mute_icon_dx = 0;
@@ -143,7 +141,8 @@ void CVolume::Init()
//printf("\n##### [volume.cpp Zeile %d] mute_ax %d, mute_dx %d\n \n", __LINE__, mute_ax, mute_dx); //printf("\n##### [volume.cpp Zeile %d] mute_ax %d, mute_dx %d\n \n", __LINE__, mute_ax, mute_dx);
switch (g_settings.volume_pos) switch (g_settings.volume_pos)
{ {
case 0:// upper right case 0:{// upper right
int x_corr = 0;
if (( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_audio) && ( neutrino->getMode() != CNeutrinoApp::mode_pic)) { if (( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_audio) && ( neutrino->getMode() != CNeutrinoApp::mode_pic)) {
if ((neutrino->isMuted()) && (!g_settings.mode_clock)) if ((neutrino->isMuted()) && (!g_settings.mode_clock))
x_corr = mute_dx + spacer; x_corr = mute_dx + spacer;
@@ -152,6 +151,7 @@ void CVolume::Init()
} }
x = sw - vbar_w - x_corr; x = sw - vbar_w - x_corr;
break; break;
}
case 1:// upper left case 1:// upper left
break; break;
case 2:// bottom left case 2:// bottom left
@@ -251,7 +251,7 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa
// volume icon // volume icon
frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar); frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar);
g_volscale->reset(); volscale->reset();
refreshVolumebar(vol); refreshVolumebar(vol);
} }
@@ -357,7 +357,7 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa
void CVolume::refreshVolumebar(int current_volume) void CVolume::refreshVolumebar(int current_volume)
{ {
// progressbar // progressbar
g_volscale->paintProgressBar2(progress_x, progress_y, current_volume); volscale->paintProgressBar2(progress_x, progress_y, current_volume);
if (paintDigits) { if (paintDigits) {
// shadow for erase digits // shadow for erase digits
if (paintShadow) if (paintShadow)

View File

@@ -28,11 +28,15 @@
#ifndef __CVOLUME__ #ifndef __CVOLUME__
#define __CVOLUME__ #define __CVOLUME__
#include <driver/framebuffer.h>
#define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0 #define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0
class CVolume : public CChangeObserver class CVolume : public CChangeObserver
{ {
private: private:
CFrameBuffer * frameBuffer;
CProgressBar *volscale;
void refreshVolumebar(int current_volume); void refreshVolumebar(int current_volume);
int x, y, sy, sw, sh; int x, y, sy, sw, sh;
@@ -55,7 +59,7 @@ class CVolume : public CChangeObserver
CVolume(); CVolume();
~CVolume(); ~CVolume();
static CVolume* getInstance(); static CVolume* getInstance();
int spacer, mute_dx; int spacer, mute_dx;
void Init(); void Init();
void AudioMute(int newValue, bool isEvent= false); void AudioMute(int newValue, bool isEvent= false);