]> git.sesse.net Git - vlc/commitdiff
* skins2: new LayoutID.isActive boolean variable
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 14 May 2006 22:16:59 +0000 (22:16 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 14 May 2006 22:16:59 +0000 (22:16 +0000)
doc/skins/skins2-howto.xml
modules/gui/skins2/parser/interpreter.cpp
modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/top_window.cpp

index 3b4acd8e4ccbe58ad935f4035ff4452ce0f2868b..37ce142d93bdb7f24ea6e400c9d13f38e6d001aa 100644 (file)
@@ -314,6 +314,11 @@ difficulty to understand how VLC skins work.</para>
 <sect3 id="Layout">
   <title>Layout</title>
   <para>A layout is one aspect of a window, i.e. a set of controls and anchors. A window can have many layouts, but only one will be visible at any time.</para>
+  <sect4 id="layoutid">
+    <title>id</title>
+    <para>Name of the layout (it may be used for actions). Two layouts cannot have the same id.</para>
+    <para>Default value: none</para>
+  </sect4>
   <sect4 id="layoutwidth">
     <title>width</title>
     <para><!--TODO: calculate it in VLC :)-->Width of the layout. this value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls.</para>
@@ -921,7 +926,7 @@ difficulty to understand how VLC skins work.</para>
     <emphasis>WindowID.hide()</emphasis>: Hide the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'.
   </para></listitem>
   <listitem><para>
-    <emphasis>WindowID.setLayout(LayoutID)</emphasis>: Change the layout of the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID', using the <link linkend="Layout">Layout</link> whose <link linkend="attrid">id</link> attribute is 'LayoutID'.
+    <emphasis>WindowID.setLayout(LayoutID)</emphasis>: Change the layout of the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID', using the <link linkend="Layout">Layout</link> whose <link linkend="layoutid">id</link> attribute is 'LayoutID'.
   </para></listitem>
 </itemizedlist>
 
@@ -1023,7 +1028,10 @@ difficulty to understand how VLC skins work.</para>
    <emphasis>dvd.isActive</emphasis>: True when a DVD is currently playing. This variable can be used to display buttons associated to the <link linkend="dvdactions">dvd.* actions</link> only when needed (since VLC 0.8.5).
   </para></listitem>
   <listitem><para>
-    <emphasis>window_name.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "window_name" is visible, false otherwise.
+    <emphasis>WindowID.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is visible, false otherwise.
+  </para></listitem>
+  <listitem><para>
+    <emphasis>LayoutID.isVisible</emphasis>: True when the layout whose <link linkend="layoutid">id</link> is "LayoutID" is the active layout in its window (even if the window is hidden), false otherwise (since VLC 0.8.6).
   </para></listitem>
 </itemizedlist>
 
index 2ba41f6139b22242b5e005c0807af8a4414b6afb..8598cac9fe08227b3b94ac41d7f46ac14c49ef81 100644 (file)
@@ -401,7 +401,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
             TopWindow *pWin = pTheme->getWindowById( windowId );
             if( pWin )
             {
-                // Push the visibility variable on the stack
+                // Push the visibility variable onto the stack
                 varStack.push_back( &pWin->getVisibleVar() );
             }
             else
@@ -410,6 +410,22 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
                 return NULL;
             }
         }
+        else if( token.find( ".isActive" ) != string::npos )
+        {
+            int leftPos = token.find( ".isActive" );
+            string layoutId = token.substr( 0, leftPos );
+            GenericLayout *pLayout = pTheme->getLayoutById( layoutId );
+            if( pLayout )
+            {
+                // Push the isActive variable onto the stack
+                varStack.push_back( &pLayout->getActiveVar() );
+            }
+            else
+            {
+                msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() );
+                return NULL;
+            }
+        }
         else
         {
             // Try to get the variable from the variable manager
index a89348eba08243086e51be6d3a8ad1e6e95a4c31..9884d06109d0918330a5c4501f6f9898be7d106c 100644 (file)
 #include "top_window.hpp"
 #include "os_factory.hpp"
 #include "os_graphics.hpp"
+#include "var_manager.hpp"
 #include "../controls/ctrl_generic.hpp"
 #include "../controls/ctrl_video.hpp"
+#include "../utils/var_bool.hpp"
 
 
 GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
@@ -36,12 +38,16 @@ GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
     SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
     m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
     m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ),
-    m_visible( false )
+    m_visible( false ), m_pVarActive( NULL )
 {
     // Get the OSFactory
     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
     // Create the graphics buffer
     m_pImage = pOsFactory->createOSGraphics( width, height );
+
+    // Create the "active layout" variable and register it in the manager
+    m_pVarActive = new VarBoolImpl( pIntf );
+    VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarActive ) );
 }
 
 
index 470f6710e03b115fb7302139cc7cb89dab627a51..adf8a17d6b0ed8c4134c6676ed4bf50e4b8d2854 100644 (file)
@@ -36,6 +36,7 @@ class Anchor;
 class OSGraphics;
 class CtrlGeneric;
 class CtrlVideo;
+class VarBoolImpl;
 
 
 /// Control and its associated layer
@@ -128,6 +129,10 @@ class GenericLayout: public SkinObject, public Box
         /// Called when the layout is hidden
         virtual void onHide();
 
+        /// Give access to the "active layout" variable
+        // FIXME: we give read/write access
+        VarBoolImpl &getActiveVar() { return *m_pVarActive; }
+
     private:
         /// Parent window of the layout
         TopWindow *m_pWindow;
@@ -145,6 +150,13 @@ class GenericLayout: public SkinObject, public Box
         list<Anchor*> m_anchorList;
         /// Flag to know if the layout is visible
         bool m_visible;
+        /// Variable for the "active state" of the layout
+        /**
+         * Note: the layout is not an observer on this variable, because it
+         * cannot be changed externally (i.e. without an explicit change of
+         * layout). This way, we avoid using a setActiveLayoutInner method.
+         */
+        mutable VarBoolImpl *m_pVarActive;
 };
 
 
index 812d9daea0680a3cfdf4d4bf5f63aa2418fa53e9..92c8597474766b842b7e8a570d362306d283a065 100644 (file)
@@ -323,9 +323,14 @@ void TopWindow::refresh( int left, int top, int width, int height )
 void TopWindow::setActiveLayout( GenericLayout *pLayout )
 {
     bool isVisible = getVisibleVar().get();
-    if( m_pActiveLayout && isVisible )
+    if( m_pActiveLayout )
     {
-        m_pActiveLayout->onHide();
+        if( isVisible )
+        {
+            m_pActiveLayout->onHide();
+        }
+        // The current layout becomes inactive
+        m_pActiveLayout->getActiveVar().set( false );
     }
 
     pLayout->setWindow( this );
@@ -338,6 +343,9 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout )
     {
         pLayout->onShow();
     }
+
+    // The new layout is active
+    pLayout->getActiveVar().set( true );
 }