Changeset 28bd3a4a6af005742657f8a0ea7fa92a4fef0618

Show
Ignore:
Timestamp:
05/15/06 00:16:59 (2 years ago)
Author:
Olivier Teulière <ipkiss@videolan.org>
git-committer:
Olivier Teulière <ipkiss@videolan.org> 1147645019 +0000
git-parent:

[ccf834a51a5ba339dff515333118635aaa3b9047]

git-author:
Olivier Teulière <ipkiss@videolan.org> 1147645019 +0000
Message:
  • skins2: new LayoutID.isActive boolean variable
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/skins/skins2-howto.xml

    rdea9733 r28bd3a4  
    315315  <title>Layout</title> 
    316316  <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> 
     317  <sect4 id="layoutid"> 
     318    <title>id</title> 
     319    <para>Name of the layout (it may be used for actions). Two layouts cannot have the same id.</para> 
     320    <para>Default value: none</para> 
     321  </sect4> 
    317322  <sect4 id="layoutwidth"> 
    318323    <title>width</title> 
     
    922927  </para></listitem> 
    923928  <listitem><para> 
    924     <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'. 
     929    <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'. 
    925930  </para></listitem> 
    926931</itemizedlist> 
     
    10241029  </para></listitem> 
    10251030  <listitem><para> 
    1026     <emphasis>window_name.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "window_name" is visible, false otherwise. 
     1031    <emphasis>WindowID.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is visible, false otherwise. 
     1032  </para></listitem> 
     1033  <listitem><para> 
     1034    <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). 
    10271035  </para></listitem> 
    10281036</itemizedlist> 
  • modules/gui/skins2/parser/interpreter.cpp

    red0b72e r28bd3a4  
    402402            if( pWin ) 
    403403            { 
    404                 // Push the visibility variable on the stack 
     404                // Push the visibility variable onto the stack 
    405405                varStack.push_back( &pWin->getVisibleVar() ); 
    406406            } 
     
    408408            { 
    409409                msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 
     410                return NULL; 
     411            } 
     412        } 
     413        else if( token.find( ".isActive" ) != string::npos ) 
     414        { 
     415            int leftPos = token.find( ".isActive" ); 
     416            string layoutId = token.substr( 0, leftPos ); 
     417            GenericLayout *pLayout = pTheme->getLayoutById( layoutId ); 
     418            if( pLayout ) 
     419            { 
     420                // Push the isActive variable onto the stack 
     421                varStack.push_back( &pLayout->getActiveVar() ); 
     422            } 
     423            else 
     424            { 
     425                msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() ); 
    410426                return NULL; 
    411427            } 
  • modules/gui/skins2/src/generic_layout.cpp

    rc90405b r28bd3a4  
    2727#include "os_factory.hpp" 
    2828#include "os_graphics.hpp" 
     29#include "var_manager.hpp" 
    2930#include "../controls/ctrl_generic.hpp" 
    3031#include "../controls/ctrl_video.hpp" 
     32#include "../utils/var_bool.hpp" 
    3133 
    3234 
     
    3739    m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ), 
    3840    m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ), 
    39     m_visible( false ) 
     41    m_visible( false ), m_pVarActive( NULL ) 
    4042{ 
    4143    // Get the OSFactory 
     
    4345    // Create the graphics buffer 
    4446    m_pImage = pOsFactory->createOSGraphics( width, height ); 
     47 
     48    // Create the "active layout" variable and register it in the manager 
     49    m_pVarActive = new VarBoolImpl( pIntf ); 
     50    VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarActive ) ); 
    4551} 
    4652 
  • modules/gui/skins2/src/generic_layout.hpp

    rf6482bd r28bd3a4  
    3737class CtrlGeneric; 
    3838class CtrlVideo; 
     39class VarBoolImpl; 
    3940 
    4041 
     
    129130        virtual void onHide(); 
    130131 
     132        /// Give access to the "active layout" variable 
     133        // FIXME: we give read/write access 
     134        VarBoolImpl &getActiveVar() { return *m_pVarActive; } 
     135 
    131136    private: 
    132137        /// Parent window of the layout 
     
    146151        /// Flag to know if the layout is visible 
    147152        bool m_visible; 
     153        /// Variable for the "active state" of the layout 
     154        /** 
     155         * Note: the layout is not an observer on this variable, because it 
     156         * cannot be changed externally (i.e. without an explicit change of 
     157         * layout). This way, we avoid using a setActiveLayoutInner method. 
     158         */ 
     159        mutable VarBoolImpl *m_pVarActive; 
    148160}; 
    149161 
  • modules/gui/skins2/src/top_window.cpp

    ra72b117 r28bd3a4  
    324324{ 
    325325    bool isVisible = getVisibleVar().get(); 
    326     if( m_pActiveLayout && isVisible ) 
    327     { 
    328         m_pActiveLayout->onHide(); 
     326    if( m_pActiveLayout ) 
     327    { 
     328        if( isVisible ) 
     329        { 
     330            m_pActiveLayout->onHide(); 
     331        } 
     332        // The current layout becomes inactive 
     333        m_pActiveLayout->getActiveVar().set( false ); 
    329334    } 
    330335 
     
    339344        pLayout->onShow(); 
    340345    } 
     346 
     347    // The new layout is active 
     348    pLayout->getActiveVar().set( true ); 
    341349} 
    342350