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