* 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 Teulière <ipkiss@via.ecp.fr>
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 ),
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;
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 )
{
* 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>
/// 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();
/// 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;
* 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 Teulière <ipkiss@via.ecp.fr>
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);
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);
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
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
(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 );
int direction = pEvtScroll->getDirection();
- double percentage = pThis->m_rVariable.get();
+ float percentage = pThis->m_rVariable.get();
if( direction == EvtScroll::kUp )
{
percentage += SCROLL_STEP;
}
-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();
// 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;
}
}
}
// 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),
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
{
int direction = ((EvtScroll&)rEvent).getDirection();
- double percentage = m_rVariable.get();
+ float percentage = m_rVariable.get();
if( direction == EvtScroll::kUp )
{
percentage += SCROLL_STEP;
}
-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();
// 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;
}
}
* 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 Teulière <ipkiss@via.ecp.fr>
/// 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
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;
};
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 );
* 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 Teulière <ipkiss@via.ecp.fr>
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 );
}
}
// 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
}
// 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() );
// 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() );
}
// 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() );
Bezier *Builder::getPoints( const char *pTag ) const
{
- vector<double> xBez, yBez;
+ vector<float> xBez, yBez;
int x, y, n;
while( 1 )
{
* 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 Teulière <ipkiss@via.ecp.fr>
#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"
/// Data from the XML
BuilderData &m_rData;
- /// Script interpreter
- Interpreter m_interpreter;
-
/// Theme under construction
Theme *m_pTheme;
* 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>
/// 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;
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;
* 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 Teulière <ipkiss@via.ecp.fr>
#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"
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 );
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 );
}
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 )
{
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;
}
* 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>
#define INTERPRETER_HPP
#include "../commands/cmd_generic.hpp"
+#include <map>
class Theme;
class VarBool;
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
/// 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
* 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 Teulière <ipkiss@via.ecp.fr>
class AsyncQueue;
class Logger;
class Dialogs;
+class Interpreter;
class OSFactory;
class OSLoop;
class VarManager;
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
* 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 Teulière <ipkiss@via.ecp.fr>
#include "vlcproc.hpp"
#include "theme.hpp"
#include "theme_loader.hpp"
+#include "../parser/interpreter.hpp"
#include "../commands/async_queue.hpp"
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;
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" );
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 );
* 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 Teulière <ipkiss@via.ecp.fr>
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 )
* 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 Teulière <ipkiss@via.ecp.fr>
VarManager::VarManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
- m_tooltip( pIntf ), m_help( pIntf )
+ m_tooltipText( pIntf ), m_helpText( 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;
+ }
+}
+
* 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 Teulière <ipkiss@via.ecp.fr>
#define VAR_MANAGER_HPP
#include "../utils/var_text.hpp"
+#include <map>
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 );
* 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 Teulière <ipkiss@via.ecp.fr>
#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 )
}
-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 );
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 )
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 );
}
}
* 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 Teulière <ipkiss@via.ecp.fr>
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
/// 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, ...)
* 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 Teulière <ipkiss@via.ecp.fr>
#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
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 );
}
-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) +
}
-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 );
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;
}
-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);
* 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>
} 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;
/// 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;
/// 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;
};
* 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 Teulière <ipkiss@via.ecp.fr>
#include "var_bool.hpp"
+const string VarBool::m_type = "bool";
+
+
VarBool::VarBool( intf_thread_t *pIntf ): Variable( pIntf ), m_value( false )
{
}
* 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 Teulière <ipkiss@via.ecp.fr>
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;
};
* 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 Teulière <ipkiss@via.ecp.fr>
#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 );
}
* 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>
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 );
/// 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;
};
* 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 Teulière <ipkiss@via.ecp.fr>
#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 )
{
* 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 Teulière <ipkiss@via.ecp.fr>
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
* 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 Teulière <ipkiss@via.ecp.fr>
#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();
}
* 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 Teulière <ipkiss@via.ecp.fr>
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;
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
* 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 Teulière <ipkiss@via.ecp.fr>
#include "../src/skin_common.hpp"
#include "pointer.hpp"
+#include <string>
/// Base class for variable objects
public:
virtual ~Variable() {}
+ /// Get the variable type
+ virtual const string &getType() const = 0;
+
protected:
Variable( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
};
* 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 Teulière <ipkiss@via.ecp.fr>
#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 )
{
* 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>
#ifndef TIME_HPP
#define TIME_HPP
-
#include "../utils/var_percent.hpp"
#include <string>
-
/// Variable for VLC volume
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;
virtual string getAsStringTime() const;
};
-
#endif
* 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 Teulière <ipkiss@via.ecp.fr>
}
-void Volume::set( double percentage )
+void Volume::set( float percentage )
{
// Avoid looping forever...
if( (int)(get() * AOUT_VOLUME_MAX) !=
* 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 Teulière <ipkiss@via.ecp.fr>
Volume( intf_thread_t *pIntf );
virtual ~Volume() {}
- virtual void set( double percentage );
+ virtual void set( float percentage );
virtual string getAsStringPercent() const;
};