gui/timeosd: rewrite based on infoclock implementation

This commit is contained in:
martii
2013-12-17 00:11:43 +01:00
committed by svenhoefer
parent 27acdadf30
commit 1c53781218
7 changed files with 145 additions and 138 deletions

View File

@@ -82,7 +82,7 @@ class CComponentsFrmClock : public CComponentsForm
///initialize clock contents ///initialize clock contents
void initCCLockItems(); void initCCLockItems();
///initialize timestring, called in initCCLockItems() ///initialize timestring, called in initCCLockItems()
void initTimeString(); virtual void initTimeString();
///initialize of general alignment of timestring segments within form area ///initialize of general alignment of timestring segments within form area
void initSegmentAlign(int* segment_width, int* segment_height); void initSegmentAlign(int* segment_width, int* segment_height);

View File

@@ -595,6 +595,7 @@ void CMoviePlayerGui::PlayFile(void)
if ((playstate >= CMoviePlayerGui::PLAY) && (timeshift || (playstate != CMoviePlayerGui::PAUSE))) { if ((playstate >= CMoviePlayerGui::PLAY) && (timeshift || (playstate != CMoviePlayerGui::PAUSE))) {
if(playback->GetPosition(position, duration)) { if(playback->GetPosition(position, duration)) {
FileTime.update(position, duration);
if(duration > 100) if(duration > 100)
file_prozent = (unsigned char) (position / (duration / 100)); file_prozent = (unsigned char) (position / (duration / 100));
#if HAVE_TRIPLEDRAGON #if HAVE_TRIPLEDRAGON

View File

@@ -154,6 +154,7 @@ class CMoviePlayerGui : public CMenuTarget
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
bool Playing() { return playing; }; bool Playing() { return playing; };
bool osdTimeVisible() { return FileTime.IsVisible(); };
std::string CurrentAudioName() { return currentaudioname; }; std::string CurrentAudioName() { return currentaudioname; };
int GetSpeed() { return speed; } int GetSpeed() { return speed; }
int GetPosition() { return position; } int GetPosition() { return position; }

View File

@@ -1,23 +1,28 @@
/* /*
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
Timerliste by Zwen TimeOSD by Zwen
Copyright (C) 2013, Thilo Graf 'dbt'
Copyright (C) 2013, Michael Liebmann 'micha-bbg'
Copyright (C) 2013, martii
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public
along with this program; if not, write to the Free Software License along with this program; if not, write to the
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@@ -26,136 +31,131 @@
#include <global.h> #include <global.h>
#include <neutrino.h> #include <neutrino.h>
#include <gui/volumebar.h>
#include <gui/timeosd.h> #include <gui/timeosd.h>
#include <driver/fontrenderer.h>
#include <system/settings.h>
#include <gui/infoclock.h>
#define TIMEOSD_FONT SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME
#define BARLEN 200
extern CInfoClock *InfoClock;
CTimeOSD::CTimeOSD() CTimeOSD::CTimeOSD():CComponentsFrmClock( 0, 0, 0, 50, "%H:%M:%S", true, CC_SHADOW_ON, COL_LIGHT_GRAY, COL_MENUCONTENT_PLUS_0,COL_MENUCONTENTDARK_PLUS_0)
{ {
frameBuffer = CFrameBuffer::getInstance(); Init();
visible=false; }
m_mode=MODE_ASC;
GetDimensions(); void CTimeOSD::Init()
timescale = new CProgressBar(); {
static int oldSize = 0;
m_mode = MODE_HIDE;
m_time_show = 0; m_time_show = 0;
if (oldSize != g_settings.infoClockFontSize) {
oldSize = g_settings.infoClockFontSize;
setClockFontSize(g_settings.infoClockFontSize);
}
//use current theme colors
syncSysColors();
paint_bg = g_settings.infoClockBackground;
setClockFormat("%H:%M:%S");
int x_old = x, y_old = y, width_old = width, height_old = height;
CVolumeHelper::getInstance()->refresh(cl_font);
CVolumeHelper::getInstance()->getTimeDimensions(&x, &y, &width, &height);
if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) {
cleanCCForm();
clearCCItems();
}
// set corner radius depending on clock height
corner_rad = (g_settings.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0;
initCCLockItems();
} }
CTimeOSD::~CTimeOSD() CTimeOSD::~CTimeOSD()
{ {
hide(); hide();
delete timescale;
} }
void CTimeOSD::show(time_t time_show) void CTimeOSD::initTimeString()
{ {
InfoClock->enableInfoClock(false); struct tm t;
strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str.c_str(), gmtime_r(&m_time_show, &t));
GetDimensions();
visible = true;
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
timescale->reset();
update(time_show);
} }
void CTimeOSD::GetDimensions() void CTimeOSD::show(time_t time_show, bool force)
{ {
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]->getMaxDigitWidth();
m_width += t1;
}
void CTimeOSD::update(time_t time_show)
{
char cDisplayTime[8+1];
fb_pixel_t color1, color2;
if(!visible)
return;
time_show /= 1000; time_show /= 1000;
if(m_time_show == time_show) if (!force && (m_mode == MODE_HIDE || m_time_show == time_show))
return; return;
//printf("CTimeOSD::update time %ld -> %ld\n", m_time_show, time_show);
m_time_show = time_show; m_time_show = time_show;
paint(false);
if(m_mode == MODE_ASC) {
color1 = COL_MENUCONTENT_PLUS_0;
color2 = COL_MENUCONTENT_TEXT;
} else {
color1 = COL_MENUCONTENTSELECTED_PLUS_0;
color2 = COL_MENUCONTENTSELECTED_TEXT;
}
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) void CTimeOSD::updatePos(int position, int duration)
{ {
if(!visible) int percent = (duration && duration > 100) ? (position * 100 / duration) : 0;
return; if(percent > 100)
percent = 100;
else if(percent < 0)
percent = 0;
if(runningPercent > 100 || runningPercent < 0) timescale.setProgress(x, y + height/4, width, height/2, percent, 100);
runningPercent = 0; timescale.setBlink();
timescale.setRgb(0, 100, 70);
timescale->setProgress(m_xstart, m_y, BARLEN, m_height -5, runningPercent, 100); timescale.paint();
timescale->setBlink(); frameBuffer->blit();
timescale->setRgb(0, 100, 70);
timescale->paint();
} }
void CTimeOSD::update(int position, int duration) void CTimeOSD::update(int position, int duration)
{ {
if(!visible) switch(m_mode) {
return; case MODE_ASC:
show(position, false);
short percent = 0; break;
if(duration > 100) case MODE_DESC:
percent = (unsigned char) (position / (duration / 100)); show(duration - position, false);
if(m_mode == CTimeOSD::MODE_ASC) break;
update(position /* / 1000*/); case MODE_BAR:
else updatePos(position, duration);
update((duration - position)/* / 1000 */); break;
updatePos(percent); default:
} ;
}
void CTimeOSD::hide()
{
if(!visible)
return;
//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;
InfoClock->enableInfoClock(true);
} }
void CTimeOSD::switchMode(int position, int duration) void CTimeOSD::switchMode(int position, int duration)
{ {
if(visible) { switch (m_mode) {
if (GetMode() == CTimeOSD::MODE_ASC) { case MODE_ASC:
SetMode(CTimeOSD::MODE_DESC); m_mode = MODE_DESC;
update(position, duration); break;
} else case MODE_DESC:
hide(); m_mode = MODE_BAR;
} else kill();
show(position); break;
case MODE_BAR:
m_mode = MODE_HIDE;
timescale.kill();
timescale.reset();
frameBuffer->blit();
return;
default:
m_mode = MODE_ASC;
}
update(position, duration);
}
void CTimeOSD::hide(void)
{
if (m_mode != MODE_HIDE) {
m_mode = MODE_HIDE;
timescale.kill();
timescale.reset();
kill();
frameBuffer->blit();
}
} }

