diff --git a/src/Makefile.am b/src/Makefile.am index 91444eafc..8963ecbb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,6 +62,7 @@ neutrino_LDADD = \ gui/libneutrino_gui2.a \ gui/components/libneutrino_gui_components.a \ eitd/libsectionsd.a \ + gui/volumebar.o \ driver/libneutrino_driver.a \ driver/audiodec/libneutrino_driver_audiodec.a \ driver/libneutrino_driver_netfile.a \ diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index c6442d60f..e5230a0e3 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -1758,18 +1758,3 @@ void CFrameBuffer::displayRGB(unsigned char *rgbbuff, int x_size, int y_size, in blit2FB(fbbuff, x_size, y_size, x_offs, y_offs, x_pan, y_pan); cs_free_uncached(fbbuff); } - -void CFrameBuffer::paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, bool paintFrame) -{ - if(paint) { - if (paintFrame) { - paintBackgroundBoxRel(ax, ay, dx, dy); - paintBoxRel(ax, ay, dx, dy, COL_MENUCONTENT_PLUS_0, RADIUS_SMALL); - } - int icon_dx=0, icon_dy=0; - getIconSize(NEUTRINO_ICON_BUTTON_MUTE, &icon_dx, &icon_dy); - paintIcon(NEUTRINO_ICON_BUTTON_MUTE, ax+((dx-icon_dx)/2), ay+((dy-icon_dy)/2)); - } - else - paintBackgroundBoxRel(ax, ay, dx, dy); -} diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index e1f79e119..c994d3a68 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -232,7 +232,6 @@ class CFrameBuffer void displayRGB(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, bool clearfb = true, int transp = 0xFF); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); bool blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh); - void paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, bool paintFrame=true); enum { diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp index 052c58fa1..73c3cff88 100644 --- a/src/driver/volume.cpp +++ b/src/driver/volume.cpp @@ -1,26 +1,24 @@ /* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + volume bar - Neutrino-GUI - - Copyright (C) 2001 Steffen Hehn 'McClean' - and some other guys - Homepage: http://dbox.cyberphoria.org/ - - Copyright (C) 2011-2012 M. Liebmann (micha-bbg) + Copyright (C) 2011-2013 M. Liebmann (micha-bbg) License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ @@ -37,11 +35,9 @@ #include #include #include +#include #include -#if HAVE_COOL_HARDWARE -#include -#endif extern CRemoteControl * g_RemoteControl; extern cAudio * audioDecoder; @@ -50,23 +46,13 @@ CVolume::CVolume() { frameBuffer = CFrameBuffer::getInstance(); volscale = NULL; -#if 0 - g_Zapit = new CZapitClient; - g_RCInput = new CRCInput; - v_RemoteControl = new CRemoteControl; -#endif - VolumeFont = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO; - paintShadow = false; // For future On/Off switch shadow - MuteIconFrame = false; // For future On/Off switch IconFrame - ShadowOffset = 4; + mute_ax = 0; mute_ay = 0; + mute_dx = 0; + mute_dy = 0; m_mode = CNeutrinoApp::getInstance()->getMode(); channel_id = 0; apid = 0; - digit_h = 0; - digit_offset = 0; - - Init(); } CVolume::~CVolume() @@ -74,120 +60,6 @@ CVolume::~CVolume() delete volscale; } -void CVolume::Init() -{ - paintDigits = g_settings.volume_digits; - mute_ay_old = mute_ay; - int faktor_h = 18; // scale * 10 - int clock_height= 0; - int clock_width = 0; - - pB = 2; // progress border - spacer = 8; - - colBar = COL_MENUCONTENT_PLUS_0; - colFrame = COL_MENUCONTENT_PLUS_3; - colContent = COL_MENUCONTENT; - colShadow = COL_MENUCONTENTDARK_PLUS_0; - - x = frameBuffer->getScreenX(); - y = sy = frameBuffer->getScreenY() + spacer / 2; - sw = g_settings.screen_EndX - spacer; - sh = frameBuffer->getScreenHeight(); - icon_w = icon_h = 0; - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_w, &icon_h); - if (paintDigits) { - digit_offset = g_Font[VolumeFont]->getDigitOffset(); - digit_h = g_Font[VolumeFont]->getDigitHeight(); - } - vbar_h = std::max((icon_h * faktor_h) / 10, digit_h + digit_offset); - progress_h = icon_h - 2*pB; - progress_w = 200; - vbar_w = spacer + icon_w + spacer + progress_w + spacer; - if (paintDigits) { - digit_w = g_Font[VolumeFont]->getRenderWidth("100"); - progress_h = std::max(icon_h, digit_h); - vbar_w += digit_w; - } - if (volscale) - delete volscale; - volscale = new CProgressBar(progress_x, progress_y, progress_w, progress_h, colFrame, colBar, colShadow, COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1, true); - volscale->setInvert(); - volscale->setFrameThickness(2); - - // mute icon - mute_icon_dx = 0; - 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; - mute_ax = sw - mute_dx; - mute_ay = y; - - CNeutrinoApp* neutrino = CNeutrinoApp::getInstance(); - - 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_ay += (clock_height - mute_dy) / 2; - } - else { - // Volume level and MuteIcon in a line. - if (mute_dy > vbar_h) - y += (mute_dy - vbar_h) / 2; - else - mute_ay += (vbar_h - mute_dy) / 2; - } - - if ((g_settings.mode_clock) && (!neutrino->isMuted())) - frameBuffer->paintBackgroundBoxRel(sw - clock_width, y, clock_width, clock_height); -//printf("\n##### [volume.cpp Zeile %d] mute_ax %d, mute_dx %d\n \n", __LINE__, mute_ax, mute_dx); - switch (g_settings.volume_pos) - { - 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->isMuted()) && (!g_settings.mode_clock)) - x_corr = mute_dx + spacer; - if (g_settings.mode_clock) - y += clock_height + spacer / 2; - } - x = sw - vbar_w - x_corr; - break; - } - case 1:// upper left - break; - case 2:// bottom left - y = sh - vbar_h; - break; - case 3:// bottom right - x = sw - vbar_w; - y = sh - vbar_h; - break; - case 4:// center default - x = ((sw - vbar_w) / 2) + x; - break; - case 5:// center higher - x = ((sw - vbar_w) / 2) + x; - y = sh - sh/15; - break; - } - - icon_x = x + spacer; - icon_y = y + ((vbar_h - icon_h) / 2); - progress_x = icon_x + icon_w + spacer; - progress_y = y + ((vbar_h - progress_h) / 2); - if (paintDigits) { - digit_x = progress_x + progress_w + spacer/2; - digit_y = y + digit_h + digit_offset + ((vbar_h - digit_h) / 2); - digit_b_x = digit_x - spacer/4; - digit_b_w = vbar_w - (digit_b_x - x); - } -} - CVolume* CVolume::getInstance() { static CVolume* Volume = NULL; @@ -196,36 +68,12 @@ CVolume* CVolume::getInstance() return Volume; } -void CVolume::AudioMute(int newValue, bool isEvent) -{ - CNeutrinoApp* neutrino = CNeutrinoApp::getInstance(); - bool doInit = newValue != (int) neutrino->isMuted(); - - CVFD::getInstance()->setMuted(newValue); - neutrino->setCurrentMuted(newValue); - g_Zapit->muteAudio(newValue); - - if( isEvent && ( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_audio) && ( neutrino->getMode() != CNeutrinoApp::mode_pic)) - { - if ((mute_ay_old != mute_ay) && (mute_ay_old > 0)) - frameBuffer->paintBackgroundBoxRel(mute_ax, mute_ay_old, mute_dx, mute_dy); - if ((g_settings.mode_clock) && (doInit)) - CInfoClock::getInstance(true)->ClearDisplay(); - frameBuffer->paintMuteIcon(newValue, mute_ax, mute_ay, mute_dx, mute_dy, MuteIconFrame); - if (doInit) { - Init(); - CInfoClock::getInstance(true)->Init(true); - } - } -} - void CVolume::setvol(int vol) { - //audioDecoder->setVolume(vol, vol); CZapit::getInstance()->SetVolume(vol); } -void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowait) +void CVolume::setVolume(const neutrino_msg_t key, bool nowait) { neutrino_msg_t msg = key; int mode = CNeutrinoApp::getInstance()->getMode(); @@ -233,34 +81,25 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa if (msg <= CRCInput::RC_MaxRC) { if(m_mode != mode) { m_mode = mode; - Init(); setVolume(msg); return; } } - - int vol = g_settings.current_volume; - fb_pixel_t * pixbuf = NULL; - if(bDoPaint) { - pixbuf = new fb_pixel_t[(vbar_w+ShadowOffset) * (vbar_h+ShadowOffset)]; - if(pixbuf!= NULL) - frameBuffer->SaveScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); + if (volscale){ + volscale->hide(); + delete volscale; + volscale = NULL; + } - // volumebar shadow - if (paintShadow) - frameBuffer->paintBoxRel(x+ShadowOffset , y+ShadowOffset , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colShadow, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); - // volumebar - frameBuffer->paintBoxRel(x , y , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colBar, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); - // volume icon - frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar); - - volscale->reset(); - refreshVolumebar(vol); + if (volscale == NULL){ + volscale = new CVolumeBar(); + volscale->paint(); } neutrino_msg_data_t data; uint64_t timeoutEnd; + int vol = g_settings.current_volume; do { if (msg <= CRCInput::RC_MaxRC) @@ -271,16 +110,17 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa (sub_chan_keybind && (msg == CRCInput::RC_right || msg == CRCInput::RC_left))) { int dir = (msg == CRCInput::RC_plus || msg == CRCInput::RC_right) ? 1 : -1; if (CNeutrinoApp::getInstance()->isMuted() && (dir > 0 || g_settings.current_volume > 0)) { - if ((bDoPaint) && (pixbuf!= NULL)) { - frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); - delete [] pixbuf; + if (volscale){ + if (volscale->isPainted()) + volscale->hide(); + delete volscale; + volscale = NULL; } - AudioMute(false, true); - Init(); + CAudioMute::getInstance()->AudioMute(false, true); setVolume(msg); return; } - + if (!CNeutrinoApp::getInstance()->isMuted()) { /* current_volume is char, we need signed to catch v < 0 */ int v = g_settings.current_volume; @@ -291,12 +131,13 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa v = 0; g_settings.current_volume = 0; if (g_settings.show_mute_icon) { - if (bDoPaint && pixbuf != NULL) { - frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); - delete []pixbuf; + if (volscale) { + if (volscale->isPainted()) + volscale->hide(); + delete volscale; + volscale = NULL; } - AudioMute(true, true); - Init(); + CAudioMute::getInstance()->AudioMute(true, true); setVolume(msg); return; } @@ -322,10 +163,10 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa break; } - if (bDoPaint) { + if (volscale) { if(vol != g_settings.current_volume) { vol = g_settings.current_volume; - refreshVolumebar(g_settings.current_volume); + volscale->repaintVolScale(); } } @@ -335,30 +176,14 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa } } while (msg != CRCInput::RC_timeout); - if( (bDoPaint) && (pixbuf!= NULL) ) { - frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); - delete [] pixbuf; + if (volscale) { + if (volscale->isPainted()) + volscale->hide(); + delete volscale; + volscale = NULL; } } -void CVolume::refreshVolumebar(int current_volume) -{ - if (paintDigits) { - // shadow for erase digits - if (paintShadow) - frameBuffer->paintBoxRel(digit_b_x+ShadowOffset, y+ShadowOffset, digit_b_w, vbar_h, colShadow, ROUNDED, CORNER_TOP_RIGHT | CORNER_BOTTOM_RIGHT); - // erase digits - frameBuffer->paintBoxRel(digit_b_x, y, digit_b_w, vbar_h, colBar, ROUNDED, CORNER_TOP_RIGHT | CORNER_BOTTOM_RIGHT); - // digits - char buff[4]; - snprintf(buff, 4, "%3d", current_volume); - g_Font[VolumeFont]->RenderString(digit_x, digit_y, digit_w, buff, colContent); - } - // progressbar - volscale->setValues(current_volume, 100); - volscale->paint(); -} - bool CVolume::changeNotify(const neutrino_locale_t OptionName, void * data) { bool ret = false; diff --git a/src/driver/volume.h b/src/driver/volume.h index 1acb333b1..06fa956b6 100644 --- a/src/driver/volume.h +++ b/src/driver/volume.h @@ -1,26 +1,24 @@ /* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + volume bar - Neutrino-GUI - - Copyright (C) 2001 Steffen Hehn 'McClean' - and some other guys - Homepage: http://dbox.cyberphoria.org/ - - Copyright (C) 2011-2012 M. Liebmann (micha-bbg) + Copyright (C) 2011-2013 M. Liebmann (micha-bbg) License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ @@ -29,28 +27,16 @@ #define __CVOLUME__ #include - -#define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0 +#include class CVolume : public CChangeObserver { private: CFrameBuffer * frameBuffer; - CProgressBar *volscale; - void refreshVolumebar(int current_volume); + CVolumeBar *volscale; - int x, y, sy, sw, sh; - int mute_ax, mute_ay, mute_dy, mute_ay_old; - int mute_icon_dx, mute_icon_dy; - int icon_w, icon_h, icon_x, icon_y; - int vbar_w, vbar_h; - int progress_w, progress_h, progress_x, progress_y, pB; - int digit_w, digit_h, digit_offset, digit_x, digit_y, digit_b_x, digit_b_w; - int VolumeFont, colShadow, colBar, colFrame, colContent; - int ShadowOffset; - int rounded; + int mute_ax, mute_ay, mute_dx, mute_dy; int m_mode; - bool paintShadow, paintDigits, MuteIconFrame; /* volume adjustment variables */ t_channel_id channel_id; int apid; @@ -59,14 +45,9 @@ class CVolume : public CChangeObserver CVolume(); ~CVolume(); static CVolume* getInstance(); - - int spacer, mute_dx; - void Init(); - void AudioMute(int newValue, bool isEvent= false); + void setvol(int vol); - void setVolume(const neutrino_msg_t key, const bool bDoPaint = true, bool nowait = false); - int getStartPosTop(){ return sy; } - int getEndPosRight(){ return sw; } + void setVolume(const neutrino_msg_t key, bool nowait = false); void SetCurrentPid(int pid) { apid = pid; } void SetCurrentChannel(t_channel_id id) { channel_id = id; } diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index f09b8aab4..32de74671 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -53,6 +53,7 @@ noinst_LIBRARIES = libtimerlist.a libneutrino_gui.a libneutrino_gui2.a libneutrino_gui_a_SOURCES = \ audio_select.cpp \ audio_setup.cpp \ + audiomute.cpp \ audioplayer.cpp \ audioplayer_setup.cpp\ bookmarkmanager.cpp \ @@ -110,6 +111,7 @@ libneutrino_gui_a_SOURCES = \ user_menue_setup.cpp \ vfd_setup.cpp \ videosettings.cpp \ + volumebar.cpp \ pipsetup.cpp \ zapit_setup.cpp diff --git a/src/gui/audiomute.cpp b/src/gui/audiomute.cpp new file mode 100644 index 000000000..409ca5187 --- /dev/null +++ b/src/gui/audiomute.cpp @@ -0,0 +1,87 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + audioMute - Neutrino-GUI + Copyright (C) 2013 M. Liebmann (micha-bbg) + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include + +CAudioMute::CAudioMute() +{ + mute_ax = 0; + mute_ay = 0; + mute_dx = 0; + mute_dy = 0; + mute_ay_old = -1; + 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); +} + +CAudioMute::~CAudioMute() +{ + delete mIcon; +} + +CAudioMute* CAudioMute::getInstance() +{ + static CAudioMute* Mute = NULL; + if(!Mute) + Mute = new CAudioMute(); + return Mute; +} + +void CAudioMute::AudioMute(int newValue, bool isEvent) +{ + CNeutrinoApp* neutrino = CNeutrinoApp::getInstance(); + bool doInit = newValue != (int) neutrino->isMuted(); + + CVFD::getInstance()->setMuted(newValue); + neutrino->setCurrentMuted(newValue); + g_Zapit->muteAudio(newValue); + + if( isEvent && ( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_audio) && ( neutrino->getMode() != CNeutrinoApp::mode_pic)) + { + CVolumeHelper::getInstance()->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy); + if ((mIcon) && (mute_ay_old != mute_ay)) { + mIcon->hide(); + mIcon->setYPos(mute_ay); + mute_ay_old = mute_ay; + } + if ((g_settings.mode_clock) && (doInit)) + CInfoClock::getInstance(true)->ClearDisplay(); + + if (newValue) + mIcon->paint(); + else + mIcon->hide(); + + if (doInit) + CInfoClock::getInstance(true)->Init(true); + } +} diff --git a/src/gui/audiomute.h b/src/gui/audiomute.h new file mode 100644 index 000000000..a45fa70e2 --- /dev/null +++ b/src/gui/audiomute.h @@ -0,0 +1,48 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + audioMute - Neutrino-GUI + Copyright (C) 2013 M. Liebmann (micha-bbg) + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __CAUDIOMUTE__ +#define __CAUDIOMUTE__ + +#include + +class CAudioMute +{ + private: + int mute_ay_old; + int mute_ax, mute_ay, mute_dx, mute_dy; + CComponentsPicture *mIcon; + + public: + + CAudioMute(); + ~CAudioMute(); + static CAudioMute* getInstance(); + + void AudioMute(int newValue, bool isEvent= false); +}; + +#endif // __CAUDIOMUTE__ diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index dee035330..4dae4fd86 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #define YOFF 0 @@ -33,14 +34,18 @@ CInfoClock::~CInfoClock() void CInfoClock::Init(bool noVolume) { - static int mute_dx = 0; - static int spacer = 0; + static int mute_dx = 0, mute_dy = 0, y_org = 0, spacer = 0; + int mute_corrY = 0; if (!noVolume) { - x = CVolume::getInstance()->getEndPosRight(); - y = CVolume::getInstance()->getStartPosTop(); - mute_dx = CVolume::getInstance()->mute_dx; - spacer = CVolume::getInstance()->spacer; + 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(); @@ -49,8 +54,14 @@ void CInfoClock::Init(bool noVolume) 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()) + 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); + } } CInfoClock* CInfoClock::getInstance(bool noVolume) @@ -98,7 +109,6 @@ void CInfoClock::ClearDisplay() void CInfoClock::StartClock() { Init(); - CVolume::getInstance()->Init(); if(!thrTimer) { pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ; @@ -108,7 +118,6 @@ void CInfoClock::StartClock() void CInfoClock::StopClock() { - CVolume::getInstance()->Init(); if(thrTimer) { pthread_cancel(thrTimer); thrTimer = 0; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 539bc1216..f9c23648a 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -891,15 +891,9 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) g_InfoViewer->changePB(); return true; } - else if ((ARE_LOCALES_EQUAL(OptionName, LOCALE_EXTRA_VOLUME_POS)) || - (ARE_LOCALES_EQUAL(OptionName, LOCALE_EXTRA_VOLUME_DIGITS))){ - CVolume::getInstance()->Init(); - return false; - } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_EXTRA_ROUNDED_CORNERS)) { osd_menu->hide(); g_settings.rounded_corners = * (int*) data; - CVolume::getInstance()->Init(); return true; } else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_RADIOTEXT)) { diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 75fec5699..c13975fbd 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -450,7 +450,7 @@ int CScanTs::handleMsg(neutrino_msg_t msg, neutrino_msg_data_t data) case CRCInput::RC_minus: case CRCInput::RC_left: case CRCInput::RC_right: - CVolume::getInstance()->setVolume(msg, true, true); + CVolume::getInstance()->setVolume(msg, true /*nowait = true*/); break; default: if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp new file mode 100644 index 000000000..65ead0134 --- /dev/null +++ b/src/gui/volumebar.cpp @@ -0,0 +1,317 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Volumebar class for gui. + Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, M. Liebmann (micha-bbg) + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include "gui/volumebar.h" + +#include +#include +#include + +using namespace std; + +CVolumeBar::CVolumeBar() +{ + initVarVolumeBar(); +} + +void CVolumeBar::initVarVolumeBar() +{ + //init inherited variables + initVarForm(); + col_body = COL_MENUCONTENT_PLUS_0; + height = 36; //default height + + //init variables this + + //assume volume value as pointer to global setting + vb_vol = &g_settings.current_volume; + + //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; + vb_pbx = 0; + vb_pbw = 0; + vb_pbh = 0; + vb_pby = 0; + // progressbar whith + pb_w = 200; + + //digit + vb_digit = NULL; + vb_digit_mode = CTextBox::CENTER; + VolumeFont = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO; + vb_font = g_Font[VolumeFont]; + + initVolumeBarSize(); + initVolumeBarPosition(); + initVolumeBarItems(); +} + +//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_w = g_Font[VolumeFont]->getRenderWidth("100 "); + } + else + digit_w = 0; + + //adapt x-pos + icon_x = corner_rad + 2; + pb_x = icon_x + icon_w + 4; + digit_x = pb_x + pb_w + 5; + + //width + if (g_settings.volume_digits) + width = digit_x + digit_w + corner_rad; + else + width = pb_x + pb_w + corner_rad + 12; + + CVolumeHelper *cvh = CVolumeHelper::getInstance(); + cvh->getSpacer(&h_spacer, &v_spacer); + cvh->getDimensions(&x, &y, &sw, &sh); + + // mute icon + cvh->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy); + + clock_height = 0; + int clock_width = 0; + 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; + } + cvh->setMuteIconCorrY(mute_corrY); + + if ((g_settings.mode_clock) && (!CNeutrinoApp::getInstance()->isMuted())) + frameBuffer->paintBackgroundBoxRel(sw - clock_width, y, clock_width, clock_height); + + vb_pbh = height-8; + vb_pby = height/2-vb_pbh/2; +} + +//init current position of form +void CVolumeBar::initVolumeBarPosition() +{ + CNeutrinoApp* neutrino = CNeutrinoApp::getInstance(); + + switch (g_settings.volume_pos) + { + 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->isMuted()) && (!g_settings.mode_clock)) + x_corr = mute_dx + h_spacer; + if (g_settings.mode_clock) + y += clock_height + v_spacer / 2; + } + x = sw - width - x_corr; + break; + } + case 1:// upper left + break; + case 2:// bottom left + y = (sh + frameBuffer->getScreenY()) - height - v_spacer; + break; + case 3:// bottom right + x = sw - width; + y = (sh + frameBuffer->getScreenY()) - height - v_spacer; + break; + case 4:// upper center + x = ((sw - width) / 2) + x; + break; + case 5:// bottom center + x = ((sw - width) / 2) + x; + y = (sh + frameBuffer->getScreenY()) - height - v_spacer; + break; + } +} + +void CVolumeBar::initVolumeBarItems() +{ + //icon + initVolumeBarIcon(); + + //scale + initVolumeBarScale(); + + //digits + if (g_settings.volume_digits) + initVolumeBarDigit(); +} + +//init current icon object +void CVolumeBar::initVolumeBarIcon() +{ + vb_icon = new CComponentsPicture(icon_x, 0, icon_w, height, NEUTRINO_ICON_VOLUME); + + vb_icon->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); + vb_icon->setColorBody(col_body); + vb_icon->setCornerRadius(corner_rad); + vb_icon->setCornerType(CORNER_LEFT); + + //add icon to container + addCCItem(vb_icon); +} + +//create new scale +void CVolumeBar::initVolumeBarScale() +{ + vb_pb = new CProgressBar(); + + vb_pbx = pb_x; + vb_pbw = pb_w; + + vb_pb->setInvert(); + vb_pb->setBlink(); + vb_pb->setRgb(85, 75, 100); + vb_pb->setFrameThickness(2); + vb_pb->setProgress(vb_pbx, vb_pby, vb_pbw, vb_pbh, *vb_vol, 100); + + //add progressbar to container + addCCItem(vb_pb); +} + +//set digit text with current volume value +void CVolumeBar::initVolumeBarDigitValue() +{ + vb_digit->setText(*vb_vol ,vb_digit_mode, vb_font); +} + +//create digit +void CVolumeBar::initVolumeBarDigit() +{ + vb_digit = new CComponentsLabel(); + + vb_digit->setDimensionsAll(digit_x, 0, digit_w, height); + vb_digit->setTextColor(COL_MENUCONTENT); + initVolumeBarDigitValue(); + + //add digit label to container + addCCItem(vb_digit); +} + +//refresh and paint digit +void CVolumeBar::paintVolumeBarDigit() +{ + // digits + CTextBox* ctb = vb_digit->getCTextBoxObject(); + if (ctb) + ctb->setFontUseDigitHeight(); + int dx = vb_digit->getRealXPos(); + int dy = vb_digit->getRealYPos(); + vb_digit->setDimensionsAll(dx, dy, digit_w, height); + vb_digit->paint(CC_SAVE_SCREEN_NO); +} + + +//refresh progressbar and digit +void CVolumeBar::repaintVolScale() +{ + paintVolScale(); + + if (g_settings.volume_digits) { + initVolumeBarDigitValue(); + paintVolumeBarDigit(); + } +} + +//set current volume value and paint form +void CVolumeBar::paintVolScale() +{ + vb_pb->setValue(*vb_vol); + vb_pb->paint(CC_SAVE_SCREEN_NO); +} + + +//final paint +void CVolumeBar::paint(bool do_save_bg) +{ + //paint form + paintForm(do_save_bg); +} + + +// CVolumeHelper #################################################################################################### + +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(); + + 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; + mute_ax = sw - mute_dx; + mute_ay = y; + mute_corrY = 0; +} + +CVolumeHelper* CVolumeHelper::getInstance() +{ + static CVolumeHelper* Helper = NULL; + if(!Helper) + Helper = new CVolumeHelper(); + return Helper; +} diff --git a/src/gui/volumebar.h b/src/gui/volumebar.h new file mode 100644 index 000000000..ce78b7f65 --- /dev/null +++ b/src/gui/volumebar.h @@ -0,0 +1,98 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Volumebar class for gui. + Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, M. Liebmann (micha-bbg) + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __VOLUMEBAR_H__ +#define __VOLUMEBAR_H__ + +#include //CComponentsForm +#include //CProgressBar + +class CVolumeBar : public CComponentsForm +{ + private: + CProgressBar *vb_pb; + CComponentsPicture *vb_icon; + CComponentsLabel *vb_digit; + int vb_digit_mode; + Font* vb_font; + int VolumeFont; + int sy, sw, sh; + int mute_ax, mute_ay, mute_dx, mute_dy, mute_ay_old; + int h_spacer, v_spacer; + + //clock + int clock_height; + + //volume value + char *vb_vol; + + //scale dimensions + int vb_pbx, vb_pby, vb_pbw, vb_pbh; + int icon_x, pb_x, digit_x; + int icon_w, pb_w, digit_w; + + void initVarVolumeBar(); + void initVolumeBarPosition(); + void initVolumeBarSize(); + + void initVolumeBarIcon(); + void initVolumeBarScale(); + void initVolumeBarDigitValue(); + void initVolumeBarDigit(); + void initVolumeBarItems(); + + void paintVolScale(); + void paintVolumeBarDigit(); + + public: + + CVolumeBar(/*int current_volume*/); +// ~CVolumeBar(); inherited from CComponentsForm + + void repaintVolScale(); + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + + +class CVolumeHelper +{ + private: + int x, y, sw, sh; + int mute_ax, mute_ay, mute_dx, mute_dy, mute_corrY; + int h_spacer, v_spacer; + + public: + + CVolumeHelper(); + static CVolumeHelper* getInstance(); + + 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 setMuteIconCorrY(int corr) { mute_corrY = corr; } +}; + +#endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 54decf183..decdc70fe 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -58,6 +58,7 @@ #include #include +#include "gui/audiomute.h" #include "gui/audioplayer.h" #include "gui/bouquetlist.h" #include "gui/cam_menu.h" @@ -173,6 +174,7 @@ CRemoteControl * g_RemoteControl; CPictureViewer * g_PicViewer; CCAMMenuHandler * g_CamHandler; CVolume * g_volume; +CAudioMute * g_audioMute; // Globale Variablen - to use import global.h @@ -1909,6 +1911,7 @@ TIMER_START(); InitTimerdClient(); g_volume = CVolume::getInstance(); + g_audioMute = CAudioMute::getInstance(); if (show_startwizard) { hintBox->hide(); @@ -1932,7 +1935,7 @@ TIMER_START(); cCA::GetInstance()->Ready(true); InitZapper(); - g_volume->AudioMute(current_muted, true); + g_audioMute->AudioMute(current_muted, true); SHTDCNT::getInstance()->init(); hintBox->hide(); @@ -2045,7 +2048,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) g_RCInput->clearRCMsg(); // restore mute symbol if (current_muted) - g_volume->AudioMute(current_muted, true); + g_audioMute->AudioMute(current_muted, true); if(g_settings.mode_clock) InfoClock->StartClock(); StartSubtitles(); @@ -2058,7 +2061,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) mainMenu.exec(NULL, ""); // restore mute symbol if (current_muted) - g_volume->AudioMute(current_muted, true); + g_audioMute->AudioMute(current_muted, true); if(g_settings.mode_clock) InfoClock->StartClock(); StartSubtitles(); @@ -2379,7 +2382,7 @@ _show: nNewChannel = bouquetList->exec(true); // restore mute symbol if (current_muted) - g_volume->AudioMute(current_muted, true); + g_audioMute->AudioMute(current_muted, true); } else if(msg == CRCInput::RC_sat) { SetChannelMode(LIST_MODE_SAT); nNewChannel = bouquetList->exec(true); @@ -2539,16 +2542,16 @@ _repeat: } else { //mute - g_volume->AudioMute(!current_muted, true); + g_audioMute->AudioMute(!current_muted, true); } return messages_return::handled; } else if( msg == CRCInput::RC_mute_on ) { - g_volume->AudioMute(true, true); + g_audioMute->AudioMute(true, true); return messages_return::handled; } else if( msg == CRCInput::RC_mute_off ) { - g_volume->AudioMute(false, true); + g_audioMute->AudioMute(false, true); return messages_return::handled; } else if( msg == CRCInput::RC_analog_on ) { @@ -3111,8 +3114,6 @@ void CNeutrinoApp::tvMode( bool rezap ) } g_InfoViewer->setUpdateTimer(LCD_UPDATE_TIME_TV_MODE); - g_volume->Init(); - CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->ShowIcon(FP_ICON_TV, true); @@ -3315,7 +3316,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) if(g_settings.mode_clock) InfoClock->StartClock(); - g_volume->AudioMute(current_muted, true); + g_audioMute->AudioMute(current_muted, true); StartSubtitles(); } lockStandbyCall = false; @@ -3935,6 +3936,8 @@ void CNeutrinoApp::Cleanup() delete g_CamHandler; g_CamHandler = NULL; printf("cleanup 17\n");fflush(stdout); delete g_volume; g_volume = NULL; + printf("cleanup 17a\n");fflush(stdout); + delete g_audioMute; g_audioMute = NULL; printf("cleanup 18\n");fflush(stdout); delete g_EpgData; g_EpgData = NULL; printf("cleanup 19\n");fflush(stdout); diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 2470b6fe7..59b833b45 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -184,12 +184,6 @@ void CColorSetupNotifier::setPalette() bool CColorSetupNotifier::changeNotify(const neutrino_locale_t, void *) { setPalette(); -#if 0 - /* recalculate volumebar */ - CVolume::getInstance()->Init(); - /* recalculate infoclock */ - CInfoClock::getInstance()->Init(); -#endif return false; } @@ -249,8 +243,6 @@ bool CFontSizeNotifier::changeNotify(const neutrino_locale_t, void *) CNeutrinoApp::getInstance()->SetupFonts(); hintBox.hide(); - /* recalculate volumebar */ - CVolume::getInstance()->Init(); /* recalculate infoclock */ CInfoClock::getInstance()->Init(); return true;