Commit 28bd3a4a authored by Olivier Teulière's avatar Olivier Teulière

* skins2: new LayoutID.isActive boolean variable

parent ccf834a5
...@@ -314,6 +314,11 @@ difficulty to understand how VLC skins work.</para> ...@@ -314,6 +314,11 @@ difficulty to understand how VLC skins work.</para>
<sect3 id="Layout"> <sect3 id="Layout">
<title>Layout</title> <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> <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"> <sect4 id="layoutwidth">
<title>width</title> <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> <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> ...@@ -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'. <emphasis>WindowID.hide()</emphasis>: Hide the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'.
</para></listitem> </para></listitem>
<listitem><para> <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> </para></listitem>
</itemizedlist> </itemizedlist>
...@@ -1023,7 +1028,10 @@ difficulty to understand how VLC skins work.</para> ...@@ -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). <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> </para></listitem>
<listitem><para> <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> </para></listitem>
</itemizedlist> </itemizedlist>
......
...@@ -401,7 +401,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme ) ...@@ -401,7 +401,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
TopWindow *pWin = pTheme->getWindowById( windowId ); TopWindow *pWin = pTheme->getWindowById( windowId );
if( pWin ) if( pWin )
{ {
// Push the visibility variable on the stack // Push the visibility variable onto the stack
varStack.push_back( &pWin->getVisibleVar() ); varStack.push_back( &pWin->getVisibleVar() );
} }
else else
...@@ -410,6 +410,22 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme ) ...@@ -410,6 +410,22 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
return NULL; 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 else
{ {
// Try to get the variable from the variable manager // Try to get the variable from the variable manager
......
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
#include "top_window.hpp" #include "top_window.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "os_graphics.hpp" #include "os_graphics.hpp"
#include "var_manager.hpp"
#include "../controls/ctrl_generic.hpp" #include "../controls/ctrl_generic.hpp"
#include "../controls/ctrl_video.hpp" #include "../controls/ctrl_video.hpp"
#include "../utils/var_bool.hpp"
GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height, GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
...@@ -36,12 +38,16 @@ 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 ), SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ), m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ), m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ),
m_visible( false ) m_visible( false ), m_pVarActive( NULL )
{ {
// Get the OSFactory // Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() ); OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Create the graphics buffer // Create the graphics buffer
m_pImage = pOsFactory->createOSGraphics( width, height ); 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 ) );
} }
......
...@@ -36,6 +36,7 @@ class Anchor; ...@@ -36,6 +36,7 @@ class Anchor;
class OSGraphics; class OSGraphics;
class CtrlGeneric; class CtrlGeneric;
class CtrlVideo; class CtrlVideo;
class VarBoolImpl;
/// Control and its associated layer /// Control and its associated layer
...@@ -128,6 +129,10 @@ class GenericLayout: public SkinObject, public Box ...@@ -128,6 +129,10 @@ class GenericLayout: public SkinObject, public Box
/// Called when the layout is hidden /// Called when the layout is hidden
virtual void onHide(); virtual void onHide();
/// Give access to the "active layout" variable
// FIXME: we give read/write access
VarBoolImpl &getActiveVar() { return *m_pVarActive; }
private: private:
/// Parent window of the layout /// Parent window of the layout
TopWindow *m_pWindow; TopWindow *m_pWindow;
...@@ -145,6 +150,13 @@ class GenericLayout: public SkinObject, public Box ...@@ -145,6 +150,13 @@ class GenericLayout: public SkinObject, public Box
list<Anchor*> m_anchorList; list<Anchor*> m_anchorList;
/// Flag to know if the layout is visible /// Flag to know if the layout is visible
bool m_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;
}; };
......
...@@ -323,9 +323,14 @@ void TopWindow::refresh( int left, int top, int width, int height ) ...@@ -323,9 +323,14 @@ void TopWindow::refresh( int left, int top, int width, int height )
void TopWindow::setActiveLayout( GenericLayout *pLayout ) void TopWindow::setActiveLayout( GenericLayout *pLayout )
{ {
bool isVisible = getVisibleVar().get(); 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 ); pLayout->setWindow( this );
...@@ -338,6 +343,9 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout ) ...@@ -338,6 +343,9 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout )
{ {
pLayout->onShow(); pLayout->onShow();
} }
// The new layout is active
pLayout->getActiveVar().set( true );
} }
......
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