Commit 75feba09 authored by Cyril Deguet's avatar Cyril Deguet

* utils/var_bool.*: VarBool is now an interface for reading bool variables

 (not writing); use VarBoolImpl instead to instanciate read/write variables.
 Bool variables can now be combined with VarNotBool and VarBoolAndBool
 (TODO: VarBoolOrBool)
* commands/cmd_show_window.hpp: the commands now call directly
  GenericWindow::show/hide, because the visibility variable of a
  window is a VarBool (so, read-only)
* commands/cmd_input.hpp: added Play and Pause commands
* parser/interpreter.cpp: beginning of support of boolean expressions,
 like "vlc.isSeekable and not vlc.isStopped" (operator precedence is
 not really well handled yet)
* src/vlcproc.*: new variables "vlc.isSeekable", "vlc.isStopped" and
 "vlc.isPaused"
* controls/ctrl_checkbox.cpp: the "state" variable of a checkbox is
  now a passive VarBool, so actions must be explicitely set with
  'action1="..." action2="..."' in the xml file
* removed src/vlcvars.* => "vlc.isMute" doesn't work any more
 (anyway it didn't work well...)
* theme/theme.xml: updated with the new VarBool behaviour
parent c89bab7c
......@@ -144,8 +144,6 @@ SOURCES_skins2 = \
vars/time.hpp \
vars/volume.cpp \
vars/volume.hpp \
vars/vlcvars.cpp \
vars/vlcvars.hpp \
\
win32/win32_dragdrop.cpp \
win32/win32_dragdrop.hpp \
......
......@@ -2,7 +2,7 @@
* cmd_input.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: cmd_input.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: cmd_input.cpp,v 1.2 2004/01/18 19:54:45 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,6 +25,30 @@
#include "cmd_input.hpp"
void CmdPlay::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist == NULL )
{
return;
}
playlist_Play( pPlaylist );
}
void CmdPause::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist == NULL )
{
return;
}
playlist_Pause( pPlaylist );
}
void CmdStop::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
......
......@@ -2,7 +2,7 @@
* cmd_input.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: cmd_input.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: cmd_input.hpp,v 1.2 2004/01/18 19:54:45 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -28,6 +28,8 @@
#include "cmd_generic.hpp"
/// Commands to control the input
DEFINE_COMMAND( Play, "play" )
DEFINE_COMMAND( Pause, "pause" )
DEFINE_COMMAND( Stop, "stop" )
DEFINE_COMMAND( Slower, "slower" )
DEFINE_COMMAND( Faster, "faster" )
......
......@@ -2,7 +2,7 @@
* cmd_show_window.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: cmd_show_window.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: cmd_show_window.hpp,v 1.2 2004/01/18 19:54:45 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -26,33 +26,47 @@
#define CMD_SHOW_WINDOW_HPP
#include "cmd_generic.hpp"
#include "../utils/var_bool.hpp"
#include "../src/generic_window.hpp"
template<bool newValue> class CmdShowHideWindow;
/// Command to show a window
class CmdShowWindow: public CmdGeneric
{
public:
CmdShowWindow( intf_thread_t *pIntf, GenericWindow &rWin ):
CmdGeneric( pIntf ), m_rWin( rWin ) {}
virtual ~CmdShowWindow() {}
typedef CmdShowHideWindow<true> CmdShowWindow;
typedef CmdShowHideWindow<false> CmdHideWindow;
/// This method does the real job of the command
virtual void execute() { m_rWin.show(); }
/// Return the type of the command
virtual string getType() const { return "show window"; }
/// "Show/Hide window" command
template<bool newValue>
class CmdShowHideWindow: public CmdGeneric
private:
/// Reference to the window
GenericWindow &m_rWin;
};
/// Command to hide a window
class CmdHideWindow: public CmdGeneric
{
public:
CmdShowHideWindow( intf_thread_t *pIntf, VarBool &rVariable ):
CmdGeneric( pIntf ), m_rVariable( rVariable ) {}
virtual ~CmdShowHideWindow() {}
CmdHideWindow( intf_thread_t *pIntf, GenericWindow &rWin ):
CmdGeneric( pIntf ), m_rWin( rWin ) {}
virtual ~CmdHideWindow() {}
/// This method does the real job of the command
virtual void execute() { m_rVariable.set( newValue ); }
virtual void execute() { m_rWin.hide(); }
/// Return the type of the command
virtual string getType() const { return "show/hide window"; }
virtual string getType() const { return "hide window"; }
private:
/// Reference to the observed variable
VarBool &m_rVariable;
/// Reference to the window
GenericWindow &m_rWin;
};
#endif
......@@ -2,7 +2,7 @@
* ctrl_checkbox.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_checkbox.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: ctrl_checkbox.cpp,v 1.2 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -184,7 +184,6 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl )
pThis->releaseMouse();
// Invert the state variable
pThis->m_rVariable.set( !pThis->m_rVariable.get() );
pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout();
......
......@@ -2,7 +2,7 @@
* interpreter.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: interpreter.cpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
* $Id: interpreter.cpp,v 1.4 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -30,13 +30,10 @@
#include "../commands/cmd_quit.hpp"
#include "../commands/cmd_input.hpp"
#include "../commands/cmd_fullscreen.hpp"
#include "../commands/cmd_show_window.hpp"
#include "../src/theme.hpp"
#include "../src/var_manager.hpp"
#include "../src/vlcproc.hpp"
#include "../vars/playlist.hpp"
#include "../vars/vlcvars.hpp"
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
......@@ -63,6 +60,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
REGISTER_CMD( "playlist.previous()", CmdPlaylistPrevious )
REGISTER_CMD( "playlist.sort()", CmdPlaylistSort )
REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen )
REGISTER_CMD( "vlc.play()", CmdPlay )
REGISTER_CMD( "vlc.pause()", CmdPause )
REGISTER_CMD( "vlc.quit()", CmdQuit )
REGISTER_CMD( "vlc.faster()", CmdFaster )
REGISTER_CMD( "vlc.slower()", CmdSlower )
......@@ -115,6 +114,34 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
rightPos - (windowId.size() + 11) );
pCommand = new CmdLayout( getIntf(), windowId, layoutId );
}
else if( rAction.find( ".show()" ) != string::npos )
{
int leftPos = rAction.find( ".show()" );
string windowId = rAction.substr( 0, leftPos );
GenericWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
pCommand = new CmdShowWindow( getIntf(), *pWin );
}
else
{
msg_Err( getIntf(), "Unknown window (%s)", windowId.c_str() );
}
}
else if( rAction.find( ".hide()" ) != string::npos )
{
int leftPos = rAction.find( ".hide()" );
string windowId = rAction.substr( 0, leftPos );
GenericWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
pCommand = new CmdHideWindow( getIntf(), *pWin );
}
else
{
msg_Err( getIntf(), "Unknown window (%s)", windowId.c_str() );
}
}
if( pCommand )
{
......@@ -136,11 +163,51 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
{
return pVar;
}
else if( rName.find( " and " ) != string::npos )
{
int leftPos = rName.find( " and " );
string name1 = rName.substr( 0, leftPos );
int rightPos = leftPos + 5; // 5 is the size of " and "
string name2 = rName.substr( rightPos, rName.size() - rightPos );
// Retrive the two boolean variables
VarBool *pVar1 = getVarBool( name1, pTheme );
VarBool *pVar2 = getVarBool( name2, pTheme );
// Create a composite boolean variable
if( pVar1 && pVar2 )
{
VarBool *pNewVar = new VarBoolAndBool( getIntf(), *pVar1, *pVar2 );
// Register this variable in the manager
pVarManager->registerVar( VariablePtr( pNewVar ), rName );
return pNewVar;
}
else
{
return NULL;
}
}
else if( rName.find( "not " ) != string::npos )
{
int rightPos = rName.find( "not " ) + 4;
string name = rName.substr( rightPos, rName.size() - rightPos );
// Retrive the boolean variable
VarBool *pVar = getVarBool( name, pTheme );
// Create a composite boolean variable
if( pVar )
{
VarBool *pNewVar = new VarNotBool( getIntf(), *pVar );
// Register this variable in the manager
pVarManager->registerVar( VariablePtr( pNewVar ), rName );
return pNewVar;
}
else
{
return NULL;
}
}
else if( rName.find( ".isVisible" ) != string::npos )
{
int leftPos = rName.find( ".isVisible" );
string windowId = rName.substr( 0, leftPos );
// XXX Need to check the IDs (isalpha())?
GenericWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
......@@ -148,7 +215,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
}
else
{
msg_Warn( getIntf(), "Unknown window (%s)", windowId.c_str() );
msg_Err( getIntf(), "Unknown window (%s)", windowId.c_str() );
return NULL;
}
}
......
......@@ -2,7 +2,7 @@
* generic_window.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic_window.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id: generic_window.hpp,v 1.2 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -146,7 +146,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
/// Tooltip
Tooltip *m_pTooltip;
/// Variable for the visibility of the window
VarBool m_varVisible;
VarBoolImpl m_varVisible;
/// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarBool> &rVariable );
......
......@@ -2,7 +2,7 @@
* vlcproc.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
* $Id: vlcproc.cpp,v 1.4 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -31,6 +31,7 @@
#include "../commands/async_queue.hpp"
#include "../commands/cmd_notify_playlist.hpp"
#include "../commands/cmd_quit.hpp"
#include "../utils/var_bool.hpp"
VlcProc *VlcProc::instance( intf_thread_t *pIntf )
......@@ -63,19 +64,20 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
// 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 );
#define REGISTER_VAR( var, type, name ) \
var = VariablePtr( new type( getIntf() ) ); \
pVarManager->registerVar( var, name );
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" )
REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" ) // XXX broken
REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
// Called when the playlist changes
var_AddCallback( pIntf->p_sys-> p_playlist, "intf-change",
......@@ -115,8 +117,10 @@ void VlcProc::manage()
// 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();
VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
// Refresh sound volume
audio_volume_t volume;
......@@ -158,20 +162,17 @@ void VlcProc::manage()
// Get the status of the playlist
playlist_status_t status = getIntf()->p_sys->p_playlist->i_status;
pVarPlaying->set( status == PLAYLIST_RUNNING, false );
if( pInput->stream.b_seekable )
{
pVarSeekablePlaying->set( status != PLAYLIST_STOPPED );
}
else
{
pVarSeekablePlaying->set( false );
}
pVarPlaying->set( status == PLAYLIST_RUNNING );
pVarStopped->set( status == PLAYLIST_STOPPED );
pVarPaused->set( status == PLAYLIST_PAUSED );
pVarSeekable->set( pInput->stream.b_seekable );
}
else
{
pVarPlaying->set( false, false );
pVarSeekablePlaying->set( false );
pVarPlaying->set( false );
pVarPaused->set( false );
pVarStopped->set( true );
pVarSeekable->set( false );
pTime->set( 0, false );
}
}
......
......@@ -2,7 +2,7 @@
* vlcproc.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.hpp,v 1.3 2004/01/11 17:12:17 asmax Exp $
* $Id: vlcproc.hpp,v 1.4 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -28,9 +28,9 @@
#include "../vars/playlist.hpp"
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
#include "../vars/vlcvars.hpp"
class OSTimer;
class VarBool;
/// Singleton object handling VLC internal state and playlist
......@@ -59,9 +59,14 @@ class VlcProc: public SkinObject
/// Getter for the playing variable
VarBool &getIsPlayingVar() { return *((VarBool*)(m_cVarPlaying.get())); }
/// Getter for the seekable/playing variable
VarBool &getIsSeekablePlayingVar()
{ return *((VarBool*)(m_cVarSeekablePlaying.get())); }
/// Getter for the stopped variable
VarBool &getIsStoppedVar() { return *((VarBool*)(m_cVarStopped.get())); }
/// Getter for the paused variable
VarBool &getIsPausedVar() { return *((VarBool*)(m_cVarPaused.get())); }
/// Getter for the seekable variable
VarBool &getIsSeekableVar() { return *((VarBool*)(m_cVarSeekable.get())); }
protected:
// Protected because it is a singleton
......@@ -81,7 +86,9 @@ class VlcProc: public SkinObject
VariablePtr m_cVarMute;
/// Variables related to the input
VariablePtr m_cVarPlaying;
VariablePtr m_cVarSeekablePlaying;
VariablePtr m_cVarStopped;
VariablePtr m_cVarPaused;
VariablePtr m_cVarSeekable;
/// Poll VLC internals to update the status (volume, current time in
/// the stream, current filename, play/pause/stop status, ...)
......
......@@ -92,15 +92,15 @@
<Text font="default_font" width="70" x="287" y="79" text="$T"/>
<Button x="42" y="42" up="preferences" down="preferences_onclick" over="preferences" action="dialogs.prefs()" tooltiptext="Preferences"/>
<Button x="17" y="64" up="stop" down="stop_onclick" over="stop" action="vlc.stop()" tooltiptext="Stop"/>
<CheckBox x="42" y="87" up1="playlist_button" down1="playlist_button_onclick" up2="playlist_button2" down2="playlist_button_onclick2" state="playlist_window.isVisible" tooltiptext1="Show Playlist" tooltiptext2="Hide Playlist"/>
<CheckBox x="83" y="44" up1="play" up2="pause" down1="play_onclick" down2="pause_onclick" state="vlc.isPlaying" tooltiptext1="Play" tooltiptext2="Pause"/>
<CheckBox x="42" y="87" up1="playlist_button" down1="playlist_button_onclick" up2="playlist_button2" down2="playlist_button_onclick2" state="playlist_window.isVisible" action1="playlist_window.show()" action2="playlist_window.hide()" tooltiptext1="Show Playlist" tooltiptext2="Hide Playlist"/>
<CheckBox x="83" y="44" up1="play" up2="pause" down1="play_onclick" down2="pause_onclick" state="vlc.isPlaying" action1="vlc.play()" action2="vlc.pause()" tooltiptext1="Play" tooltiptext2="Pause"/>
<Button x="159" y="37" up="rev" down="rev_click" over="rev" action="vlc.slower()" tooltiptext="Slower"/>
<Button x="159" y="89" up="fast" down="fast_click" over="fast" action="vlc.faster()" tooltiptext="Faster"/>
<Button x="196" y="46" up="previous" down="previous_onclick" over="previous" action="playlist.previous()" tooltiptext="Previous Item"/>
<Button x="196" y="79" up="next" down="next_onclick" over="next" action="playlist.next()" tooltiptext="Next Item"/>
<Button x="8" y="5" up="close" down="close_onclick" over="close_mouseover" action="vlc.quit()" tooltiptext="Quit VLC" help="quit"/>
<Image x="29" y="5" image="reduce_disabled"/>
<Slider id="time_slider" x="24" y="130" up="slider" down="slider_onclick" points="(0,0),(366,0)" value="time" visible="vlc.isSeekablePlaying" tooltiptext="Time: $T"/>
<Slider id="time_slider" x="24" y="130" up="slider" down="slider_onclick" points="(0,0),(366,0)" value="time" visible="vlc.isSeekable and not vlc.isStopped" tooltiptext="Time: $T"/>
<Slider id="volume_slider" x="391" y="53" up="slider_volume" down="slider_volume_onclick" points="(0,47),(0,0)" value="volume" tooltiptext="Volume: $V%"/>
</Group>
</Layout>
......
......@@ -2,7 +2,7 @@
* var_bool.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_bool.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: var_bool.cpp,v 1.3 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -28,12 +28,13 @@
const string VarBool::m_type = "bool";
VarBool::VarBool( intf_thread_t *pIntf ): Variable( pIntf ), m_value( false )
VarBoolImpl::VarBoolImpl( intf_thread_t *pIntf ):
VarBool( pIntf ), m_value( false )
{
}
void VarBool::set( bool value )
void VarBoolImpl::set( bool value )
{
if( value != m_value )
{
......@@ -43,3 +44,45 @@ void VarBool::set( bool value )
}
}
VarBoolAndBool::VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1,
VarBool &rVar2 ):
VarBool( pIntf ), m_rVar1( rVar1 ), m_rVar2( rVar2 )
{
m_rVar1.addObserver( this );
m_rVar2.addObserver( this );
}
VarBoolAndBool::~VarBoolAndBool()
{
m_rVar1.delObserver( this );
m_rVar2.delObserver( this );
}
void VarBoolAndBool::onUpdate( Subject<VarBool> &rVariable )
{
notify();
}
VarNotBool::VarNotBool( intf_thread_t *pIntf, VarBool &rVar ):
VarBool( pIntf ), m_rVar( rVar )
{
m_rVar.addObserver( this );
}
VarNotBool::~VarNotBool()
{
m_rVar.delObserver( this );
}
void VarNotBool::onUpdate( Subject<VarBool> &rVariable )
{
notify();
}
......@@ -2,7 +2,7 @@
* var_bool.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: var_bool.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: var_bool.hpp,v 1.3 2004/01/18 19:54:46 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -29,25 +29,81 @@
#include "observer.hpp"
/// Percentage variable
/// Interface for read-only boolean variable
class VarBool: public Variable, public Subject<VarBool>
{
public:
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; }
/// Get the boolean value
virtual bool get() const = 0;
protected:
VarBool( intf_thread_t *pIntf ): Variable( pIntf ) {}
virtual ~VarBool() {}
private:
/// Variable type
static const string m_type;
};
/// Boolean variable implementation (read/write)
class VarBoolImpl: public VarBool
{
public:
VarBoolImpl( intf_thread_t *pIntf );
virtual ~VarBoolImpl() {}
// Get the boolean value
virtual bool get() const { return m_value; }
/// Set the internal value
virtual void set( bool value );
private:
/// Boolean value
bool m_value;
};
/// Conjunction of two boolean variables (AND)
class VarBoolAndBool: public VarBool, public Observer<VarBool>
{
public:
VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
virtual ~VarBoolAndBool();
// Get the boolean value
virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
// Called when one of the observed variables is changed
void onUpdate( Subject<VarBool> &rVariable );
private:
/// Boolean variables
VarBool &m_rVar1, &m_rVar2;
};
/// Negation of a boolean variable (NOT)
class VarNotBool: public VarBool, public Observer<VarBool>
{
public:
VarNotBool( intf_thread_t *pIntf, VarBool &rVar );
virtual ~VarNotBool();
// Get the boolean value
virtual bool get() const { return !m_rVar.get(); }
// Called when the observed variable is changed
void onUpdate( Subject<VarBool> &rVariable );
private:
/// Boolean variable
VarBool &m_rVar;
};
#endif
/*****************************************************************************
* vlcvars.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcvars.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "vlcvars.hpp"
#include <vlc/aout.h>
void VlcIsMute::set( bool value )
{
VarBool::set( value );
aout_VolumeMute( getIntf(), NULL );
}
void VlcIsPlaying::set( bool value, bool updateVLC )
{
VarBool::set( value );
if( !updateVLC )
{
return;
}
if( value )
{
//XXX use a command
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist == NULL )
{
return;
}
playlist_Play( pPlaylist );
}
else
{
//XXX use a command
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist == NULL )
{
return;
}
playlist_Pause( pPlaylist );
}
}
/*****************************************************************************
* vlcvars.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcvars.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef VLCVARS_HPP
#define VLCVARS_HPP
#include "../utils/var_bool.hpp"
class VlcIsMute: public VarBool
{
public:
VlcIsMute( intf_thread_t *pIntf ): VarBool( pIntf ) {}
virtual ~VlcIsMute() {}
virtual void set( bool value );
};
class VlcIsPlaying: public VarBool
{
public:
VlcIsPlaying( intf_thread_t *pIntf ): VarBool( pIntf ) {}
virtual ~VlcIsPlaying() {}
virtual void set( bool value, bool updateVLC );
virtual void set( bool value ) { set( value, true ); }
};
class VlcIsSeekablePlaying: public VarBool
{
public:
VlcIsSeekablePlaying( intf_thread_t *pIntf ): VarBool( pIntf ) {}
virtual ~VlcIsSeekablePlaying() {}
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment