Movieplayer cleanup: remove unused code, move all time realted to CTimeOSD

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1964 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
focus
2011-12-10 12:09:10 +00:00
parent f323ffceb1
commit 2be4e1e21f
4 changed files with 125 additions and 290 deletions

View File

@@ -30,43 +30,43 @@
#include <driver/fontrenderer.h>
#include <system/settings.h>
#include <gui/widget/progressbar.h>
#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);
}