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>
<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>
......
......@@ -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
......
......@@ -26,8 +26,10 @@
#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 ) );
}
......
......@@ -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;
};
......
......@@ -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 );
}
......
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