Changeset 09539802dc311c3fc03d551f14627a25f8066359

Show
Ignore:
Timestamp:
28/01/07 21:37:21 (2 years ago)
Author:
Olivier Teulière <ipkiss@videolan.org>
git-committer:
Olivier Teulière <ipkiss@videolan.org> 1170016641 +0000
git-parent:

[618352d27ca9ddf5a86f667b7654e2b87bf36576]

git-author:
Olivier Teulière <ipkiss@videolan.org> 1170016641 +0000
Message:
  • skins2:
    • new WindowID.maximize() and WindowID.unmaximize() actions
    • new WindowID.isMaximized boolean variable
    • doc updated
Files:

Legend:

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

    r8086b07 r0953980  
    997997  </para></listitem> 
    998998  <listitem><para> 
     999    <emphasis>WindowID.maximize()</emphasis>: Maximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0. 
     1000  </para></listitem> 
     1001  <listitem><para> 
     1002    <emphasis>WindowID.unmaximize()</emphasis>: Unmaximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0. 
     1003  </para></listitem> 
     1004  <listitem><para> 
    9991005    <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'. 
    10001006  </para></listitem> 
     
    10971103  <listitem><para> 
    10981104   <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). 
     1105  </para></listitem> 
     1106  <listitem><para> 
     1107    <emphasis>WindowID.isMaximized</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is maximized, false otherwise. 
    10991108  </para></listitem> 
    11001109  <listitem><para> 
  • modules/gui/skins2/commands/cmd_minimize.cpp

    r1cf7350 r0953980  
    66 * 
    77 * Authors: Mohammed Adnène Trojette     <adn@via.ecp.fr> 
     8 *          Olivier Teulière <ipkiss@via.ecp.fr> 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    2324 
    2425#include "cmd_minimize.hpp" 
     26#include "../src/window_manager.hpp" 
    2527#include "../src/os_factory.hpp" 
    2628 
     
    3941    OSFactory *pOsFactory = OSFactory::instance( getIntf() ); 
    4042    pOsFactory->restore(); 
     43} 
     44 
     45 
     46CmdMaximize::CmdMaximize( intf_thread_t *pIntf, 
     47                          WindowManager &rWindowManager, 
     48                          TopWindow &rWindow ): 
     49    CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ), 
     50    m_rWindow( rWindow ) 
     51{ 
     52} 
     53 
     54 
     55void CmdMaximize::execute() 
     56{ 
     57    // Simply delegate the job to the WindowManager 
     58    m_rWindowManager.maximize( m_rWindow ); 
     59} 
     60 
     61 
     62CmdUnmaximize::CmdUnmaximize( intf_thread_t *pIntf, 
     63                              WindowManager &rWindowManager, 
     64                              TopWindow &rWindow ): 
     65    CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ), 
     66    m_rWindow( rWindow ) 
     67{ 
     68} 
     69 
     70 
     71void CmdUnmaximize::execute() 
     72{ 
     73    // Simply delegate the job to the WindowManager 
     74    m_rWindowManager.unmaximize( m_rWindow ); 
    4175} 
    4276 
  • modules/gui/skins2/commands/cmd_minimize.hpp

    r1cf7350 r0953980  
    2727#include "cmd_generic.hpp" 
    2828 
     29class WindowManager; 
     30class TopWindow; 
     31 
    2932 
    3033DEFINE_COMMAND(Minimize, "minimize" ) 
    3134DEFINE_COMMAND(Restore, "restore" ) 
     35 
     36/// Command to maximize a window 
     37class CmdMaximize: public CmdGeneric 
     38{ 
     39    public: 
     40        /// Maximize the given layout 
     41        CmdMaximize( intf_thread_t *pIntf, WindowManager &rWindowManager, 
     42                     TopWindow &rWindow ); 
     43        virtual ~CmdMaximize() {} 
     44 
     45        /// This method does the real job of the command 
     46        virtual void execute(); 
     47 
     48        /// Return the type of the command 
     49        virtual string getType() const { return "maximize"; } 
     50 
     51    private: 
     52        WindowManager &m_rWindowManager; 
     53        TopWindow &m_rWindow; 
     54}; 
     55 
     56 
     57/// Command to unmaximize a window 
     58class CmdUnmaximize: public CmdGeneric 
     59{ 
     60    public: 
     61        /// Unmaximize the given layout 
     62        CmdUnmaximize( intf_thread_t *pIntf, WindowManager &rWindowManager, 
     63                     TopWindow &rWindow ); 
     64        virtual ~CmdUnmaximize() {} 
     65 
     66        /// This method does the real job of the command 
     67        virtual void execute(); 
     68 
     69        /// Return the type of the command 
     70        virtual string getType() const { return "unmaximize"; } 
     71 
     72    private: 
     73        WindowManager &m_rWindowManager; 
     74        TopWindow &m_rWindow; 
     75}; 
     76 
     77 
    3278DEFINE_COMMAND(AddInTray, "add in tray" ) 
    3379DEFINE_COMMAND(RemoveFromTray, "remove from tray" ) 
  • modules/gui/skins2/parser/interpreter.cpp

    r95ff93b r0953980  
    226226        } 
    227227    } 
     228    else if( rAction.find( ".maximize()" ) != string::npos ) 
     229    { 
     230        int leftPos = rAction.find( ".maximize()" ); 
     231        string windowId = rAction.substr( 0, leftPos ); 
     232 
     233        TopWindow *pWin = pTheme->getWindowById( windowId ); 
     234        if( !pWin ) 
     235        { 
     236            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 
     237        } 
     238        else 
     239        { 
     240            pCommand = new CmdMaximize( getIntf(), 
     241                                        pTheme->getWindowManager(), 
     242                                        *pWin ); 
     243        } 
     244    } 
     245    else if( rAction.find( ".unmaximize()" ) != string::npos ) 
     246    { 
     247        int leftPos = rAction.find( ".unmaximize()" ); 
     248        string windowId = rAction.substr( 0, leftPos ); 
     249 
     250        TopWindow *pWin = pTheme->getWindowById( windowId ); 
     251        if( !pWin ) 
     252        { 
     253            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 
     254        } 
     255        else 
     256        { 
     257            pCommand = new CmdUnmaximize( getIntf(), 
     258                                          pTheme->getWindowManager(), 
     259                                          *pWin ); 
     260        } 
     261    } 
    228262    else if( rAction.find( ".show()" ) != string::npos ) 
    229263    { 
     
    421455                else 
    422456                { 
    423                     msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 
     457                    msg_Err( getIntf(), "unknown window (%s)", 
     458                             windowId.c_str() ); 
     459                    return NULL; 
     460                } 
     461            } 
     462            else if( token.find( ".isMaximized" ) != string::npos ) 
     463            { 
     464                int leftPos = token.find( ".isMaximized" ); 
     465                string windowId = token.substr( 0, leftPos ); 
     466                TopWindow *pWin = pTheme->getWindowById( windowId ); 
     467                if( pWin ) 
     468                { 
     469                    // Push the "maximized" variable onto the stack 
     470                    varStack.push_back( &pWin->getMaximizedVar() ); 
     471                } 
     472                else 
     473                { 
     474                    msg_Err( getIntf(), "unknown window (%s)", 
     475                             windowId.c_str() ); 
    424476                    return NULL; 
    425477                } 
     
    437489                else 
    438490                { 
    439                     msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() ); 
     491                    msg_Err( getIntf(), "unknown layout (%s)", 
     492                             layoutId.c_str() ); 
    440493                    return NULL; 
    441494                } 
  • modules/gui/skins2/src/generic_window.cpp

    re1670ac r0953980  
    130130void GenericWindow::onUpdate( Subject<VarBool> &rVariable, void*arg ) 
    131131{ 
    132     if( m_pVarVisible->get()
     132    if (&rVariable == m_pVarVisible
    133133    { 
    134         innerShow(); 
    135     } 
    136     else 
    137     { 
    138         innerHide(); 
     134        if( m_pVarVisible->get() ) 
     135        { 
     136            innerShow(); 
     137        } 
     138        else 
     139        { 
     140            innerHide(); 
     141        } 
    139142    } 
    140143} 
  • modules/gui/skins2/src/top_window.cpp

    rf485214 r0953980  
    5959    // Register as a moving window 
    6060    m_rWindowManager.registerWindow( *this ); 
     61 
     62    // Create the "maximized" variable and register it in the manager 
     63    m_pVarMaximized = new VarBoolImpl( pIntf ); 
     64    VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarMaximized ) ); 
    6165} 
    6266 
  • modules/gui/skins2/src/top_window.hpp

    r91e5a90 r0953980  
    7979        virtual void onTooltipChange( const CtrlGeneric &rCtrl ); 
    8080 
     81        /// Get the "maximized" variable 
     82        VarBool &getMaximizedVar() { return *m_pVarMaximized; } 
     83 
    8184        /// Get the initial visibility status 
    8285        bool isVisible() const { return m_visible; } 
     
    9093 
    9194    private: 
     95        /** 
     96         * These methods are only used by the window manager 
     97         */ 
     98        //@{ 
    9299        /// Change the active layout 
    93100        virtual void setActiveLayout( GenericLayout *pLayout ); 
     101        //@} 
    94102 
    95103        /// Initial visibility status 
     
    108116        int m_currModifier; 
    109117 
    110         /// Find the uppest control in the layout hit by the mouse, and send 
    111         /// it an enter event if needed 
     118        /// Variable for the visibility of the window 
     119        VarBoolImpl *m_pVarMaximized; 
     120 
     121        /** 
     122         * Find the uppest control in the layout hit by the mouse, and send 
     123         * it an enter event if needed 
     124         */ 
    112125        CtrlGeneric *findHitControl( int xPos, int yPos ); 
    113126 
    114         /// Update the lastHitControl pointer and send a leave event to the 
    115         /// right control 
     127        /** 
     128         * Update the lastHitControl pointer and send a leave event to the 
     129         * right control 
     130         */ 
    116131        void setLastHit( CtrlGeneric *pNewHitControl ); 
    117132}; 
  • modules/gui/skins2/src/window_manager.cpp

    r8086b07 r0953980  
    3030#include "tooltip.hpp" 
    3131#include "var_manager.hpp" 
    32 #include "../utils/position.hpp" 
    3332 
    3433 
    3534WindowManager::WindowManager( intf_thread_t *pIntf ): 
    3635    SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ), 
     36    m_maximizeRect(0, 0, 50, 50), 
    3737    m_pTooltip( NULL ), m_pPopup( NULL ) 
    3838{ 
     
    318318 
    319319 
     320void WindowManager::maximize( TopWindow &rWindow ) 
     321{ 
     322    // Save the current position/size of the window, to be able to restore it 
     323    m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(), 
     324                           rWindow.getLeft() + rWindow.getWidth(), 
     325                           rWindow.getTop() + rWindow.getHeight() ); 
     326 
     327    Rect workArea = OSFactory::instance( getIntf() )->getWorkArea(); 
     328    // Move the window 
     329    startMove( rWindow ); 
     330    move( rWindow, workArea.getLeft(), workArea.getTop() ); 
     331    stopMove(); 
     332    // Now resize it 
     333    // FIXME: Ugly const_cast 
     334    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); 
     335    startResize( rLayout, kResizeSE ); 
     336    resize( rLayout, workArea.getWidth(), workArea.getHeight() ); 
     337    stopResize(); 
     338    rWindow.m_pVarMaximized->set( true ); 
     339 
     340    // Make the window unmovable by unregistering it 
     341//     unregisterWindow( rWindow ); 
     342} 
     343 
     344 
     345void WindowManager::unmaximize( TopWindow &rWindow ) 
     346{ 
     347    // Register the window to allow moving it 
     348//     registerWindow( rWindow ); 
     349 
     350    // Resize the window 
     351    // FIXME: Ugly const_cast 
     352    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); 
     353    startResize( rLayout, kResizeSE ); 
     354    resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() ); 
     355    stopResize(); 
     356    // Now move it 
     357    startMove( rWindow ); 
     358    move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() ); 
     359    stopMove(); 
     360    rWindow.m_pVarMaximized->set( false ); 
     361} 
     362 
     363 
    320364void WindowManager::synchVisibility() const 
    321365{ 
  • modules/gui/skins2/src/window_manager.hpp

    r8086b07 r0953980  
    2828#include "skin_common.hpp" 
    2929#include "top_window.hpp" 
     30#include "../utils/position.hpp" 
    3031#include <list> 
    3132#include <map> 
     
    8990 
    9091        /** 
    91          * Resize the rWindow window to (width, height), and move all its 
     92         * Resize the rLayout layout to (width, height), and move all its 
    9293         * anchored windows, if some anchors are moved during the resizing. 
    9394         * If a new anchoring is detected, the windows will move (or resize) 
     
    9596         */ 
    9697        void resize( GenericLayout &rLayout, int width, int height ) const; 
     98 
     99        /// Maximize the given window 
     100        void maximize( TopWindow &rWindow ); 
     101 
     102        /// Unmaximize the given window 
     103        void unmaximize( TopWindow &rWindow ); 
    97104 
    98105        /// Raise all the registered windows 
     
    202209        /// Direction of the current resizing 
    203210        Direction_t m_direction; 
     211        /// Rect of the last maximized window 
     212        Rect m_maximizeRect; 
    204213        /// Tooltip 
    205214        Tooltip *m_pTooltip; 
  • modules/gui/skins2/utils/position.hpp

    r8086b07 r0953980  
    6060        virtual int getLeft() const { return m_left; } 
    6161        virtual int getTop() const { return m_top; } 
     62        virtual int getRight() const { return m_right; } 
     63        virtual int getBottom() const { return m_bottom; } 
    6264        virtual int getWidth() const { return m_right - m_left; } 
    6365        virtual int getHeight() const { return m_bottom - m_top; }