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/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 84385943e..662e3968a 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -292,6 +292,8 @@ return 0; upper = halflinegap+ascender+3; // we add 3 at top lower = -descender+halflinegap+1; // we add 1 at bottom height=upper+lower; // this is total height == distance of lines + DigitHeight = ascender+2; + DigitOffset = -descender+halflinegap; // hack end //printf("glyph: hM=%d tM=%d hg=%d tg=%d ascender=%d descender=%d height=%d linegap/2=%d upper=%d lower=%d\n", @@ -310,6 +312,16 @@ int Font::getHeight(void) return height; } +int Font::getDigitHeight(void) +{ + return DigitHeight; +} + +int Font::getDigitOffset(void) +{ + return DigitOffset; +} + int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on error { int unicode_value; diff --git a/src/driver/fontrenderer.h b/src/driver/fontrenderer.h index 28d519ea7..e10baf6dc 100644 --- a/src/driver/fontrenderer.h +++ b/src/driver/fontrenderer.h @@ -51,7 +51,7 @@ class Font FT_Error getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit); // these are HACKED values, because the font metrics were unusable. - int height,ascender,descender,upper,lower; + int height,DigitHeight,DigitOffset,ascender,descender,upper,lower; int fontwidth; public: @@ -68,6 +68,8 @@ class Font int getRenderWidth(const char * text, const bool utf8_encoded = false); int getRenderWidth(const std::string & text, const bool utf8_encoded = false); int getHeight(void); + int getDigitHeight(void); + int getDigitOffset(void); int getWidth(void); int getSize(){return font.width;} int setSize(int isize); diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 5f84f50f4..d1588a160 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -179,6 +179,10 @@ CFrameBuffer::CFrameBuffer() backgroundFilename = ""; fd = 0; tty = 0; + m_transparent_default = CFrameBuffer::TM_BLACK; // TM_BLACK: Transparency when black content ('pseudo' transparency) + // TM_NONE: No 'pseudo' transparency + // TM_INI: Transparency depends on g_settings.infobar_alpha ??? + m_transparent = m_transparent_default; //FIXME: test memset(red, 0, 256*sizeof(__u16)); memset(green, 0, 256*sizeof(__u16)); @@ -292,6 +296,7 @@ printf("smem_start %x\n", smem_start); paletteSet(); useBackground(false); + m_transparent = m_transparent_default; #if 0 if ((tty=open("/dev/vc/0", O_RDWR))<0) { perror("open (tty)"); @@ -1627,27 +1632,36 @@ void * CFrameBuffer::int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long count = x * y; fbbuff = (unsigned int *) cs_malloc_uncached(count * sizeof(unsigned int)); - if(fbbuff == NULL) - { + if(fbbuff == NULL) { printf("convertRGB2FB%s: Error: cs_malloc_uncached\n", ((alpha) ? " (Alpha)" : "")); return NULL; } - if (alpha) - { + if (alpha) { for(i = 0; i < count ; i++) fbbuff[i] = ((rgbbuff[i*4+3] << 24) & 0xFF000000) | ((rgbbuff[i*4] << 16) & 0x00FF0000) | ((rgbbuff[i*4+1] << 8) & 0x0000FF00) | ((rgbbuff[i*4+2]) & 0x000000FF); - }else - { - for(i = 0; i < count ; i++) - { - transp = 0; - if(rgbbuff[i*3] || rgbbuff[i*3+1] || rgbbuff[i*3+2]) - transp = 0xFF; - fbbuff[i] = (transp << 24) | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + } else { + switch (m_transparent) { + case CFrameBuffer::TM_BLACK: + for(i = 0; i < count ; i++) { + transp = 0; + if(rgbbuff[i*3] || rgbbuff[i*3+1] || rgbbuff[i*3+2]) + transp = 0xFF; + fbbuff[i] = (transp << 24) | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + } + break; + case CFrameBuffer::TM_INI: + for(i = 0; i < count ; i++) + fbbuff[i] = (transp << 24) | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + break; + case CFrameBuffer::TM_NONE: + default: + for(i = 0; i < count ; i++) + fbbuff[i] = 0xFF000000 | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + break; } } return (void *) fbbuff; @@ -1744,3 +1758,18 @@ 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 c042c4d01..e971dabc1 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -114,6 +114,7 @@ class CFrameBuffer std::map icon_cache; int cache_size; void * int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp, bool alpha); + int m_transparent_default, m_transparent; public: fb_pixel_t realcolor[256]; @@ -221,7 +222,17 @@ 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 + { + TM_EMPTY = 0, + TM_NONE = 1, + TM_BLACK = 2, + TM_INI = 3 + }; + void SetTransparent(int t){ m_transparent = t; } + void SetTransparentDefault(){ m_transparent = m_transparent_default; } }; - #endif diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 44209f8ad..2dab2184c 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -547,25 +547,19 @@ void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int m } } -bool CPictureViewer::DisplayImage (const std::string & name, int posx, int posy, int width, int height) +bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, int width, int height, int transp) { - return int_DisplayImage(name, posx, posy, width, height, false); -} + CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); + if (transp > CFrameBuffer::TM_EMPTY) + frameBuffer->SetTransparent(transp); -bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, int width, int height, const fb_pixel_t colBg) -{ - return int_DisplayImage(name, posx, posy, width, height, true, colBg); -} - -bool CPictureViewer::int_DisplayImage(const std::string & name, int posx, int posy, int width, int height, bool paintBg, const fb_pixel_t colBg) -{ /* TODO: cache or check for same */ fb_pixel_t * data = getImage(name, width, height); + if (transp > CFrameBuffer::TM_EMPTY) + frameBuffer->SetTransparentDefault(); + if(data) { - CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); - if (paintBg) - frameBuffer->paintBoxRel(posx, posy, width, height, colBg); frameBuffer->blit2FB(data, width, height, posx, posy); cs_free_uncached(data); return true; diff --git a/src/driver/pictureviewer/pictureviewer.h b/src/driver/pictureviewer/pictureviewer.h index eb1619ce5..094a11217 100644 --- a/src/driver/pictureviewer/pictureviewer.h +++ b/src/driver/pictureviewer/pictureviewer.h @@ -63,8 +63,7 @@ class CPictureViewer void Cleanup(); void SetVisible(int startx, int endx, int starty, int endy); static double m_aspect_ratio_correction; - bool DisplayImage (const std::string & name, int posx, int posy, int width, int height); - bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, const fb_pixel_t colBg); + bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height); bool GetLogoName(uint64_t channel_id, std::string ChanName, std::string & name, int *width = NULL, int *height = NULL); fb_pixel_t * getImage (const std::string & name, int width, int height); @@ -112,7 +111,6 @@ class CPictureViewer void add_format(int (*picsize)(const char *,int *,int*,int,int),int (*picread)(const char *,unsigned char **,int*,int*), int (*id)(const char*)); unsigned char * int_Resize(unsigned char *orgin, int ox, int oy, int dx, int dy, ScalingMode type, unsigned char * dst, bool alpha); fb_pixel_t * int_getImage(const std::string & name, int *width, int *height, bool GetImage); - bool int_DisplayImage (const std::string & name, int posx, int posy, int width, int height, bool paintBg, const fb_pixel_t colBg=0); }; 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/Makefile.am b/src/gui/Makefile.am index 1527aa0d9..4d42ab11b 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -80,6 +80,7 @@ libneutrino_gui_a_SOURCES = \ settings_manager.cpp \ sleeptimer.cpp \ software_update.cpp \ + start_wizard.cpp \ streaminfo2.cpp \ subchannel_select.cpp \ test_menu.cpp \ 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/moviebrowser.cpp b/src/gui/moviebrowser.cpp index d5cc1c4f9..8c523d21c 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1253,7 +1253,7 @@ void CMovieBrowser::refreshMovieInfo(void) g_PicViewer->rescaleImageDimensions(&flogo_w, &flogo_h, picw-2, pich-2); lx = m_cBoxFrameInfo.iX+m_cBoxFrameInfo.iWidth - flogo_w -14; ly = m_cBoxFrameInfo.iY - 1 + (m_cBoxFrameInfo.iHeight-flogo_h)/2; - g_PicViewer->DisplayImage(fname, lx+2, ly+1, flogo_w, flogo_h); + g_PicViewer->DisplayImage(fname, lx+2, ly+1, flogo_w, flogo_h, CFrameBuffer::TM_NONE); m_pcWindow->paintVLineRel(lx, ly, flogo_h+1, COL_WHITE); m_pcWindow->paintVLineRel(lx+flogo_w+2, ly, flogo_h+2, COL_WHITE); m_pcWindow->paintHLineRel(lx, flogo_w+2, ly, COL_WHITE); diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index 19ab1cd6d..b4135cc70 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,17 @@ CNetworkSetup::~CNetworkSetup() //delete networkConfig; } +CNetworkSetup* CNetworkSetup::getInstance() +{ + static CNetworkSetup* me = NULL; + + if(!me) { + me = new CNetworkSetup(); + dprintf(DEBUG_DEBUG, "CNetworkSetup Instance created\n"); + } + return me; +} + int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey) { int res = menu_return::RETURN_REPAINT; diff --git a/src/gui/network_setup.h b/src/gui/network_setup.h index 1c8a08c1b..7e17e2816 100644 --- a/src/gui/network_setup.h +++ b/src/gui/network_setup.h @@ -32,7 +32,6 @@ #define __network_setup__ #include -#include #include #include @@ -123,6 +122,8 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver CNetworkSetup(bool wizard_mode = N_SETUP_MODE_WIZARD_NO); ~CNetworkSetup(); + static CNetworkSetup* getInstance(); + bool getWizardMode() {return is_wizard;}; void setWizardMode(bool mode); 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 9b9f97c6d..2020d71e3 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -434,7 +435,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/gui/start_wizard.cpp b/src/gui/start_wizard.cpp new file mode 100644 index 000000000..79b7168d3 --- /dev/null +++ b/src/gui/start_wizard.cpp @@ -0,0 +1,124 @@ +/* + Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 Steffen Hehn 'McClean' + http://www.tuxbox.org + + Startup wizard + based upon an implementation created by + Copyright (C) 2009 CoolStream International Ltd. + + Reworked by dbt (Thilo Graf) + Copyright (C) 2012 dbt + http://www.dbox2-tuning.net + + License: GPL + + This software 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. + + NOTE for ignorant distributors: + It's not allowed to distribute any compiled parts of this code, if you don't accept the terms of GPL. + Please read it and understand it right! + This means for you: Hold it, if not, leave it! You could face legal action! + Otherwise ask the copyright owners, anything else would be theft! +*/ + + +#include "start_wizard.h" + +#include +#include +#include + +#include "network_setup.h" +#include "osd_setup.h" +#include "osdlang_setup.h" +#include "scan_setup.h" + +#include + +#include + +extern cVideo * videoDecoder; +using namespace std; + + +CStartUpWizard::CStartUpWizard() +{ + +} + +CStartUpWizard::~CStartUpWizard() +{ + +} + +int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) +{ + int res = menu_return::RETURN_REPAINT; + showBackgroundLogo(); + + if (parent) + parent->hide(); + + COsdLangSetup languageSettings(COsdLangSetup::OSDLANG_SETUP_MODE_WIZARD); + + languageSettings.exec(NULL, ""); + + if(ShowMsgUTF (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) + { + //open video settings in wizardmode + g_videoSettings->setWizardMode(CVideoSettings::V_SETUP_MODE_WIZARD); + + COsdSetup osdSettings(COsdSetup::OSD_SETUP_MODE_WIZARD); + + res = g_videoSettings->exec(NULL, ""); + g_videoSettings->setWizardMode(CVideoSettings::V_SETUP_MODE_WIZARD_NO); + + if(res != menu_return::RETURN_EXIT_ALL) + { + res = osdSettings.exec(NULL, ""); + } + if(res != menu_return::RETURN_EXIT_ALL) + { + CNetworkSetup::getInstance()->setWizardMode(CNetworkSetup::N_SETUP_MODE_WIZARD); + res = CNetworkSetup::getInstance()->exec(NULL, ""); + CNetworkSetup::getInstance()->setWizardMode(CNetworkSetup::N_SETUP_MODE_WIZARD_NO); + } + if(res != menu_return::RETURN_EXIT_ALL) + { + CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD); + res = CScanSetup::getInstance()->exec(NULL, ""); + CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD_NO); + } + } + + + + killBackgroundLogo(); + return res; +} + + +inline void CStartUpWizard::showBackgroundLogo() +{ + videoDecoder->ShowPicture(DATADIR "/neutrino/icons/start.jpg"); +} + +inline void CStartUpWizard::killBackgroundLogo() +{ + videoDecoder->StopPicture(); +} + diff --git a/src/gui/start_wizard.h b/src/gui/start_wizard.h new file mode 100644 index 000000000..2fbafcb6a --- /dev/null +++ b/src/gui/start_wizard.h @@ -0,0 +1,59 @@ +/* + Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 Steffen Hehn 'McClean' + http://www.tuxbox.org + + Startup wizard + based upon an implementation created by + Copyright (C) 2009 CoolStream International Ltd. + + Reworked by dbt (Thilo Graf) + Copyright (C) 2012 dbt + http://www.dbox2-tuning.net + + License: GPL + + This software 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. + + NOTE for ignorant distributors: + It's not allowed to distribute any compiled parts of this code, if you don't accept the terms of GPL. + Please read it and understand it right! + This means for you: Hold it, if not, leave it! You could face legal action! + Otherwise ask the copyright owners, anything else would be theft! +*/ + +#ifndef __start_wizard__ +#define __start_wizard__ + +#include +#include +#include + + +class CStartUpWizard : public CMenuTarget +{ + private: + void showBackgroundLogo(); + void killBackgroundLogo(); + public: + CStartUpWizard(); + ~CStartUpWizard(); + + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + + +#endif diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index c602b448c..6620933d6 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -49,6 +49,7 @@ #include "gui/scan.h" #include "gui/scan_setup.h" #include +#include extern int cs_test_card(int unit, char * str); diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index 2f14b2c87..a2e371b16 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 9b10c81ad..288ebed71 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" @@ -74,6 +75,7 @@ #include "gui/plugins.h" #include "gui/rc_lock.h" #include "gui/scan_setup.h" +#include "gui/start_wizard.h" #include "gui/timerlist.h" #include "gui/videosettings.h" @@ -177,6 +179,7 @@ CPlugins * g_PluginList; CRemoteControl * g_RemoteControl; CPictureViewer * g_PicViewer; CCAMMenuHandler * g_CamHandler; +CVolume * g_volume; // Globale Variablen - to use import global.h @@ -208,6 +211,7 @@ static void initGlobals(void) InfoClock = NULL; g_CamHandler = NULL; g_Radiotext = NULL; + g_volume = NULL; } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -227,10 +231,9 @@ CNeutrinoApp::CNeutrinoApp() channelList = NULL; 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)); } @@ -1630,20 +1633,17 @@ int CNeutrinoApp::run(int argc, char **argv) int loadSettingsErg = loadSetup(NEUTRINO_SETTINGS_FILE); - bool display_language_selection; - initialize_iso639_map(); + bool show_startwizard = false; CLocaleManager::loadLocale_ret_t loadLocale_ret = g_Locale->loadLocale(g_settings.language); if (loadLocale_ret == CLocaleManager::NO_SUCH_LOCALE) { strcpy(g_settings.language, "english"); loadLocale_ret = g_Locale->loadLocale(g_settings.language); - display_language_selection = true; + show_startwizard = true; } - else - display_language_selection = false; - + SetupFonts(); SetupTiming(); g_PicViewer = new CPictureViewer(); @@ -1695,9 +1695,6 @@ int CNeutrinoApp::run(int argc, char **argv) // trigger a change audioSetupNotifier->changeNotify(LOCALE_AUDIOMENU_AVSYNC, NULL); - if(display_language_selection) - videoDecoder->ShowPicture(DATADIR "/neutrino/icons/start.jpg"); - powerManager = new cPowerManager; if (powerManager) { @@ -1746,10 +1743,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; @@ -1855,41 +1848,10 @@ int CNeutrinoApp::run(int argc, char **argv) g_Timerd->registerEvent(CTimerdClient::EVT_EXEC_PLUGIN, 222, NEUTRINO_UDS_NAME); - if (display_language_selection) - { - COsdLangSetup languageSettings(COsdLangSetup::OSDLANG_SETUP_MODE_WIZARD); + if (show_startwizard) { hintBox->hide(); - - languageSettings.exec(NULL, ""); - - if(ShowMsgUTF (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) - { - //open video settings in wizardmode - g_videoSettings->setWizardMode(CVideoSettings::V_SETUP_MODE_WIZARD); - - COsdSetup osdSettings(COsdSetup::OSD_SETUP_MODE_WIZARD); - - bool ret = g_videoSettings->exec(NULL, ""); - g_videoSettings->setWizardMode(CVideoSettings::V_SETUP_MODE_WIZARD_NO); - - if(ret != menu_return::RETURN_EXIT_ALL) - { - ret = osdSettings.exec(NULL, ""); - } - if(ret != menu_return::RETURN_EXIT_ALL) - { - networksetup->setWizardMode(CNetworkSetup::N_SETUP_MODE_WIZARD); - ret = networksetup->exec(NULL, ""); - networksetup->setWizardMode(CNetworkSetup::N_SETUP_MODE_WIZARD_NO); - } - if(ret != menu_return::RETURN_EXIT_ALL) - { - CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD); - ret = CScanSetup::getInstance()->exec(NULL, ""); - CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD_NO); - } - } - videoDecoder->StopPicture(); + CStartUpWizard startwizard; + startwizard.exec(NULL, ""); } if(loadSettingsErg) { @@ -1912,11 +1874,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(); @@ -1964,7 +1926,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"); @@ -1975,10 +1937,12 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) if(g_settings.power_standby || init_cec_setting) standbyMode(true); -#if 0 -INFO("cCA::GetInstance()->Ready\n"); - cCA::GetInstance()->Ready(true); -#endif + InfoClock = CInfoClock::getInstance(); + if(g_settings.mode_clock) + InfoClock->StartClock(); + + //cCA::GetInstance()->Ready(true); + while( true ) { g_RCInput->getMsg(&msg, &data, 100, ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) && (g_RemoteControl->subChannels.size() < 1)) ? true : false); // 10 secs.. @@ -2015,7 +1979,9 @@ INFO("cCA::GetInstance()->Ready\n"); //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(); @@ -2027,7 +1993,8 @@ INFO("cCA::GetInstance()->Ready\n"); 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(); @@ -2041,37 +2008,37 @@ INFO("cCA::GetInstance()->Ready\n"); 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(); } @@ -2079,8 +2046,8 @@ INFO("cCA::GetInstance()->Ready\n"); 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 ); @@ -2196,8 +2163,8 @@ INFO("cCA::GetInstance()->Ready\n"); 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); } @@ -2234,7 +2201,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); @@ -2298,6 +2265,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); @@ -2432,7 +2402,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 ) { @@ -2442,16 +2412,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 ) { @@ -2504,7 +2474,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; @@ -3074,182 +3044,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 ) { INFO("rezap %d current mode %d", rezap, mode); @@ -3266,6 +3060,8 @@ void CNeutrinoApp::tvMode( bool rezap ) StartSubtitles(!rezap); } + g_volume->Init(); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->ShowIcon(VFD_ICON_TV, true); @@ -3458,7 +3254,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(); @@ -3523,11 +3319,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..78f9bbf55 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -40,7 +40,6 @@ #include #include #include -#include #include #include /* CChannelList */ #include @@ -100,21 +99,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; @@ -140,7 +124,6 @@ private: bool skipShutdownTimer; bool pbBlinkChange; CColorSetupNotifier *colorSetupNotifier; - CNetworkSetup *networksetup; CMoviePluginChangeExec *MoviePluginChanger; COnekeyPluginChangeExec *OnekeyPluginChanger; CIPChangeNotifier *MyIPChanger; @@ -154,8 +137,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 +154,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 +176,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 +208,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/neutrino_menue.cpp b/src/neutrino_menue.cpp index c1ae615ae..f3fee8895 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -62,6 +62,7 @@ #include "gui/miscsettings_menu.h" #include "gui/motorcontrol.h" #include "gui/movieplayer.h" +#include #include "gui/osd_setup.h" #include "gui/osdlang_setup.h" #include "gui/parentallock_setup.h" @@ -259,9 +260,7 @@ void CNeutrinoApp::InitMenuSettings() personalize.addItem(MENU_SETTINGS, new CMenuForwarder(LOCALE_PARENTALLOCK_PARENTALLOCK, true, NULL, new CParentalSetup()), &show, false, CPersonalizeGui::PERSONALIZE_SHOW_NO); // network - if(networksetup == NULL) - networksetup = new CNetworkSetup(); - personalize.addItem(MENU_SETTINGS, new CMenuForwarder(LOCALE_MAINSETTINGS_NETWORK, true, NULL, networksetup), &g_settings.personalize[SNeutrinoSettings::P_MSET_NETWORK]); + personalize.addItem(MENU_SETTINGS, new CMenuForwarder(LOCALE_MAINSETTINGS_NETWORK, true, NULL, CNetworkSetup::getInstance()), &g_settings.personalize[SNeutrinoSettings::P_MSET_NETWORK]); // record settings personalize.addItem(MENU_SETTINGS, new CMenuForwarder(LOCALE_MAINSETTINGS_RECORDING, true, NULL, new CRecordSetup()), &g_settings.personalize[SNeutrinoSettings::P_MSET_RECORDING]); diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 83a03b614..fd6f74d3e 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -60,6 +60,8 @@ #include #include #include +#include +#include // obsolete #include @@ -250,6 +252,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; } @@ -325,7 +331,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; }