Commit c45fb127 authored by Cyril Deguet's avatar Cyril Deguet

* modules/gui/skins/*:

 - huge cleaning of the interpreter; all the variables are stored in
 the container VarManager, and can be retrieved by their name (with
 type checking if needed). Some variables are still owned by VlcProc
 for technical reasons (their interface is not compliant with normal
 variable, because of the "updateVLC" trick)
 - replaced double by float
parent effba799
......@@ -2,7 +2,7 @@
* ctrl_radialslider.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_radialslider.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: ctrl_radialslider.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -35,8 +35,8 @@
CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
const GenericBitmap &rBmpSeq, int numImg,
VarPercent &rVariable, double minAngle,
double maxAngle, const UString &rHelp ):
VarPercent &rVariable, float minAngle,
float maxAngle, const UString &rHelp ):
CtrlGeneric( pIntf, rHelp ), m_fsm( pIntf ), m_numImg( numImg ),
m_rVariable( rVariable ), m_minAngle( minAngle ), m_maxAngle( maxAngle ),
m_cmdUpDown( this, &transUpDown ), m_cmdDownUp( this, &transDownUp ),
......@@ -150,12 +150,12 @@ void CtrlRadialSlider::setCursor( int posX, int posY, bool blocking )
int y = posY - pPos->getTop() - m_width / 2;
// Compute the polar coordinates. angle is -(-j,OM)
double r = sqrt(x*x + y*y);
float r = sqrt(x*x + y*y);
if( r == 0 )
{
return;
}
double angle = acos(y/r);
float angle = acos(y/r);
if( x > 0 )
{
angle = 2*M_PI - angle;
......@@ -163,7 +163,7 @@ void CtrlRadialSlider::setCursor( int posX, int posY, bool blocking )
if( angle >= m_minAngle && angle <= m_maxAngle )
{
double newVal = (angle - m_minAngle) / (m_maxAngle - m_minAngle);
float newVal = (angle - m_minAngle) / (m_maxAngle - m_minAngle);
// Avoid too fast moves of the cursor if blocking mode
if( !blocking || fabs( m_rVariable.get() - newVal ) < 0.5 )
{
......
......@@ -2,7 +2,7 @@
* ctrl_radialslider.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_radialslider.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: ctrl_radialslider.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -42,8 +42,8 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
/// Create a radial slider with the given image, which must be
/// composed of numImg subimages of the same size
CtrlRadialSlider( intf_thread_t *pIntf, const GenericBitmap &rBmpSeq,
int numImg, VarPercent &rVariable, double minAngle,
double maxAngle, const UString &rHelp );
int numImg, VarPercent &rVariable, float minAngle,
float maxAngle, const UString &rHelp );
virtual ~CtrlRadialSlider();
......@@ -64,7 +64,7 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
/// Variable associated to the slider
VarPercent &m_rVariable;
/// Min and max angles of the button
double m_minAngle, m_maxAngle;
float m_minAngle, m_maxAngle;
/// Callbacks objects
Callback m_cmdUpDown;
Callback m_cmdDownUp;
......
......@@ -2,7 +2,7 @@
* ctrl_slider.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_slider.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: ctrl_slider.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -133,7 +133,7 @@ bool CtrlSliderCursor::mouseOver( int x, int y ) const
m_curve.getPoint( m_rVariable.get(), xPos, yPos );
// Compute the resize factors
double factorX = 0, factorY = 0;
float factorX = 0, factorY = 0;
getResizeFactors( factorX, factorY );
xPos = (int)(xPos * factorX);
yPos = (int)(yPos * factorY);
......@@ -157,7 +157,7 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
m_curve.getPoint( m_rVariable.get(), xPos, yPos );
// Compute the resize factors
double factorX = 0, factorY = 0;
float factorX = 0, factorY = 0;
getResizeFactors( factorX, factorY );
xPos = (int)(xPos * factorX);
yPos = (int)(yPos * factorY);
......@@ -190,7 +190,7 @@ void CtrlSliderCursor::transOverDown( SkinObject *pCtrl )
EvtMouse *pEvtMouse = (EvtMouse*)pThis->m_pEvt;
// Compute the resize factors
double factorX = 0, factorY = 0;
float factorX = 0, factorY = 0;
pThis->getResizeFactors( factorX, factorY );
// Compute the offset
......@@ -245,7 +245,7 @@ void CtrlSliderCursor::transMove( SkinObject *pCtrl )
const Position *pPos = pThis->getPosition();
// Compute the resize factors
double factorX = 0, factorY = 0;
float factorX = 0, factorY = 0;
pThis->getResizeFactors( factorX, factorY );
// XXX: This could be optimized a little bit
......@@ -253,7 +253,7 @@ void CtrlSliderCursor::transMove( SkinObject *pCtrl )
(int)((pEvtMouse->getXPos() - pPos->getLeft()) / factorX),
(int)((pEvtMouse->getYPos() - pPos->getTop()) / factorY) ) < RANGE )
{
double percentage = pThis->m_curve.getNearestPercent(
float percentage = pThis->m_curve.getNearestPercent(
(int)((pEvtMouse->getXPos() - pThis->m_xOffset) / factorX),
(int)((pEvtMouse->getYPos() - pThis->m_yOffset) / factorY) );
pThis->m_rVariable.set( percentage );
......@@ -271,7 +271,7 @@ void CtrlSliderCursor::transScroll( SkinObject *pCtrl )
int direction = pEvtScroll->getDirection();
double percentage = pThis->m_rVariable.get();
float percentage = pThis->m_rVariable.get();
if( direction == EvtScroll::kUp )
{
percentage += SCROLL_STEP;
......@@ -285,8 +285,8 @@ void CtrlSliderCursor::transScroll( SkinObject *pCtrl )
}
void CtrlSliderCursor::getResizeFactors( double &rFactorX,
double &rFactorY ) const
void CtrlSliderCursor::getResizeFactors( float &rFactorX,
float &rFactorY ) const
{
// Get the position of the control
const Position *pPos = getPosition();
......@@ -297,11 +297,11 @@ void CtrlSliderCursor::getResizeFactors( double &rFactorX,
// Compute the resize factors
if( m_width > 0 )
{
rFactorX = (double)pPos->getWidth() / (double)m_width;
rFactorX = (float)pPos->getWidth() / (float)m_width;
}
if( m_height > 0 )
{
rFactorY = (double)pPos->getHeight() / (double)m_height;
rFactorY = (float)pPos->getHeight() / (float)m_height;
}
}
......@@ -326,7 +326,7 @@ bool CtrlSliderBg::mouseOver( int x, int y ) const
}
// Compute the resize factors
double factorX = 0, factorY = 1.0;
float factorX = 0, factorY = 1.0;
getResizeFactors( factorX, factorY );
return (m_curve.getMinDist( (int)(x / factorY),
......@@ -339,7 +339,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
if( rEvent.getAsString().find( "mouse:left:down" ) != string::npos )
{
// Compute the resize factors
double factorX = 0, factorY = 1.0;
float factorX = 0, factorY = 1.0;
getResizeFactors( factorX, factorY );
// Get the position of the control
......@@ -368,7 +368,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
{
int direction = ((EvtScroll&)rEvent).getDirection();
double percentage = m_rVariable.get();
float percentage = m_rVariable.get();
if( direction == EvtScroll::kUp )
{
percentage += SCROLL_STEP;
......@@ -390,7 +390,7 @@ void CtrlSliderBg::onUpdate( Subject<VarBool> &rVariable )
}
void CtrlSliderBg::getResizeFactors( double &rFactorX, double &rFactorY ) const
void CtrlSliderBg::getResizeFactors( float &rFactorX, float &rFactorY ) const
{
// Get the position of the control
const Position *pPos = getPosition();
......@@ -401,11 +401,11 @@ void CtrlSliderBg::getResizeFactors( double &rFactorX, double &rFactorY ) const
// Compute the resize factors
if( m_width > 0 )
{
rFactorX = (double)pPos->getWidth() / (double)m_width;
rFactorX = (float)pPos->getWidth() / (float)m_width;
}
if( m_height > 0 )
{
rFactorY = (double)pPos->getHeight() / (double)m_height;
rFactorY = (float)pPos->getHeight() / (float)m_height;
}
}
......@@ -2,7 +2,7 @@
* ctrl_slider.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_slider.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: ctrl_slider.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -86,7 +86,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>,
/// Position of the cursor
int m_xPosition, m_yPosition;
/// Last saved position of the cursor (stored as a percentage)
double m_lastPercentage;
float m_lastPercentage;
/// Offset between the mouse pointer and the center of the cursor
int m_xOffset, m_yOffset;
/// The last received event
......@@ -113,7 +113,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>,
virtual void onUpdate( Subject<VarBool> &rVariable );
/// Methode to compute the resize factors
void getResizeFactors( double &rFactorX, double &rFactorY ) const;
void getResizeFactors( float &rFactorX, float &rFactorY ) const;
};
......@@ -148,7 +148,7 @@ class CtrlSliderBg: public CtrlGeneric
int m_width, m_height;
/// Methode to compute the resize factors
void getResizeFactors( double &rFactorX, double &rFactorY ) const;
void getResizeFactors( float &rFactorX, float &rFactorY ) const;
/// Method called when the visibility variable is modified
virtual void onUpdate( Subject<VarBool> &rVariable );
......
......@@ -2,7 +2,7 @@
* builder.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: builder.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -48,15 +48,14 @@
Builder::Builder( intf_thread_t *pIntf, BuilderData &rData):
SkinObject( pIntf ), m_rData( rData ), m_interpreter( pIntf ),
m_pTheme( NULL )
SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
{
}
CmdGeneric *Builder::parseAction( const string &rAction )
{
return m_interpreter.parseAction( rAction, m_pTheme );
return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme );
}
......@@ -275,7 +274,8 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
}
// Get the state variable
VarBool *pVar = m_interpreter.getVarBool( rData.m_state, m_pTheme );
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
VarBool *pVar = pInterpreter->getVarBool( rData.m_state, m_pTheme );
if( pVar == NULL )
{
// TODO: default state
......@@ -402,7 +402,8 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
}
// Get the variable associated to the slider
VarPercent *pVar = m_interpreter.getVarPercent( rData.m_value, m_pTheme );
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
if( pVar == NULL )
{
msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
......@@ -458,10 +459,11 @@ void Builder::addSlider( const BuilderData::Slider &rData )
// Get the visibility variable
// XXX check when it is null
VarBool *pVisible = m_interpreter.getVarBool( rData.m_visible, m_pTheme );
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
// Get the variable associated to the slider
VarPercent *pVar = m_interpreter.getVarPercent( rData.m_value, m_pTheme );
VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
if( pVar == NULL )
{
msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
......@@ -510,7 +512,8 @@ void Builder::addList( const BuilderData::List &rData )
}
// Get the list variable
VarList *pVar = m_interpreter.getVarList( rData.m_var, m_pTheme );
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
VarList *pVar = pInterpreter->getVarList( rData.m_var, m_pTheme );
if( pVar == NULL )
{
msg_Err( getIntf(), "No such list variable: %s", rData.m_var.c_str() );
......@@ -645,7 +648,7 @@ const Position Builder::makePosition( const string &rLeftTop,
Bezier *Builder::getPoints( const char *pTag ) const
{
vector<double> xBez, yBez;
vector<float> xBez, yBez;
int x, y, n;
while( 1 )
{
......
......@@ -2,7 +2,7 @@
* builder.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: builder.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -26,7 +26,6 @@
#define BUILDER_HPP
#include "builder_data.hpp"
#include "interpreter.hpp"
#include "../src/os_graphics.hpp"
#include "../src/generic_window.hpp"
#include "../src/generic_layout.hpp"
......@@ -62,9 +61,6 @@ class Builder: public SkinObject
/// Data from the XML
BuilderData &m_rData;
/// Script interpreter
Interpreter m_interpreter;
/// Theme under construction
Theme *m_pTheme;
......
......@@ -2,7 +2,7 @@
* builder_data.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder_data.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: builder_data.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -227,7 +227,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_fontId( fontId ), m_text( text ),
/// Type definition
struct RadialSlider
{
RadialSlider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & sequence, int nbImages, double minAngle, double maxAngle, const string & value, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ):
RadialSlider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & sequence, int nbImages, float minAngle, float maxAngle, const string & value, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ):
m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_sequence( sequence ), m_nbImages( nbImages ), m_minAngle( minAngle ), m_maxAngle( maxAngle ), m_value( value ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
const string m_id;
......@@ -238,8 +238,8 @@ m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( lef
const string m_rightBottom;
const string m_sequence;
int m_nbImages;
double m_minAngle;
double m_maxAngle;
float m_minAngle;
float m_maxAngle;
const string m_value;
const string m_tooltip;
const string m_help;
......
......@@ -2,7 +2,7 @@
* interpreter.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: interpreter.cpp,v 1.2 2004/01/05 22:17:32 asmax Exp $
* $Id: interpreter.cpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -31,6 +31,7 @@
#include "../commands/cmd_input.hpp"
#include "../commands/cmd_fullscreen.hpp"
#include "../src/theme.hpp"
#include "../src/var_manager.hpp"
#include "../src/vlcproc.hpp"
#include "../vars/playlist.hpp"
#include "../vars/vlcvars.hpp"
......@@ -40,95 +41,71 @@
Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
{
/// Create the generic commands
#define REGISTER_CMD( name, cmd ) \
m_commandMap[name] = CmdGenericPtr( new cmd( getIntf() ) );
REGISTER_CMD( "none", CmdDummy )
REGISTER_CMD( "dialogs.changeSkin()", CmdDlgChangeSkin )
REGISTER_CMD( "dialogs.fileSimple()", CmdDlgFileSimple )
REGISTER_CMD( "dialogs.file()", CmdDlgFile )
REGISTER_CMD( "dialogs.disc()", CmdDlgDisc )
REGISTER_CMD( "dialogs.net()", CmdDlgNet )
REGISTER_CMD( "dialogs.messages()", CmdDlgMessages )
REGISTER_CMD( "dialogs.prefs()", CmdDlgPrefs )
REGISTER_CMD( "dialogs.fileInfo()", CmdDlgFileInfo )
REGISTER_CMD( "dialogs.popup()", CmdDlgPopupMenu )
REGISTER_CMD( "playlist.add()", CmdDlgAdd )
VarList &rVar = VlcProc::instance( getIntf() )->getPlaylistVar();
m_commandMap["playlist.del()"] =
CmdGenericPtr( new CmdPlaylistDel( getIntf(), rVar ) );
REGISTER_CMD( "playlist.next()", CmdPlaylistNext )
REGISTER_CMD( "playlist.previous()", CmdPlaylistPrevious )
REGISTER_CMD( "playlist.sort()", CmdPlaylistSort )
REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen )
REGISTER_CMD( "vlc.quit()", CmdQuit )
REGISTER_CMD( "vlc.faster()", CmdFaster )
REGISTER_CMD( "vlc.slower()", CmdSlower )
REGISTER_CMD( "vlc.stop()", CmdStop )
}
CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
Interpreter *Interpreter::instance( intf_thread_t *pIntf )
{
// XXX should not be so hardcoded!
CmdGeneric *pCommand = NULL;
if( rAction == "none" )
{
pCommand = new CmdDummy( getIntf() );
}
else if( rAction == "dialogs.changeSkin()" )
{
pCommand = new CmdDlgChangeSkin( getIntf() );
}
else if( rAction == "dialogs.fileSimple()" )
{
pCommand = new CmdDlgFileSimple( getIntf() );
}
else if( rAction == "dialogs.file()" )
{
pCommand = new CmdDlgFile( getIntf() );
}
else if( rAction == "dialogs.disc()" )
{
pCommand = new CmdDlgDisc( getIntf() );
}
else if( rAction == "dialogs.net()" )
{
pCommand = new CmdDlgNet( getIntf() );
}
else if( rAction == "dialogs.messages()" )
{
pCommand = new CmdDlgMessages( getIntf() );
}
else if( rAction == "dialogs.prefs()" )
{
pCommand = new CmdDlgPrefs( getIntf() );
}
else if( rAction == "dialogs.fileInfo()" )
{
pCommand = new CmdDlgFileInfo( getIntf() );
}
else if( rAction == "dialogs.popup()" )
{
pCommand = new CmdDlgPopupMenu( getIntf() );
}
else if( rAction == "playlist.add()" )
{
pCommand = new CmdDlgAdd( getIntf() );
}
else if( rAction == "playlist.del()" )
{
VarList &rVar = VlcProc::instance( getIntf() )->getPlaylistVar();
pCommand = new CmdPlaylistDel( getIntf(), rVar );
}
else if( rAction == "playlist.next()" )
{
pCommand = new CmdPlaylistNext( getIntf() );
}
else if( rAction == "playlist.previous()" )
{
pCommand = new CmdPlaylistPrevious( getIntf() );
}
else if( rAction == "playlist.sort()" )
{
pCommand = new CmdPlaylistSort( getIntf() );
}
else if( rAction == "vlc.fullscreen()" )
{
pCommand = new CmdFullscreen( getIntf() );
}
else if( rAction == "vlc.quit()" )
{
pCommand = new CmdQuit( getIntf() );
}
else if( rAction == "vlc.stop()" )
if( ! pIntf->p_sys->p_interpreter )
{
pCommand = new CmdStop( getIntf() );
Interpreter *pInterpreter;
pInterpreter = new Interpreter( pIntf );
if( pInterpreter )
{
pIntf->p_sys->p_interpreter = pInterpreter;
}
}
else if( rAction == "vlc.slower()" )
return pIntf->p_sys->p_interpreter;
}
void Interpreter::destroy( intf_thread_t *pIntf )
{
if( pIntf->p_sys->p_interpreter )
{
pCommand = new CmdSlower( getIntf() );
delete pIntf->p_sys->p_interpreter;
pIntf->p_sys->p_interpreter = NULL;
}
else if( rAction == "vlc.faster()" )
}
CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
{
// Try to find the command in the global command map
if( m_commandMap.find( rAction ) != m_commandMap.end() )
{
pCommand = new CmdFaster( getIntf() );
return m_commandMap[rAction].get();
}
else if( rAction.find( ".setLayout(" ) != string::npos )
CmdGeneric *pCommand = NULL;
if( rAction.find( ".setLayout(" ) != string::npos )
{
int leftPos = rAction.find( ".setLayout(" );
string windowId = rAction.substr( 0, leftPos );
......@@ -136,7 +113,6 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
int rightPos = rAction.find( ")", windowId.size() + 11 );
string layoutId = rAction.substr( windowId.size() + 11,
rightPos - (windowId.size() + 11) );
// XXX check the IDs (isalpha())
pCommand = new CmdLayout( getIntf(), windowId, layoutId );
}
......@@ -152,19 +128,13 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
{
VarBool *pVar = NULL;
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() );
VarBool *pVar = (VarBool*)pVarManager->getVar( rName, "bool" );
if( rName == "vlc.isPlaying" )
{
pVar = &VlcProc::instance( getIntf() )->getIsPlayingVar();
}
else if( rName == "vlc.isSeekablePlaying" )
if( pVar )
{
pVar = &VlcProc::instance( getIntf() )->getIsSeekablePlayingVar();
}
else if( rName == "vlc.isMute" )
{
pVar = &VlcProc::instance( getIntf() )->getIsMuteVar();
return pVar;
}
else if( rName.find( ".isVisible" ) != string::npos )
{
......@@ -174,49 +144,35 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
GenericWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
pVar = &pWin->getVisibleVar();
return &pWin->getVisibleVar();
}
else
{
msg_Warn( getIntf(), "Unknown window (%s)", windowId.c_str() );
return NULL;
}
}
return pVar;
else
{
return NULL;
}
}
VarPercent *Interpreter::getVarPercent( const string &rName, Theme *pTheme )
{
VarPercent *pVar = NULL;
if( rName == "time" )
{
pVar = &VlcProc::instance( getIntf() )->getTimeVar();
}
else if( rName == "volume" )
{
pVar = &VlcProc::instance( getIntf() )->getVolumeVar();
}
else if( rName == "playlist.slider" )
{
pVar = &VlcProc::instance( getIntf() )->
getPlaylistVar().getPositionVar();
}
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() );
VarPercent *pVar = (VarPercent*)pVarManager->getVar( rName, "percent" );
return pVar;
}
VarList *Interpreter::getVarList( const string &rName, Theme *pTheme )
{
VarList *pVar = NULL;
if( rName == "playlist" )
{
pVar = &VlcProc::instance( getIntf() )->getPlaylistVar();
}
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() );
VarList *pVar = (VarList*)pVarManager->getVar( rName, "list" );
return pVar;
}
......@@ -2,7 +2,7 @@
* interpreter.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: interpreter.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: interpreter.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -26,6 +26,7 @@
#define INTERPRETER_HPP
#include "../commands/cmd_generic.hpp"
#include <map>
class Theme;
class VarBool;
......@@ -37,8 +38,11 @@ class VarPercent;
class Interpreter: public SkinObject
{
public:
Interpreter( intf_thread_t *pIntf );
virtual ~Interpreter() {}
/// Get the instance of Interpreter
static Interpreter *instance( intf_thread_t *pIntf );
/// Delete the instance of Interpreter
static void destroy( intf_thread_t *pIntf );
/// Parse an action tag and returns a pointer on a command
/// (the intepreter takes care of deleting it, don't do it
......@@ -54,6 +58,14 @@ class Interpreter: public SkinObject
/// Returns the list variable corresponding to the given name
VarList *getVarList( const string &rName, Theme *pTheme );
private:
/// Map of global commands
map<string, CmdGenericPtr> m_commandMap;
// Private because it is a singleton
Interpreter( intf_thread_t *pIntf );
virtual ~Interpreter() {}
};
#endif
......@@ -2,7 +2,7 @@
* skin_common.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_common.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: skin_common.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -33,6 +33,7 @@ using namespace std;
class AsyncQueue;
class Logger;
class Dialogs;
class Interpreter;
class OSFactory;
class OSLoop;
class VarManager;
......@@ -74,6 +75,8 @@ struct intf_sys_t
AsyncQueue *p_queue;
/// Dialog provider
Dialogs *p_dialogs;
/// Script interpreter
Interpreter *p_interpreter;
/// Factory for OS specific classes
OSFactory *p_osFactory;
/// Main OS specific message loop
......
......@@ -2,7 +2,7 @@
* skin_main.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_main.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: skin_main.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -32,6 +32,7 @@
#include "vlcproc.hpp"
#include "theme.hpp"
#include "theme_loader.hpp"
#include "../parser/interpreter.hpp"
#include "../commands/async_queue.hpp"
......@@ -85,6 +86,7 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_logger = NULL;
p_intf->p_sys->p_queue = NULL;
p_intf->p_sys->p_dialogs = NULL;
p_intf->p_sys->p_interpreter = NULL;
p_intf->p_sys->p_osFactory = NULL;
p_intf->p_sys->p_osLoop = NULL;
p_intf->p_sys->p_varManager = NULL;
......@@ -99,6 +101,11 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_intf, "Cannot initialize AsyncQueue" );
return VLC_EGENERIC;
}
if( Interpreter::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot instanciate Interpreter" );
return VLC_EGENERIC;
}
if( OSFactory::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot initialize OSFactory" );
......@@ -131,6 +138,7 @@ static void Close( vlc_object_t *p_this )
OSFactory::instance( p_intf )->destroyOSLoop();
OSFactory::destroy( p_intf );
Dialogs::destroy( p_intf );
Interpreter::destroy( p_intf );
AsyncQueue::destroy( p_intf );
VarManager::destroy( p_intf );
......
......@@ -2,7 +2,7 @@
* tooltip.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: tooltip.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: tooltip.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -48,7 +48,7 @@ Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
Tooltip::~Tooltip()
{
VarManager::instance( getIntf() )->getTooltipText().delObserver( this );
// VarManager::instance( getIntf() )->getTooltipText().delObserver( this );
SKINS_DELETE( m_pTimer );
SKINS_DELETE( m_pOsTooltip );
if( m_pImage )
......
......@@ -2,7 +2,7 @@
* var_manager.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_manager.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_manager.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -26,7 +26,7 @@
VarManager::VarManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_tooltip( pIntf ), m_help( pIntf )
m_tooltipText( pIntf ), m_helpText( pIntf )
{
}
......@@ -55,3 +55,47 @@ void VarManager::destroy( intf_thread_t *pIntf )
}
}
void VarManager::registerVar( const VariablePtr &rcVar, const string &rName )
{
m_varMap[rName] = rcVar;
}
Variable *VarManager::getVar( const string &rName )
{
if( m_varMap.find( rName ) != m_varMap.end() )
{
return m_varMap[rName].get();
}
else
{
return NULL;
}
}
Variable *VarManager::getVar( const string &rName, const string &rType )
{
if( m_varMap.find( rName ) != m_varMap.end() )
{
Variable *pVar = m_varMap[rName].get();
// Check the variable type
if( pVar->getType() != rType )
{
msg_Warn( getIntf(), "Variable %s has incorrect type (%s instead"
" of (%s)", rName.c_str(), pVar->getType().c_str(),
rType.c_str() );
return NULL;
}
else
{
return pVar;
}
}
else
{
return NULL;
}
}
......@@ -2,7 +2,7 @@
* var_manager.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_manager.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_manager.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -26,6 +26,7 @@
#define VAR_MANAGER_HPP
#include "../utils/var_text.hpp"
#include <map>
class VarManager: public SkinObject
......@@ -37,17 +38,28 @@ class VarManager: public SkinObject
/// Delete the instance of VarManager
static void destroy( intf_thread_t *pIntf );
/// Register a variable in the manager
void registerVar( const VariablePtr &rcVar, const string &rName );
/// Get a variable by its name (NULL if not found)
Variable *getVar( const string &rName );
/// Get a variable by its name and check the type (NULL if not found)
Variable *getVar( const string &rName, const string &rType );
/// Get the tooltip text variable
VarText &getTooltipText() { return m_tooltip; }
VarText &getTooltipText() { return m_tooltipText; }
/// Get the help text variable
VarText &getHelpText() { return m_help; }
VarText &getHelpText() { return m_helpText; }
private:
/// Tooltip text
VarText m_tooltip;
VarText m_tooltipText;
/// Help text
VarText m_help;
VarText m_helpText;
/// Map of registerd variables
map<string, VariablePtr> m_varMap;
/// Private because it is a singleton
VarManager( intf_thread_t *pIntf );
......
......@@ -2,7 +2,7 @@
* vlcproc.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.2 2004/01/11 00:21:22 asmax Exp $
* $Id: vlcproc.cpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -27,12 +27,12 @@
#include "vlcproc.hpp"
#include "os_factory.hpp"
#include "os_timer.hpp"
#include "var_manager.hpp"
#include "../commands/async_queue.hpp"
#include "../commands/cmd_notify_playlist.hpp"
#include "../commands/cmd_quit.hpp"
VlcProc *VlcProc::instance( intf_thread_t *pIntf )
{
if( pIntf->p_sys->p_vlcProc == NULL )
......@@ -54,16 +54,29 @@ void VlcProc::destroy( intf_thread_t *pIntf )
}
VlcProc::VlcProc( intf_thread_t *pIntf ):
SkinObject( pIntf ), m_playlist( pIntf), m_varTime( pIntf ),
m_varVolume( pIntf ), m_varMute( pIntf ), m_varPlaying( pIntf ),
m_varSeekablePlaying( pIntf )
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
{
// Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pTimer = pOsFactory->createOSTimer( Callback( this, &doManage ) );
m_pTimer->start( 100, false );
// Create and register VLC variables
VarManager *pVarManager = VarManager::instance( getIntf() );
#define REGISTER_VAR( name, var, type ) \
name = VariablePtr( new var( getIntf() ) ); \
pVarManager->registerVar( name, type );
REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
"playlist.slider" );
REGISTER_VAR( m_cVarTime, Time, "time" )
REGISTER_VAR( m_cVarVolume, Volume, "volume" )
REGISTER_VAR( m_cVarMute, VlcIsMute, "vlc.isMute" )
REGISTER_VAR( m_cVarPlaying, VlcIsPlaying, "vlc.isPlaying" )
REGISTER_VAR( m_cVarSeekablePlaying, VlcIsSeekablePlaying,
"vlc.isSeekablePlaying" )
// Called when the playlist changes
var_AddCallback( pIntf->p_sys-> p_playlist, "intf-change",
onIntfChange, this );
......@@ -99,10 +112,16 @@ void VlcProc::manage()
pQueue->push( CmdGenericPtr( pCmd ) );
}
// Get the VLC variables
Time *pTime = (Time*)m_cVarTime.get();
Volume *pVolume = (Volume*)m_cVarVolume.get();
VlcIsPlaying *pVarPlaying = (VlcIsPlaying*)m_cVarPlaying.get();
VarBool *pVarSeekablePlaying = (VarBool*)m_cVarSeekablePlaying.get();
// Refresh sound volume
audio_volume_t volume;
aout_VolumeGet( getIntf(), &volume);
m_varVolume.set( (double)volume / AOUT_VOLUME_MAX );
pVolume->set( (double)volume / AOUT_VOLUME_MAX );
// Update the input
if( getIntf()->p_sys->p_input == NULL )
......@@ -128,32 +147,32 @@ void VlcProc::manage()
var_Get( pInput, "position", &pos );
if( pos.f_float >= 0.0 )
{
m_varTime.set( pos.f_float, false );
pTime->set( pos.f_float, false );
}
}
else
{
m_varTime.set( 0, false );
pTime->set( 0, false );
}
// Get the status of the playlist
playlist_status_t status = getIntf()->p_sys->p_playlist->i_status;
m_varPlaying.set( status == PLAYLIST_RUNNING, false );
pVarPlaying->set( status == PLAYLIST_RUNNING, false );
if( pInput->stream.b_seekable )
{
m_varSeekablePlaying.set( status != PLAYLIST_STOPPED );
pVarSeekablePlaying->set( status != PLAYLIST_STOPPED );
}
else
{
m_varSeekablePlaying.set( false );
pVarSeekablePlaying->set( false );
}
}
else
{
m_varPlaying.set( false, false );
m_varSeekablePlaying.set( false );
m_varTime.set( 0, false );
pVarPlaying->set( false, false );
pVarSeekablePlaying->set( false );
pTime->set( 0, false );
}
}
......
......@@ -2,7 +2,7 @@
* vlcproc.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.hpp,v 1.2 2004/01/11 00:21:22 asmax Exp $
* $Id: vlcproc.hpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -45,23 +45,23 @@ class VlcProc: public SkinObject
static void destroy( intf_thread_t *pIntf );
/// Getter for the playlist variable
Playlist &getPlaylistVar() { return m_playlist; }
Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
/// Getter for the time variable
Time &getTimeVar() { return m_varTime; }
Time &getTimeVar() { return *((Time*)(m_cVarTime.get())); }
/// Getter for the volume variable
Volume &getVolumeVar() { return m_varVolume; }
Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
/// Getter for the mute variable
VlcIsMute &getIsMuteVar() { return m_varMute; }
VarBool &getIsMuteVar() { return *((VarBool*)(m_cVarMute.get())); }
/// Getter for the playing variable
VlcIsPlaying &getIsPlayingVar() { return m_varPlaying; }
VarBool &getIsPlayingVar() { return *((VarBool*)(m_cVarPlaying.get())); }
/// Getter for the seekable/playing variable
VlcIsSeekablePlaying &getIsSeekablePlayingVar()
{ return m_varSeekablePlaying; }
VarBool &getIsSeekablePlayingVar()
{ return *((VarBool*)(m_cVarSeekablePlaying.get())); }
protected:
// Protected because it is a singleton
......@@ -72,16 +72,16 @@ class VlcProc: public SkinObject
/// Timer to call manage() regularly (via doManage())
OSTimer *m_pTimer;
/// Playlist variable
Playlist m_playlist;
/// Variable for the position in the stream
Time m_varTime;
VariablePtr m_cPlaylist;
/// Variable for current position of the stream
VariablePtr m_cVarTime;
/// Variable for audio volume
Volume m_varVolume;
VariablePtr m_cVarVolume;
/// Variable for the "mute" state
VlcIsMute m_varMute;
VariablePtr m_cVarMute;
/// Variables related to the input
VlcIsPlaying m_varPlaying;
VlcIsSeekablePlaying m_varSeekablePlaying;
VariablePtr m_cVarPlaying;
VariablePtr m_cVarSeekablePlaying;
/// Poll VLC internals to update the status (volume, current time in
/// the stream, current filename, play/pause/stop status, ...)
......
......@@ -2,7 +2,7 @@
* bezier.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bezier.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: bezier.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -26,8 +26,8 @@
#include <math.h>
Bezier::Bezier( intf_thread_t *p_intf, const vector<double> &rAbscissas,
const vector<double> &rOrdinates, Flag_t flag )
Bezier::Bezier( intf_thread_t *p_intf, const vector<float> &rAbscissas,
const vector<float> &rOrdinates, Flag_t flag )
: SkinObject( p_intf )
{
// We expect rAbscissas and rOrdinates to have the same size, of course
......@@ -55,8 +55,8 @@ Bezier::Bezier( intf_thread_t *p_intf, const vector<double> &rAbscissas,
m_topVect[0] = oldy;
// Compute the number of different points
double percentage;
for( double j = 1; j <= MAX_BEZIER_POINT; j++ )
float percentage;
for( float j = 1; j <= MAX_BEZIER_POINT; j++ )
{
percentage = j / MAX_BEZIER_POINT;
getPoint( percentage, cx, cy );
......@@ -74,14 +74,14 @@ Bezier::Bezier( intf_thread_t *p_intf, const vector<double> &rAbscissas,
}
double Bezier::getNearestPercent( int x, int y ) const
float Bezier::getNearestPercent( int x, int y ) const
{
int nearest = findNearestPoint( x, y );
return (double)nearest / (double)(m_nbPoints - 1);
return (float)nearest / (float)(m_nbPoints - 1);
}
double Bezier::getMinDist( int x, int y ) const
float Bezier::getMinDist( int x, int y ) const
{
// XXX: duplicate code with findNearestPoint
int minDist = (m_leftVect[0] - x) * (m_leftVect[0] - x) +
......@@ -101,13 +101,13 @@ double Bezier::getMinDist( int x, int y ) const
}
void Bezier::getPoint( double t, int &x, int &y ) const
void Bezier::getPoint( float t, int &x, int &y ) const
{
// See http://astronomy.swin.edu.au/~pbourke/curves/bezier/ for a simple
// explanation of the algorithm
double xPos = 0;
double yPos = 0;
double coeff;
float xPos = 0;
float yPos = 0;
float coeff;
for( int i = 0; i < m_nbCtrlPt; i++ )
{
coeff = computeCoeff( i, m_nbCtrlPt - 1, t );
......@@ -115,7 +115,7 @@ void Bezier::getPoint( double t, int &x, int &y ) const
yPos += m_pty[i] * coeff;
}
// Double cast to avoid strange truncatures
// float cast to avoid strange truncatures
// XXX: not very nice...
x = (int)(float)xPos;
y = (int)(float)yPos;
......@@ -174,14 +174,14 @@ int Bezier::findNearestPoint( int x, int y ) const
}
inline double Bezier::computeCoeff( int i, int n, double t ) const
inline float Bezier::computeCoeff( int i, int n, float t ) const
{
return (power( t, i ) * power( 1 - t, (n - i) ) *
(m_ft[n] / m_ft[i] / m_ft[n - i]));
}
inline double Bezier::power( double x, int n ) const
inline float Bezier::power( float x, int n ) const
{
if( n > 0 )
return x * power( x, n - 1);
......
......@@ -2,7 +2,7 @@
* bezier.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bezier.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: bezier.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -46,22 +46,22 @@ class Bezier: public SkinObject
} Flag_t;
Bezier( intf_thread_t *p_intf,
const vector<double> &pAbscissas,
const vector<double> &pOrdinates,
const vector<float> &pAbscissas,
const vector<float> &pOrdinates,
Flag_t flag = kCoordsBoth );
~Bezier() {}
/// Return the percentage (between 0 and 1) of the curve point nearest
/// from (x, y)
double getNearestPercent( int x, int y ) const;
float getNearestPercent( int x, int y ) const;
/// Return the distance of (x, y) to the curve
double getMinDist( int x, int y ) const;
float getMinDist( int x, int y ) const;
/// Get the coordinates of the point at t precent of
/// the curve (t must be between 0 and 1)
void getPoint( double t, int &x, int &y ) const;
void getPoint( float t, int &x, int &y ) const;
/// Get the width (maximum abscissa) of the curve
int getWidth() const;
......@@ -73,10 +73,10 @@ class Bezier: public SkinObject
/// Number of control points
int m_nbCtrlPt;
/// vectors containing the coordinates of the control points
vector<double> m_ptx;
vector<double> m_pty;
vector<float> m_ptx;
vector<float> m_pty;
/// Vector containing precalculated factoriels
vector<double> m_ft;
vector<float> m_ft;
/// Number of points (=pixels) used by the curve
int m_nbPoints;
......@@ -87,9 +87,9 @@ class Bezier: public SkinObject
/// Return the index of the curve point that is the nearest from (x, y)
int findNearestPoint( int x, int y ) const;
/// Helper function to compute a coefficient of the curve
inline double computeCoeff( int i, int n, double t ) const;
inline float computeCoeff( int i, int n, float t ) const;
/// x^n
inline double power( double x, int n ) const;
inline float power( float x, int n ) const;
};
......
......@@ -2,7 +2,7 @@
* var_bool.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_bool.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_bool.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,6 +25,9 @@
#include "var_bool.hpp"
const string VarBool::m_type = "bool";
VarBool::VarBool( intf_thread_t *pIntf ): Variable( pIntf ), m_value( false )
{
}
......
......@@ -2,7 +2,7 @@
* var_bool.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_bool.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_bool.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -36,11 +36,17 @@ class VarBool: public Variable, public Subject<VarBool>
VarBool( intf_thread_t *pIntf );
virtual ~VarBool() {}
/// Get the variable type
virtual const string &getType() const { return m_type; }
/// Set the internal value
virtual void set( bool value );
virtual bool get() const { return m_value; }
private:
/// Variable type
static const string m_type;
/// Boolean value
bool m_value;
};
......
......@@ -2,7 +2,7 @@
* var_list.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_list.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_list.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,10 +25,14 @@
#include "var_list.hpp"
VarList::VarList( intf_thread_t *pIntf ): Variable( pIntf ),
m_position( pIntf )
const string VarList::m_type = "list";
VarList::VarList( intf_thread_t *pIntf ): Variable( pIntf )
{
m_position.set( 1.0 );
// Create the position variable
m_cPosition = VariablePtr( new VarPercent( pIntf ) );
getPositionVar().set( 1.0 );
}
......
......@@ -2,7 +2,7 @@
* var_list.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_list.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_list.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -40,6 +40,9 @@ class VarList: public Variable, public Subject<VarList>
VarList( intf_thread_t *pIntf );
virtual ~VarList();
/// Get the variable type
virtual const string &getType() const { return m_type; }
/// Add a pointer on a string in the list
virtual void add( const UStringPtr &rcString );
......@@ -84,16 +87,22 @@ class VarList: public Variable, public Subject<VarList>
/// Execute the action associated to this item
virtual void action( Elem_t *pItem ) {}
/// Get the position variable
VarPercent &getPositionVar() { return m_position; }
/// Get a reference on the position variable
VarPercent &getPositionVar() const
{ return *((VarPercent*)m_cPosition.get()); }
/// Get a counted pointer on the position variable
const VariablePtr &getPositionVarPtr() const { return m_cPosition; }
protected:
/// List of elements
list<Elem_t> m_list;
private:
/// Variable type
static const string m_type;
/// Position variable
VarPercent m_position;
VariablePtr m_cPosition;
};
......
......@@ -2,7 +2,7 @@
* var_percent.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_percent.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_percent.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,12 +25,15 @@
#include "var_percent.hpp"
const string VarPercent::m_type = "percent";
VarPercent::VarPercent( intf_thread_t *pIntf ): Variable( pIntf ), m_value( 0 )
{
}
void VarPercent::set( double percentage )
void VarPercent::set( float percentage )
{
if( percentage < 0 )
{
......
......@@ -2,7 +2,7 @@
* var_percent.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_percent.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_percent.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -36,12 +36,18 @@ class VarPercent: public Variable, public Subject<VarPercent>
VarPercent( intf_thread_t *pIntf );
virtual ~VarPercent() {}
/// Get the variable type
virtual const string &getType() const { return m_type; }
/// Set the internal value
virtual void set( double percentage );
virtual double get() const { return m_value; }
virtual void set( float percentage );
virtual float get() const { return m_value; }
private:
double m_value;
/// Variable type
static const string m_type;
/// Percent value
float m_value;
};
#endif
......@@ -2,7 +2,7 @@
* var_text.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_text.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_text.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -29,10 +29,12 @@
#include "../vars/volume.hpp"
const string VarText::m_type = "text";
VarText::VarText( intf_thread_t *pIntf ): Variable( pIntf ),
m_text( pIntf, "" ), m_lastText( pIntf, "" )
{
m_lastText = get();
}
......
......@@ -2,7 +2,7 @@
* var_text.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_text.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: var_text.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -39,6 +39,9 @@ class VarText: public Variable, public Subject<VarText>,
VarText( intf_thread_t *pIntf );
virtual ~VarText();
/// Get the variable type
virtual const string &getType() const { return m_type; }
/// Set the internal value
virtual void set( const UString &rText );
virtual const UString get() const;
......@@ -48,6 +51,8 @@ class VarText: public Variable, public Subject<VarText>,
virtual void onUpdate( Subject<VarText> &rVariable );
private:
/// Variable type
static const string m_type;
/// The text of the variable
UString m_text;
/// Actual text after having replaced the variables
......
......@@ -2,7 +2,7 @@
* variable.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: variable.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: variable.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -27,6 +27,7 @@
#include "../src/skin_common.hpp"
#include "pointer.hpp"
#include <string>
/// Base class for variable objects
......@@ -35,6 +36,9 @@ class Variable: public SkinObject
public:
virtual ~Variable() {}
/// Get the variable type
virtual const string &getType() const = 0;
protected:
Variable( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
};
......
......@@ -2,7 +2,7 @@
* time.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: time.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: time.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -28,7 +28,7 @@
#include <vlc/input.h>
void Time::set( double percentage, bool updateVLC )
void Time::set( float percentage, bool updateVLC )
{
if( getIntf()->p_sys->p_input == NULL )
{
......
......@@ -2,7 +2,7 @@
* time.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: time.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: time.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -25,11 +25,9 @@
#ifndef TIME_HPP
#define TIME_HPP
#include "../utils/var_percent.hpp"
#include <string>
/// Variable for VLC volume
class Time: public VarPercent
{
......@@ -37,9 +35,9 @@ class Time: public VarPercent
Time( intf_thread_t *pIntf ): VarPercent( pIntf ) {}
virtual ~Time() {}
virtual void set( double percentage, bool updateVLC );
virtual void set( float percentage, bool updateVLC );
virtual void set( double percentage ) { set( percentage, true ); }
virtual void set( float percentage ) { set( percentage, true ); }
/// Return a string containing a value from 0 to 100
virtual string getAsStringPercent() const;
......@@ -47,5 +45,4 @@ class Time: public VarPercent
virtual string getAsStringTime() const;
};
#endif
......@@ -2,7 +2,7 @@
* volume.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: volume.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: volume.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -37,7 +37,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
}
void Volume::set( double percentage )
void Volume::set( float percentage )
{
// Avoid looping forever...
if( (int)(get() * AOUT_VOLUME_MAX) !=
......
......@@ -2,7 +2,7 @@
* volume.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: volume.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: volume.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -37,7 +37,7 @@ class Volume: public VarPercent
Volume( intf_thread_t *pIntf );
virtual ~Volume() {}
virtual void set( double percentage );
virtual void set( float percentage );
virtual string getAsStringPercent() const;
};
......
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