Commit b3d9b331 authored by Olivier Teulière's avatar Olivier Teulière

* skins2: support $t, $d, and $l in text controls. They do the same as $T, $D

   and $L, except that the hour is not printed if it is 0.
parent 3c5d89e5
...@@ -43,6 +43,7 @@ BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap, ...@@ -43,6 +43,7 @@ BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
{ {
m_table['0'+i].m_xPos = i * m_width; m_table['0'+i].m_xPos = i * m_width;
} }
m_table[(size_t)' '].m_xPos = 10 * m_width;
m_table[(size_t)'-'].m_xPos = 11 * m_width; m_table[(size_t)'-'].m_xPos = 11 * m_width;
} }
else if( rType == "text" ) else if( rType == "text" )
......
...@@ -83,16 +83,31 @@ const UString VarText::get() const ...@@ -83,16 +83,31 @@ const UString VarText::get() const
temp.replace( pos, 2, temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringCurrTime().c_str() ); pVlcProc->getTimeVar().getAsStringCurrTime().c_str() );
} }
while( (pos = temp.find( "$t" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringCurrTime(true).c_str() );
}
while( (pos = temp.find( "$L" )) != UString::npos ) while( (pos = temp.find( "$L" )) != UString::npos )
{ {
temp.replace( pos, 2, temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringTimeLeft().c_str() ); pVlcProc->getTimeVar().getAsStringTimeLeft().c_str() );
} }
while( (pos = temp.find( "$l" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringTimeLeft(true).c_str() );
}
while( (pos = temp.find( "$D" )) != UString::npos ) while( (pos = temp.find( "$D" )) != UString::npos )
{ {
temp.replace( pos, 2, temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringDuration().c_str() ); pVlcProc->getTimeVar().getAsStringDuration().c_str() );
} }
while( (pos = temp.find( "$d" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringDuration(true).c_str() );
}
while( (pos = temp.find( "$V" )) != UString::npos ) while( (pos = temp.find( "$V" )) != UString::npos )
{ {
temp.replace( pos, 2, temp.replace( pos, 2,
...@@ -137,15 +152,18 @@ void VarText::set( const UString &rText ) ...@@ -137,15 +152,18 @@ void VarText::set( const UString &rText )
{ {
pVarManager->getHelpText().addObserver( this ); pVarManager->getHelpText().addObserver( this );
} }
if( m_text.find( "$T" ) != UString::npos ) if( m_text.find( "$T" ) != UString::npos ||
m_text.find( "$t" ) != UString::npos )
{ {
pVlcProc->getTimeVar().addObserver( this ); pVlcProc->getTimeVar().addObserver( this );
} }
if( m_text.find( "$L" ) != UString::npos ) if( m_text.find( "$L" ) != UString::npos ||
m_text.find( "$l" ) != UString::npos )
{ {
pVlcProc->getTimeVar().addObserver( this ); pVlcProc->getTimeVar().addObserver( this );
} }
if( m_text.find( "$D" ) != UString::npos ) if( m_text.find( "$D" ) != UString::npos ||
m_text.find( "$d" ) != UString::npos )
{ {
pVlcProc->getTimeVar().addObserver( this ); pVlcProc->getTimeVar().addObserver( this );
} }
......
...@@ -56,7 +56,7 @@ const string StreamTime::getAsStringPercent() const ...@@ -56,7 +56,7 @@ const string StreamTime::getAsStringPercent() const
} }
const string StreamTime::getAsStringCurrTime() const const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
{ {
if( getIntf()->p_sys->p_input == NULL ) if( getIntf()->p_sys->p_input == NULL )
{ {
...@@ -73,11 +73,11 @@ const string StreamTime::getAsStringCurrTime() const ...@@ -73,11 +73,11 @@ const string StreamTime::getAsStringCurrTime() const
vlc_value_t time; vlc_value_t time;
var_Get( getIntf()->p_sys->p_input, "time", &time ); var_Get( getIntf()->p_sys->p_input, "time", &time );
return formatTime( time.i_time / 1000000 ); return formatTime( time.i_time / 1000000, bShortFormat );
} }
const string StreamTime::getAsStringTimeLeft() const const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
{ {
if( getIntf()->p_sys->p_input == NULL ) if( getIntf()->p_sys->p_input == NULL )
{ {
...@@ -95,11 +95,12 @@ const string StreamTime::getAsStringTimeLeft() const ...@@ -95,11 +95,12 @@ const string StreamTime::getAsStringTimeLeft() const
var_Get( getIntf()->p_sys->p_input, "time", &time ); var_Get( getIntf()->p_sys->p_input, "time", &time );
var_Get( getIntf()->p_sys->p_input, "length", &duration ); var_Get( getIntf()->p_sys->p_input, "length", &duration );
return formatTime( (duration.i_time - time.i_time) / 1000000 ); return formatTime( (duration.i_time - time.i_time) / 1000000,
bShortFormat );
} }
const string StreamTime::getAsStringDuration() const const string StreamTime::getAsStringDuration( bool bShortFormat ) const
{ {
if( getIntf()->p_sys->p_input == NULL ) if( getIntf()->p_sys->p_input == NULL )
{ {
...@@ -116,17 +117,26 @@ const string StreamTime::getAsStringDuration() const ...@@ -116,17 +117,26 @@ const string StreamTime::getAsStringDuration() const
vlc_value_t time; vlc_value_t time;
var_Get( getIntf()->p_sys->p_input, "length", &time ); var_Get( getIntf()->p_sys->p_input, "length", &time );
return formatTime( time.i_time / 1000000 ); return formatTime( time.i_time / 1000000, bShortFormat );
} }
const string StreamTime::formatTime( int seconds ) const const string StreamTime::formatTime( int seconds, bool bShortFormat ) const
{ {
char *psz_time = new char[MSTRTIME_MAX_SIZE]; char *psz_time = new char[MSTRTIME_MAX_SIZE];
if( bShortFormat && (seconds < 60 * 60) )
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, " %02d:%02d",
(int) (seconds / 60 % 60),
(int) (seconds % 60) );
}
else
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d", snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
(int) (seconds / (60 * 60)), (int) (seconds / (60 * 60)),
(int) (seconds / 60 % 60), (int) (seconds / 60 % 60),
(int) (seconds % 60) ); (int) (seconds % 60) );
}
string ret = psz_time; string ret = psz_time;
delete[] psz_time; delete[] psz_time;
......
...@@ -42,15 +42,15 @@ class StreamTime: public VarPercent ...@@ -42,15 +42,15 @@ class StreamTime: public VarPercent
/// Return a string containing a value from 0 to 100 /// Return a string containing a value from 0 to 100
virtual const string getAsStringPercent() const; virtual const string getAsStringPercent() const;
/// Return the current time formatted as a time display (h:mm:ss) /// Return the current time formatted as a time display (h:mm:ss)
virtual const string getAsStringCurrTime() const; virtual const string getAsStringCurrTime( bool bShortFormat = false ) const;
/// Return the time left formatted as a time display (h:mm:ss) /// Return the time left formatted as a time display (h:mm:ss)
virtual const string getAsStringTimeLeft() const; virtual const string getAsStringTimeLeft( bool bShortFormat = false ) const;
/// Return the duration formatted as a time display (h:mm:ss) /// Return the duration formatted as a time display (h:mm:ss)
virtual const string getAsStringDuration() const; virtual const string getAsStringDuration( bool bShortFormat = false ) const;
private: private:
/// Convert a number of seconds into "h:mm:ss" format /// Convert a number of seconds into "h:mm:ss" format
const string formatTime( int seconds ) const; const string formatTime( int seconds, bool bShortFormat ) const;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment