<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>
<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>
<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>
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
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
#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,
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 ) );
}
class OSGraphics;
class CtrlGeneric;
class CtrlVideo;
+class VarBoolImpl;
/// Control and its associated layer
/// 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;
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;
};
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 );
{
pLayout->onShow();
}
+
+ // The new layout is active
+ pLayout->getActiveVar().set( true );
}