View File

@@ -2,62 +2,59 @@
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
TimeOSD by Zwen TimeOSD by Zwen
Homepage: http://dbox.cyberphoria.org/ Homepage: http://dbox.cyberphoria.org/
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public
along with this program; if not, write to the Free Software License along with this program; if not, write to the
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/ */
#ifndef __timeosd__ #ifndef __timeosd__
#define __timeosd__ #define __timeosd__
#include <time.h>
#include <driver/framebuffer.h>
#include <gui/components/cc.h> #include <gui/components/cc.h>
#include <time.h>
class CTimeOSD class CTimeOSD : public CComponentsFrmClock
{ {
public: public:
enum mode enum mode
{ {
MODE_ASC, MODE_ASC,
MODE_DESC MODE_DESC,
MODE_BAR,
MODE_HIDE
}; };
private: private:
CFrameBuffer *frameBuffer; CProgressBar timescale;
CProgressBar *timescale;
time_t m_time_show;
bool visible;
int m_xstart,m_xend,m_y,m_height, m_width, t1;
mode m_mode; mode m_mode;
void GetDimensions(); time_t m_time_show;
void Init();
void initTimeString();
void updatePos(int position, int duration);
public: public:
CTimeOSD(); CTimeOSD();
~CTimeOSD(); ~CTimeOSD();
void show(time_t time_show); void show(time_t time_show, bool force = true);
void update(time_t time_show);
void updatePos(short runningPercent);
void hide(); void hide();
bool IsVisible() {return visible;} bool IsVisible() {return m_mode != MODE_HIDE;}
void SetMode(mode m) { m_mode = m;}
mode GetMode() { return m_mode;}
void update(int position, int duration); void update(int position, int duration);
void switchMode(int position, int duration); void switchMode(int position, int duration);
}; };

