Changeset dda858d436bceafa45b834836a6dd302ad7da181
- Timestamp:
- 08/05/06 15:37:06 (2 years ago)
- git-parent:
- Files:
-
- doc/skins/skins2-howto.xml (modified) (3 diffs)
- modules/gui/skins2/parser/builder.cpp (modified) (11 diffs)
- modules/gui/skins2/parser/builder.hpp (modified) (1 diff)
- modules/gui/skins2/parser/builder_data.def (modified) (1 diff)
- modules/gui/skins2/parser/builder_data.hpp (modified) (13 diffs)
- modules/gui/skins2/parser/skin_parser.cpp (modified) (18 diffs)
- modules/gui/skins2/utils/position.cpp (modified) (5 diffs)
- modules/gui/skins2/utils/position.hpp (modified) (2 diffs)
- share/skins2/skin.dtd (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/skins/skins2-howto.xml
re99be2d rdda858d 399 399 <sect4 id="anchorrange"> 400 400 <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> 402 402 <para>Default value: 10</para> 403 403 </sect4> … … 407 407 <sect3 id="commattr"> 408 408 <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, Play tree, Video)</para>409 <para>The following attributes are common to all the controls (Image, Button, Checkbox, Text, Slider, RadialSlider, Playlist, Playtree, Video)</para> 410 410 <sect4 id="attrid"> 411 411 <title>id</title> … … 437 437 <para>Indicate to which corner of the Layout the bottom-right-hand corner of this control is attached, in case of resizing.</para> 438 438 <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> 439 451 </sect4> 440 452 <sect4 id="help"> modules/gui/skins2/parser/builder.cpp
r4809df7 rdda858d 431 431 rData.m_xPos, rData.m_yPos, 432 432 pBmpUp->getWidth(), 433 pBmpUp->getHeight(), *pLayout ); 433 pBmpUp->getHeight(), *pLayout, 434 rData.m_xKeepRatio, rData.m_yKeepRatio ); 434 435 435 436 pLayout->addControl( pButton, pos, rData.m_layer ); … … 506 507 rData.m_xPos, rData.m_yPos, 507 508 pBmpUp1->getWidth(), 508 pBmpUp1->getHeight(), *pLayout ); 509 pBmpUp1->getHeight(), *pLayout, 510 rData.m_xKeepRatio, rData.m_yKeepRatio ); 509 511 510 512 pLayout->addControl( pCheckbox, pos, rData.m_layer ); … … 552 554 // Compute the position of the control 553 555 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 ); 557 560 558 561 // XXX: test to be changed! XXX … … 661 664 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 662 665 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 ); 665 668 666 669 pLayout->addControl( pText, pos, rData.m_layer ); … … 709 712 // XXX: resizing is not supported 710 713 // 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 ); 715 720 716 721 pLayout->addControl( pRadial, pos, rData.m_layer ); … … 773 778 rData.m_xPos, rData.m_yPos, 774 779 pCurve->getWidth(), pCurve->getHeight(), 775 *pLayout ); 780 *pLayout, 781 rData.m_xKeepRatio, rData.m_yKeepRatio ); 776 782 777 783 pLayout->addControl( pBackground, pos, rData.m_layer ); … … 853 859 rData.m_xPos, rData.m_yPos, 854 860 rData.m_width, rData.m_height, 855 *pLayout ); 861 *pLayout, 862 rData.m_xKeepRatio, rData.m_yKeepRatio ); 856 863 857 864 pLayout->addControl( pList, pos, rData.m_layer ); … … 917 924 rData.m_xPos, rData.m_yPos, 918 925 rData.m_width, rData.m_height, 919 *pLayout ); 926 *pLayout, 927 rData.m_xKeepRatio, rData.m_yKeepRatio ); 920 928 921 929 pLayout->addControl( pTree, pos, rData.m_layer ); … … 946 954 rData.m_xPos, rData.m_yPos, 947 955 rData.m_width, rData.m_height, 948 *pLayout ); 956 *pLayout, 957 rData.m_xKeepRatio, rData.m_yKeepRatio ); 949 958 950 959 pLayout->addControl( pVideo, pos, rData.m_layer ); … … 957 966 const string &rRightBottom, 958 967 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 960 970 { 961 971 int left = 0, top = 0, right = 0, bottom = 0; … … 1019 1029 1020 1030 return Position( left, top, right, bottom, rBox, refLeftTop, 1021 refRightBottom );1031 refRightBottom, xKeepRatio, yKeepRatio ); 1022 1032 } 1023 1033 modules/gui/skins2/parser/builder.hpp
ra5a9346 rdda858d 91 91 const string &rRightBottom, 92 92 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; 94 95 95 96 // Build the full path of a file modules/gui/skins2/parser/builder_data.def
r24648f4 rdda858d 10 10 Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string 11 11 Anchor 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:string13 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:string14 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:string12 Button 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 13 Checkbox 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 14 Image 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 15 15 IniFile 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:string17 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:string18 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:string19 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:string20 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:string21 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:string16 Text 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 17 RadialSlider 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 18 Slider 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 19 List 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 20 Tree 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 21 Video 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 204 204 struct Button 205 205 { 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 ): 207 m_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; 214 216 string m_visible; 215 217 string m_upId; … … 229 231 struct Checkbox 230 232 { 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 ): 234 m_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; 239 243 string m_visible; 240 244 string m_up1Id; … … 260 264 struct Image 261 265 { 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 ): 267 m_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; 270 276 string m_visible; 271 277 string m_bmpId; … … 296 302 struct Text 297 303 { 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 ): 305 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_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 ) {} 300 306 301 307 string m_id; … … 308 314 string m_leftTop; 309 315 string m_rightBottom; 316 bool m_xKeepRatio; 317 bool m_yKeepRatio; 310 318 uint32_t m_color; 311 319 string m_scrolling; … … 322 330 struct RadialSlider 323 331 { 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 ): 333 m_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; 333 343 string m_sequence; 334 344 int m_nbImages; … … 348 358 struct Slider 349 359 { 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 ): 361 m_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; 359 371 string m_upId; 360 372 string m_downId; … … 380 392 struct List 381 393 { 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 ): 395 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_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 ) {} 384 396 385 397 string m_id; … … 391 403 string m_leftTop; 392 404 string m_rightBottom; 405 bool m_xKeepRatio; 406 bool m_yKeepRatio; 393 407 string m_fontId; 394 408 string m_var; … … 410 424 struct Tree 411 425 { 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 ): 427 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_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 ) {} 414 428 415 429 string m_id; … … 422 436 string m_leftTop; 423 437 string m_rightBottom; 438 bool m_xKeepRatio; 439 bool m_yKeepRatio; 424 440 string m_fontId; 425 441 string m_var; … … 444 460 struct Video 445 461 { 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 ): 463 m_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 ) {} 448 464 449 465 string m_id; … … 454 470 string m_leftTop; 455 471 string m_rightBottom; 472 bool m_xKeepRatio; 473 bool m_yKeepRatio; 456 474 string m_visible; 457 475 bool m_autoResize; modules/gui/skins2/parser/skin_parser.cpp
r24648f4 rdda858d 182 182 CheckDefault( "lefttop", "lefttop" ); 183 183 CheckDefault( "rightbottom", "lefttop" ); 184 CheckDefault( "xkeepratio", "false" ); 185 CheckDefault( "ykeepratio", "false" ); 184 186 CheckDefault( "down", "none" ); 185 187 CheckDefault( "over", "none" ); … … 190 192 const BuilderData::Button button( uniqueId( attr["id"] ), 191 193 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"], 193 197 attr["up"], attr["down"], attr["over"], attr["action"], 194 198 attr["tooltiptext"], attr["help"], … … 209 213 CheckDefault( "lefttop", "lefttop" ); 210 214 CheckDefault( "rightbottom", "lefttop" ); 215 CheckDefault( "xkeepratio", "false" ); 216 CheckDefault( "ykeepratio", "false" ); 211 217 CheckDefault( "down1", "none" ); 212 218 CheckDefault( "over1", "none" ); … … 221 227 const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ), 222 228 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"], 224 232 attr["up1"], attr["down1"], attr["over1"], 225 233 attr["up2"], attr["down2"], attr["over2"], attr["state"], … … 262 270 CheckDefault( "lefttop", "lefttop" ); 263 271 CheckDefault( "rightbottom", "lefttop" ); 272 CheckDefault( "xkeepratio", "false" ); 273 CheckDefault( "ykeepratio", "false" ); 264 274 CheckDefault( "action", "none" ); 265 275 CheckDefault( "action2", "none" ); … … 269 279 const BuilderData::Image imageData( uniqueId( attr["id"] ), 270 280 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"], 272 284 attr["image"], attr["action"], attr["action2"], attr["resize"], 273 285 attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); … … 306 318 CheckDefault( "lefttop", "lefttop" ); 307 319 CheckDefault( "rightbottom", "lefttop" ); 320 CheckDefault( "xkeepratio", "false" ); 321 CheckDefault( "ykeepratio", "false" ); 308 322 CheckDefault( "bgimage", "none" ); 309 323 CheckDefault( "itemimage", "none" ); … … 322 336 atoi( attr["width"]), atoi( attr["height"] ), 323 337 attr["lefttop"], attr["rightbottom"], 338 convertBoolean( attr["xkeepratio"] ), 339 convertBoolean( attr["ykeepratio"] ), 324 340 attr["font"], "playtree", 325 341 attr["bgimage"], attr["itemimage"], … … 346 362 CheckDefault( "lefttop", "lefttop" ); 347 363 CheckDefault( "rightbottom", "lefttop" ); 364 CheckDefault( "xkeepratio", "false" ); 365 CheckDefault( "ykeepratio", "false" ); 348 366 CheckDefault( "bgimage", "none" ); 349 367 CheckDefault( "itemimage", "none" ); … … 363 381 atoi( attr["width"]), atoi( attr["height"] ), 364 382 attr["lefttop"], attr["rightbottom"], 383 convertBoolean( attr["xkeepratio"] ), 384 convertBoolean( attr["ykeepratio"] ), 365 385 attr["font"], "playtree", 366 386 attr["bgimage"], attr["itemimage"], … … 384 404 CheckDefault( "lefttop", "lefttop" ); 385 405 CheckDefault( "rightbottom", "lefttop" ); 406 CheckDefault( "xkeepratio", "false" ); 407 CheckDefault( "ykeepratio", "false" ); 386 408 CheckDefault( "minangle", "0" ); 387 409 CheckDefault( "maxangle", "360" ); … … 393 415 attr["visible"], 394 416 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"], 396 420 atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI /180, 397 421 atof( attr["maxAngle"] ) * M_PI / 180, attr["value"], … … 414 438 CheckDefault( "lefttop", "lefttop" ); 415 439 CheckDefault( "rightbottom", "lefttop" ); 440 CheckDefault( "xkeepratio", "false" ); 441 CheckDefault( "ykeepratio", "false" ); 416 442 CheckDefault( "down", "none" ); 417 443 CheckDefault( "over", "none" ); … … 430 456 attr["visible"], atoi( attr["x"] ) + m_xOffset, 431 457 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"], 433 460 attr["over"], attr["points"], atoi( attr["thickness"] ), 434 461 newValue, "none", 0, 0, 0, 0, attr["tooltiptext"], … … 470 497 CheckDefault( "lefttop", "lefttop" ); 471 498 CheckDefault( "rightbottom", "lefttop" ); 499 CheckDefault( "xkeepratio", "false" ); 500 CheckDefault( "ykeepratio", "false" ); 472 501 CheckDefault( "help", "" ); 473 502 … … 477 506 attr["text"], atoi( attr["width"] ), 478 507 attr["lefttop"], attr["rightbottom"], 508 convertBoolean( attr["xkeepratio"] ), 509 convertBoolean( attr["ykeepratio"] ), 479 510 convertColor( attr["color"] ), 480 511 attr["scrolling"], attr["alignment"], … … 523 554 CheckDefault( "lefttop", "lefttop" ); 524 555 CheckDefault( "rightbottom", "lefttop" ); 556 CheckDefault( "xkeepratio", "false" ); 557 CheckDefault( "ykeepratio", "false" ); 525 558 CheckDefault( "autoresize", "false" ); 526 559 CheckDefault( "help", "" ); … … 530 563 atoi( attr["width"] ), atoi( attr["height" ]), 531 564 attr["lefttop"], attr["rightbottom"], 565 convertBoolean( attr["xkeepratio"] ), 566 convertBoolean( attr["ykeepratio"] ), 532 567 attr["visible"], convertBoolean( attr["autoresize"] ), 533 568 attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); modules/gui/skins2/utils/position.cpp
radc858d rdda858d 36 36 37 37 Position::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 ): 39 40 m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom ), 40 41 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 43 106 } 44 107 … … 46 109 int Position::getLeft() const 47 110 { 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 } 61 134 } 62 135 … … 64 137 int Position::getTop() const 65 138 { 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 } 79 162 } 80 163 … … 82 165 int Position::getRight() const 83 166 { 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 } 97 190 } 98 191 … … 100 193 int Position::getBottom() const 101 194 { 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
