From: Olivier Teulière Date: Sun, 28 Jan 2007 16:49:30 +0000 (+0000) Subject: * skins2: X-Git-Tag: 0.9.0-test0~8772 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8086b07cf076736d43c955c00c4cbb1464e53dd7;p=vlc * skins2: - New Panel tag, allowing to group the resizing behaviour of controls - Documentation updated accordingly - Fixed a memory leak due to CtrlMove/CtrlResize objects --- diff --git a/doc/skins/skins2-howto.xml b/doc/skins/skins2-howto.xml index 0fb610baab..55db43dc2d 100644 --- a/doc/skins/skins2-howto.xml +++ b/doc/skins/skins2-howto.xml @@ -65,24 +65,6 @@ difficulty to understand how VLC skins work. - -Bezier curves - -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! - -This is not the place to explain how Bezier curves work (see http://astronomy.swin.edu.au/~pbourke/curves/bezier/ 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 CurveMaker utility for example), you just need to enter the list of points in the points attribute. Here is an example with 3 points: points="(2,50),(45,120),(88,50)". - -Bezier curves can be used with the Slider and Anchor tags: - - - 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 Slider you need to provide it yourself using the Image tag. - 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 :)). - - -The coordinates are relative to the upper-left corner of the control (i.e. to its x and y attributes). - - - The bitmaps @@ -321,12 +303,12 @@ difficulty to understand how VLC skins work. width - 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. + 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. Required. height - 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. + 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. Required. @@ -353,25 +335,63 @@ difficulty to understand how VLC skins work. Group - Adds 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 Layout tag). Group tags can be nested. + 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 Layout tag). Group tags can be nested. Note that Group elements are deprecated, since Panel elements are more powerful. x - Try and guess. + Horizontal offset, relative to the container box (see the Layout model for more details). Default value: 0 y - What do you think? + Vertical offset, relative to the container box (see the Layout model for more details). Default value: 0 + + Panel + A Panel can be seen as an enhanced Group. 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. + See the common attributes. + + x + Same as the x attribute of the common attributes. + + + y + Same as the y attribute of the common attributes. + + + width + Initial width of this container box (see the Layout model for more details). + + + height + Initial height of this container box (see the Layout model for more details). + + + lefttop + Same as the lefttop attribute of the common attributes. + + + rightbottom + Same as the rightbottom attribute of the common attributes. + + + xkeepratio + Same as the xkeepratio attribute of the common attributes. + + + ykeepratio + Same as the ykeepratio attribute of the common attributes. + + + Anchor Create a "magnetic point" (or curve) in the current window. If an anchor of another window enters in the range of action of this anchor, the 2 anchors will automatically be on the same place, and the windows are "sticked". Each anchor has a priority (priority attribute), and the anchor with the highest priority is the winner, which means that when moving its window all the other anchored windows will move too. To break the effect of 2 anchored windows, you need to move the window whose anchor has the lower priority. x - Is it really necessary to explain ? + Is it really necessary to explain? Default value: 0 @@ -419,34 +439,34 @@ difficulty to understand how VLC skins work. x - Horizontal offset of the control, relative to the parent tag (usually Group or Layout). + Horizontal offset of the control, relative to the container box (see the Layout model) or to the parent Group. Default value: 0 y - Vertical offset of the control, relative to the parent tag (usually Group or Layout). + Vertical offset of the control, relative to the container box (see the Layout model) or to the parent Group. Default value: 0 lefttop - 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'. + 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 Layout model for more details. Default value: lefttop rightbottom - Indicate to which corner of the Layout the bottom-right-hand corner of this control is attached, in case of resizing. + Indicate to which corner of the container box the bottom-right-hand corner of this control is attached, in case of resizing. See the Layout model for more details. Default value: lefttop xkeepratio - When set to true, the behaviour of the horizontal resizing is changed. Instead of taking into account the lefttop and rightbottom attributes to determine how the control will be moved/resized, only its initial position inside the Layout 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. - 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. + When set to true, the behaviour of the horizontal resizing is changed. Instead of taking into account the lefttop and rightbottom 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. + 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 Layout model for more details. Available since VLC 0.8.6. Default value: false ykeepratio When set to true, the behaviour of the vertical resizing is changed. Instead of taking into account the lefttop and rightbottom attributes to determine how the control will be moved/resized, only its initial position inside the Layout 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. - 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. + 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 Layout model for more details. Available since VLC 0.8.6. Default value: false @@ -1114,6 +1134,38 @@ difficulty to understand how VLC skins work. + +Layout model + +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. + +There are 2 kinds of boxes: + + + + simple boxes: These boxes cannot contain other boxes. All the visible controls are simple boxes: Image, Button, Checkbox, Text, Slider, RadialSlider, Playlist, Playtree, Video. + + + container boxes: These boxes can contain other boxes. Only two XML tags create container boxes: Panel and Layout. The Layout tag is necessarily the top-level box for the current layout, and cannot be contained, but Panel elements can be contained. + + + +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): + + + corners anchoring: 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! + + This mechanism is controlled by the lefttop and rightbottom attributes of the controls. + + + constant ratio: 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). + + This mechanism is controlled by the xkeepratio and ykeepratio attributes of the controls. + + + + + @@ -1136,6 +1188,24 @@ difficulty to understand how VLC skins work. + +Bezier curves + +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! + +This is not the place to explain how Bezier curves work (see http://astronomy.swin.edu.au/~pbourke/curves/bezier/ 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 CurveMaker utility for example), you just need to enter the list of points in the points attribute. Here is an example with 3 points: points="(2,50),(45,120),(88,50)". + +Bezier curves can be used with the Slider and Anchor tags: + + + 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 Slider you need to provide it yourself using a SliderBackground or Image tag. + 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 :)). + + +The coordinates are relative to the upper-left corner of the control (i.e. to its x and y attributes). + + + Tools and advice @@ -1143,7 +1213,7 @@ difficulty to understand how VLC skins work. Generating Bezier curves -To generate easily Bezier curves, you can use the curve-maker (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 points attribute of your Slider or Playlist. 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. +To generate easily Bezier curves, you can use the CurveMaker 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 points attribute of your Slider or Anchor. 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. This tool was made for the first version of the skins and has not been modified since then. This explains why it does not use PNG files and why it does not generate directly the value of the points attribute. diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index f35f844992..7acddf2b31 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -107,6 +107,7 @@ Theme *Builder::build() // (at least) can give a valid window handle to the OSPopup objects ADD_OBJECTS( PopupMenu ); ADD_OBJECTS( Layout ); + ADD_OBJECTS( Panel ); ADD_OBJECTS( Anchor ); ADD_OBJECTS( Button ); ADD_OBJECTS( Checkbox ); @@ -138,6 +139,25 @@ Theme *Builder::build() } \ } + +// Macro to get the parent box of a control, given the panel ID +#define GET_BOX( pRect, id, pLayout ) \ + if( id == "none" ) \ + pRect = &pLayout->getRect(); \ + else \ + { \ + const Position *pParent = \ + m_pTheme->getPositionById( rData.m_panelId ); \ + if( pParent == NULL ) \ + { \ + msg_Err( getIntf(), "parent panel could not be found: %s", \ + rData.m_panelId.c_str() ); \ + return; \ + } \ + pRect = pParent; \ + } + + void Builder::addTheme( const BuilderData::Theme &rData ) { WindowManager &rManager = m_pTheme->getWindowManager(); @@ -382,7 +402,8 @@ void Builder::addAnchor( const BuilderData::Anchor &rData ) const Position pos = makePosition( rData.m_leftTop, rData.m_leftTop, rData.m_xPos, rData.m_yPos, pCurve->getWidth(), - pCurve->getHeight(), *pLayout ); + pCurve->getHeight(), + pLayout->getRect() ); Anchor *pAnc = new Anchor( getIntf(), pos, rData.m_range, rData.m_priority, *pCurve, *pLayout ); @@ -424,18 +445,19 @@ void Builder::addButton( const BuilderData::Button &rData ) CtrlButton *pButton = new CtrlButton( getIntf(), *pBmpUp, *pBmpOver, *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ), UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton ); // Compute the position of the control // XXX (we suppose all the images have the same size...) + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, pBmpUp->getWidth(), - pBmpUp->getHeight(), *pLayout, + pBmpUp->getHeight(), *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pButton, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton ); } @@ -500,18 +522,19 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData ) *pCommand2, UString( getIntf(), rData.m_tooltip1.c_str() ), UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox ); // Compute the position of the control // XXX (we suppose all the images have the same size...) + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, pBmpUp1->getWidth(), - pBmpUp1->getHeight(), *pLayout, + pBmpUp1->getHeight(), *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pCheckbox, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox ); } @@ -550,20 +573,23 @@ void Builder::addImage( const BuilderData::Image &rData ) (rData.m_resize == "scale" ? CtrlImage::kScale : CtrlImage::kMosaic); CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, *pCommand, resizeMethod, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage ); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, pBmp->getWidth(), pBmp->getHeight(), - *pLayout, rData.m_xKeepRatio, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); - // XXX: test to be changed! XXX if( rData.m_actionId == "move" ) { CtrlMove *pMove = new CtrlMove( getIntf(), m_pTheme->getWindowManager(), *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id + "_move"] = CtrlGenericPtr( pMove ); pLayout->addControl( pMove, pos, rData.m_layer ); } else if( rData.m_actionId == "resizeS" ) @@ -572,6 +598,7 @@ void Builder::addImage( const BuilderData::Image &rData ) m_pTheme->getWindowManager(), *pImage, *pLayout, UString( getIntf(), rData.m_help.c_str() ), pVisible, WindowManager::kResizeS ); + m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); pLayout->addControl( pResize, pos, rData.m_layer ); } else if( rData.m_actionId == "resizeE" ) @@ -580,6 +607,7 @@ void Builder::addImage( const BuilderData::Image &rData ) m_pTheme->getWindowManager(), *pImage, *pLayout, UString( getIntf(), rData.m_help.c_str() ), pVisible, WindowManager::kResizeE ); + m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); pLayout->addControl( pResize, pos, rData.m_layer ); } else if( rData.m_actionId == "resizeSE" ) @@ -588,14 +616,38 @@ void Builder::addImage( const BuilderData::Image &rData ) m_pTheme->getWindowManager(), *pImage, *pLayout, UString( getIntf(), rData.m_help.c_str() ), pVisible, WindowManager::kResizeSE ); + m_pTheme->m_controls[rData.m_id + "_rsz"] = CtrlGenericPtr( pResize ); pLayout->addControl( pResize, pos, rData.m_layer ); } else { pLayout->addControl( pImage, pos, rData.m_layer ); } +} - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage ); + +void Builder::addPanel( const BuilderData::Panel &rData ) +{ + // This method makes the assumption that the Panels are created in the + // order of the XML, because each child Panel expects its parent Panel + // in order to be fully created + + GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId ); + if( pLayout == NULL ) + { + msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); + return; + } + + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); + Position *pPos = + new Position( makePosition( rData.m_leftTop, rData.m_rightBottom, + rData.m_xPos, rData.m_yPos, + rData.m_width, rData.m_height, + *pRect, rData.m_xKeepRatio, + rData.m_yKeepRatio ) ); + m_pTheme->m_positions[rData.m_id] = PositionPtr( pPos ); } @@ -657,13 +709,16 @@ void Builder::addText( const BuilderData::Text &rData ) CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont, UString( getIntf(), rData.m_help.c_str() ), rData.m_color, pVisible, scrolling, alignment ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText ); int height = pFont->getSize(); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, - rData.m_width, height, *pLayout, + rData.m_width, height, *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pText, pos, rData.m_layer ); @@ -671,8 +726,6 @@ void Builder::addText( const BuilderData::Text &rData ) // Set the text of the control UString msg( getIntf(), rData.m_text.c_str() ); pVar->set( msg ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText ); } @@ -708,19 +761,20 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData ) rData.m_minAngle, rData.m_maxAngle, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial ); // XXX: resizing is not supported // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, pSeq->getWidth(), pSeq->getHeight() / rData.m_nbImages, - *pLayout, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pRadial, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial ); } @@ -772,18 +826,19 @@ void Builder::addSlider( const BuilderData::Slider &rData ) *pCurve, *pVar, rData.m_thickness, pBgImage, rData.m_nbHoriz, rData.m_nbVert, rData.m_padHoriz, rData.m_padVert, pVisible, UString( getIntf(), rData.m_help.c_str() ) ); + m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground ); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, pCurve->getWidth(), pCurve->getHeight(), - *pLayout, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pBackground, pos, rData.m_layer ); - m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground ); - // Get the bitmaps of the cursor GenericBitmap *pBmpUp = NULL; GET_BMP( pBmpUp, rData.m_upId ); @@ -799,11 +854,10 @@ void Builder::addSlider( const BuilderData::Slider &rData ) *pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible, UString( getIntf(), rData.m_tooltip.c_str() ), UString( getIntf(), rData.m_help.c_str() ) ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor ); pLayout->addControl( pCursor, pos, rData.m_layer ); - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor ); - // Associate the cursor to the background pBackground->associateCursor( *pCursor ); } @@ -853,17 +907,18 @@ void Builder::addList( const BuilderData::List &rData ) CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont, pBgBmp, fgColor, playColor, bgColor1, bgColor2, selColor, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList ); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, rData.m_width, rData.m_height, - *pLayout, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pList, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList ); } void Builder::addTree( const BuilderData::Tree &rData ) @@ -918,17 +973,18 @@ void Builder::addTree( const BuilderData::Tree &rData ) pItemBmp, pOpenBmp, pClosedBmp, fgColor, playColor, bgColor1, bgColor2, selColor, UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pTree ); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, rData.m_width, rData.m_height, - *pLayout, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pTree, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pTree ); } void Builder::addVideo( const BuilderData::Video &rData ) @@ -948,32 +1004,33 @@ void Builder::addVideo( const BuilderData::Video &rData ) CtrlVideo *pVideo = new CtrlVideo( getIntf(), *pLayout, rData.m_autoResize, UString( getIntf(), rData.m_help.c_str() ), pVisible ); + m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo ); // Compute the position of the control + const GenericRect *pRect; + GET_BOX( pRect, rData.m_panelId , pLayout); const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos, rData.m_yPos, rData.m_width, rData.m_height, - *pLayout, + *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio ); pLayout->addControl( pVideo, pos, rData.m_layer ); - - m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo ); } const Position Builder::makePosition( const string &rLeftTop, const string &rRightBottom, int xPos, int yPos, int width, - int height, const Box &rBox, + int height, const GenericRect &rRect, bool xKeepRatio, bool yKeepRatio ) const { int left = 0, top = 0, right = 0, bottom = 0; Position::Ref_t refLeftTop = Position::kLeftTop; Position::Ref_t refRightBottom = Position::kLeftTop; - int boxWidth = rBox.getWidth(); - int boxHeight = rBox.getHeight(); + int boxWidth = rRect.getWidth(); + int boxHeight = rRect.getHeight(); // Position of the left top corner if( rLeftTop == "lefttop" ) @@ -1042,7 +1099,7 @@ const Position Builder::makePosition( const string &rLeftTop, bottom = yPos + height; } - return Position( left, top, right, bottom, rBox, refLeftTop, + return Position( left, top, right, bottom, rRect, refLeftTop, refRightBottom, xKeepRatio, yKeepRatio ); } @@ -1101,14 +1158,7 @@ Bezier *Builder::getPoints( const char *pTag ) const { return NULL; } -#if 0 - if( x < 0 || y < 0 ) - { - msg_Err( getIntf(), - "Slider points cannot have negative coordinates!" ); - return NULL; - } -#endif + xBez.push_back( x ); yBez.push_back( y ); pTag += n; diff --git a/modules/gui/skins2/parser/builder.hpp b/modules/gui/skins2/parser/builder.hpp index 49f4b365fd..f771e1c9a7 100644 --- a/modules/gui/skins2/parser/builder.hpp +++ b/modules/gui/skins2/parser/builder.hpp @@ -37,7 +37,7 @@ class Bezier; class CmdGeneric; class GenericFont; class Position; -class Box; +class GenericRect; /// Class for skin construction @@ -79,6 +79,7 @@ class Builder: public SkinObject void addButton( const BuilderData::Button &rData ); void addCheckbox( const BuilderData::Checkbox &rData ); void addImage( const BuilderData::Image &rData ); + void addPanel( const BuilderData::Panel &rData ); void addText( const BuilderData::Text &rData ); void addRadialSlider( const BuilderData::RadialSlider &rData ); void addSlider( const BuilderData::Slider &rData ); @@ -90,7 +91,8 @@ class Builder: public SkinObject const Position makePosition( const string &rLeftTop, const string &rRightBottom, int xPos, int yPos, int width, int height, - const Box &rBox, bool xKeepRatio = false, + const GenericRect &rRect, + bool xKeepRatio = false, bool yKeepRatio = false ) const; // Build the full path of a file diff --git a/modules/gui/skins2/parser/builder_data.def b/modules/gui/skins2/parser/builder_data.def index eebde0e265..5a84045ca1 100644 --- a/modules/gui/skins2/parser/builder_data.def +++ b/modules/gui/skins2/parser/builder_data.def @@ -9,13 +9,14 @@ MenuSeparator pos:int popupId:string Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string Anchor xPos:int yPos:int leftTop:string range:int priority:int points:string layoutId:string -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 -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 -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 +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 +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 +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 IniFile id:string file:string -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 -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 -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 -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 -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 -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 +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 +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 +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 +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 +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 +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 +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 diff --git a/modules/gui/skins2/parser/builder_data.hpp b/modules/gui/skins2/parser/builder_data.hpp index d0c6ec08f0..d4ede19c75 100644 --- a/modules/gui/skins2/parser/builder_data.hpp +++ b/modules/gui/skins2/parser/builder_data.hpp @@ -203,8 +203,8 @@ m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_range( range ), m_priori /// Type definition struct Button { - 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 ): -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 ) {} + 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 ): +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 ) {} string m_id; int m_xPos; @@ -223,6 +223,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( int m_layer; string m_windowId; string m_layoutId; + string m_panelId; }; /// List list