From 04f20ee14bbcf9dfad66e902354e1daec93a8906 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sun, 18 Mar 2012 18:46:48 +0000 Subject: [PATCH] neutrino: GUI Painting of Vol. Mute and Clock (Part3) - Use new class for volumebar - Numeric display added for volumebar (switchable) - Display of volumebar, mute icon and info clock optimized (top right) - Volumebar better scalable git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@2153 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/6a5ffc315f750ec40a4ec5b76349686506ae937f Author: Michael Liebmann Date: 2012-03-18 (Sun, 18 Mar 2012) Origin message was: ------------------ * neutrino: GUI Painting of Vol. Mute and Clock (Part3) - Use new class for volumebar - Numeric display added for volumebar (switchable) - Display of volumebar, mute icon and info clock optimized (top right) - Volumebar better scalable git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@2153 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/driver/Makefile.am | 3 +- src/driver/volume.cpp | 327 +++++++++++++++++++++++++++++++++ src/driver/volume.h | 65 +++++++ src/gui/infoclock.cpp | 55 ++++-- src/gui/infoclock.h | 25 +-- src/gui/osd_setup.cpp | 10 +- src/gui/scan.cpp | 3 +- src/neutrino.cpp | 267 +++++---------------------- src/neutrino.h | 40 ++-- src/system/setting_helpers.cpp | 11 +- 10 files changed, 533 insertions(+), 273 deletions(-) create mode 100644 src/driver/volume.cpp create mode 100644 src/driver/volume.h diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index e7feb5544..480080a76 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -34,7 +34,8 @@ libneutrino_driver_a_SOURCES = \ radiotext.cpp \ fade.cpp \ screenshot.cpp \ - ringbuffer.c + ringbuffer.c \ + volume.cpp if BOXTYPE_COOL libneutrino_driver_a_SOURCES += \ diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp new file mode 100644 index 000000000..340a189e2 --- /dev/null +++ b/src/driver/volume.cpp @@ -0,0 +1,327 @@ +/* + 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) + + License: GPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library 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, + 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. + + You should have received a copy of the GNU Library General Public + License along with this library; 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 +#include +#include +#include +#include +#include + +#if HAVE_COOL_HARDWARE +#include +#endif + +CFrameBuffer * frameBuffer; +CRemoteControl * v_RemoteControl; +extern cAudio * audioDecoder; +static CProgressBar *g_volscale = NULL; + +CVolume::CVolume() +{ + frameBuffer = CFrameBuffer::getInstance(); + g_Zapit = new CZapitClient; + g_RCInput = new CRCInput; + v_RemoteControl = new CRemoteControl; + VolumeFont = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO; + paintDigits = true; // For future On/Off digits + paintShadow = false; // For future On/Off switch shadow + MuteIconFrame = false; // For future On/Off switch IconFrame + ShadowOffset = 4; + mute_ay = 0; + + Init(); +} + +CVolume::~CVolume() +{ + if (g_volscale) + delete g_volscale; +} + +void CVolume::Init() +{ + mute_ay_old = mute_ay; + int faktor_h = 18; // scale * 10 + int clock_height= 0; + int clock_width = 0; + int x_corr = 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(); + + frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_w, &icon_h); + 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"); + digit_offset = g_Font[VolumeFont]->getDigitOffset(); + digit_h = g_Font[VolumeFont]->getDigitHeight(); + progress_h = std::max(icon_h, digit_h) - 2*pB; + vbar_w += digit_w; + } + + g_volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true); + + // 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; + + 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) && (!CNeutrinoApp::getInstance()->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 + if (CNeutrinoApp::getInstance()->isMuted()) + x_corr = mute_dx + spacer; + x = sw - vbar_w - x_corr; + if (g_settings.mode_clock) + y += clock_height + spacer / 2; + 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; + if(!Volume) + Volume = new CVolume(); + return Volume; +} + +void CVolume::AudioMute(int newValue, bool isEvent) +{ + if((g_settings.current_volume == 0) && (g_settings.show_mute_icon == 1)) + return; + 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); +} + +void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowait) +{ + neutrino_msg_t msg = key; + 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); + + // volumebar shadow + if (paintShadow) + frameBuffer->paintBoxRel(x+ShadowOffset , y+ShadowOffset , (paintDigits) ? vbar_w - vbar_h : vbar_w, vbar_h, colShadow, ROUNDED, CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT); + // volumebar + frameBuffer->paintBoxRel(x , y , (paintDigits) ? vbar_w - vbar_h : vbar_w, vbar_h, colBar, ROUNDED, CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT); + // frame for progress + frameBuffer->paintBoxRel(progress_x-pB, progress_y-pB, progress_w+pB*1, progress_h+pB*2, colFrame); + // volume icon + frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar); + + g_volscale->reset(); + refreshVolumebar(vol); + } + + neutrino_msg_data_t data; + uint64_t timeoutEnd; + + do { + if (msg <= CRCInput::RC_MaxRC) + { + int sub_chan_keybind = 0; + if (g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME && v_RemoteControl->subChannels.size() < 1) + sub_chan_keybind = 1; + + if ((msg == CRCInput::RC_plus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_right))) { + if (g_settings.current_volume < 100 - g_settings.current_volume_step) + g_settings.current_volume += g_settings.current_volume_step; + else + g_settings.current_volume = 100; + + if(CNeutrinoApp::getInstance()->isMuted()) { + if ((bDoPaint) && (pixbuf!= NULL)) { + frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); + delete [] pixbuf; + } + AudioMute(false, true); + Init(); + setVolume(msg); + return; + } + } + else if ((msg == CRCInput::RC_minus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_left))) { + if (g_settings.current_volume > g_settings.current_volume_step) + g_settings.current_volume -= g_settings.current_volume_step; + else if ((g_settings.show_mute_icon == 1) && (g_settings.current_volume = 1)) { + (g_settings.current_volume = 1); + AudioMute( true, true); + g_settings.current_volume = 0; + } + else if (g_settings.show_mute_icon == 0) + g_settings.current_volume = 0; + } + else if (msg == CRCInput::RC_home) + break; + else { + g_RCInput->postMsg(msg, data); + break; + } + + setvol(g_settings.current_volume); + timeoutEnd = CRCInput::calcTimeoutEnd(nowait ? 1 : 3); + } + else if (msg == NeutrinoMessages::EVT_VOLCHANGED) { + timeoutEnd = CRCInput::calcTimeoutEnd(3); + } + else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::unhandled) { + g_RCInput->postMsg(msg, data); + break; + } + + if (bDoPaint) { + if(vol != g_settings.current_volume) { + vol = g_settings.current_volume; + refreshVolumebar(g_settings.current_volume); + } + } + + CVFD::getInstance()->showVolume(g_settings.current_volume); + if (msg != CRCInput::RC_timeout) { + g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); + } + } while (msg != CRCInput::RC_timeout); + + if( (bDoPaint) && (pixbuf!= NULL) ) { + frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); + delete [] pixbuf; + } +} + +void CVolume::refreshVolumebar(int current_volume) +{ + // progressbar + g_volscale->paintProgressBar2(progress_x, progress_y, 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); + } +} diff --git a/src/driver/volume.h b/src/driver/volume.h new file mode 100644 index 000000000..5615eb7df --- /dev/null +++ b/src/driver/volume.h @@ -0,0 +1,65 @@ +/* + 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) + + License: GPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library 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, + 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. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CVOLUME__ +#define __CVOLUME__ + +#define ROUNDED g_settings.rounded_corners ? vbar_h/2 : 0 + +class CVolume +{ + private: + void refreshVolumebar(int current_volume); + + 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; + bool paintShadow, paintDigits, MuteIconFrame; + + public: + 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; } +}; + + +#endif // __CVOLUME__ diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index cef4dbf32..6449d5fea 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -10,16 +10,17 @@ #include #include #include -#include "infoclock.h" +#include +#include #define YOFF 0 -CInfoClock::CInfoClock() +CInfoClock::CInfoClock(bool noVolume) { frameBuffer = CFrameBuffer::getInstance(); x = y = clock_x = 0; time_height = time_width = thrTimer = 0; - Init(); + Init(noVolume); } CInfoClock::~CInfoClock() @@ -29,23 +30,34 @@ CInfoClock::~CInfoClock() thrTimer = 0; } -void CInfoClock::Init() +void CInfoClock::Init(bool noVolume) { - //TOTO Give me a framebuffer->getScreenEndX (); - x = frameBuffer->getScreenWidth() + frameBuffer->getScreenX(); - y = frameBuffer->getScreenY(); + static int mute_dx = 0; + static int spacer = 0; + if (!noVolume) { + x = CVolume::getInstance()->getEndPosRight(); + y = CVolume::getInstance()->getStartPosTop(); + mute_dx = CVolume::getInstance()->mute_dx; + spacer = CVolume::getInstance()->spacer; + } - 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; + 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); +} - int dvx, dummy; - frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE,&dvx,&dummy); - dvx += (dvx/4); - - x -= dvx; - clock_x = x - time_width - 10; +CInfoClock* CInfoClock::getInstance(bool noVolume) +{ + static CInfoClock* InfoClock = NULL; + if(!InfoClock) + InfoClock = new CInfoClock(noVolume); + return InfoClock; } void CInfoClock::paintTime( bool show_dot) @@ -57,7 +69,7 @@ void CInfoClock::paintTime( bool show_dot) 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 + time_height, time_width, timestr, COL_MENUCONTENT); + 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); } void* CInfoClock::TimerProc(void *arg) @@ -77,9 +89,15 @@ void* CInfoClock::TimerProc(void *arg) return 0; } +void CInfoClock::ClearDisplay() +{ + frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height); +} + void CInfoClock::StartClock() { Init(); + CVolume::getInstance()->Init(); if(!thrTimer) { pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ; @@ -89,6 +107,7 @@ void CInfoClock::StartClock() void CInfoClock::StopClock() { + CVolume::getInstance()->Init(); if(thrTimer) { pthread_cancel(thrTimer); thrTimer = 0; diff --git a/src/gui/infoclock.h b/src/gui/infoclock.h index f7b5f12c2..a03abf2a6 100644 --- a/src/gui/infoclock.h +++ b/src/gui/infoclock.h @@ -16,23 +16,24 @@ class CInfoClock private: CFrameBuffer * frameBuffer; - pthread_t thrTimer; - void Init(); - int time_width; - int time_height; - int clock_x; - void paintTime( bool show_dot); - int y,x; - static void CleanUpProc(void* arg); - static void* TimerProc(void *arg); + pthread_t thrTimer; + void paintTime( bool show_dot); + int time_offset, digit_offset, digit_h; + int x, y, clock_x; + static void CleanUpProc(void* arg); + static void* TimerProc(void *arg); public: - CInfoClock(); + CInfoClock(bool noVolume=false); ~CInfoClock(); + static CInfoClock* getInstance(bool noVolume=false); - void StartClock(); - void StopClock(); + void Init(bool noVolume=false); + void StartClock(); + void StopClock(); + void ClearDisplay(); + int time_width, time_height; }; #endif diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index a9cd3e515..16527cdab 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -53,6 +53,7 @@ #include #include +#include #include @@ -431,10 +432,10 @@ int COsdSetup::showOsdSetup() osd_menu->addItem(GenericMenuSeparatorLine); //options - osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_ROUNDED_CORNERS, &g_settings.rounded_corners, MENU_CORNERSETTINGS_TYPE_OPTIONS, MENU_CORNERSETTINGS_TYPE_OPTION_COUNT, true)); + osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_ROUNDED_CORNERS, &g_settings.rounded_corners, MENU_CORNERSETTINGS_TYPE_OPTIONS, MENU_CORNERSETTINGS_TYPE_OPTION_COUNT, true, this)); osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_SCRAMBLED_MESSAGE, &g_settings.scrambled_message, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); osd_menu->addItem(new CMenuOptionChooser(LOCALE_INFOVIEWER_SUBCHAN_DISP_POS, &g_settings.infobar_subchan_disp_pos, INFOBAR_SUBCHAN_DISP_POS_OPTIONS, INFOBAR_SUBCHAN_DISP_POS_OPTIONS_COUNT, true)); - osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_VOLUME_POS, &g_settings.volume_pos, VOLUMEBAR_DISP_POS_OPTIONS, VOLUMEBAR_DISP_POS_OPTIONS_COUNT, true)); + osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_VOLUME_POS, &g_settings.volume_pos, VOLUMEBAR_DISP_POS_OPTIONS, VOLUMEBAR_DISP_POS_OPTIONS_COUNT, true, this)); osd_menu->addItem(new CMenuOptionChooser(LOCALE_EXTRA_SHOW_MUTE_ICON, &g_settings.show_mute_icon, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); osd_menu->addItem(new CMenuOptionChooser(LOCALE_SETTINGS_MENU_POS, &g_settings.menu_pos, MENU_DISP_POS_OPTIONS, MENU_DISP_POS_OPTIONS_COUNT, true, this)); osd_menu->addItem(new CMenuOptionChooser(LOCALE_COLORMENU_FADE, &g_settings.widget_fade, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true )); @@ -664,6 +665,11 @@ 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_ROUNDED_CORNERS))) { + CVolume::getInstance()->Init(); + return true; + } return false; } diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 505a1280c..ecd983552 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -439,7 +440,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: - CNeutrinoApp::getInstance()->setVolume(msg, true, true); + CVolume::getInstance()->setVolume(msg, true, true); break; default: if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index b8d68d432..898275ec1 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "gui/audioplayer.h" #include "gui/bouquetlist.h" @@ -175,6 +176,7 @@ CPlugins * g_PluginList; CRemoteControl * g_RemoteControl; CPictureViewer * g_PicViewer; CCAMMenuHandler * g_CamHandler; +CVolume * g_volume; // Globale Variablen - to use import global.h @@ -206,6 +208,7 @@ static void initGlobals(void) InfoClock = NULL; g_CamHandler = NULL; g_Radiotext = NULL; + g_volume = NULL; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -226,9 +229,9 @@ CNeutrinoApp::CNeutrinoApp() TVchannelList = NULL; RADIOchannelList = NULL; networksetup = NULL; - skipShutdownTimer=false; - current_muted = 0; - recordingstatus = 0; + skipShutdownTimer = false; + current_muted = 0; + recordingstatus = 0; memset(&font, 0, sizeof(neutrino_font_descr_struct)); } @@ -1735,10 +1738,6 @@ int CNeutrinoApp::run(int argc, char **argv) CVFD::getInstance()->showVolume(g_settings.current_volume); CVFD::getInstance()->setMuted(current_muted); - InfoClock = new CInfoClock(); - if(g_settings.mode_clock) - InfoClock->StartClock(); - g_RCInput = new CRCInput; g_Sectionsd = new CSectionsdClient; @@ -1899,11 +1898,11 @@ int CNeutrinoApp::run(int argc, char **argv) hdd->exec(NULL, ""); delete hdd; + g_volume = CVolume::getInstance(); cCA::GetInstance()->Ready(true); InitZapper(); - AudioMute( current_muted, true); - + g_volume->AudioMute(current_muted, true); SHTDCNT::getInstance()->init(); hintBox->hide(); @@ -1949,7 +1948,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) { neutrino_msg_t msg; neutrino_msg_data_t data; - + dprintf(DEBUG_NORMAL, "initialized everything\n"); g_PluginList->startPlugin("startup.cfg"); @@ -1960,6 +1959,10 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) if(g_settings.power_standby || init_cec_setting) standbyMode(true); + InfoClock = CInfoClock::getInstance(); + if(g_settings.mode_clock) + InfoClock->StartClock(); + //cCA::GetInstance()->Ready(true); while( true ) { @@ -1998,7 +2001,9 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) //if(!g_settings.cacheTXT) // tuxtxt_stop(); g_RCInput->clearRCMsg(); - AudioMute(current_muted, true); + // restore mute symbol + if (current_muted) + g_volume->AudioMute(current_muted, true); if(g_settings.mode_clock) InfoClock->StartClock(); StartSubtitles(); @@ -2010,7 +2015,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) InfoClock->StopClock(); mainMenu.exec(NULL, ""); // restore mute symbol - AudioMute(current_muted, true); + if (current_muted) + g_volume->AudioMute(current_muted, true); if(g_settings.mode_clock) InfoClock->StartClock(); StartSubtitles(); @@ -2024,37 +2030,37 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) switchTvRadioMode(); //used with defined rc key TODO: do we really need this, because we already have a specified key on the remote control } else if( msg == (neutrino_msg_t) g_settings.key_subchannel_up ) { - if(g_RemoteControl->subChannels.size() > 0) { - StopSubtitles(); - g_RemoteControl->subChannelUp(); - g_InfoViewer->showSubchan(); - } else if(g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { - setVolume(msg, true); - } else if((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) || (g_settings.mode_left_right_key_tv == SNeutrinoSettings::INFOBAR)) { + if(g_RemoteControl->subChannels.size() > 0) { + StopSubtitles(); + g_RemoteControl->subChannelUp(); + g_InfoViewer->showSubchan(); + } else if (g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { + g_volume->setVolume(msg, true); + } else if((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) || (g_settings.mode_left_right_key_tv == SNeutrinoSettings::INFOBAR)) { if(channelList->getSize()) { showInfo(); } - } else + } else quickZap( msg ); } else if( msg == (neutrino_msg_t) g_settings.key_subchannel_down ) { - if(g_RemoteControl->subChannels.size()> 0) { - StopSubtitles(); - g_RemoteControl->subChannelDown(); - g_InfoViewer->showSubchan(); - } else if(g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { - setVolume(msg, true); - } else if((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) || (g_settings.mode_left_right_key_tv == SNeutrinoSettings::INFOBAR)) { + if(g_RemoteControl->subChannels.size()> 0) { + StopSubtitles(); + g_RemoteControl->subChannelDown(); + g_InfoViewer->showSubchan(); + } else if(g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { + g_volume->setVolume(msg, true); + } else if((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) || (g_settings.mode_left_right_key_tv == SNeutrinoSettings::INFOBAR)) { if(channelList->getSize()) { showInfo(); } - } else + } else quickZap( msg ); } /* in case key_subchannel_up/down redefined */ else if( msg == CRCInput::RC_left || msg == CRCInput::RC_right) { if(g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { - setVolume(msg, true); + g_volume->setVolume(msg, true); } else if(channelList->getSize()) { showInfo(); } @@ -2062,8 +2068,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else if( msg == (neutrino_msg_t) g_settings.key_zaphistory ) { // Zap-History "Bouquet" if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { - InfoClock->StopClock(); g_settings.mode_clock=false; + InfoClock->StopClock(); } else { StopSubtitles(); int res = channelList->numericZap( msg ); @@ -2179,8 +2185,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else { if (msg == CRCInput::RC_home) { if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { - InfoClock->StopClock(); g_settings.mode_clock=false; + InfoClock->StopClock(); } CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); } @@ -2217,7 +2223,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) g_Zapit->getVolume(&volume, &volume); current_volume = 100 - volume*100/63; printf("zapit volume %d new current %d mode %d\n", volume, current_volume, g_settings.audio_AnalogMode); - setvol(current_volume); + g_volume->setvol(current_volume); #endif g_RCInput->killTimer(scrambled_timer); @@ -2307,6 +2313,9 @@ _show: nNewChannel = bouquetList->Bouquets[old_b]->channelList->exec();//with ZAP! else nNewChannel = bouquetList->exec(true); + // restore mute symbol + if (current_muted) + g_volume->AudioMute(current_muted, true); } else if(msg == CRCInput::RC_sat) { SetChannelMode(LIST_MODE_SAT); nNewChannel = bouquetList->exec(true); @@ -2441,7 +2450,7 @@ _repeat: } else if ((msg == CRCInput::RC_plus) || (msg == CRCInput::RC_minus)) { - setVolume(msg, (mode != mode_scart)); + g_volume->setVolume(msg, (mode != mode_scart)); return messages_return::handled; } else if( msg == CRCInput::RC_spkr ) { @@ -2451,16 +2460,16 @@ _repeat: } else { //mute - AudioMute( !current_muted, true); + g_volume->AudioMute(!current_muted, true); } return messages_return::handled; } else if( msg == CRCInput::RC_mute_on ) { - AudioMute( true, true); + g_volume->AudioMute(true, true); return messages_return::handled; } else if( msg == CRCInput::RC_mute_off ) { - AudioMute( false, true); + g_volume->AudioMute(false, true); return messages_return::handled; } else if( msg == CRCInput::RC_analog_on ) { @@ -2513,7 +2522,7 @@ _repeat: #if 0 CControldMsg::commandMute* cmd = (CControldMsg::commandMute*) data; if(cmd->type == (CControld::volume_type)g_settings.audio_avs_Control) - AudioMute( cmd->mute, true ); + g_volume->AudioMute(cmd->mute, true ); delete[] (unsigned char*) data; #endif return messages_return::handled; @@ -3083,182 +3092,6 @@ void CNeutrinoApp::saveEpg(bool cvfd_mode) } } -void CNeutrinoApp::AudioMute( int newValue, bool isEvent ) -{ - if((g_settings.current_volume == 0) && (g_settings.show_mute_icon == 1)) - return; - //printf("MUTE: val %d current %d event %d\n", newValue, current_muted, isEvent); - int dx = 0; - int dy = 0; - frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE,&dx,&dy); - int offset = (dx/4); - dx += offset; - dy += offset; - - int x = g_settings.screen_EndX-dx; - int y = g_settings.screen_StartY; - -printf("AudioMute: current %d new %d isEvent: %d\n", current_muted, newValue, isEvent); - CVFD::getInstance()->setMuted(newValue); - current_muted = newValue; - - //if( !isEvent ) - g_Zapit->muteAudio(current_muted); - - if( isEvent && ( mode != mode_scart ) && ( mode != mode_audio) && ( mode != mode_pic)) - { - if( current_muted ) { - frameBuffer->paintBoxRel(x, y, dx, dy, COL_INFOBAR_PLUS_0); - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MUTE, x+(offset/2), y+(offset/2)); - } - else - frameBuffer->paintBackgroundBoxRel(x, y, dx, dy); - } -} - -void CNeutrinoApp::setvol(int vol) -{ - audioDecoder->setVolume(vol, vol); -} - -void CNeutrinoApp::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowait) -{ - neutrino_msg_t msg = key; - - int dx = 0;//256 - int dy = 0;//32 - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME,&dx,&dy); -printf("CNeutrinoApp::setVolume dx %d dy %d\n", dx, dy); - dx *=16; - dy *=2; -#if 0 // orig - int x = (((g_settings.screen_EndX- g_settings.screen_StartX)- dx) / 2) + g_settings.screen_StartX; - int y = g_settings.screen_EndY - 100; -#else - - int x = frameBuffer->getScreenX(); - int y = frameBuffer->getScreenY(); -#endif - int vol = g_settings.current_volume; - int sw = frameBuffer->getScreenWidth(); - int sh = frameBuffer->getScreenHeight(); - int clock_height = 0; - - switch( g_settings.volume_pos ) - { - case 0:// upper right - if(g_settings.mode_clock){ - clock_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getHeight(); - } - x = sw - dx - 6; - y += clock_height; - break; - case 1:// upper left - break; - case 2:// bottom left - y = sh - dy; - break; - case 3:// bottom right - x = sw - dx; - y = sh - dy; - break; - case 4:// center default - x = ((sw - dx) / 2) + x; - break; - case 5:// center higher - x = ((sw - dx) / 2) + x; - y = sh - sh/15; - break; - } - - fb_pixel_t * pixbuf = NULL; - - if(bDoPaint) { - pixbuf = new fb_pixel_t[dx * dy]; - if(pixbuf!= NULL) - frameBuffer->SaveScreen(x, y, dx, dy, pixbuf); - - frameBuffer->paintBoxRel(x , y , dx, dy, COL_MENUCONTENT_PLUS_0, g_settings.rounded_corners ? dy/2 : 0); - frameBuffer->paintBoxRel(x+dy+dy/4-2, y+dy/4-2, dy*25/4+4, dy/2+4, COL_MENUCONTENT_PLUS_3); - frameBuffer->paintBoxRel(x+dy+dy/4, y+dy/4, dy*25/4, dy/2, COL_MENUCONTENT_PLUS_1); - frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME,x+dy/2,y+(dy/4), 0, COL_MENUCONTENT_PLUS_0); - - g_volscale->reset(); - g_volscale->paintProgressBar2(x + dy+ (dy/4), y +(dy/4), g_settings.current_volume); - } - - neutrino_msg_data_t data; - - uint64_t timeoutEnd; - - do { - if (msg <= CRCInput::RC_MaxRC) - { - int sub_chan_keybind = 0; - if (g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME && g_RemoteControl->subChannels.size() < 1) - sub_chan_keybind = 1; - - if ((msg == CRCInput::RC_plus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_right))) { - if (g_settings.current_volume < 100 - g_settings.current_volume_step) - g_settings.current_volume += g_settings.current_volume_step; - else - g_settings.current_volume = 100; - - if(current_muted) - AudioMute( false, true); - } - else if ((msg == CRCInput::RC_minus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_left))) { - if (g_settings.current_volume > g_settings.current_volume_step) - g_settings.current_volume -= g_settings.current_volume_step; - else if ((g_settings.show_mute_icon == 1) && (g_settings.current_volume = 1)) { - (g_settings.current_volume = 1); - AudioMute( true, true); - g_settings.current_volume = 0; - } - else if (g_settings.show_mute_icon == 0) - g_settings.current_volume = 0; - } - else if (msg == CRCInput::RC_home) - break; - else { - g_RCInput->postMsg(msg, data); - break; - } - - setvol(g_settings.current_volume); - timeoutEnd = CRCInput::calcTimeoutEnd(nowait ? 1 : 3); - } - else if (msg == NeutrinoMessages::EVT_VOLCHANGED) { - //current_volume = g_Controld->getVolume((CControld::volume_type)g_settings.audio_avs_Control);//FIXME - //printf("setVolume EVT_VOLCHANGED %d\n", current_volume); - timeoutEnd = CRCInput::calcTimeoutEnd(3); - } - else if (handleMsg(msg, data) & messages_return::unhandled) { - g_RCInput->postMsg(msg, data); - break; - } - - if (bDoPaint) { - if(vol != g_settings.current_volume) { - vol = g_settings.current_volume; - g_volscale->paintProgressBar2(x + dy+ (dy/4), y +(dy/4), g_settings.current_volume); - } - } - - CVFD::getInstance()->showVolume(g_settings.current_volume); - if (msg != CRCInput::RC_timeout) { - g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); - } - } while (msg != CRCInput::RC_timeout); - - //frameBuffer->paintBackgroundBoxRel(x, y, dx, dy); //FIXME osd bug - - if( (bDoPaint) && (pixbuf!= NULL) ) { - frameBuffer->RestoreScreen(x, y, dx, dy, pixbuf); - delete [] pixbuf; - } -} - void CNeutrinoApp::tvMode( bool rezap ) { if(mode==mode_radio ) { @@ -3274,6 +3107,8 @@ void CNeutrinoApp::tvMode( bool rezap ) StartSubtitles(!rezap); } + g_volume->Init(); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->ShowIcon(VFD_ICON_TV, true); @@ -3464,7 +3299,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff ) if(g_settings.mode_clock) InfoClock->StartClock(); - AudioMute(current_muted, true); + g_volume->AudioMute(current_muted, true); if((mode == mode_tv) && wasshift) { //startAutoRecord(); CRecordManager::getInstance()->StartAutoRecord(); @@ -3528,11 +3363,11 @@ void CNeutrinoApp::switchTvRadioMode(const int prev_mode) void CNeutrinoApp::switchClockOnOff() { if(g_settings.mode_clock) { - InfoClock->StopClock(); g_settings.mode_clock=false; + InfoClock->StopClock(); } else { - InfoClock->StartClock(); g_settings.mode_clock=true; + InfoClock->StartClock(); } } diff --git a/src/neutrino.h b/src/neutrino.h index 8c732fb85..6c2f81b5a 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -100,21 +100,6 @@ public: private: CFrameBuffer * frameBuffer; - enum - { - mode_unknown = -1, - mode_tv = 1, - mode_radio = 2, - mode_scart = 3, - mode_standby = 4, - mode_audio = 5, - mode_pic = 6, - mode_ts = 7, - mode_off = 8, - mode_mask = 0xFF, - norezap = 0x100 - }; - CConfigFile configfile; CScanSettings scanSettings; CPersonalizeGui personalize; @@ -154,8 +139,6 @@ private: void radioMode( bool rezap = true ); void scartMode( bool bOnOff ); void standbyMode( bool bOnOff ); - void AudioMute( int newValue, bool isEvent= false ); - void setvol(int vol); void saveEpg(bool cvfd_mode); void ExitRun(const bool write_si = true, int retcode = 0); @@ -173,6 +156,21 @@ private: CNeutrinoApp(); public: + enum + { + mode_unknown = -1, + mode_tv = 1, + mode_radio = 2, + mode_scart = 3, + mode_standby = 4, + mode_audio = 5, + mode_pic = 6, + mode_ts = 7, + mode_off = 8, + mode_mask = 0xFF, + norezap = 0x100 + }; + void saveSetup(const char * fname); int loadSetup(const char * fname); void loadKeys(const char * fname = NULL); @@ -180,8 +178,7 @@ public: void SetupTiming(); void SetupFonts(); void setupRecordingDevice(void); - - void setVolume(const neutrino_msg_t key, const bool bDoPaint = true, bool nowait = false); + ~CNeutrinoApp(); CScanSettings& getScanSettings() { return scanSettings; @@ -213,9 +210,8 @@ public: void switchTvRadioMode(const int prev_mode = mode_unknown); void switchClockOnOff(); - bool isMuted() { - return current_muted; - } + bool isMuted() {return current_muted; } + void setCurrentMuted(int m) { current_muted = m; } int recordingstatus; void SendSectionsdConfig(void); int GetChannelMode(void) { diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index e2392fa74..79bb7d926 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -60,6 +60,8 @@ #include #include #include +#include +#include // obsolete #include @@ -403,6 +405,10 @@ bool CColorSetupNotifier::changeNotify(const neutrino_locale_t, void *) 8, convertSetupAlpha2Alpha(g_settings.infobar_alpha) ); frameBuffer->paletteSet(); + /* recalculate volumebar */ + CVolume::getInstance()->Init(); + /* recalculate infoclock */ + CInfoClock::getInstance()->Init(); return false; } @@ -496,7 +502,10 @@ 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; }