diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 6e3e48705..57a659560 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -164,7 +164,6 @@ CMoviePlayerGui::CMoviePlayerGui() void CMoviePlayerGui::Init(void) { stopped = false; - hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEPLAYER_PLEASEWAIT)); // UTF-8 frameBuffer = CFrameBuffer::getInstance(); @@ -200,17 +199,9 @@ void CMoviePlayerGui::Init(void) tsfilefilter.addFilter("mp4"); tsfilefilter.addFilter("mov"); - - vlcfilefilter.addFilter("mpg"); - vlcfilefilter.addFilter("mpeg"); - vlcfilefilter.addFilter("m2p"); - vlcfilefilter.addFilter("avi"); - vlcfilefilter.addFilter("vob"); - pesfilefilter.addFilter("mpv"); filebrowser->Filter = &tsfilefilter; - rct = 0; speed = 1; - slow = 0; + //slow = 0; jumpseconds = 0; showaudioselectdialog = false; timeshift = 0; @@ -223,7 +214,6 @@ CMoviePlayerGui::~CMoviePlayerGui() delete filebrowser; if (moviebrowser) delete moviebrowser; - delete hintBox; if (bookmarkmanager) delete bookmarkmanager; g_Zapit->setStandby(false); @@ -272,8 +262,6 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) bookmarkmanager = new CBookmarkManager(); -// dvbsub_pause(); - if (parent) { parent->hide(); } @@ -284,21 +272,9 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) frameBuffer->Clear(); } - const CBookmark *theBookmark = NULL; - if (actionKey == "bookmarkplayback") { - isBookmark = true; - theBookmark = bookmarkmanager->getBookmark(NULL); - if (theBookmark == NULL) { - bookmarkmanager->flush(); - return menu_return::RETURN_REPAINT; - } - } - - isBookmark = false; startfilename = ""; startposition = 0; - isMovieBrowser = false; minuteoffset = MINUTEOFFSET; secondoffset = minuteoffset / 60; @@ -306,62 +282,44 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) if (system(MOVIEPLAYER_START_SCRIPT) != 0) perror(MOVIEPLAYER_START_SCRIPT " failed"); -#if 0 - if (actionKey == "fileplayback") { - cutNeutrino(); - PlayStream(STREAMTYPE_FILE); - } else if (actionKey == "dvdplayback") { - cutNeutrino(); - PlayStream(STREAMTYPE_DVD); - } else if (actionKey == "vcdplayback") { - cutNeutrino(); - PlayStream(STREAMTYPE_SVCD); - } else if (actionKey == "tsplayback") { - timeshift = 0; - PlayFile(); - } else -#endif + isMovieBrowser = false; + isBookmark = false; + timeshift = 0; if (actionKey == "tsmoviebrowser") { isMovieBrowser = true; - timeshift = 0; - PlayFile(); } else if (actionKey == "fileplayback") { - timeshift = 0; - PlayFile(); } else if (actionKey == "timeshift") { cutNeutrino(); timeshift = 1; - PlayFile(); } else if (actionKey == "ptimeshift") { cutNeutrino(); timeshift = 2; - PlayFile(); } else if (actionKey == "rtimeshift") { cutNeutrino(); timeshift = 3; - PlayFile(); } #if 0 else if (actionKey == "bookmarkplayback") { isBookmark = true; - if (theBookmark != NULL) { - cutNeutrino(); - startfilename = theBookmark->getUrl(); - sscanf(theBookmark->getTime(), "%lld", &startposition); - int vlcpos = startfilename.rfind("vlc://"); - if (vlcpos == 0) { - PlayStream(STREAMTYPE_FILE); - } else { - timeshift = 0; - PlayFile(); - } + const CBookmark * theBookmark = bookmarkmanager->getBookmark(NULL); + if (theBookmark == NULL) { + bookmarkmanager->flush(); + return menu_return::RETURN_REPAINT; } + startfilename = theBookmark->getUrl(); + sscanf(theBookmark->getTime(), "%lld", &startposition); } #endif + else { + delete bookmarkmanager; + return menu_return::RETURN_REPAINT; + } + + PlayFile(); bookmarkmanager->flush(); // Restore previous background @@ -377,17 +335,13 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) restoreNeutrino(); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); - //g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR, 0); - //dvbsub_start(0); - if (bookmarkmanager) - delete bookmarkmanager; + delete bookmarkmanager; if (timeshift) { timeshift = 0; return menu_return::RETURN_EXIT_ALL; } return menu_return::RETURN_REPAINT; - //return menu_return::RETURN_EXIT_ALL; } void CMoviePlayerGui::updateLcd(const std::string & sel_filename) @@ -398,37 +352,22 @@ void CMoviePlayerGui::updateLcd(const std::string & sel_filename) switch (playstate) { case CMoviePlayerGui::PAUSE: lcd = "|| "; - lcd += sel_filename; - //lcd += ')'; break; case CMoviePlayerGui::REW: sprintf(tmp, "%dx<< ", speed); lcd = tmp; - lcd += sel_filename; break; case CMoviePlayerGui::FF: sprintf(tmp, "%dx>> ", speed); lcd = tmp; - lcd += sel_filename; break; -#if 0 - case CMoviePlayerGui::JF: - sprintf(tmp, "%ds>> ", speed); - lcd = tmp; - lcd += sel_filename; + case CMoviePlayerGui::PLAY: + lcd = "> "; break; -#endif default: - if (slow) { - sprintf(tmp, "%ds||> ", slow); - lcd = tmp; - } else - lcd = "> "; - lcd += sel_filename; break; } - - //CVFD::getInstance()->showServicename(lcd); + lcd += sel_filename; CVFD::getInstance()->showMenuText(0, lcd.c_str(), -1, true); } @@ -525,8 +464,6 @@ void CMoviePlayerGui::PlayFile(void) bookStartMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_MOVIESTART, true, NULL, &cSelectedMenuBookStart[4])); bookStartMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_MOVIEEND, true, NULL, &cSelectedMenuBookStart[5])); - rct = 0; - go_repeat: do { @@ -686,11 +623,7 @@ void CMoviePlayerGui::PlayFile(void) CFile::FileType ftype; ftype = file->getType(); - if(ftype == CFile::FILE_AVI || ftype == CFile::FILE_MKV) { - is_file_player = true; // Movie player AVI/MKV - } else { - is_file_player = false; // Movie player AVI/MKV - } + is_file_player = false; filename = file->Name.c_str(); sel_filename = file->getFileName(); @@ -706,23 +639,7 @@ void CMoviePlayerGui::PlayFile(void) minuteoffset = MINUTEOFFSET; secondoffset = minuteoffset / 60; } -#if 0 - if(!p_movie_info->audioPids.empty()) { - CAPIDSelectExec::g_currentapid = p_movie_info->audioPids[0].epgAudioPid; //FIXME - CAPIDSelectExec::g_currentac3 = p_movie_info->audioPids[0].atype; - } - for (int i = 0; i < (int)p_movie_info->audioPids.size(); i++) { - CAPIDSelectExec::g_apids[i] = p_movie_info->audioPids[i].epgAudioPid; - CAPIDSelectExec::g_ac3flags[i] = p_movie_info->audioPids[i].atype; - g_numpida++; - if (p_movie_info->audioPids[i].selected) { - CAPIDSelectExec::g_currentapid = p_movie_info->audioPids[i].epgAudioPid; //FIXME - CAPIDSelectExec::g_currentac3 = p_movie_info->audioPids[i].atype; - } - } - g_vpid = p_movie_info->epgVideoPid; - g_vtype = p_movie_info->VideoType; -#endif + fillPids(p_movie_info); printf("CMoviePlayerGui::PlayFile: file %s apid %X atype %d vpid %x vtype %d\n", filename, CAPIDSelectExec::g_currentapid, CAPIDSelectExec::g_currentac3, g_vpid, g_vtype); printf("Bytes per minute: %lld\n", minuteoffset); @@ -751,15 +668,6 @@ void CMoviePlayerGui::PlayFile(void) ftype = file->getType(); is_file_player = true; -#if 0 - if(ftype == CFile::FILE_AVI || ftype == CFile::FILE_MKV || ftype == CFile::FILE_WAV || ftype == CFile::FILE_ASF) { - - is_file_player = true; // Movie player AVI/MKV - - } else { - is_file_player = false; // Movie player AVI/MKV - } -#endif filename = file->Name.c_str(); update_lcd = true; @@ -862,14 +770,7 @@ void CMoviePlayerGui::PlayFile(void) update_lcd = true; } - if (FileTime.IsVisible() /*FIXME && playstate == CMoviePlayerGui::PLAY */ ) { - if (FileTime.GetMode() == CTimeOSD::MODE_ASC) { - FileTime.update(position / 1000); - } else { - FileTime.update((duration - position) / 1000); - } - FileTime.updatePos(file_prozent); - } + FileTime.update(position, duration); if (start_play) { printf("Startplay at %d seconds\n", startposition/1000); @@ -985,14 +886,12 @@ void CMoviePlayerGui::PlayFile(void) speed = 1; playback->SetSpeed(speed); if (!timeshift) - callInfoViewer(p_movie_info->epgTitle, p_movie_info->epgInfo1, p_movie_info->epgChannel, duration, position); + callInfoViewer(p_movie_info, duration, position); } else if (!timeshift) { open_filebrowser = true; } if (time_forced) { time_forced = false; - if (g_settings.mode_clock) - InfoClock->StopClock(); FileTime.hide(); } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { @@ -1009,7 +908,7 @@ void CMoviePlayerGui::PlayFile(void) playback->SetSpeed(speed); } if (!timeshift) - callInfoViewer(p_movie_info->epgTitle, p_movie_info->epgInfo1, p_movie_info->epgChannel, duration, position); + callInfoViewer(p_movie_info, duration, position); } else if (msg == (neutrino_msg_t) g_settings.mpkey_bookmark) { // is there already a bookmark activity? @@ -1113,23 +1012,7 @@ void CMoviePlayerGui::PlayFile(void) } else if (msg == (neutrino_msg_t) g_settings.mpkey_audio) { showaudioselectdialog = true; } else if (msg == (neutrino_msg_t) g_settings.mpkey_time) { - if (FileTime.IsVisible()) { - if (FileTime.GetMode() == CTimeOSD::MODE_ASC) { - FileTime.SetMode(CTimeOSD::MODE_DESC); - FileTime.update((duration - position) / 1000); - FileTime.updatePos(file_prozent); - } else { - if (g_settings.mode_clock) - InfoClock->StopClock(); - FileTime.hide(); - } - } else { - if (g_settings.mode_clock) - InfoClock->StartClock(); - FileTime.SetMode(CTimeOSD::MODE_ASC); - FileTime.show(position / 1000); - FileTime.updatePos(file_prozent); - } + FileTime.switchMode(position, duration); } else if (msg == (neutrino_msg_t) g_settings.mpkey_rewind) { // rewind if (speed >= 0) speed = -1; @@ -1141,14 +1024,10 @@ void CMoviePlayerGui::PlayFile(void) update_lcd = true; if (!timeshift) - callInfoViewer(p_movie_info->epgTitle, p_movie_info->epgInfo1, p_movie_info->epgChannel, duration, position); + callInfoViewer(p_movie_info, duration, position); if (!FileTime.IsVisible()) { - if (g_settings.mode_clock) - InfoClock->StartClock(); - FileTime.SetMode(CTimeOSD::MODE_ASC); - FileTime.show(position / 1000); - FileTime.updatePos(file_prozent); + FileTime.show(position); time_forced = true; } } else if (msg == (neutrino_msg_t) g_settings.mpkey_forward) { // fast-forward @@ -1163,31 +1042,20 @@ void CMoviePlayerGui::PlayFile(void) playstate = CMoviePlayerGui::FF; if (!timeshift) - callInfoViewer(p_movie_info->epgTitle, p_movie_info->epgInfo1, p_movie_info->epgChannel, duration, position); + callInfoViewer(p_movie_info, duration, position); if (!FileTime.IsVisible()) { - if (g_settings.mode_clock) - InfoClock->StartClock(); - FileTime.SetMode(CTimeOSD::MODE_ASC); - FileTime.show(position / 1000); - FileTime.updatePos(file_prozent); + FileTime.show(position); time_forced = true; } } else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info) { - if (timeshift) - g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber(), CNeutrinoApp::getInstance()->channelList->getActiveChannelName(), CNeutrinoApp::getInstance()->channelList->getActiveSatellitePosition(), CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID()); // UTF-8 - - else { - callInfoViewer(p_movie_info->epgTitle, p_movie_info->epgInfo1, p_movie_info->epgChannel, duration, position); - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8); - update_lcd = true; - //showHelpTS(); - } + callInfoViewer(p_movie_info, duration, position); + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8); + update_lcd = true; + //showHelpTS(); } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute - //update_lcd = true; playback->SetPosition(-60 * 1000); } else if (msg == CRCInput::RC_3) { // Jump Forward 1 minute - //update_lcd = true; playback->SetPosition(60 * 1000); } else if (msg == CRCInput::RC_4) { // Jump Backwards 5 minutes playback->SetPosition(-5 * 60 * 1000); @@ -1216,47 +1084,13 @@ void CMoviePlayerGui::PlayFile(void) } jump_not_until = (position / 1000) + 10; // avoid bookmark jumping for the next 10 seconds, , TODO: might be moved to another key } - } else if (msg == CRCInput::RC_up || msg == CRCInput::RC_down) { - if (msg == CRCInput::RC_up) { - if (slow == 2) - slow = 0; - if (slow > 0) - slow--; - } else if (msg == CRCInput::RC_down) { - if (slow == 0) - slow++; - slow++; - } - //set_slow (slow); - update_lcd = true; - } else if (msg == CRCInput::RC_radio) { - if (isMovieBrowser == true && p_movie_info != NULL) { - std::string fname = p_movie_info->file.Name; - strReplace(fname, ".ts", ".bmp"); - //CVCRControl::getInstance()->Screenshot(0, (char *)fname.c_str()); - } - } -#if 0 - else if (msg == CRCInput::RC_shift_radio) { - if (isMovieBrowser == true && p_movie_info != NULL) { - time_t t = time(NULL); - char filename[512]; - sprintf(filename, "%s", p_movie_info->file.Name.c_str()); - int pos = strlen(filename); - strftime(&(filename[pos - 3]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t)); - strcat(filename, ".bmp"); - CVCRControl::getInstance()->Screenshot(0, filename); - } - } -#endif + } else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { //FIXME do nothing ? } else if(timeshift && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg)) { bool restore = FileTime.IsVisible(); FileTime.hide(); - if (g_settings.mode_clock) - InfoClock->StopClock(); if( msg == CRCInput::RC_epg ) g_EventList->exec(CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID(), CNeutrinoApp::getInstance()->channelList->getActiveChannelName()); @@ -1266,11 +1100,8 @@ void CMoviePlayerGui::PlayFile(void) tuxtx_main(g_RCInput->getFileHandle(), g_RemoteControl->current_PIDs.PIDs.vtxtpid, 0, 2); frameBuffer->paintBackground(); } - if (g_settings.mode_clock) - InfoClock->StartClock(); if(restore) { FileTime.show(position / 1000); - FileTime.updatePos(file_prozent); } } else if (msg == CRCInput::RC_timeout) { @@ -1281,17 +1112,12 @@ void CMoviePlayerGui::PlayFile(void) } else if (timeshift && msg == NeutrinoMessages::SHOW_EPG ) { bool restore = FileTime.IsVisible(); FileTime.hide(); - if (g_settings.mode_clock) - InfoClock->StopClock(); - g_EpgData->show(CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID()); + g_EpgData->show(CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID()); if(restore) { FileTime.show(position / 1000); - FileTime.updatePos(file_prozent); } - - } else if ( msg == NeutrinoMessages::ZAPTO || msg == NeutrinoMessages::STANDBY_ON || msg == NeutrinoMessages::SHUTDOWN || @@ -1308,10 +1134,7 @@ void CMoviePlayerGui::PlayFile(void) } if (first_start_timeshift) { - g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber(), - CNeutrinoApp::getInstance()->channelList->getActiveChannelName(), - CNeutrinoApp::getInstance()->channelList->getActiveSatellitePosition(), - CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID()); + callInfoViewer(p_movie_info, duration, position); first_start_timeshift = false; } @@ -1349,11 +1172,17 @@ printf("CMoviePlayerGui::PlayFile: exit, isMovieBrowser %d p_movie_info %x\n", i InfoClock->StartClock(); } -void CMoviePlayerGui::callInfoViewer(const std::string & epg_title, const std::string & epg_info1, - const std::string & epg_channel, const int duration, const int curr_pos) +void CMoviePlayerGui::callInfoViewer(MI_MOVIE_INFO * p_movie_info, const int duration, const int curr_pos) { - if (isMovieBrowser) { - g_InfoViewer->showMovieTitle(playstate, epg_channel, epg_title, epg_info1, + if(timeshift) { + g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber(), + CNeutrinoApp::getInstance()->channelList->getActiveChannelName(), + CNeutrinoApp::getInstance()->channelList->getActiveSatellitePosition(), + CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID()); + return; + } + if (isMovieBrowser && p_movie_info) { + g_InfoViewer->showMovieTitle(playstate, p_movie_info->epgChannel, p_movie_info->epgTitle, p_movie_info->epgInfo1, duration, curr_pos); return; } diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index be91d04be..146e82b3a 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -61,17 +61,9 @@ class CMoviePlayerGui : public CMenuTarget PAUSE = 4, FF = 5, REW = 6, - RESYNC = 7, - JPOS = 8, // jump to absolute position - JF = 9, - JB = 10, - SKIP = 11, - AUDIOSELECT = 12, - SOFTRESET = 99 }; private: - pthread_t rct; CFrameBuffer * frameBuffer; int m_LastMode; const char *filename; @@ -80,7 +72,6 @@ class CMoviePlayerGui : public CMenuTarget bool isBookmark; bool isMovieBrowser; int speed; - int slow; off64_t fullposition; int startposition; int jumpseconds; @@ -90,10 +81,6 @@ class CMoviePlayerGui : public CMenuTarget std::string startfilename; std::string Path_local; - std::string Path_vlc; - std::string Path_vlc_settings; - std::string g_file_epg; - std::string g_file_epg1; static unsigned short g_numpida; static unsigned short g_vtype; static unsigned short g_vpid; @@ -102,27 +89,22 @@ class CMoviePlayerGui : public CMenuTarget CFileBrowser * filebrowser; CMovieBrowser* moviebrowser; - CHintBox *hintBox; CBookmarkManager * bookmarkmanager; CFileFilter tsfilefilter; - CFileFilter pesfilefilter; - CFileFilter vlcfilefilter; static cPlayback *playback; static CMoviePlayerGui* instance_mp; void Init(void); - void PlayStream(int streamtype); void PlayFile(); void cutNeutrino(); void restoreNeutrino(); void showHelpTS(void); void showHelpVLC(void); - void callInfoViewer(const std::string & epg_title, const std::string & epg_info1, - const std::string & epg_channel, const int duration, const int pos); + void callInfoViewer(MI_MOVIE_INFO * p_movie_info, const int duration, const int pos); void fillPids(MI_MOVIE_INFO * p_movie_info); CMoviePlayerGui(const CMoviePlayerGui&) {}; diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index ae787fa23..3e3345bbb 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -30,43 +30,43 @@ #include #include #include +#include "gui/infoclock.h" -static CProgressBar *timescale = 0; +//static CProgressBar *timescale = 0; #define TIMEOSD_FONT SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME #define BARLEN 200 + +extern CInfoClock *InfoClock; + CTimeOSD::CTimeOSD() { frameBuffer = CFrameBuffer::getInstance(); visible=false; m_mode=MODE_ASC; GetDimensions(); - if (! timescale ){ - if(m_height < 5) - m_height = 10; - timescale = new CProgressBar(true, BARLEN, m_height -5, 40, 100, 70, true); - } + timescale = new CProgressBar(true, BARLEN, m_height -5, 40, 100, 70, true); + m_time_show = 0; } CTimeOSD::~CTimeOSD() { hide(); - if(timescale) { - delete timescale; - timescale = 0; - } + delete timescale; } void CTimeOSD::show(time_t time_show) { + if (g_settings.mode_clock) + InfoClock->StartClock(); + GetDimensions(); visible = true; - m_time_dis = time(NULL); - m_time_show = time_show; + SetMode(CTimeOSD::MODE_ASC); + m_time_show = 0; frameBuffer->paintBoxRel(m_xstart-2, m_y, 2+BARLEN+2, m_height, COL_INFOBAR_SHADOW_PLUS_0); //border - if(timescale) - timescale->reset(); - update(); + timescale->reset(); + update(time_show); } void CTimeOSD::GetDimensions() @@ -74,72 +74,92 @@ void CTimeOSD::GetDimensions() m_xstart = g_settings.screen_StartX + 10; m_xend = frameBuffer->getScreenWidth(); m_height = g_Font[TIMEOSD_FONT]->getHeight(); + if(m_height < 10) + m_height = 10; m_y = frameBuffer->getScreenY(); m_width = g_Font[TIMEOSD_FONT]->getRenderWidth("00:00:00"); t1 = g_Font[TIMEOSD_FONT]->getRenderWidth(widest_number); m_width += t1; - if(g_settings.mode_clock) { + if(g_settings.mode_clock) m_xend = m_xend - m_width - (m_width/4); - } } void CTimeOSD::update(time_t time_show) { - time_t tDisplayTime; - static time_t oldDisplayTime = 0; char cDisplayTime[8+1]; fb_pixel_t color1, color2; -//printf("CTimeOSD::update time %ld\n", time_show); if(!visible) return; + + time_show /= 1000; + if(m_time_show == time_show) + return; + + //printf("CTimeOSD::update time %ld -> %ld\n", m_time_show, time_show); + m_time_show = time_show; + if(m_mode == MODE_ASC) { color1 = COL_MENUCONTENT_PLUS_0; color2 = COL_MENUCONTENT; } else { color1 = COL_MENUCONTENTSELECTED_PLUS_0; color2 = COL_MENUCONTENTSELECTED; - if(!time_show) time_show = 1; - } - if(time_show) { - m_time_show = time_show; - tDisplayTime = m_time_show; - } else { - if(m_mode == MODE_ASC) { - tDisplayTime = m_time_show + (time(NULL) - m_time_dis); - } else { - tDisplayTime = m_time_show + (m_time_dis - time(NULL)); - } - } - if(tDisplayTime < 0) - tDisplayTime=0; - if(tDisplayTime != oldDisplayTime) { - oldDisplayTime = tDisplayTime; - strftime(cDisplayTime, 9, "%T", gmtime(&tDisplayTime)); - frameBuffer->paintBoxRel(m_xend - m_width - t1, m_y, m_width, m_height, color1,RADIUS_SMALL); - g_Font[TIMEOSD_FONT]->RenderString(m_xend - m_width - (t1/2), m_y + m_height, m_width, cDisplayTime, color2); } + strftime(cDisplayTime, 9, "%T", gmtime(&time_show)); + frameBuffer->paintBoxRel(m_xend - m_width - t1, m_y, m_width, m_height, color1,RADIUS_SMALL); + g_Font[TIMEOSD_FONT]->RenderString(m_xend - m_width - (t1/2), m_y + m_height, m_width, cDisplayTime, color2); } void CTimeOSD::updatePos(short runningPercent) { - if(timescale){ - if(runningPercent > 100 || runningPercent < 0){ - runningPercent = 0; - } - timescale->paintProgressBar2(m_xstart, m_y, runningPercent); - } + if(!visible) + return; + + if(runningPercent > 100 || runningPercent < 0) + runningPercent = 0; + + timescale->paintProgressBar2(m_xstart, m_y, runningPercent); +} + +void CTimeOSD::update(int position, int duration) +{ + if(!visible) + return; + + int percent = 0; + if(duration > 100) + percent = (unsigned char) (position / (duration / 100)); + if(m_mode == CTimeOSD::MODE_ASC) + update(position /* / 1000*/); + else + update((duration - position)/* / 1000 */); + updatePos(percent); } void CTimeOSD::hide() { - GetDimensions(); if(!visible) return; - frameBuffer->paintBackgroundBoxRel(m_xend - m_width - t1, m_y, m_width, m_height); - visible=false; - if(timescale) - timescale->reset(); - frameBuffer->paintBackgroundBoxRel(m_xstart-2, m_y, 2+BARLEN+2, m_height); //clear border + if (g_settings.mode_clock) + InfoClock->StopClock(); + + //GetDimensions(); + frameBuffer->paintBackgroundBoxRel(m_xend - m_width - t1, m_y, m_width, m_height); + timescale->reset(); + frameBuffer->paintBackgroundBoxRel(m_xstart-2, m_y, 2+BARLEN+2, m_height); //clear border + visible=false; +} + +void CTimeOSD::switchMode(int position, int duration) +{ + if(visible) { + if (GetMode() == CTimeOSD::MODE_ASC) { + SetMode(CTimeOSD::MODE_DESC); + update(position, duration); + } else + hide(); + } else + show(position); } diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index bc0882ae4..66ed1fdda 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -27,6 +27,7 @@ #include #include +#include class CTimeOSD { @@ -39,7 +40,8 @@ class CTimeOSD private: CFrameBuffer *frameBuffer; - time_t m_time_dis; + CProgressBar *timescale; + time_t m_time_show; bool visible; int m_xstart,m_xend,m_y,m_height, m_width, t1; @@ -50,11 +52,13 @@ class CTimeOSD CTimeOSD(); ~CTimeOSD(); void show(time_t time_show); - void update(time_t time_show = 0); + void update(time_t time_show); void updatePos(short runningPercent); void hide(); bool IsVisible() {return visible;} void SetMode(mode m) { m_mode = m;} mode GetMode() { return m_mode;} + void update(int position, int duration); + void switchMode(int position, int duration); }; #endif