View File

@@ -29,6 +29,7 @@
#endif #endif
#include "gui/volumebar.h" #include "gui/volumebar.h"
#include "gui/movieplayer.h"
#include <neutrino.h> #include <neutrino.h>
#include <gui/infoclock.h> #include <gui/infoclock.h>
@@ -130,6 +131,8 @@ void CVolumeBar::initVolumeBarPosition()
break; break;
} }
case VOLUMEBAR_POS_TOP_LEFT: case VOLUMEBAR_POS_TOP_LEFT:
if (CMoviePlayerGui::getInstance().osdTimeVisible())
y = clock_y + clock_height + v_spacer + SHADOW_OFFSET;
break; break;
case VOLUMEBAR_POS_BOTTOM_LEFT: case VOLUMEBAR_POS_BOTTOM_LEFT:
y = (sh + frameBuffer->getScreenY()) - height - v_spacer; y = (sh + frameBuffer->getScreenY()) - height - v_spacer;
@@ -319,6 +322,9 @@ void CVolumeHelper::initInfoClock(Font** font)
else else
mute_corrY = (vol_height - mute_dy) / 2; mute_corrY = (vol_height - mute_dy) / 2;
} }
time_dx = t1*7 + t2*2;
time_ax = frameBuffer->getScreenX() + h_spacer;
} }
void CVolumeHelper::initMuteIcon() void CVolumeHelper::initMuteIcon()

View File

@@ -102,6 +102,7 @@ class CVolumeHelper
int x, y, sw, sh; int x, y, sw, sh;
int mute_ax, mute_ay, mute_dx, mute_dy, mute_corrY; int mute_ax, mute_ay, mute_dx, mute_dy, mute_corrY;
int clock_ax, clock_ay, clock_dx, clock_dy, digit_h, digit_offset; int clock_ax, clock_ay, clock_dx, clock_dy, digit_h, digit_offset;
int time_ax, time_dx;
int icon_width, icon_height, digit_width; int icon_width, icon_height, digit_width;
int h_spacer, v_spacer; int h_spacer, v_spacer;
int vol_ay, vol_height; int vol_ay, vol_height;
@@ -126,6 +127,7 @@ class CVolumeHelper
void getMuteIconDimensions(int *_x, int *_y, int *w, int *h) { *_x = mute_ax; *_y = mute_ay+mute_corrY; *w = mute_dx; *h = mute_dy; } void getMuteIconDimensions(int *_x, int *_y, int *w, int *h) { *_x = mute_ax; *_y = mute_ay+mute_corrY; *w = mute_dx; *h = mute_dy; }
int getInfoClockX(); int getInfoClockX();
void getInfoClockDimensions(int *_x, int *_y, int *w, int *h) { *_x = getInfoClockX(); *_y = clock_ay; *w = clock_dx; *h = clock_dy; } void getInfoClockDimensions(int *_x, int *_y, int *w, int *h) { *_x = getInfoClockX(); *_y = clock_ay; *w = clock_dx; *h = clock_dy; }
void getTimeDimensions(int *_x, int *_y, int *w, int *h) { *_x = time_ax; *_y = clock_ay; *w = time_dx; *h = clock_dy; }
void getVolBarDimensions(int *_y, int *_dy) { *_y = vol_ay; *_dy = vol_height; } void getVolBarDimensions(int *_y, int *_dy) { *_y = vol_ay; *_dy = vol_height; }
void setMuteIconCorrY(int corr) { mute_corrY = corr; } void setMuteIconCorrY(int corr) { mute_corrY = corr; }
void refresh(Font** font=NULL); void refresh(Font** font=NULL);