]> git.sesse.net Git - vlc/commitdiff
* utils/var_bool.*: VarBool is now an interface for reading bool variables
authorCyril Deguet <asmax@videolan.org>
Sun, 18 Jan 2004 19:54:46 +0000 (19:54 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 18 Jan 2004 19:54:46 +0000 (19:54 +0000)
 (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

14 files changed:
modules/gui/skins2/Modules.am
modules/gui/skins2/commands/cmd_input.cpp
modules/gui/skins2/commands/cmd_input.hpp
modules/gui/skins2/commands/cmd_show_window.hpp
modules/gui/skins2/controls/ctrl_checkbox.cpp
modules/gui/skins2/parser/interpreter.cpp
modules/gui/skins2/src/generic_window.hpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/theme/theme.xml
modules/gui/skins2/utils/var_bool.cpp
modules/gui/skins2/utils/var_bool.hpp
modules/gui/skins2/vars/vlcvars.cpp [deleted file]
modules/gui/skins2/vars/vlcvars.hpp [deleted file]

index 11d2b652e01d84a1f6e2003ba3ee1c6f0a4cf17a..2c10fdb2e1b941543b14c68e9a41ec37115c5f92 100644 (file)
@@ -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 \
index 54a55ce7a84fa563ab6ef24c6182fdb97faba8af..d6b4e944a6bf903b2a29d35a9f0940474f90236d 100644 (file)
@@ -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 Teulière <ipkiss@via.ecp.fr>
 #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;
index d6bd2b6f3cdb1fecb7bf2dcb444a9a43abd5c7a8..911624c7c536acfbc6a294556161d9d2a4a073b7 100644 (file)
@@ -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" )
index 1696340191d6727090588a8db40d79c29c08dfd0..1ea28161d49eece00e47d34d0cbb740d48e3ac2e 100755 (executable)
@@ -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 Teulière <ipkiss@via.ecp.fr>
 #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
index 088bcf7bd3ba04126c51351f1a29689cb0dbf842..d53a4041454976ce566a259be412a9a96b6841fe 100755 (executable)
@@ -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 Teulière <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();
 
index 13abf48a0bccff13dbc49c29386ea669c747fcba..01b5c462d33dfab6babbeda0e484b362b0391da9 100644 (file)
@@ -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 Teulière <ipkiss@via.ecp.fr>
 #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;
         }
     }
index e4c8877df7dc833287dd4ed30d3ae189c25c0a4c..a2013d803bc0286f2921d3e4081bcac6625b7a7d 100644 (file)
@@ -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 Teulière <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 );
index c3745eea49fd9c9f55c166efd31dbd7eab6085d7..565027ef764b2c4894795745c42c5ef1d06020db 100755 (executable)
@@ -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 Teulière <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 );
     }
 }
index 978832e66bea7da32de63f51749aa8c31962da10..ffbcae613dddf2fe10f093cd0380aef6240276b1 100755 (executable)
@@ -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 Teulière <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, ...)
index 48fbc40fbebfcd229ecb481b07249f99714c2c6c..8a79f8ec61d6aea2518d83cd87a56bfcaa127fc6 100644 (file)
       <Text font="default_font" width="70" x="287" y="79" text="$T"/>\r
       <Button x="42" y="42" up="preferences" down="preferences_onclick" over="preferences" action="dialogs.prefs()" tooltiptext="Preferences"/>\r
       <Button x="17" y="64" up="stop" down="stop_onclick" over="stop" action="vlc.stop()" tooltiptext="Stop"/>\r
-      <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"/>\r
-      <CheckBox x="83" y="44" up1="play" up2="pause" down1="play_onclick" down2="pause_onclick" state="vlc.isPlaying" tooltiptext1="Play" tooltiptext2="Pause"/>\r
+      <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"/>\r
+      <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"/>\r
       <Button x="159" y="37" up="rev" down="rev_click" over="rev" action="vlc.slower()" tooltiptext="Slower"/>\r
       <Button x="159" y="89" up="fast" down="fast_click" over="fast" action="vlc.faster()" tooltiptext="Faster"/>\r
       <Button x="196" y="46" up="previous" down="previous_onclick" over="previous" action="playlist.previous()" tooltiptext="Previous Item"/>\r
       <Button x="196" y="79" up="next" down="next_onclick" over="next" action="playlist.next()" tooltiptext="Next Item"/>\r
       <Button x="8" y="5" up="close" down="close_onclick" over="close_mouseover" action="vlc.quit()" tooltiptext="Quit VLC" help="quit"/>\r
       <Image x="29" y="5" image="reduce_disabled"/>\r
-      <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"/>\r
+      <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"/>\r
       <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%"/>\r
     </Group>\r
    </Layout>\r
index 125fde415b3404237e127ec0077bfcb829a9a4c5..1774fff2586fcfb8aca2de9d38bca3bd2b7a85ec 100755 (executable)
@@ -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 Teulière <ipkiss@via.ecp.fr>
 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();
+}
+
+
index 7d02cdd533a31d8e5f47bf55364f517734791faa..430f53cbe1cbd7bc7222d57389e529af68b9cd05 100755 (executable)
@@ -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 Teulière <ipkiss@via.ecp.fr>
 #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
diff --git a/modules/gui/skins2/vars/vlcvars.cpp b/modules/gui/skins2/vars/vlcvars.cpp
deleted file mode 100644 (file)
index 37e428d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************************
- * 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 Teulière <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 );
-    }
-}
diff --git a/modules/gui/skins2/vars/vlcvars.hpp b/modules/gui/skins2/vars/vlcvars.hpp
deleted file mode 100644 (file)
index 5af0a29..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * 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 Teulière <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