vlc | branch: master | Erwan Tulou <[email protected]> | Sat Jun 22 17:24:11 
2013 +0200| [91a9eee8d96f13e26336a72307291f3e716200a0] | committer: Erwan Tulou

skins2: add width/height parameters to slider

These parameters will allow to create a slider which adapts to the display.
width/height parameters will be optional. If set, the initial slider will
be resized to meet these requirements.

A main use case will be the possibility to create a fullscreen timeslider
that automatically spans the whole screen whatever the screen resolution.
e.g syntax would be <Slider width="100%" ....>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91a9eee8d96f13e26336a72307291f3e716200a0
---

 modules/gui/skins2/parser/builder.cpp      |    5 +++--
 modules/gui/skins2/parser/builder_data.def |    2 +-
 modules/gui/skins2/parser/builder_data.hpp |    6 ++++--
 modules/gui/skins2/parser/skin_parser.cpp  |    8 ++++++--
 share/skins2/skin.dtd                      |    2 ++
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/parser/builder.cpp 
b/modules/gui/skins2/parser/builder.cpp
index 06196f9..ece673f 100644
--- a/modules/gui/skins2/parser/builder.cpp
+++ b/modules/gui/skins2/parser/builder.cpp
@@ -902,12 +902,13 @@ void Builder::addSlider( const BuilderData::Slider &rData 
)
     m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
 
     // Compute the position of the control
+    int width = (rData.m_width > 0) ? rData.m_width : pCurve->getWidth();
+    int height = (rData.m_height > 0) ? rData.m_height : pCurve->getHeight();
     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(),
-                                       *pRect,
+                                       width, height, *pRect,
                                        rData.m_xKeepRatio, rData.m_yKeepRatio 
);
 
     pLayout->addControl( pBackground, pos, rData.m_layer );
diff --git a/modules/gui/skins2/parser/builder_data.def 
b/modules/gui/skins2/parser/builder_data.def
index 08939c8..e2d61f5 100644
--- a/modules/gui/skins2/parser/builder_data.def
+++ b/modules/gui/skins2/parser/builder_data.def
@@ -16,7 +16,7 @@ IniFile id:string file: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 focus: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
+Slider id:string visible:string xPos:int yPos:int width:int height: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 a14bdf5..f16dac7 100644
--- a/modules/gui/skins2/parser/builder_data.hpp
+++ b/modules/gui/skins2/parser/builder_data.hpp
@@ -396,13 +396,15 @@ m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( 
yPos ), m_leftTop( lef
     /// Type definition
     struct Slider
     {
-        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, const string & panelId ):
-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 ), m_panelId( 
panelId ) {}
+        Slider( const string & id, const string & visible, int xPos, int yPos, 
int width, int height, 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, const string & panelId ):
+m_id( id ), m_visible( visible ), 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_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 ), m_panelId( panelId ) {}
 
         string m_id;
         string m_visible;
         int m_xPos;
         int m_yPos;
+        int m_width;
+        int m_height;
         string m_leftTop;
         string m_rightBottom;
         bool m_xKeepRatio;
diff --git a/modules/gui/skins2/parser/skin_parser.cpp 
b/modules/gui/skins2/parser/skin_parser.cpp
index a96771b..f4e7ce7 100644
--- a/modules/gui/skins2/parser/skin_parser.cpp
+++ b/modules/gui/skins2/parser/skin_parser.cpp
@@ -556,6 +556,8 @@ void SkinParser::handleBeginElement( const string &rName, 
AttrList_t &attr )
         DefaultAttr( attr, "visible", "true" );
         DefaultAttr( attr, "x", "0" );
         DefaultAttr( attr, "y", "0" );
+        DefaultAttr( attr, "width", "-1" );
+        DefaultAttr( attr, "height", "-1" );
         DefaultAttr( attr, "lefttop", "lefttop" );
         DefaultAttr( attr, "rightbottom", "lefttop" );
         DefaultAttr( attr, "xkeepratio", "false" );
@@ -578,9 +580,11 @@ void SkinParser::handleBeginElement( const string &rName, 
AttrList_t &attr )
         getRefDimensions( refWidth, refHeight, false );
         int x = getDimension( attr["x"], refWidth );
         int y = getDimension( attr["y"], refHeight );
+        int width = getDimension( attr["width"], refWidth );
+        int height = getDimension( attr["height"], refHeight );
         const BuilderData::Slider slider( uniqueId( attr["id"] ),
-                attr["visible"], x + m_xOffset,
-                y + m_yOffset, attr["lefttop"],
+                attr["visible"], x + m_xOffset, y + m_yOffset,
+                width, height, attr["lefttop"],
                 attr["rightbottom"], convertBoolean( attr["xkeepratio"] ),
                 convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"],
                 attr["over"], attr["points"], atoi( attr["thickness"] ),
diff --git a/share/skins2/skin.dtd b/share/skins2/skin.dtd
index f1c05f7..6517aaa 100644
--- a/share/skins2/skin.dtd
+++ b/share/skins2/skin.dtd
@@ -200,6 +200,8 @@
         visible     CDATA   "true"
         x           CDATA   "0"
         y           CDATA   "0"
+        width       CDATA   "-1"
+        height      CDATA   "-1"
         lefttop     CDATA   "lefttop"
         rightbottom CDATA   "lefttop"
         xkeepratio  CDATA   "false"

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to