Changeset 24648f43cf4371f6c6d6d78db2f5ae755f810cc8

Show
Ignore:
Timestamp:
06/04/06 01:57:40 (2 years ago)
Author:
Olivier Teulière <ipkiss@videolan.org>
git-committer:
Olivier Teulière <ipkiss@videolan.org> 1149379060 +0000
git-parent:

[fef44fa9395f5d7c7fa1a80c6725f877affa3fad]

git-author:
Olivier Teulière <ipkiss@videolan.org> 1149379060 +0000
Message:
  • modules/gui/skins2/*:
    • anchors have a new "lefttop" attribute, allowing them to follow the
      border of the window when resizing
    • the resizing is now handled by the WindowManager? class (to enforce the
      mediator pattern). This makes it possible to handle tricky cases,
      such as:

window B is anchored to window A, and A is resized
==> B moves accordingly, and can still be anchored by other windows

Files:

Legend:

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

    r28bd3a4 r24648f4  
    380380    <para>Default value: 0</para> 
    381381  </sect4> 
     382  <sect4 id="anchorlefttop"> 
     383    <title>lefttop</title> 
     384    <para>Indicate to which corner of the Layout the top-left-hand corner of this anchor is attached, in case of resizing. Possible values are 'lefttop', 'leftbottom', 'righttop' and 'rightbottom'.</para> 
     385    <para>Note that there is no "rightbottom" attribute for the anchors (contrarily to normal controls), because an anchor is not resizable (even when the anchor is not ponctual and follows a Bezier curve).</para> 
     386    <para>Default value: lefttop</para> 
     387  </sect4> 
    382388  <sect4 id="anchorpriority"> 
    383389    <title>priority</title> 
  • modules/gui/skins2/commands/cmd_resize.cpp

    radc858d r24648f4  
    2525#include "cmd_resize.hpp" 
    2626#include "../src/generic_layout.hpp" 
     27#include "../src/window_manager.hpp" 
    2728#include "../src/vlcproc.hpp" 
    2829 
    2930 
    30 CmdResize::CmdResize( intf_thread_t *pIntf, GenericLayout &rLayout, int width
    31                       int height ): 
    32     CmdGeneric( pIntf ), m_rLayout( rLayout ), m_width( width ), 
    33     m_height( height ) 
     31CmdResize::CmdResize( intf_thread_t *pIntf, const WindowManager &rWindowManager
     32                      GenericLayout &rLayout, int width, int height ): 
     33    CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ), 
     34    m_rLayout( rLayout ), m_width( width ), m_height( height ) 
    3435{ 
    3536} 
     
    3940{ 
    4041    // Resize the layout 
    41     m_rLayout.resize( m_width, m_height ); 
     42    m_rWindowManager.resize( m_rLayout, m_width, m_height ); 
    4243} 
    4344 
  • modules/gui/skins2/commands/cmd_resize.hpp

    radc858d r24648f4  
    2828#include "cmd_generic.hpp" 
    2929 
     30class WindowManager; 
    3031class GenericLayout; 
    3132 
     
    3637    public: 
    3738        /// Resize the given layout 
    38         CmdResize( intf_thread_t *pIntf, GenericLayout &rLayout, int width
    39                    int height ); 
     39        CmdResize( intf_thread_t *pIntf, const WindowManager &rWindowManager
     40                   GenericLayout &rLayout, int width, int height ); 
    4041        virtual ~CmdResize() {} 
    4142 
     
    4748 
    4849    private: 
     50        const WindowManager &m_rWindowManager; 
    4951        GenericLayout &m_rLayout; 
    5052        int m_width, m_height; 
  • modules/gui/skins2/controls/ctrl_resize.cpp

    radc858d r24648f4  
    3434 
    3535 
    36 CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl, 
    37                         GenericLayout &rLayout, const UString &rHelp, 
    38                         VarBool *pVisible, Direction_t direction ): 
    39     CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ), 
     36CtrlResize::CtrlResize( intf_thread_t *pIntf, WindowManager &rWindowManager, 
     37                        CtrlFlat &rCtrl, GenericLayout &rLayout, 
     38                        const UString &rHelp, VarBool *pVisible, 
     39                        WindowManager::Direction_t direction ): 
     40    CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), 
     41    m_rWindowManager( rWindowManager ), m_rCtrl( rCtrl ), 
    4042    m_rLayout( rLayout ), m_direction( direction ),  m_cmdOutStill( this ), 
    4143    m_cmdStillOut( this ), 
     
    104106 
    105107 
    106 void CtrlResize::changeCursor( Direction_t direction ) const 
     108void CtrlResize::changeCursor( WindowManager::Direction_t direction ) const 
    107109{ 
    108110    OSFactory *pOsFactory = OSFactory::instance( getIntf() ); 
    109     if( direction == kResizeSE ) 
     111    if( direction == WindowManager::kResizeSE ) 
    110112        pOsFactory->changeCursor( OSFactory::kResizeNWSE ); 
    111     else if( direction == kResizeS ) 
     113    else if( direction == WindowManager::kResizeS ) 
    112114        pOsFactory->changeCursor( OSFactory::kResizeNS ); 
    113     else if( direction == kResizeE ) 
     115    else if( direction == WindowManager::kResizeE ) 
    114116        pOsFactory->changeCursor( OSFactory::kResizeWE ); 
    115     else if( direction == kNone ) 
     117    else if( direction == WindowManager::kNone ) 
    116118        pOsFactory->changeCursor( OSFactory::kDefaultArrow ); 
    117119} 
     
    126128void CtrlResize::CmdStillOut::execute() 
    127129{ 
    128     m_pParent->changeCursor( kNone ); 
     130    m_pParent->changeCursor( WindowManager::kNone ); 
    129131} 
    130132 
     
    150152    m_pParent->m_width = m_pParent->m_rLayout.getWidth(); 
    151153    m_pParent->m_height = m_pParent->m_rLayout.getHeight(); 
     154 
     155    m_pParent->m_rWindowManager.startResize( m_pParent->m_rLayout, 
     156                                             m_pParent->m_direction); 
    152157} 
    153158 
     
    159164 
    160165    m_pParent->releaseMouse(); 
     166 
     167    m_pParent->m_rWindowManager.stopResize(); 
    161168} 
    162169 
     
    170177 
    171178    int newWidth = m_pParent->m_width; 
     179    newWidth += pEvtMotion->getXPos() - m_pParent->m_xPos; 
    172180    int newHeight = m_pParent->m_height; 
    173     if( m_pParent->m_direction != kResizeS ) 
    174         newWidth += pEvtMotion->getXPos() - m_pParent->m_xPos; 
    175     if( m_pParent->m_direction != kResizeE ) 
    176         newHeight += pEvtMotion->getYPos() - m_pParent->m_yPos; 
     181    newHeight += pEvtMotion->getYPos() - m_pParent->m_yPos; 
    177182 
    178     // Create a resize command 
     183    // Create a resize command, instead of calling the window manager directly. 
     184    // Thanks to this trick, the duplicate resizing commands will be trashed 
     185    // in the asynchronous queue, thus making resizing faster 
    179186    CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(), 
     187                                      m_pParent->m_rWindowManager, 
    180188                                      m_pParent->m_rLayout, 
    181189                                      newWidth, newHeight ); 
    182190    // Push the command in the asynchronous command queue 
    183     AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() ); 
     191    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() ); 
    184192    pQueue->push( CmdGenericPtr( pCmd ) ); 
    185193} 
  • modules/gui/skins2/controls/ctrl_resize.hpp

    radc858d r24648f4  
    2828#include "ctrl_flat.hpp" 
    2929#include "../commands/cmd_generic.hpp" 
     30#include "../src/window_manager.hpp" 
    3031#include "../utils/fsm.hpp" 
     32 
     33class WindowManager; 
    3134 
    3235 
     
    3538{ 
    3639    public: 
    37         enum Direction_t 
    38         { 
    39             kResizeE,   // East 
    40             kResizeSE,  // South-East 
    41             kResizeS,   // South 
    42             kNone       // Reserved for internal use 
    43         }; 
    44  
    45         CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl, 
    46                     GenericLayout &rLayout, const UString &rHelp, 
    47                     VarBool *pVisible, Direction_t direction ); 
     40        CtrlResize( intf_thread_t *pIntf, WindowManager &rWindowManager, 
     41                    CtrlFlat &rCtrl, GenericLayout &rLayout, 
     42                    const UString &rHelp, VarBool *pVisible, 
     43                    WindowManager::Direction_t direction ); 
    4844        virtual ~CtrlResize() {} 
    4945 
     
    6965    private: 
    7066        FSM m_fsm; 
     67        /// Window manager 
     68        WindowManager &m_rWindowManager; 
    7169        /// Decorated CtrlFlat 
    7270        CtrlFlat &m_rCtrl; 
     
    7876        int m_xPos, m_yPos; 
    7977        /// Direction of the resizing 
    80         Direction_t m_direction; 
     78        WindowManager::Direction_t m_direction; 
    8179 
    8280        /// Change the cursor, based on the given direction 
    83         void changeCursor( Direction_t direction ) const; 
     81        void changeCursor( WindowManager::Direction_t direction ) const; 
    8482 
    8583        /// Callback objects 
  • modules/gui/skins2/controls/ctrl_video.cpp

    r91e5a90 r24648f4  
    2727#include "../src/os_graphics.hpp" 
    2828#include "../src/vlcproc.hpp" 
     29#include "../src/window_manager.hpp" 
    2930#include "../commands/async_queue.hpp" 
    3031#include "../commands/cmd_resize.hpp" 
     
    107108 
    108109    // Create a resize command 
    109     CmdGeneric *pCmd = new CmdResize( getIntf(), m_rLayout, newWidth, 
    110                                       newHeight ); 
     110    // FIXME: this way of getting the window manager kind of sucks 
     111    WindowManager &rWindowManager = 
     112        getIntf()->p_sys->p_theme->getWindowManager(); 
     113    rWindowManager.startResize( m_rLayout, WindowManager::kResizeSE ); 
     114    CmdGeneric *pCmd = new CmdResize( getIntf(), rWindowManager, 
     115                                      m_rLayout, newWidth, newHeight ); 
    111116    // Push the command in the asynchronous command queue 
    112117    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() ); 
    113118    pQueue->push( CmdGenericPtr( pCmd ) ); 
     119 
     120    // FIXME: this should be a command too 
     121    rWindowManager.stopResize(); 
    114122} 
    115123 
  • modules/gui/skins2/parser/builder.cpp

    r1aff501 r24648f4  
    3939#include "../src/popup.hpp" 
    4040#include "../src/theme.hpp" 
     41#include "../src/window_manager.hpp" 
    4142#include "../commands/cmd_generic.hpp" 
    4243#include "../controls/ctrl_button.hpp" 
     
    378379    m_pTheme->m_curves.push_back( BezierPtr( pCurve ) ); 
    379380 
    380     Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos, 
    381                                rData.m_range, rData.m_priority, 
     381    // Compute the position of the anchor 
     382    const Position pos = makePosition( rData.m_leftTop, rData.m_leftTop, 
     383                                       rData.m_xPos, rData.m_yPos, 
     384                                       pCurve->getWidth(), 
     385                                       pCurve->getHeight(), *pLayout ); 
     386 
     387    Anchor *pAnc = new Anchor( getIntf(), pos, rData.m_range, rData.m_priority, 
    382388                               *pCurve, *pLayout ); 
    383389    pLayout->addAnchor( pAnc ); 
     
    560566    else if( rData.m_actionId == "resizeS" ) 
    561567    { 
    562         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout, 
     568        CtrlResize *pResize = new CtrlResize( getIntf(), 
     569                m_pTheme->getWindowManager(), *pImage, *pLayout, 
    563570                UString( getIntf(), rData.m_help.c_str() ), pVisible, 
    564                 CtrlResize::kResizeS ); 
     571                WindowManager::kResizeS ); 
    565572        pLayout->addControl( pResize, pos, rData.m_layer ); 
    566573    } 
    567574    else if( rData.m_actionId == "resizeE" ) 
    568575    { 
    569         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout, 
     576        CtrlResize *pResize = new CtrlResize( getIntf(), 
     577                m_pTheme->getWindowManager(), *pImage, *pLayout, 
    570578                UString( getIntf(), rData.m_help.c_str() ), pVisible, 
    571                 CtrlResize::kResizeE ); 
     579                WindowManager::kResizeE ); 
    572580        pLayout->addControl( pResize, pos, rData.m_layer ); 
    573581    } 
    574582    else if( rData.m_actionId == "resizeSE" ) 
    575583    { 
    576         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout, 
     584        CtrlResize *pResize = new CtrlResize( getIntf(), 
     585                m_pTheme->getWindowManager(), *pImage, *pLayout, 
    577586                UString( getIntf(), rData.m_help.c_str() ), pVisible, 
    578                 CtrlResize::kResizeSE ); 
     587                WindowManager::kResizeSE ); 
    579588        pLayout->addControl( pResize, pos, rData.m_layer ); 
    580589    } 
  • modules/gui/skins2/parser/builder_data.def

    ra5a9346 r24648f4  
    99Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool 
    1010Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string 
    11 Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string 
     11Anchor xPos:int yPos:int leftTop:string range:int priority:int points:string layoutId:string 
    1212Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string 
    1313Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string up1Id:string down1Id:string over1Id:string up2Id:string down2Id:string over2Id:string state:string action1:string action2:string tooltip1:string tooltip2:string help:string layer:int windowId:string layoutId:string 
  • modules/gui/skins2/parser/builder_data.hpp

    ra5a9346 r24648f4  
    187187    struct Anchor 
    188188    { 
    189         Anchor( int xPos, int yPos, int range, int priority, const string & points, const string & layoutId ): 
    190 m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_points( points ), m_layoutId( layoutId ) {} 
    191  
    192         int m_xPos; 
    193         int m_yPos; 
     189        Anchor( int xPos, int yPos, const string & leftTop, int range, int priority, const string & points, const string & layoutId ): 
     190m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_range( range ), m_priority( priority ), m_points( points ), m_layoutId( layoutId ) {} 
     191 
     192        int m_xPos; 
     193        int m_yPos; 
     194        string m_leftTop; 
    194195        int m_range; 
    195196        int m_priority; 
  • modules/gui/skins2/parser/skin_parser.cpp

    r2a4da6a r24648f4  
    8989        CheckDefault( "x", "0" ); 
    9090        CheckDefault( "y", "0" ); 
     91        CheckDefault( "lefttop", "lefttop" ); 
    9192        CheckDefault( "points", "(0,0)" ); 
    9293        CheckDefault( "range", "10" ); 
    9394 
    9495        const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset, 
    95                 atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ), 
    96                 atoi( attr["priority"] ), attr["points"], m_curLayoutId ); 
     96                atoi( attr["y"] ) + m_yOffset, attr["lefttop"], 
     97                atoi( attr["range"] ), atoi( attr["priority"] ), 
     98                attr["points"], m_curLayoutId ); 
    9799        m_pData->m_listAnchor.push_back( anchor ); 
    98100    } 
  • modules/gui/skins2/src/anchor.hpp

    radc858d r24648f4  
    2929#include "generic_layout.hpp" 
    3030#include "../utils/bezier.hpp" 
     31#include "../utils/position.hpp" 
    3132 
    3233 
     
    3536{ 
    3637    public: 
    37         Anchor( intf_thread_t *pIntf, int xPos, int yPos, int range, 
     38        Anchor( intf_thread_t *pIntf, const Position &rPosition, int range, 
    3839                int priority, const Bezier &rCurve, GenericLayout &rLayout ): 
    39             SkinObject( pIntf ), m_xPos( xPos ), m_yPos( yPos ), 
     40            SkinObject( pIntf ), m_position( rPosition ), 
    4041            m_rCurve( rCurve ), m_range( range ), m_priority( priority ), 
    4142            m_rLayout( rLayout ) {} 
    4243        virtual ~Anchor() {} 
    4344 
    44         /// Return true if the given anchor is hanged by this one 
    45         /// Two conditions are required: 
    46         ///  - the other anchor must be in position of anchoring (as defined 
    47         ///    by canHang()) 
    48         ///  - the priority of the other anchor must be lower than this one's 
     45        /** 
     46         * Return true if the given anchor is hanged by this one 
     47         * Two conditions are required: 
     48         *  - the other anchor must be in position of anchoring (as defined 
     49         *    by canHang()) 
     50         *  - the priority of the other anchor must be lower than this one's 
     51         */ 
    4952        bool isHanging( const Anchor &rOther ) const; 
    5053 
    51         /// Return true if the other anchor, moved by the (xOffset, yOffset) 
    52         /// vector, is "hangable" by this one (i.e. if it is in its range of 
    53         /// action), else return false. 
    54         /// When the function returns true, the xOffset and yOffset parameters 
    55         /// are modified to indicate the position that the other anchor would 
    56         /// take if hanged by this one (this position is calculated to minimize 
    57         /// the difference with the old xOffset and yOffset, so that the window 
    58         /// doesn't "jump" in a strange way). 
     54        /** 
     55         * Return true if the other anchor, moved by the (xOffset, yOffset) 
     56         * vector, is "hangable" by this one (i.e. if it is in its range of 
     57         * action), else return false. 
     58         * When the function returns true, the xOffset and yOffset parameters 
     59         * are modified to indicate the position that the other anchor would 
     60         * take if hanged by this one (this position is calculated to minimize 
     61         * the difference with the old xOffset and yOffset, so that the window 
     62         * doesn't "jump" in a strange way). 
     63         */ 
    5964        bool canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const; 
    6065 
     
    6368 
    6469        // Getters 
    65         int getXPosAbs() const { return (m_xPos + m_rLayout.getLeft()); } 
    66         int getYPosAbs() const { return (m_yPos + m_rLayout.getTop()); } 
     70        const Position & getPosition() const { return m_position; } 
     71 
     72        int getXPosAbs() const 
     73        { 
     74            return (m_position.getLeft() + m_rLayout.getLeft()); 
     75        } 
     76 
     77        int getYPosAbs() const 
     78        { 
     79            return (m_position.getTop() + m_rLayout.getTop()); 
     80        } 
    6781 
    6882    private: 
    69         /// Coordinates relative to the window 
    70         int m_xPos, m_yPos
     83        /// Position in the layout 
     84        Position m_position
    7185 
    7286        /// Curve of the anchor 
     
    7993        int m_priority; 
    8094 
    81         /// Parent window 
     95        /// Parent layout 
    8296        GenericLayout &m_rLayout; 
    8397}; 
  • modules/gui/skins2/src/generic_layout.cpp

    r28bd3a4 r24648f4  
    159159void GenericLayout::resize( int width, int height ) 
    160160{ 
    161     // Check boundaries 
    162     if( width < m_minWidth ) 
    163     { 
    164         width = m_minWidth; 
    165     } 
    166     if( width > m_maxWidth ) 
    167     { 
    168         width = m_maxWidth; 
    169     } 
    170     if( height < m_minHeight ) 
    171     { 
    172         height = m_minHeight; 
    173     } 
    174     if( height > m_maxHeight ) 
    175     { 
    176         height = m_maxHeight; 
    177     } 
    178  
    179     if( width == m_width && height == m_height ) 
    180     { 
    181         return; 
    182     } 
    183  
    184161    // Update the window size 
    185162    m_width = width; 
  • modules/gui/skins2/src/window_manager.cpp

    rfb9fadd r24648f4  
    2929#include "anchor.hpp" 
    3030#include "tooltip.hpp" 
     31#include "var_manager.hpp" 
    3132#include "../utils/position.hpp" 
    32 #include "../src/var_manager.hpp" 
    3333 
    3434 
    3535WindowManager::WindowManager( intf_thread_t *pIntf ): 
    36     SkinObject( pIntf ), m_magnet( 0 ), m_pTooltip( NULL ), m_pPopup( NULL ) 
     36    SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ), 
     37    m_pTooltip( NULL ), m_pPopup( NULL ) 
    3738{ 
    3839    // Create and register a variable for the "on top" status 
     
    171172 
    172173 
     174void WindowManager::startResize( GenericLayout &rLayout, Direction_t direction ) 
     175{ 
     176    m_direction = direction; 
     177 
     178    // Rebuild the set of moving windows. 
     179    // From the resized window, we only take into account the anchors which 
     180    // are mobile with the current type of resizing, and that are hanging a 
     181    // window. The hanged windows will come will all their dependencies. 
     182 
     183    m_resizeMovingE.clear(); 
     184    m_resizeMovingS.clear(); 
     185    m_resizeMovingSE.clear(); 
     186 
     187    WinSet_t::const_iterator itWin; 
     188    AncList_t::const_iterator itAnc1, itAnc2; 
     189    // Get the anchors of the layout 
     190    const AncList_t &ancList1 = rLayout.getAnchorList(); 
     191 
     192    // Iterate through all the hanged windows 
     193    for( itWin = m_dependencies[rLayout.getWindow()].begin(); 
     194         itWin != m_dependencies[rLayout.getWindow()].end(); itWin++ ) 
     195    { 
     196        // Now, check for anchoring between the 2 windows 
     197        const AncList_t &ancList2 = 
     198            (*itWin)->getActiveLayout().getAnchorList(); 
     199        for( itAnc1 = ancList1.begin(); itAnc1 != ancList1.end(); itAnc1++ ) 
     200        { 
     201            for( itAnc2 = ancList2.begin(); 
     202                 itAnc2 != ancList2.end(); itAnc2++ ) 
     203            { 
     204                if( (*itAnc1)->isHanging( **itAnc2 ) ) 
     205                { 
     206                    // Add the dependencies of the hanged window to one of the 
     207                    // lists of moving windows 
     208                    Position::Ref_t aRefPos = 
     209                        (*itAnc1)->getPosition().getRefLeftTop(); 
     210                    if( aRefPos == Position::kRightTop ) 
     211                        buildDependSet( m_resizeMovingE, *itWin ); 
     212                    else if( aRefPos == Position::kLeftBottom ) 
     213                        buildDependSet( m_resizeMovingS, *itWin ); 
     214                    else if( aRefPos == Position::kRightBottom ) 
     215                        buildDependSet( m_resizeMovingSE, *itWin ); 
     216                    break; 
     217                } 
     218            } 
     219        } 
     220    } 
     221 
     222    // The checkAnchors() method will need to have m_movingWindows properly set 
     223    // so let's insert in it the contents of the other sets 
     224    m_movingWindows.clear(); 
     225    m_movingWindows.insert( rLayout.getWindow() ); 
     226    m_movingWindows.insert( m_resizeMovingE.begin(), m_resizeMovingE.end() ); 
     227    m_movingWindows.insert( m_resizeMovingS.begin(), m_resizeMovingS.end() ); 
     228    m_movingWindows.insert( m_resizeMovingSE.begin(), m_resizeMovingSE.end() ); 
     229} 
     230 
     231 
     232void WindowManager::stopResize() 
     233{ 
     234    // Nothing different from stopMove(), luckily 
     235    stopMove(); 
     236} 
     237 
     238 
     239void WindowManager::resize( GenericLayout &rLayout, 
     240                            int width, int height ) const 
     241{ 
     242    // TODO: handle anchored windows 
     243    // Compute the real resizing offset 
     244    int xOffset = width - rLayout.getWidth(); 
     245    int yOffset = height - rLayout.getHeight(); 
     246 
     247    // Check anchoring; this can change the values of xOffset and yOffset 
     248    checkAnchors( rLayout.getWindow(), xOffset, yOffset ); 
     249    if( m_direction == kResizeS ) 
     250        xOffset = 0; 
     251    if( m_direction == kResizeE ) 
     252        yOffset = 0; 
     253 
     254    int newWidth = rLayout.getWidth() + xOffset; 
     255    int newHeight = rLayout.getHeight() + yOffset; 
     256 
     257    // Check boundaries 
     258    if( newWidth < rLayout.getMinWidth() ) 
     259    { 
     260        newWidth = rLayout.getMinWidth(); 
     261    } 
     262    if( newWidth > rLayout.getMaxWidth() ) 
     263    { 
     264        newWidth = rLayout.getMaxWidth(); 
     265    } 
     266    if( newHeight < rLayout.getMinHeight() ) 
     267    { 
     268        newHeight = rLayout.getMinHeight(); 
     269    } 
     270    if( newHeight > rLayout.getMaxHeight() ) 
     271    { 
     272        newHeight = rLayout.getMaxHeight(); 
     273    } 
     274 
     275    if( newWidth == rLayout.getWidth() && newHeight == rLayout.getHeight() ) 
     276    { 
     277        return; 
     278    } 
     279 
     280    // New offset, after the last corrections 
     281    int xNewOffset = newWidth - rLayout.getWidth(); 
     282    int yNewOffset = newHeight - rLayout.getHeight(); 
     283 
     284    // Do the actual resizing 
     285    rLayout.resize( newWidth, newHeight ); 
     286 
     287    // Move all the anchored windows 
     288    WinSet_t::const_iterator it; 
     289    if( m_direction == kResizeE || 
     290        m_direction == kResizeSE ) 
     291    { 
     292        for( it = m_resizeMovingE.begin(); it != m_resizeMovingE.end(); it++ ) 
     293        { 
     294            (*it)->move( (*it)->getLeft() + xNewOffset, 
     295                         (*it)->getTop() ); 
     296        } 
     297    } 
     298    if( m_direction == kResizeE || 
     299        m_direction == kResizeSE ) 
     300    { 
     301        for( it = m_resizeMovingS.begin(); it != m_resizeMovingS.end(); it++ ) 
     302        { 
     303            (*it)->move( (*it)->getLeft(), 
     304                         (*it)->getTop( )+ yNewOffset ); 
     305        } 
     306    } 
     307    if( m_direction == kResizeE || 
     308        m_direction == kResizeS || 
     309        m_direction == kResizeSE ) 
     310    { 
     311        for( it = m_resizeMovingSE.begin(); it != m_resizeMovingSE.end(); it++ ) 
     312        { 
     313            (*it)->move( (*it)->getLeft() + xNewOffset, 
     314                         (*it)->getTop() + yNewOffset ); 
     315        } 
     316    } 
     317} 
     318 
     319 
    173320void WindowManager::synchVisibility() const 
    174321{ 
     
    204351        // When the theme is opened for the first time, 
    205352        // only show the window if set as visible in the XML 
    206         if ((*it)->isVisible() || !firstTime
     353        if( (*it)->isVisible() || !firstTime
    207354        { 
    208355            (*it)->show(); 
     
    382529    else 
    383530    { 
    384         msg_Warn( getIntf(), "tooltip already created!"); 
     531        msg_Warn( getIntf(), "tooltip already created!" ); 
    385532    } 
    386533} 
  • modules/gui/skins2/src/window_manager.hpp

    radc858d r24648f4  
    4545{ 
    4646    public: 
     47        /// Direction of the resizing 
     48        enum Direction_t 
     49        { 
     50            kResizeE,   // East 
     51            kResizeSE,  // South-East 
     52            kResizeS,   // South 
     53            kNone       // Reserved for internal use 
     54        }; 
     55 
    4756        /// Constructor 
    4857        WindowManager( intf_thread_t *pIntf); 
     
    5867        void unregisterWindow( TopWindow &rWindow ); 
    5968 
    60         /// Tell the window manager that a move is initiated for pWindow. 
     69        /// Tell the window manager that a move is initiated for rWindow 
    6170        void startMove( TopWindow &rWindow ); 
    6271 
    63         /// Tell the window manager that the current move ended. 
     72        /// Tell the window manager that the current move ended 
    6473        void stopMove(); 
    6574 
    66         /// Move the pWindow window to (left, top), and move all its 
    67         /// anchored windows. 
    68         /// If a new anchoring is detected, the windows will move accordingly. 
     75        /** 
     76         * Move the rWindow window to (left, top), and move all its 
     77         * anchored windows. 
     78         * If a new anchoring is detected, the windows will move accordingly. 
     79         */ 
    6980        void move( TopWindow &rWindow, int left, int top ) const; 
     81 
     82        /// Tell the window manager that a resize is initiated for rWindow 
     83        void startResize( GenericLayout &rLayout, Direction_t direction ); 
     84 
     85        /// Tell the window manager that the current resizing ended 
     86        void stopResize(); 
     87 
     88        /** 
     89         * Resize the rWindow window to (width, height), and move all its 
     90         * anchored windows, if some anchors are moved during the resizing. 
     91         * If a new anchoring is detected, the windows will move (or resize) 
     92         * accordingly. 
     93         */ 
     94        void resize( GenericLayout &rLayout, int width, int height ) const; 
    7095 
    7196        /// Raise all the registered windows 
     
    7398 
    7499        /// Show all the registered windows 
    75         void showAll(bool firstTime = false) const; 
     100        void showAll( bool firstTime = false ) const; 
    76101 
    77102        /// Hide all the registered windows 
     
    143168        /// move. 
    144169        WinSet_t m_movingWindows; 
     170        /** 
     171         * Store the moving windows in the context of resizing 
     172         * These sets are updated at every start of move 
     173         */ 
     174        //@{ 
     175        WinSet_t m_resizeMovingE; 
     176        WinSet_t m_resizeMovingS; 
     177        WinSet_t m_resizeMovingSE; 
     178        //@} 
    145179        /// Indicate whether the windows are currently on top 
    146180        VariablePtr m_cVarOnTop; 
     
    151185        /// Alpha value of the moving windows 
    152186        int m_moveAlpha; 
     187        /// Direction of the current resizing 
     188        Direction_t m_direction; 
    153189        /// Tooltip 
    154190        Tooltip *m_pTooltip; 
  • modules/gui/skins2/utils/position.hpp

    radc858d r24648f4  
    9696        int getWidth() const; 
    9797        int getHeight() const; 
     98        /// Get the reference corners 
     99        Ref_t getRefLeftTop() const { return m_refLeftTop; } 
     100        Ref_t getRefRightBottom() const { return m_refRighBottom; } 
    98101 
    99102    private: 
  • share/skins2/skin.dtd

    ra5a9346 r24648f4  
    100100        x           CDATA   "0" 
    101101        y           CDATA   "0" 
     102        lefttop     CDATA   "lefttop" 
    102103        priority    CDATA   #REQUIRED 
    103104        points      CDATA   "(0,0)"