Changeset dda858d436bceafa45b834836a6dd302ad7da181

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

[3d353c9e2704e7b02de167015c93702bccc01e22]

git-author:
Olivier Teulière <ipkiss@videolan.org> 1154785026 +0000
Message:
  • skins2: new "xkeepratio" and "ykeepratio" attributes, common to all the
    controls. When set to "true", the behaviour of the resizing is changed
    (cf. documentation). The main use for these attributes is to keep a
    a control centered in the layout (horizontally, vertically or both) without
    resizing the control.
Files:

Legend:

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

    re99be2d rdda858d  
    399399  <sect4 id="anchorrange"> 
    400400    <title>range</title> 
    401     <para>Range of action of the anchor, in pixels. Default is "10".</para> 
     401    <para>Range of action of the anchor, in pixels.</para> 
    402402    <para>Default value: 10</para> 
    403403  </sect4> 
     
    407407<sect3 id="commattr"> 
    408408  <title>Attributes common to all the controls</title> 
    409   <para>The following attributes are common to all the controls (Image, Button, Checkbox, Text, Slider, RadialSlider, Playtree, Video)</para> 
     409  <para>The following attributes are common to all the controls (Image, Button, Checkbox, Text, Slider, RadialSlider, Playlist, Playtree, Video)</para> 
    410410  <sect4 id="attrid"> 
    411411    <title>id</title> 
     
    437437    <para>Indicate to which corner of the Layout the bottom-right-hand corner of this control is attached, in case of resizing.</para> 
    438438    <para>Default value: lefttop</para> 
     439  </sect4> 
     440  <sect4 id="xkeepratio"> 
     441    <title>xkeepratio</title> 
     442    <para>When set to true, the behaviour of the horizontal resizing is changed. Instead of taking into account the <link linkend="lefttop">lefttop</link> and <link linkend="rightbottom">rightbottom</link> attributes to determine how the control will be moved/resized, only its initial position inside the <link linkend="Layout">Layout</link> matters. For example, if initially the space to the left of the control is twice as big as the one to its right, this will stay the same during any horizontal resizing. The width of the control stays constant.</para> 
     443    <para>This attribute can be particularly useful to keep a control centered in the layout, without resizing it (to resize it, you would rather use the lefttop/rightbottom attributes).</para> 
     444    <para>Default value: false</para> 
     445  </sect4> 
     446  <sect4 id="ykeepratio"> 
     447    <title>ykeepratio</title> 
     448    <para>When set to true, the behaviour of the vertical resizing is changed. Instead of taking into account the <link linkend="lefttop">lefttop</link> and <link linkend="rightbottom">rightbottom</link> attributes to determine how the control will be moved/resized, only its initial position inside the <link linkend="Layout">Layout</link> matters. For example, if initially the space to the top of the control is twice as big as the one to its bottom, this will stay the same during any vertical resizing. The height of the control stays constant.</para> 
     449    <para>This attribute can be particularly useful to keep a control centered in the layout, without resizing it (to resize it, you would rather use the lefttop/rightbottom attributes).</para> 
     450    <para>Default value: false</para> 
    439451  </sect4> 
    440452  <sect4 id="help"> 
  • modules/gui/skins2/parser/builder.cpp

    r4809df7 rdda858d  
    431431                                       rData.m_xPos, rData.m_yPos, 
    432432                                       pBmpUp->getWidth(), 
    433                                        pBmpUp->getHeight(), *pLayout ); 
     433                                       pBmpUp->getHeight(), *pLayout, 
     434                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    434435 
    435436    pLayout->addControl( pButton, pos, rData.m_layer ); 
     
    506507                                       rData.m_xPos, rData.m_yPos, 
    507508                                       pBmpUp1->getWidth(), 
    508                                        pBmpUp1->getHeight(), *pLayout ); 
     509                                       pBmpUp1->getHeight(), *pLayout, 
     510                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    509511 
    510512    pLayout->addControl( pCheckbox, pos, rData.m_layer ); 
     
    552554    // Compute the position of the control 
    553555    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 
    554                                        rData.m_xPos, 
    555                                        rData.m_yPos, pBmp->getWidth(), 
    556                                        pBmp->getHeight(), *pLayout ); 
     556                                       rData.m_xPos, rData.m_yPos, 
     557                                       pBmp->getWidth(), pBmp->getHeight(), 
     558                                       *pLayout, rData.m_xKeepRatio, 
     559                                       rData.m_yKeepRatio ); 
    557560 
    558561    // XXX: test to be changed! XXX 
     
    661664    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 
    662665                                       rData.m_xPos, rData.m_yPos, 
    663                                        rData.m_width, height, 
    664                                        *pLayout ); 
     666                                       rData.m_width, height, *pLayout, 
     667                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    665668 
    666669    pLayout->addControl( pText, pos, rData.m_layer ); 
     
    709712    // XXX: resizing is not supported 
    710713    // Compute the position of the control 
    711     const Position pos = 
    712         makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, 
    713                       rData.m_yPos, pSeq->getWidth(), 
    714                       pSeq->getHeight() / rData.m_nbImages, *pLayout ); 
     714    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 
     715                                       rData.m_xPos, rData.m_yPos, 
     716                                       pSeq->getWidth(), 
     717                                       pSeq->getHeight() / rData.m_nbImages, 
     718                                       *pLayout, 
     719                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    715720 
    716721    pLayout->addControl( pRadial, pos, rData.m_layer ); 
     
    773778                                       rData.m_xPos, rData.m_yPos, 
    774779                                       pCurve->getWidth(), pCurve->getHeight(), 
    775                                        *pLayout ); 
     780                                       *pLayout, 
     781                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    776782 
    777783    pLayout->addControl( pBackground, pos, rData.m_layer ); 
     
    853859                                       rData.m_xPos, rData.m_yPos, 
    854860                                       rData.m_width, rData.m_height, 
    855                                        *pLayout ); 
     861                                       *pLayout, 
     862                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    856863 
    857864    pLayout->addControl( pList, pos, rData.m_layer ); 
     
    917924                                       rData.m_xPos, rData.m_yPos, 
    918925                                       rData.m_width, rData.m_height, 
    919                                        *pLayout ); 
     926                                       *pLayout, 
     927                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    920928 
    921929    pLayout->addControl( pTree, pos, rData.m_layer ); 
     
    946954                                       rData.m_xPos, rData.m_yPos, 
    947955                                       rData.m_width, rData.m_height, 
    948                                        *pLayout ); 
     956                                       *pLayout, 
     957                                       rData.m_xKeepRatio, rData.m_yKeepRatio ); 
    949958 
    950959    pLayout->addControl( pVideo, pos, rData.m_layer ); 
     
    957966                                      const string &rRightBottom, 
    958967                                      int xPos, int yPos, int width, 
    959                                       int height, const Box &rBox ) const 
     968                                      int height, const Box &rBox, 
     969                                      bool xKeepRatio, bool yKeepRatio ) const 
    960970{ 
    961971    int left = 0, top = 0, right = 0, bottom = 0; 
     
    10191029 
    10201030    return Position( left, top, right, bottom, rBox, refLeftTop, 
    1021                      refRightBottom ); 
     1031                     refRightBottom, xKeepRatio, yKeepRatio ); 
    10221032} 
    10231033 
  • modules/gui/skins2/parser/builder.hpp

    ra5a9346 rdda858d  
    9191                                     const string &rRightBottom, 
    9292                                     int xPos, int yPos, int width, int height, 
    93                                      const Box &rBox ) const; 
     93                                     const Box &rBox, bool xKeepRatio = false, 
     94                                     bool yKeepRatio = false ) const; 
    9495 
    9596        // Build the full path of a file 
  • modules/gui/skins2/parser/builder_data.def

    r24648f4 rdda858d  
    1010Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string 
    1111Anchor xPos:int yPos:int leftTop:string range:int priority:int points:string layoutId:string 
    12 Button 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 
    13 Checkbox 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 
    14 Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string action2Id:string resize:string help:string layer:int windowId:string layoutId:string 
     12Button id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string 
     13Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool 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 
     14Image id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool visible:string bmpId:string actionId:string action2Id:string resize:string help:string layer:int windowId:string layoutId:string 
    1515IniFile id:string file:string 
    16 Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string color:uint32_t scrolling:string alignment:string help:string layer:int windowId:string layoutId:string 
    17 RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string 
    18 Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string upId:string downId:string overId:string points:string thickness:int value:string imageId:string nbHoriz:int nbVert:int padHoriz:int padVert:int tooltip:string help:string layer:int windowId:string layoutId:string 
    19 List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string fgColor:string playColor:string bgColor1:string bgColor2:string selColor:string help:string layer:int windowId:string layoutId:string 
    20 Tree id:string xPos:int yPos:int visible:string flat:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:string playColor:string bgColor1:string bgColor2:string selColor:string help:string layer:int windowId:string layoutId:string 
    21 Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string autoResize:bool help:string layer:int windowId:string layoutId:string 
     16Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool color:uint32_t scrolling:string alignment:string help:string layer:int windowId:string layoutId:string 
     17RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string 
     18Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool upId:string downId:string overId:string points:string thickness:int value:string imageId:string nbHoriz:int nbVert:int padHoriz:int padVert:int tooltip:string help:string layer:int windowId:string layoutId:string 
     19List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool fontId:string var:string bgImageId:string fgColor:string playColor:string bgColor1:string bgColor2:string selColor:string help:string layer:int windowId:string layoutId:string 
     20Tree id:string xPos:int yPos:int visible:string flat:string width:int height:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:string playColor:string bgColor1:string bgColor2:string selColor:string help:string layer:int windowId:string layoutId:string 
     21Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool visible:string autoResize:bool help:string layer:int windowId:string layoutId:string 
  • modules/gui/skins2/parser/builder_data.hpp

    r24648f4 rdda858d  
    204204    struct Button 
    205205    { 
    206         Button( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & upId, const string & downId, const string & overId, const string & actionId, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
    207 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_upId( upId ), m_downId( downId ), m_overId( overId ), m_actionId( actionId ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    208  
    209         string m_id; 
    210         int m_xPos; 
    211         int m_yPos; 
    212         string m_leftTop; 
    213         string m_rightBottom; 
     206        Button( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & visible, const string & upId, const string & downId, const string & overId, const string & actionId, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
     207m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_visible( visible ), m_upId( upId ), m_downId( downId ), m_overId( overId ), m_actionId( actionId ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     208 
     209        string m_id; 
     210        int m_xPos; 
     211        int m_yPos; 
     212        string m_leftTop; 
     213        string m_rightBottom; 
     214        bool m_xKeepRatio; 
     215        bool m_yKeepRatio; 
    214216        string m_visible; 
    215217        string m_upId; 
     
    229231    struct Checkbox 
    230232    { 
    231         Checkbox( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & up1Id, const string & down1Id, const string & over1Id, const string & up2Id, const string & down2Id, const string & over2Id, const string & state, const string & action1, const string & action2, const string & tooltip1, const string & tooltip2, const string & help, int layer, const string & windowId, const string & layoutId ): 
    232 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_up1Id( up1Id ), m_down1Id( down1Id ), m_over1Id( over1Id ), m_up2Id( up2Id ), m_down2Id( down2Id ), m_over2Id( over2Id ), m_state( state ), m_action1( action1 ), m_action2( action2 ), m_tooltip1( tooltip1 ), m_tooltip2( tooltip2 ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    233  
    234         string m_id; 
    235         int m_xPos; 
    236         int m_yPos; 
    237         string m_leftTop; 
    238         string m_rightBottom; 
     233        Checkbox( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & visible, const string & up1Id, const string & down1Id, const string & over1Id, const string & up2Id, const string & down2Id, const string & over2Id, const string & state, const string & action1, const string & action2, const string & tooltip1, const string & tooltip2, const string & help, int layer, const string & windowId, const string & layoutId ): 
     234m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_visible( visible ), m_up1Id( up1Id ), m_down1Id( down1Id ), m_over1Id( over1Id ), m_up2Id( up2Id ), m_down2Id( down2Id ), m_over2Id( over2Id ), m_state( state ), m_action1( action1 ), m_action2( action2 ), m_tooltip1( tooltip1 ), m_tooltip2( tooltip2 ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     235 
     236        string m_id; 
     237        int m_xPos; 
     238        int m_yPos; 
     239        string m_leftTop; 
     240        string m_rightBottom; 
     241        bool m_xKeepRatio; 
     242        bool m_yKeepRatio; 
    239243        string m_visible; 
    240244        string m_up1Id; 
     
    260264    struct Image 
    261265    { 
    262         Image( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & bmpId, const string & actionId, const string & action2Id, const string & resize, const string & help, int layer, const string & windowId, const string & layoutId ): 
    263 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_bmpId( bmpId ), m_actionId( actionId ), m_action2Id( action2Id ), m_resize( resize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    264  
    265         string m_id; 
    266         int m_xPos; 
    267         int m_yPos; 
    268         string m_leftTop; 
    269         string m_rightBottom; 
     266        Image( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & visible, const string & bmpId, const string & actionId, const string & action2Id, const string & resize, const string & help, int layer, const string & windowId, const string & layoutId ): 
     267m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_visible( visible ), m_bmpId( bmpId ), m_actionId( actionId ), m_action2Id( action2Id ), m_resize( resize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     268 
     269        string m_id; 
     270        int m_xPos; 
     271        int m_yPos; 
     272        string m_leftTop; 
     273        string m_rightBottom; 
     274        bool m_xKeepRatio; 
     275        bool m_yKeepRatio; 
    270276        string m_visible; 
    271277        string m_bmpId; 
     
    296302    struct Text 
    297303    { 
    298         Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, const string & leftTop, const string & rightBottom, uint32_t color, const string & scrolling, const string & alignment, const string & help, int layer, const string & windowId, const string & layoutId ): 
    299 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_color( color ), m_scrolling( scrolling ), m_alignment( alignment ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     304        Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, uint32_t color, const string & scrolling, const string & alignment, const string & help, int layer, const string & windowId, const string & layoutId ): 
     305m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_color( color ), m_scrolling( scrolling ), m_alignment( alignment ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    300306 
    301307        string m_id; 
     
    308314        string m_leftTop; 
    309315        string m_rightBottom; 
     316        bool m_xKeepRatio; 
     317        bool m_yKeepRatio; 
    310318        uint32_t m_color; 
    311319        string m_scrolling; 
     
    322330    struct RadialSlider 
    323331    { 
    324         RadialSlider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & sequence, int nbImages, float minAngle, float maxAngle, const string & value, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
    325 m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_sequence( sequence ), m_nbImages( nbImages ), m_minAngle( minAngle ), m_maxAngle( maxAngle ), m_value( value ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    326  
    327         string m_id; 
    328         string m_visible; 
    329         int m_xPos; 
    330         int m_yPos; 
    331         string m_leftTop; 
    332         string m_rightBottom; 
     332        RadialSlider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & sequence, int nbImages, float minAngle, float maxAngle, const string & value, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
     333m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_sequence( sequence ), m_nbImages( nbImages ), m_minAngle( minAngle ), m_maxAngle( maxAngle ), m_value( value ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     334 
     335        string m_id; 
     336        string m_visible; 
     337        int m_xPos; 
     338        int m_yPos; 
     339        string m_leftTop; 
     340        string m_rightBottom; 
     341        bool m_xKeepRatio; 
     342        bool m_yKeepRatio; 
    333343        string m_sequence; 
    334344        int m_nbImages; 
     
    348358    struct Slider 
    349359    { 
    350         Slider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & upId, const string & downId, const string & overId, const string & points, int thickness, const string & value, const string & imageId, int nbHoriz, int nbVert, int padHoriz, int padVert, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
    351 m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_upId( upId ), m_downId( downId ), m_overId( overId ), m_points( points ), m_thickness( thickness ), m_value( value ), m_imageId( imageId ), m_nbHoriz( nbHoriz ), m_nbVert( nbVert ), m_padHoriz( padHoriz ), m_padVert( padVert ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    352  
    353         string m_id; 
    354         string m_visible; 
    355         int m_xPos; 
    356         int m_yPos; 
    357         string m_leftTop; 
    358         string m_rightBottom; 
     360        Slider( const string & id, const string & visible, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & upId, const string & downId, const string & overId, const string & points, int thickness, const string & value, const string & imageId, int nbHoriz, int nbVert, int padHoriz, int padVert, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): 
     361m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_upId( upId ), m_downId( downId ), m_overId( overId ), m_points( points ), m_thickness( thickness ), m_value( value ), m_imageId( imageId ), m_nbHoriz( nbHoriz ), m_nbVert( nbVert ), m_padHoriz( padHoriz ), m_padVert( padVert ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     362 
     363        string m_id; 
     364        string m_visible; 
     365        int m_xPos; 
     366        int m_yPos; 
     367        string m_leftTop; 
     368        string m_rightBottom; 
     369        bool m_xKeepRatio; 
     370        bool m_yKeepRatio; 
    359371        string m_upId; 
    360372        string m_downId; 
     
    380392    struct List 
    381393    { 
    382         List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ): 
    383 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     394        List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & fontId, const string & var, const string & bgImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ): 
     395m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    384396 
    385397        string m_id; 
     
    391403        string m_leftTop; 
    392404        string m_rightBottom; 
     405        bool m_xKeepRatio; 
     406        bool m_yKeepRatio; 
    393407        string m_fontId; 
    394408        string m_var; 
     
    410424    struct Tree 
    411425    { 
    412         Tree( const string & id, int xPos, int yPos, const string & visible, const string & flat, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ): 
    413 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     426        Tree( const string & id, int xPos, int yPos, const string & visible, const string & flat, int width, int height, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ): 
     427m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    414428 
    415429        string m_id; 
     
    422436        string m_leftTop; 
    423437        string m_rightBottom; 
     438        bool m_xKeepRatio; 
     439        bool m_yKeepRatio; 
    424440        string m_fontId; 
    425441        string m_var; 
     
    444460    struct Video 
    445461    { 
    446         Video( const string & id, int xPos, int yPos, int width, int height, const string & leftTop, const string & rightBottom, const string & visible, bool autoResize, const string & help, int layer, const string & windowId, const string & layoutId ): 
    447 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_autoResize( autoResize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
     462        Video( const string & id, int xPos, int yPos, int width, int height, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, const string & visible, bool autoResize, const string & help, int layer, const string & windowId, const string & layoutId ): 
     463m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_visible( visible ), m_autoResize( autoResize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} 
    448464 
    449465        string m_id; 
     
    454470        string m_leftTop; 
    455471        string m_rightBottom; 
     472        bool m_xKeepRatio; 
     473        bool m_yKeepRatio; 
    456474        string m_visible; 
    457475        bool m_autoResize; 
  • modules/gui/skins2/parser/skin_parser.cpp

    r24648f4 rdda858d  
    182182        CheckDefault( "lefttop", "lefttop" ); 
    183183        CheckDefault( "rightbottom", "lefttop" ); 
     184        CheckDefault( "xkeepratio", "false" ); 
     185        CheckDefault( "ykeepratio", "false" ); 
    184186        CheckDefault( "down", "none" ); 
    185187        CheckDefault( "over", "none" ); 
     
    190192        const BuilderData::Button button( uniqueId( attr["id"] ), 
    191193                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, 
    192                 attr["lefttop"], attr["rightbottom"], attr["visible"], 
     194                attr["lefttop"], attr["rightbottom"], 
     195                convertBoolean( attr["xkeepratio"] ), 
     196                convertBoolean( attr["ykeepratio"] ), attr["visible"], 
    193197                attr["up"], attr["down"], attr["over"], attr["action"], 
    194198                attr["tooltiptext"], attr["help"], 
     
    209213        CheckDefault( "lefttop", "lefttop" ); 
    210214        CheckDefault( "rightbottom", "lefttop" ); 
     215        CheckDefault( "xkeepratio", "false" ); 
     216        CheckDefault( "ykeepratio", "false" ); 
    211217        CheckDefault( "down1", "none" ); 
    212218        CheckDefault( "over1", "none" ); 
     
    221227        const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ), 
    222228                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, 
    223                 attr["lefttop"], attr["rightbottom"], attr["visible"], 
     229                attr["lefttop"], attr["rightbottom"], 
     230                convertBoolean( attr["xkeepratio"] ), 
     231                convertBoolean( attr["ykeepratio"] ), attr["visible"], 
    224232                attr["up1"], attr["down1"], attr["over1"], 
    225233                attr["up2"], attr["down2"], attr["over2"], attr["state"], 
     
    262270        CheckDefault( "lefttop", "lefttop" ); 
    263271        CheckDefault( "rightbottom", "lefttop" ); 
     272        CheckDefault( "xkeepratio", "false" ); 
     273        CheckDefault( "ykeepratio", "false" ); 
    264274        CheckDefault( "action", "none" ); 
    265275        CheckDefault( "action2", "none" ); 
     
    269279        const BuilderData::Image imageData( uniqueId( attr["id"] ), 
    270280                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, 
    271                 attr["lefttop"], attr["rightbottom"], attr["visible"], 
     281                attr["lefttop"], attr["rightbottom"], 
     282                convertBoolean( attr["xkeepratio"] ), 
     283                convertBoolean( attr["ykeepratio"] ), attr["visible"], 
    272284                attr["image"], attr["action"], attr["action2"], attr["resize"], 
    273285                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); 
     
    306318        CheckDefault( "lefttop", "lefttop" ); 
    307319        CheckDefault( "rightbottom", "lefttop" ); 
     320        CheckDefault( "xkeepratio", "false" ); 
     321        CheckDefault( "ykeepratio", "false" ); 
    308322        CheckDefault( "bgimage", "none" ); 
    309323        CheckDefault( "itemimage", "none" ); 
     
    322336                atoi( attr["width"]), atoi( attr["height"] ), 
    323337                attr["lefttop"], attr["rightbottom"], 
     338                convertBoolean( attr["xkeepratio"] ), 
     339                convertBoolean( attr["ykeepratio"] ), 
    324340                attr["font"], "playtree", 
    325341                attr["bgimage"], attr["itemimage"], 
     
    346362        CheckDefault( "lefttop", "lefttop" ); 
    347363        CheckDefault( "rightbottom", "lefttop" ); 
     364        CheckDefault( "xkeepratio", "false" ); 
     365        CheckDefault( "ykeepratio", "false" ); 
    348366        CheckDefault( "bgimage", "none" ); 
    349367        CheckDefault( "itemimage", "none" ); 
     
    363381                atoi( attr["width"]), atoi( attr["height"] ), 
    364382                attr["lefttop"], attr["rightbottom"], 
     383                convertBoolean( attr["xkeepratio"] ), 
     384                convertBoolean( attr["ykeepratio"] ), 
    365385                attr["font"], "playtree", 
    366386                attr["bgimage"], attr["itemimage"], 
     
    384404        CheckDefault( "lefttop", "lefttop" ); 
    385405        CheckDefault( "rightbottom", "lefttop" ); 
     406        CheckDefault( "xkeepratio", "false" ); 
     407        CheckDefault( "ykeepratio", "false" ); 
    386408        CheckDefault( "minangle", "0" ); 
    387409        CheckDefault( "maxangle", "360" ); 
     
    393415                attr["visible"], 
    394416                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, 
    395                 attr["lefttop"], attr["rightbottom"], attr["sequence"], 
     417                attr["lefttop"], attr["rightbottom"], 
     418                convertBoolean( attr["xkeepratio"] ), 
     419                convertBoolean( attr["ykeepratio"] ), attr["sequence"], 
    396420                atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI /180, 
    397421                atof( attr["maxAngle"] ) * M_PI / 180, attr["value"], 
     
    414438        CheckDefault( "lefttop", "lefttop" ); 
    415439        CheckDefault( "rightbottom", "lefttop" ); 
     440        CheckDefault( "xkeepratio", "false" ); 
     441        CheckDefault( "ykeepratio", "false" ); 
    416442        CheckDefault( "down", "none" ); 
    417443        CheckDefault( "over", "none" ); 
     
    430456                attr["visible"], atoi( attr["x"] ) + m_xOffset, 
    431457                atoi( attr["y"] ) + m_yOffset, attr["lefttop"], 
    432                 attr["rightbottom"], attr["up"], attr["down"], 
     458                attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), 
     459                convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"], 
    433460                attr["over"], attr["points"], atoi( attr["thickness"] ), 
    434461                newValue, "none", 0, 0, 0, 0, attr["tooltiptext"], 
     
    470497        CheckDefault( "lefttop", "lefttop" ); 
    471498        CheckDefault( "rightbottom", "lefttop" ); 
     499        CheckDefault( "xkeepratio", "false" ); 
     500        CheckDefault( "ykeepratio", "false" ); 
    472501        CheckDefault( "help", "" ); 
    473502 
     
    477506                attr["text"], atoi( attr["width"] ), 
    478507                attr["lefttop"], attr["rightbottom"], 
     508                convertBoolean( attr["xkeepratio"] ), 
     509                convertBoolean( attr["ykeepratio"] ), 
    479510                convertColor( attr["color"] ), 
    480511                attr["scrolling"], attr["alignment"], 
     
    523554        CheckDefault( "lefttop", "lefttop" ); 
    524555        CheckDefault( "rightbottom", "lefttop" ); 
     556        CheckDefault( "xkeepratio", "false" ); 
     557        CheckDefault( "ykeepratio", "false" ); 
    525558        CheckDefault( "autoresize", "false" ); 
    526559        CheckDefault( "help", "" ); 
     
    530563                atoi( attr["width"] ), atoi( attr["height" ]), 
    531564                attr["lefttop"], attr["rightbottom"], 
     565                convertBoolean( attr["xkeepratio"] ), 
     566                convertBoolean( attr["ykeepratio"] ), 
    532567                attr["visible"], convertBoolean( attr["autoresize"] ), 
    533568                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); 
  • modules/gui/skins2/utils/position.cpp

    radc858d rdda858d  
    3636 
    3737Position::Position( int left, int top, int right, int bottom, const Box &rBox, 
    38                     Ref_t refLeftTop, Ref_t refRightBottom ): 
     38                    Ref_t refLeftTop, Ref_t refRightBottom, bool xKeepRatio, 
     39                    bool yKeepRatio ): 
    3940    m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom ), 
    4041    m_rBox( rBox ), m_refLeftTop( refLeftTop ), 
    41     m_refRighBottom( refRightBottom ) 
    42 
     42    m_refRighBottom( refRightBottom ), m_xKeepRatio( xKeepRatio ), 
     43    m_yKeepRatio( yKeepRatio ) 
     44
     45    // Here is how the resizing algorithm works: 
     46    // 
     47    //  - if we "keep the ratio" (xkeepratio="true" in the XML), the relative 
     48    //    position of the control in the layout (i.e. the given rBox) is 
     49    //    saved, and will be kept constant. The size of the control will not 
     50    //    be changed, only its position may vary. To do that, we consider the 
     51    //    part of the layout to the left of the control (for an horizontal 
     52    //    resizing) and the part of the layout to the right of the control, 
     53    //    and we make sure that the ratio between their widths is constant. 
     54    // 
     55    //  - if we don't keep the ratio, the resizing algorithm is completely 
     56    //    different. We consider that the top left hand corner of the control 
     57    //    ("lefttop" attribute in the XML) is linked to one of the 4 corners 
     58    //    of the layouts ("lefttop", "leftbottom", "righttop" and 
     59    //    "rightbottom" values for the attribute). Same thing for the bottom 
     60    //    right hand corner ("rightbottom" attribute). When resizing occurs, 
     61    //    the linked corners will move together, and this will drive the 
     62    //    moving/resizing of the control. 
     63 
     64    // Initialize the horizontal ratio 
     65    if( m_xKeepRatio ) 
     66    { 
     67        // First compute the width of the box minus the width of the control 
     68        int freeSpace = m_rBox.getWidth() - (m_right - m_left); 
     69        // Instead of computing left/right, we compute left/(left+right), 
     70        // which is more convenient in my opinion. 
     71        if( freeSpace != 0 ) 
     72        { 
     73            m_xRatio = (double)m_left / (double)freeSpace; 
     74        } 
     75        else 
     76        { 
     77            // If the control has the same size as the box, we can't compute 
     78            // the ratio in the same way (otherwise we would divide by zero). 
     79            // So we consider that the intent was to keep the control centered 
     80            // (if you are unhappy with this, go and fix your skin :)) 
     81            m_xRatio = 0.5; 
     82        } 
     83    } 
     84 
     85    // Initial the vertical ratio 
     86    if( m_yKeepRatio ) 
     87    { 
     88        // First compute the width of the box minus the width of the control 
     89        int freeSpace = m_rBox.getHeight() - (m_bottom - m_top); 
     90        // Instead of computing left/right, we compute left/(left+right), 
     91        // which is more convenient in my opinion. 
     92        if( freeSpace != 0 ) 
     93        { 
     94            m_yRatio = (double)m_top / (double)freeSpace; 
     95        } 
     96        else 
     97        { 
     98            // If the control has the same size as the box, we can't compute 
     99            // the ratio in the same way (otherwise we would divide by zero). 
     100            // So we consider that the intent was to keep the control centered 
     101            // (if you are unhappy with this, go and fix your skin :)) 
     102            m_yRatio = 0.5; 
     103        } 
     104    } 
     105 
    43106} 
    44107 
     
    46109int Position::getLeft() const 
    47110{ 
    48     switch( m_refLeftTop ) 
    49     { 
    50         case kLeftTop: 
    51         case kLeftBottom: 
    52             return m_left; 
    53             break; 
    54         case kRightTop: 
    55         case kRightBottom: 
    56             return m_rBox.getWidth() + m_left - 1; 
    57             break; 
    58     } 
    59     // Avoid a warning 
    60     return 0; 
     111    if( m_xKeepRatio ) 
     112    { 
     113        // Ratio mode 
     114        // First compute the width of the box minus the width of the control 
     115        int freeSpace = m_rBox.getWidth() - (m_right - m_left); 
     116        return (int)(m_xRatio * freeSpace); 
     117    } 
     118    else 
     119    { 
     120        switch( m_refLeftTop ) 
     121        { 
     122            case kLeftTop: 
     123            case kLeftBottom: 
     124                return m_left; 
     125                break; 
     126            case kRightTop: 
     127            case kRightBottom: 
     128                return m_rBox.getWidth() + m_left - 1; 
     129                break; 
     130        } 
     131        // Avoid a warning 
     132        return 0; 
     133    } 
    61134} 
    62135 
     
    64137int Position::getTop() const 
    65138{ 
    66     switch( m_refLeftTop ) 
    67     { 
    68         case kLeftTop: 
    69         case kRightTop: 
    70             return m_top; 
    71             break; 
    72         case kRightBottom: 
    73         case kLeftBottom: 
    74             return m_rBox.getHeight() + m_top - 1; 
    75             break; 
    76     } 
    77     // Avoid a warning 
    78     return 0; 
     139    if( m_yKeepRatio ) 
     140    { 
     141        // Ratio mode 
     142        // First compute the height of the box minus the height of the control 
     143        int freeSpace = m_rBox.getHeight() - (m_bottom - m_top); 
     144        return (int)(m_yRatio * freeSpace); 
     145    } 
     146    else 
     147    { 
     148        switch( m_refLeftTop ) 
     149        { 
     150            case kLeftTop: 
     151            case kRightTop: 
     152                return m_top; 
     153                break; 
     154            case kRightBottom: 
     155            case kLeftBottom: 
     156                return m_rBox.getHeight() + m_top - 1; 
     157                break; 
     158        } 
     159        // Avoid a warning 
     160        return 0; 
     161    } 
    79162} 
    80163 
     
    82165int Position::getRight() const 
    83166{ 
    84     switch( m_refRighBottom ) 
    85     { 
    86         case kLeftTop: 
    87         case kLeftBottom: 
    88             return m_right; 
    89             break; 
    90         case kRightTop: 
    91         case kRightBottom: 
    92             return m_rBox.getWidth() + m_right - 1; 
    93             break; 
    94     } 
    95     // Avoid a warning 
    96     return 0; 
     167    if( m_xKeepRatio ) 
     168    { 
     169        // Ratio mode 
     170        // The width of the control being constant, we can use the result of 
     171        // getLeft() (this will avoid rounding issues). 
     172        return getLeft() + m_right - m_left; 
     173    } 
     174    else 
     175    { 
     176        switch( m_refRighBottom ) 
     177        { 
     178            case kLeftTop: 
     179            case kLeftBottom: 
     180                return m_right; 
     181                break; 
     182            case kRightTop: 
     183            case kRightBottom: 
     184                return m_rBox.getWidth() + m_right - 1; 
     185                break; 
     186        } 
     187        // Avoid a warning 
     188        return 0; 
     189    } 
    97190} 
    98191 
     
    100193int Position::getBottom() const 
    101194{ 
    102     switch( m_refRighBottom ) 
    103     { 
    104         case kLeftTop: 
    105         case kRightTop: 
    106             return m_bottom; 
    107             break; 
    108         case kLeftBottom: 
    109         case kRightBottom: 
    110             return m_rBox.getHeight() + m_bottom - 1; 
    111             break; 
    112     } 
    113     // Avoid a warning 
    114     return 0; 
     195    if( m_yKeepRatio ) 
     196    { 
     197        // Ratio mode 
     198        // The height of the control being constant, we can use the result of 
     199        // getTop() (this will avoid rounding issues). 
     200        return getTop() + m_bottom - m_top; 
     201    }&n