Changeset 8086b07cf076736d43c955c00c4cbb1464e53dd7
- Timestamp:
- 01/28/07 17:49:30 (1 year ago)
- git-parent:
- Files:
-
- doc/skins/skins2-howto.xml (modified) (9 diffs)
- modules/gui/skins2/parser/builder.cpp (modified) (23 diffs)
- modules/gui/skins2/parser/builder.hpp (modified) (3 diffs)
- modules/gui/skins2/parser/builder_data.def (modified) (1 diff)
- modules/gui/skins2/parser/builder_data.hpp (modified) (18 diffs)
- modules/gui/skins2/parser/skin_parser.cpp (modified) (12 diffs)
- modules/gui/skins2/parser/skin_parser.hpp (modified) (1 diff)
- modules/gui/skins2/src/generic_layout.cpp (modified) (5 diffs)
- modules/gui/skins2/src/generic_layout.hpp (modified) (4 diffs)
- modules/gui/skins2/src/theme.cpp (modified) (1 diff)
- modules/gui/skins2/src/theme.hpp (modified) (3 diffs)
- modules/gui/skins2/src/window_manager.cpp (modified) (1 diff)
- modules/gui/skins2/src/window_manager.hpp (modified) (1 diff)
- modules/gui/skins2/utils/position.cpp (modified) (11 diffs)
- modules/gui/skins2/utils/position.hpp (modified) (8 diffs)
- share/skins2/skin.dtd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/skins/skins2-howto.xml
rccd0b04 r8086b07 63 63 <para>Those of you who have already made skins for other software should have no 64 64 difficulty to understand how VLC skins work.</para> 65 66 </sect1>67 68 <sect1 id="bezier">69 <title>Bezier curves</title>70 71 <para>One cool thing with VLC sliders is that they are not necessarily rectilinear, but they can follow any Bezier curve. So if you want to have a slider moving on a half-circle, or even doing a loop, you can!</para>72 73 <para>This is not the place to explain how Bezier curves work (see <ulink url="http://astronomy.swin.edu.au/~pbourke/curves/bezier/">http://astronomy.swin.edu.au/~pbourke/curves/bezier/</ulink> for a nice introduction), the main thing to know is that a Bezier curve can be characterized by a set of points. Once you have them (thanks to the <link linkend="CurveMaker">CurveMaker</link> utility for example<!--XXX: deprecated-->), you just need to enter the list of points in the <link linkend="sliderpoints">points</link> attribute. Here is an example with 3 points: points="(2,50),(45,120),(88,50)".</para>74 75 <para>Bezier curves can be used with the <link linkend="Slider">Slider</link> and <link linkend="Anchor">Anchor</link> tags:</para>76 77 <itemizedlist>78 <listitem><para>For sliders, it defines the curve followed by the cursor of the slider. This curve is of course invisible, so if you want a visible background for your <link linkend="Slider">Slider</link> you need to provide it yourself using the <link linkend="Image">Image</link> tag.</para></listitem>79 <listitem><para>For anchors, the use of Bezier curves is more anecdotic. Its purpose is to have non-ponctual anchor, the whole curve becoming the anchor. In this case, a ponctual anchor (and only a ponctual one) can be attracted by any point of the curve, if it is in its range of action. In fact, you can consider the curve as an easy way to define at once many anchors that share the same properties (except their position, of course :)).</para></listitem>80 </itemizedlist>81 82 <note><para>The coordinates are relative to the upper-left corner of the control (i.e. to its <link linkend="x">x</link> and <link linkend="y">y</link> attributes).</para></note>83 65 84 66 </sect1> … … 322 304 <sect3 id="layoutwidth"> 323 305 <title>width</title> 324 <para><!--TODO: calculate it in VLC :)--> Width of the layout. this value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls.</para>306 <para><!--TODO: calculate it in VLC :)-->Initial width of the layout. This value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls.</para> 325 307 <para><emphasis>Required.</emphasis></para> 326 308 </sect3> 327 309 <sect3 id="layoutheight"> 328 310 <title>height</title> 329 <para><!--TODO: calculate it in VLC :)--> Height of the layout. this value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls.</para>311 <para><!--TODO: calculate it in VLC :)-->Initial height of the layout. This value is required since VLC is not (yet?) able to calculate it using the sizes and positions of the controls.</para> 330 312 <para><emphasis>Required.</emphasis></para> 331 313 </sect3> … … 354 336 <sect2 id="Group"> 355 337 <title>Group</title> 356 <para>Add s an offset to the elements it contains. A Group is only supposed to ease the job of the skin designer, who can adjust the position of a group of controls without modifying all the coordinates, but you can ignore it if you want (only one Group is necessary, inside the <link linkend="Layout">Layout</link> tag). Group tags can be nested.</para>338 <para>Add an offset to the elements it contains. A Group is only supposed to ease the job of the skin designer, who can adjust the position of a group of controls without modifying all the coordinates, but you can ignore it if you want (only one Group is necessary, inside the <link linkend="Layout">Layout</link> tag). Group tags can be nested. Note that Group elements are deprecated, since <link linkend="Panel">Panel</link> elements are more powerful.</para> 357 339 <sect3 id="groupx"> 358 340 <title>x</title> 359 <para> Try and guess.</para>341 <para>Horizontal offset, relative to the container box (see the <link linkend="layoutmodel">Layout model</link> for more details).</para> 360 342 <para>Default value: 0</para> 361 343 </sect3> 362 344 <sect3 id="groupy"> 363 345 <title>y</title> 364 <para>What do you think?</para> 365 <para>Default value: 0</para> 346 <para>Vertical offset, relative to the container box (see the <link linkend="layoutmodel">Layout model</link> for more details).</para> 347 <para>Default value: 0</para> 348 </sect3> 349 </sect2> 350 351 <sect2 id="Panel"> 352 <title>Panel</title> 353 <para>A Panel can be seen as an enhanced <link linkend="Layout">Group</link>. It also adds an offset to the elements it contains, but in addition it becomes their reference for the lefttop, rightbottom, xkeepratio and ykeepratio attributes. Panel tags can be nested. Since VLC 0.9.0.</para> 354 <para>See the <link linkend="commattr">common attributes</link>.</para> 355 <sect3 id="panelx"> 356 <title>x</title> 357 <para>Same as the <link linkend="x">x</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 358 </sect3> 359 <sect3 id="panely"> 360 <title>y</title> 361 <para>Same as the <link linkend="y">y</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 362 </sect3> 363 <sect3 id="panelwidth"> 364 <title>width</title> 365 <para>Initial width of this container box (see the <link linkend="layoutmodel">Layout model</link> for more details).</para> 366 </sect3> 367 <sect3 id="panelheight"> 368 <title>height</title> 369 <para>Initial height of this container box (see the <link linkend="layoutmodel">Layout model</link> for more details).</para> 370 </sect3> 371 <sect3 id="panellefttop"> 372 <title>lefttop</title> 373 <para>Same as the <link linkend="lefttop">lefttop</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 374 </sect3> 375 <sect3 id="panelrightbottom"> 376 <title>rightbottom</title> 377 <para>Same as the <link linkend="rightbottom">rightbottom</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 378 </sect3> 379 <sect3 id="panelxkeepratio"> 380 <title>xkeepratio</title> 381 <para>Same as the <link linkend="xkeepratio">xkeepratio</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 382 </sect3> 383 <sect3 id="panelykeepratio"> 384 <title>ykeepratio</title> 385 <para>Same as the <link linkend="ykeepratio">ykeepratio</link> attribute of the <link linkend="commattr">common attributes</link>.</para> 366 386 </sect3> 367 387 </sect2> … … 372 392 <sect3 id="anchorx"> 373 393 <title>x</title> 374 <para>Is it really necessary to explain ?</para>394 <para>Is it really necessary to explain?</para> 375 395 <para>Default value: 0</para> 376 396 </sect3> … … 420 440 <sect3 id="x"> 421 441 <title>x</title> 422 <para>Horizontal offset of the control, relative to the parent tag (usually <link linkend="Group">Group</link> or <link linkend="Layout">Layout</link>).</para>442 <para>Horizontal offset of the control, relative to the container box (see the <link linkend="layoutmodel">Layout model</link>) or to the parent <link linkend="Group">Group</link>.</para> 423 443 <para>Default value: 0</para> 424 444 </sect3> 425 445 <sect3 id="y"> 426 446 <title>y</title> 427 <para>Vertical offset of the control, relative to the parent tag (usually <link linkend="Group">Group</link> or <link linkend="Layout">Layout</link>).</para>447 <para>Vertical offset of the control, relative to the container box (see the <link linkend="layoutmodel">Layout model</link>) or to the parent <link linkend="Group">Group</link>.</para> 428 448 <para>Default value: 0</para> 429 449 </sect3> 430 450 <sect3 id="lefttop"> 431 451 <title>lefttop</title> 432 <para>Indicate to which corner of the Layout the top-left-hand corner of this control is attached, in case of resizing. Possible values are 'lefttop', 'leftbottom', 'righttop' and 'rightbottom'.</para>452 <para>Indicate to which corner of the container box the top-left-hand corner of this control is attached, in case of resizing. Possible values are 'lefttop', 'leftbottom', 'righttop' and 'rightbottom'. See the <link linkend="layoutmodel">Layout model</link> for more details.</para> 433 453 <para>Default value: lefttop</para> 434 454 </sect3> 435 455 <sect3 id="rightbottom"> 436 456 <title>rightbottom</title> 437 <para>Indicate to which corner of the Layout the bottom-right-hand corner of this control is attached, in case of resizing.</para>457 <para>Indicate to which corner of the container box the bottom-right-hand corner of this control is attached, in case of resizing. See the <link linkend="layoutmodel">Layout model</link> for more details.</para> 438 458 <para>Default value: lefttop</para> 439 459 </sect3> 440 460 <sect3 id="xkeepratio"> 441 461 <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). Available since VLC 0.8.6.</para>462 <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 container box 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> 463 <para>This attribute can be particularly useful to keep a control centered in the container box, without resizing it (to resize it, you would rather use the lefttop/rightbottom attributes). See the <link linkend="layoutmodel">Layout model</link> for more details. Available since VLC 0.8.6.</para> 444 464 <para>Default value: false</para> 445 465 </sect3> … … 447 467 <title>ykeepratio</title> 448 468 <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). Available since VLC 0.8.6.</para>469 <para>This attribute can be particularly useful to keep a control centered in the container box, without resizing it (to resize it, you would rather use the lefttop/rightbottom attributes). See the <link linkend="layoutmodel">Layout model</link> for more details. Available since VLC 0.8.6.</para> 450 470 <para>Default value: false</para> 451 471 </sect3> … … 1115 1135 </sect1> 1116 1136 1137 <sect1 id="layoutmodel"> 1138 <title>Layout model</title> 1139 1140 <para>Placing the controls on a window is easy, using their x and y attributes, but these positions become insufficient for a resizable window. Some controls (or groups of controls) should stay centered in the window, others should follow the right side of the window, others should change their size automatically, etc... To handle these various behaviours, the layout model followed by the skins engine is a model based on nested boxes.</para> 1141 1142 <para>There are 2 kinds of boxes:</para> 1143 1144 <itemizedlist> 1145 <listitem><para> 1146 <emphasis>simple boxes</emphasis>: These boxes cannot contain other boxes. All the visible controls are simple boxes: Image, Button, Checkbox, Text, Slider, RadialSlider, Playlist, Playtree, Video. 1147 </para></listitem> 1148 <listitem><para> 1149 <emphasis>container boxes</emphasis>: These boxes can contain other boxes. Only two XML tags create container boxes: <link linkend="Panel">Panel</link> and <link linkend="Layout">Layout</link>. The Layout tag is necessarily the top-level box for the current layout, and cannot be contained, but Panel elements can be contained. 1150 </para></listitem> 1151 </itemizedlist> 1152 1153 <para>A box inside a container box always defines how it should react when its container box is resized. Two different mechanisms are provided: corners anchoring (useful when resizing of the inner box is wanted, for example) and constant ratio (mainly useful to keep the inner box centered inside its parent):</para> 1154 <itemizedlist> 1155 <listitem><para> 1156 <emphasis>corners anchoring</emphasis>: The top-left-hand corner (TL) and the bottom-right-hand corner (BR) of the inner box are "tied" to corners of the container box (TL, TR, BL or BR). When any resizing occurs, tied corners move together, which can move or resize the inner box. For example, if the TL corner of the inner box is tied to the TL corner of the container (let's write it TL/TL), and if the BR corner of the inner box is also tied to the TL corner of the container box (BR/TL), the inner box will not be resized, and will always stay at the same place (this is the default behaviour). If we have TL/TL and TL/BL, the inner box is resized vertically its container is resized. If we have TL/TR and BR/TR, the inner box moves with the TR corner of its container. We could even define TL/BR and BR/TL, in which case increasing the size of the container box would shrink the size of the inner box... until it disappears completely! 1157 </para> 1158 <para>This mechanism is controlled by the <link linkend="lefttop">lefttop</link> and <link linkend="rightbottom">rightbottom</link> attributes of the controls. 1159 </para></listitem> 1160 <listitem><para> 1161 <emphasis>constant ratio</emphasis>: When a box doesn't fill completely its container box, there is space on the top, bottom, left and right of the inner box. It is possible to force the ratio between the space on the top and the space on the bottom (or the one on the left and the one on the right) to be constant. Any resizing of the container box will then move the inner box accordingly, and the size of the inner box will never change (it overrides the corners anchoring mechanism). The horizontal and vertical ratios being independent, it is for example possible to keep only the horizontal ratio constant, in which case the inner box can still resize vertically (depending on its attributes for the corners anchoring, of course). 1162 </para> 1163 <para>This mechanism is controlled by the <link linkend="xkeepratio">xkeepratio</link> and <link linkend="ykeepratio">ykeepratio</link> attributes of the controls. 1164 </para></listitem> 1165 </itemizedlist> 1166 1167 </sect1> 1168 1117 1169 1118 1170 <sect1> … … 1137 1189 </sect1> 1138 1190 1191 <sect1 id="bezier"> 1192 <title>Bezier curves</title> 1193 1194 <para>One cool thing with VLC sliders is that they are not necessarily rectilinear, but they can follow any Bezier curve. So if you want to have a slider moving on a half-circle, or even doing a loop, you can!</para> 1195 1196 <para>This is not the place to explain how Bezier curves work (see <ulink url="http://astronomy.swin.edu.au/~pbourke/curves/bezier/">http://astronomy.swin.edu.au/~pbourke/curves/bezier/</ulink> for a nice introduction), the main thing to know is that a Bezier curve can be characterized by a set of points. Once you have them (thanks to the <link linkend="CurveMaker">CurveMaker</link> utility for example<!--XXX: deprecated-->), you just need to enter the list of points in the <link linkend="sliderpoints">points</link> attribute. Here is an example with 3 points: points="(2,50),(45,120),(88,50)".</para> 1197 1198 <para>Bezier curves can be used with the <link linkend="Slider">Slider</link> and <link linkend="Anchor">Anchor</link> tags:</para> 1199 1200 <itemizedlist> 1201 <listitem><para>For sliders, it defines the curve followed by the cursor of the slider. This curve is of course invisible, so if you want a visible background for your <link linkend="Slider">Slider</link> you need to provide it yourself using a <link linkend="SliderBackground">SliderBackground</link> or <link linkend="Image">Image</link> tag.</para></listitem> 1202 <listitem><para>For anchors, the use of Bezier curves is more anecdotic. Its purpose is to have non-ponctual anchor, the whole curve becoming the anchor. In this case, a ponctual anchor (and only a ponctual one) can be attracted by any point of the curve, if it is in its range of action. In fact, you can consider the curve as an easy way to define at once many anchors that share the same properties (except their position, of course :)).</para></listitem> 1203 </itemizedlist> 1204 1205 <note><para>The coordinates are relative to the upper-left corner of the control (i.e. to its <link linkend="x">x</link> and <link linkend="y">y</link> attributes).</para></note> 1206 1207 </sect1> 1208 1139 1209 <sect1> 1140 1210 <title>Tools and advice</title> … … 1144 1214 1145 1215 <para> 1146 To generate easily Bezier curves, you can use the <ulink url="/vlc/skins/VLC-curve-maker.exe"> curve-maker</ulink> (sorry, this is for Windows users only). Basically, you add and remove points at will, and you can move them to see how the curve evolves. When you have reached the perfect curve, you just have to copy-paste the list of abscissas and ordinates to form the <link linkend="sliderpoints">points</link> attribute of your <link linkend="Slider">Slider</link> or <link linkend="Playlist">Playlist</link>. The curve-maker also allows to load a .bmp file, this could be useful if you want to follow a specific pattern of a slider, for example.1216 To generate easily Bezier curves, you can use the <ulink url="/vlc/skins/VLC-curve-maker.exe">CurveMaker</ulink> utility (sorry, this is for Windows users only). Basically, you add and remove points at will, and you can move them to see how the curve evolves. When you have reached the perfect curve, you just have to copy-paste the list of abscissas and ordinates to form the <link linkend="sliderpoints">points</link> attribute of your <link linkend="Slider">Slider</link> or <link linkend="Anchor">Anchor</link>. The curve-maker also allows to load a .bmp file, this could be useful if you want to follow a specific pattern of a slider, for example. 1147 1217 </para> 1148 1218 modules/gui/skins2/parser/builder.cpp
rdb7965b r8086b07 108 108 ADD_OBJECTS( PopupMenu ); 109 109 ADD_OBJECTS( Layout ); 110 ADD_OBJECTS( Panel ); 110 111 ADD_OBJECTS( Anchor ); 111 112 ADD_OBJECTS( Button ); … … 138 139 } \ 139 140 } 141 142 143 // Macro to get the parent box of a control, given the panel ID 144 #define GET_BOX( pRect, id, pLayout ) \ 145 if( id == "none" ) \ 146 pRect = &pLayout->getRect(); \ 147 else \ 148 { \ 149 const Position *pParent = \ 150 m_pTheme->getPositionById( rData.m_panelId ); \ 151 if( pParent == NULL ) \ 152 { \ 153 msg_Err( getIntf(), "parent panel could not be found: %s", \ 154 rData.m_panelId.c_str() ); \ 155 return; \ 156 } \ 157 pRect = pParent; \ 158 } 159 140 160 141 161 void Builder::addTheme( const BuilderData::Theme &rData ) … … 383 403 rData.m_xPos, rData.m_yPos, 384 404 pCurve->getWidth(), 385 pCurve->getHeight(), *pLayout ); 405 pCurve->getHeight(), 406 pLayout->getRect() ); 386 407 387 408 Anchor *pAnc = new Anchor( getIntf(), pos, rData.m_range, rData.m_priority, … … 425 446 *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ), 426 447 UString( getIntf(), rData.m_help.c_str() ), pVisible ); 448 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton ); 427 449 428 450 // Compute the position of the control 429 451 // XXX (we suppose all the images have the same size...) 452 const GenericRect *pRect; 453 GET_BOX( pRect, rData.m_panelId , pLayout); 430 454 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 431 455 rData.m_xPos, rData.m_yPos, 432 456 pBmpUp->getWidth(), 433 pBmpUp->getHeight(), *p Layout,457 pBmpUp->getHeight(), *pRect, 434 458 rData.m_xKeepRatio, rData.m_yKeepRatio ); 435 459 436 460 pLayout->addControl( pButton, pos, rData.m_layer ); 437 438 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );439 461 } 440 462 … … 501 523 UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar, 502 524 UString( getIntf(), rData.m_help.c_str() ), pVisible ); 525 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox ); 503 526 504 527 // Compute the position of the control 505 528 // XXX (we suppose all the images have the same size...) 529 const GenericRect *pRect; 530 GET_BOX( pRect, rData.m_panelId , pLayout); 506 531 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 507 532 rData.m_xPos, rData.m_yPos, 508 533 pBmpUp1->getWidth(), 509 pBmpUp1->getHeight(), *p Layout,534 pBmpUp1->getHeight(), *pRect, 510 535 rData.m_xKeepRatio, rData.m_yKeepRatio ); 511 536 512 537 pLayout->addControl( pCheckbox, pos, rData.m_layer ); 513 514 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox );515 538 } 516 539 … … 551 574 CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, *pCommand, 552 575 resizeMethod, UString( getIntf(), rData.m_help.c_str() ), pVisible ); 576 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage ); 553 577 554 578 // Compute the position of the control 579 const GenericRect *pRect; 580 GET_BOX( pRect, rData.m_panelId , pLayout); 555 581 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 556 582 rData.m_xPos, rData.m_yPos, 557 583 pBmp->getWidth(), pBmp->getHeight(), 558 *p Layout, rData.m_xKeepRatio,584 *pRect, rData.m_xKeepRatio, 559 585 rData.m_yKeepRatio ); 560 586 561 // XXX: test to be changed! XXX562 587 if( rData.m_actionId == "move" ) 563 588 { … … 565 590 *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ), 566 591 pVisible ); 592 m_pTheme->m_controls[rData.m_id + "_move"] = CtrlGenericPtr( pMove ); 567 593 pLayout->addControl( pMove, pos, rData.m_layer ); 568 594 } … … 573 599 UString( getIntf(), rData.m_help.c_str() ), pVisible, 574 600 WindowManager::kResizeS ); 601 m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); 575 602 pLayout->addControl( pResize, pos, rData.m_layer ); 576 603 } … … 581 608 UString( getIntf(), rData.m_help.c_str() ), pVisible, 582 609 WindowManager::kResizeE ); 610 m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); 583 611 pLayout->addControl( pResize, pos, rData.m_layer ); 584 612 } … … 589 617 UString( getIntf(), rData.m_help.c_str() ), pVisible, 590 618 WindowManager::kResizeSE ); 619 m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); 591 620 pLayout->addControl( pResize, pos, rData.m_layer ); 592 621 } … … 595 624 pLayout->addControl( pImage, pos, rData.m_layer ); 596 625 } 597 598 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage ); 626 } 627 628 629 void Builder::addPanel( const BuilderData::Panel &rData ) 630 { 631 // This method makes the assumption that the Panels are created in the 632 // order of the XML, because each child Panel expects its parent Panel 633 // in order to be fully created 634 635 GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId ); 636 if( pLayout == NULL ) 637 { 638 msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); 639 return; 640 } 641 642 const GenericRect *pRect; 643 GET_BOX( pRect, rData.m_panelId , pLayout); 644 Position *pPos = 645 new Position( makePosition( rData.m_leftTop, rData.m_rightBottom, 646 rData.m_xPos, rData.m_yPos, 647 rData.m_width, rData.m_height, 648 *pRect, rData.m_xKeepRatio, 649 rData.m_yKeepRatio ) ); 650 m_pTheme->m_positions[rData.m_id] = PositionPtr( pPos ); 599 651 } 600 652 … … 658 710 UString( getIntf(), rData.m_help.c_str() ), rData.m_color, pVisible, 659 711 scrolling, alignment ); 712 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText ); 660 713 661 714 int height = pFont->getSize(); 662 715 663 716 // Compute the position of the control 717 const GenericRect *pRect; 718 GET_BOX( pRect, rData.m_panelId , pLayout); 664 719 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 665 720 rData.m_xPos, rData.m_yPos, 666 rData.m_width, height, *p Layout,721 rData.m_width, height, *pRect, 667 722 rData.m_xKeepRatio, rData.m_yKeepRatio ); 668 723 … … 672 727 UString msg( getIntf(), rData.m_text.c_str() ); 673 728 pVar->set( msg ); 674 675 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );676 729 } 677 730 … … 709 762 UString( getIntf(), rData.m_help.c_str() ), 710 763 pVisible ); 764 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial ); 711 765 712 766 // XXX: resizing is not supported 713 767 // Compute the position of the control 768 const GenericRect *pRect; 769 GET_BOX( pRect, rData.m_panelId , pLayout); 714 770 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 715 771 rData.m_xPos, rData.m_yPos, 716 772 pSeq->getWidth(), 717 773 pSeq->getHeight() / rData.m_nbImages, 718 *p Layout,774 *pRect, 719 775 rData.m_xKeepRatio, rData.m_yKeepRatio ); 720 776 721 777 pLayout->addControl( pRadial, pos, rData.m_layer ); 722 723 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial );724 778 } 725 779 … … 773 827 rData.m_nbVert, rData.m_padHoriz, rData.m_padVert, 774 828 pVisible, UString( getIntf(), rData.m_help.c_str() ) ); 829 m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground ); 775 830 776 831 // Compute the position of the control 832 const GenericRect *pRect; 833 GET_BOX( pRect, rData.m_panelId , pLayout); 777 834 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 778 835 rData.m_xPos, rData.m_yPos, 779 836 pCurve->getWidth(), pCurve->getHeight(), 780 *p Layout,837 *pRect, 781 838 rData.m_xKeepRatio, rData.m_yKeepRatio ); 782 839 783 840 pLayout->addControl( pBackground, pos, rData.m_layer ); 784 785 m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );786 841 787 842 // Get the bitmaps of the cursor … … 800 855 UString( getIntf(), rData.m_tooltip.c_str() ), 801 856 UString( getIntf(), rData.m_help.c_str() ) ); 857 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor ); 802 858 803 859 pLayout->addControl( pCursor, pos, rData.m_layer ); 804 805 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );806 860 807 861 // Associate the cursor to the background … … 854 908 fgColor, playColor, bgColor1, bgColor2, selColor, 855 909 UString( getIntf(), rData.m_help.c_str() ), pVisible ); 910 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList ); 856 911 857 912 // Compute the position of the control 913 const GenericRect *pRect; 914 GET_BOX( pRect, rData.m_panelId , pLayout); 858 915 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 859 916 rData.m_xPos, rData.m_yPos, 860 917 rData.m_width, rData.m_height, 861 *p Layout,918 *pRect, 862 919 rData.m_xKeepRatio, rData.m_yKeepRatio ); 863 920 864 921 pLayout->addControl( pList, pos, rData.m_layer ); 865 866 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList );867 922 } 868 923 … … 919 974 fgColor, playColor, bgColor1, bgColor2, selColor, 920 975 UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat ); 976 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pTree ); 921 977 922 978 // Compute the position of the control 979 const GenericRect *pRect; 980 GET_BOX( pRect, rData.m_panelId , pLayout); 923 981 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 924 982 rData.m_xPos, rData.m_yPos, 925 983 rData.m_width, rData.m_height, 926 *p Layout,984 *pRect, 927 985 rData.m_xKeepRatio, rData.m_yKeepRatio ); 928 986 929 987 pLayout->addControl( pTree, pos, rData.m_layer ); 930 931 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pTree );932 988 } 933 989 … … 949 1005 rData.m_autoResize, UString( getIntf(), rData.m_help.c_str() ), 950 1006 pVisible ); 1007 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo ); 951 1008 952 1009 // Compute the position of the control 1010 const GenericRect *pRect; 1011 GET_BOX( pRect, rData.m_panelId , pLayout); 953 1012 const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, 954 1013 rData.m_xPos, rData.m_yPos, 955 1014 rData.m_width, rData.m_height, 956 *p Layout,1015 *pRect, 957 1016 rData.m_xKeepRatio, rData.m_yKeepRatio ); 958 1017 959 1018 pLayout->addControl( pVideo, pos, rData.m_layer ); 960 961 m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo );962 1019 } 963 1020 … … 966 1023 const string &rRightBottom, 967 1024 int xPos, int yPos, int width, 968 int height, const Box &rBox,1025 int height, const GenericRect &rRect, 969 1026 bool xKeepRatio, bool yKeepRatio ) const 970 1027 { … … 973 1030 Position::Ref_t refRightBottom = Position::kLeftTop; 974 1031 975 int boxWidth = r Box.getWidth();976 int boxHeight = r Box.getHeight();1032 int boxWidth = rRect.getWidth(); 1033 int boxHeight = rRect.getHeight(); 977 1034 978 1035 // Position of the left top corner … … 1043 1100 } 1044 1101 1045 return Position( left, top, right, bottom, r Box, refLeftTop,1102 return Position( left, top, right, bottom, rRect, refLeftTop, 1046 1103 refRightBottom, xKeepRatio, yKeepRatio ); 1047 1104 } … … 1102 1159 return NULL; 1103 1160 } 1104 #if 0 1105 if( x < 0 || y < 0 ) 1106 { 1107 msg_Err( getIntf(), 1108 "Slider points cannot have negative coordinates!" ); 1109 return NULL; 1110 } 1111 #endif 1161 1112 1162 xBez.push_back( x ); 1113 1163 yBez.push_back( y ); modules/gui/skins2/parser/builder.hpp
rdda858d r8086b07 38 38 class GenericFont; 39 39 class Position; 40 class Box;40 class GenericRect; 41 41 42 42 … … 80 80 void addCheckbox( const BuilderData::Checkbox &rData ); 81 81 void addImage( const BuilderData::Image &rData ); 82 void addPanel( const BuilderData::Panel &rData ); 82 83 void addText( const BuilderData::Text &rData ); 83 84 void addRadialSlider( const BuilderData::RadialSlider &rData ); … … 91 92 const string &rRightBottom, 92 93 int xPos, int yPos, int width, int height, 93 const Box &rBox, bool xKeepRatio = false, 94 const GenericRect &rRect, 95 bool xKeepRatio = false, 94 96 bool yKeepRatio = false ) const; 95 97 modules/gui/skins2/parser/builder_data.def
rdda858d r8086b07 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 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 12 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 panelId: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 panelId: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 panelId: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 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 16 Panel id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool width:int height:int layer:int windowId:string layoutId:string panelId:string 17 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 panelId:string 18 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 panelId:string 19 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 panelId:string 20 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 panelId:string 21 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 panelId:string 22 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 panelId:string modules/gui/skins2/parser/builder_data.hpp
rdda858d r8086b07 204 204 struct Button 205 205 { 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 ) {}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, const string & panelId ): 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 ), m_panelId( panelId ) {} 208 208 209 209 string m_id; … … 224 224 string m_windowId; 225 225 string m_layoutId; 226 string m_panelId; 226 227 }; 227 228 /// List … … 231 232 struct Checkbox 232 233 { 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 ) {}234 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, const string & panelId ): 235 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 ), m_panelId( panelId ) {} 235 236 236 237 string m_id; … … 257 258 string m_windowId; 258 259 string m_layoutId; 260 string m_panelId; 259 261 }; 260 262 /// List … … 264 266 struct Image 265 267 { 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 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, const string & panelId ): 269 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 ), m_panelId( panelId ) {} 268 270 269 271 string m_id; … … 283 285 string m_windowId; 284 286 string m_layoutId; 287 string m_panelId; 285 288 }; 286 289 /// List … … 300 303 301 304 /// Type definition 305 struct Panel 306 { 307 Panel( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, int width, int height, int layer, const string & windowId, const string & layoutId, const string & panelId ): 308 m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_width( width ), m_height( height ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ), m_panelId( panelId ) {} 309 310 string m_id; 311 int m_xPos; 312 int m_yPos; 313 string m_leftTop; 314 string m_rightBottom; 315 bool m_xKeepRatio; 316 bool m_yKeepRatio; 317 int m_width; 318 int m_height; 319 int m_layer; 320 string m_windowId; 321 string m_layoutId; 322 string m_panelId; 323 }; 324 /// List 325 list<Panel> m_listPanel; 326 327 /// Type definition 302 328 struct Text 303 329 { 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 ) {}330 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 & w
