X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fskins2%2Fparser%2Fskin_parser.cpp;h=29df8f46429b8c7044f0feff356c17b5ae38a645;hb=0530638a5038a8bc4abb4fae36d64420e61fb05b;hp=c04bf090f990a6ceb6e51cb0d1d9122babc358cd;hpb=85fad441ea3f7a343c9a3b8bed0a6c3ec8b5e224;p=vlc diff --git a/modules/gui/skins2/parser/skin_parser.cpp b/modules/gui/skins2/parser/skin_parser.cpp index c04bf090f9..29df8f4642 100644 --- a/modules/gui/skins2/parser/skin_parser.cpp +++ b/modules/gui/skins2/parser/skin_parser.cpp @@ -18,11 +18,12 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include "skin_parser.hpp" #include "../src/os_factory.hpp" +#include "interpreter.hpp" #include SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName, @@ -35,6 +36,11 @@ SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName, { m_pData = new BuilderData(); } + + // Special id, we don't want any control to have the same one + m_idSet.insert( "none" ); + // At the beginning, there is no Panel + m_panelStack.push_back( "none" ); } @@ -46,146 +52,210 @@ SkinParser::~SkinParser() } } +inline bool SkinParser::MissingAttr( AttrList_t &attr, const string &name, + const char *a ) +{ + if( attr.find(a) == attr.end() ) + { + msg_Err( getIntf(), "bad theme (element: %s, missing attribute: %s)", + name.c_str(), a ); + m_errors = true; return true; + } + return false; +} void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) { -#define CheckDefault( a, b ) \ - if( attr.find(a) == attr.end() ) attr[strdup(a)] = strdup(b); -#define RequireDefault( a ) \ - if( attr.find(a) == attr.end() ) \ - { \ - msg_Err( getIntf(), "Bad theme (element: %s, missing attribute: %s)", \ - rName.c_str(), a ); \ - m_errors = true; return; \ - } +#define RequireAttr( attr, name, a ) \ + if( MissingAttr( attr, name, a ) ) return; if( rName == "Include" ) { - RequireDefault( "file" ); + RequireAttr( attr, rName, "file" ); OSFactory *pFactory = OSFactory::instance( getIntf() ); string fullPath = m_path + pFactory->getDirSeparator() + attr["file"]; - msg_Dbg( getIntf(), "Opening included XML file: %s", fullPath.c_str() ); + msg_Dbg( getIntf(), "opening included XML file: %s", fullPath.c_str() ); // FIXME: We do not use the DTD to validate the included XML file, // as the parser seems to dislike it otherwise... SkinParser subParser( getIntf(), fullPath.c_str(), false, m_pData ); subParser.parse(); } + else if( rName == "IniFile" ) + { + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "file" ); + + const BuilderData::IniFile iniFile( uniqueId( attr["id"] ), + attr["file"] ); + m_pData->m_listIniFile.push_back( iniFile ); + } + else if( rName == "Anchor" ) { - RequireDefault( "priority" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "points", "(0,0)" ); - CheckDefault( "range", "10" ); + RequireAttr( attr, rName, "priority" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "points", "(0,0)" ); + DefaultAttr( attr, "range", "10" ); const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset, - atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ), - atoi( attr["priority"] ), attr["points"], m_curLayoutId ); + atoi( attr["y"] ) + m_yOffset, attr["lefttop"], + atoi( attr["range"] ), atoi( attr["priority"] ), + attr["points"], m_curLayoutId ); m_pData->m_listAnchor.push_back( anchor ); } else if( rName == "Bitmap" ) { - RequireDefault( "id" ); - RequireDefault( "file" ); - RequireDefault( "alphacolor" ); + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "file" ); + RequireAttr( attr, rName, "alphacolor" ); + DefaultAttr( attr, "nbframes", "1" ); + DefaultAttr( attr, "fps", "4" ); + DefaultAttr( attr, "loop", "0" ); m_curBitmapId = uniqueId( attr["id"] ); const BuilderData::Bitmap bitmap( m_curBitmapId, - attr["file"], convertColor( attr["alphacolor"] ) ); + attr["file"], convertColor( attr["alphacolor"] ), + atoi( attr["nbframes"] ), atoi( attr["fps"] ), + atoi( attr["loop"] ) ); m_pData->m_listBitmap.push_back( bitmap ); } else if( rName == "SubBitmap" ) { - RequireDefault( "id" ); - RequireDefault( "x" ); - RequireDefault( "y" ); - RequireDefault( "width" ); - RequireDefault( "height" ); + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "x" ); + RequireAttr( attr, rName, "y" ); + RequireAttr( attr, rName, "width" ); + RequireAttr( attr, rName, "height" ); + DefaultAttr( attr, "nbframes", "1" ); + DefaultAttr( attr, "fps", "4" ); + DefaultAttr( attr, "loop", "0" ); const BuilderData::SubBitmap bitmap( uniqueId( attr["id"] ), m_curBitmapId, atoi( attr["x"] ), atoi( attr["y"] ), - atoi( attr["width"] ), atoi( attr["height"] ) ); + atoi( attr["width"] ), atoi( attr["height"] ), + atoi( attr["nbframes"] ), atoi( attr["fps"] ), + atoi( attr["loop"] ) ); m_pData->m_listSubBitmap.push_back( bitmap ); } else if( rName == "BitmapFont" ) { - RequireDefault( "id" ); - RequireDefault( "file" ); - CheckDefault( "type", "digits" ); + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "file" ); + DefaultAttr( attr, "type", "digits" ); - const BuilderData::BitmapFont font( attr["id"], + const BuilderData::BitmapFont font( uniqueId( attr["id"] ), attr["file"], attr["type"] ); m_pData->m_listBitmapFont.push_back( font ); } + else if( rName == "PopupMenu" ) + { + RequireAttr( attr, rName, "id" ); + + m_popupPosList.push_back(0); + m_curPopupId = uniqueId( attr["id"] ); + const BuilderData::PopupMenu popup( m_curPopupId ); + m_pData->m_listPopupMenu.push_back( popup ); + } + + else if( rName == "MenuItem" ) + { + RequireAttr( attr, rName, "label" ); + DefaultAttr( attr, "action", "none" ); + + const BuilderData::MenuItem item( attr["label"], attr["action"], + m_popupPosList.back(), + m_curPopupId ); + m_pData->m_listMenuItem.push_back( item ); + m_popupPosList.back()++; + } + + else if( rName == "MenuSeparator" ) + { + const BuilderData::MenuSeparator sep( m_popupPosList.back(), + m_curPopupId ); + m_pData->m_listMenuSeparator.push_back( sep ); + m_popupPosList.back()++; + } + else if( rName == "Button" ) { - RequireDefault( "up" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "down", "none" ); - CheckDefault( "over", "none" ); - CheckDefault( "action", "none" ); - CheckDefault( "tooltiptext", "" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "up" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "down", "none" ); + DefaultAttr( attr, "over", "none" ); + DefaultAttr( attr, "action", "none" ); + DefaultAttr( attr, "tooltiptext", "" ); + DefaultAttr( attr, "help", "" ); const BuilderData::Button button( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, - attr["lefttop"], attr["rightbottom"], attr["visible"], + attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["visible"], attr["up"], attr["down"], attr["over"], attr["action"], attr["tooltiptext"], attr["help"], - m_curLayer, m_curWindowId, m_curLayoutId ); + m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listButton.push_back( button ); } else if( rName == "Checkbox" ) { - RequireDefault( "up1" ); - RequireDefault( "up2" ); - RequireDefault( "state" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "down1", "none" ); - CheckDefault( "over1", "none" ); - CheckDefault( "down2", "none" ); - CheckDefault( "over2", "none" ); - CheckDefault( "action1", "none" ); - CheckDefault( "action2", "none" ); - CheckDefault( "tooltiptext1", "" ); - CheckDefault( "tooltiptext2", "" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "up1" ); + RequireAttr( attr, rName, "up2" ); + RequireAttr( attr, rName, "state" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "down1", "none" ); + DefaultAttr( attr, "over1", "none" ); + DefaultAttr( attr, "down2", "none" ); + DefaultAttr( attr, "over2", "none" ); + DefaultAttr( attr, "action1", "none" ); + DefaultAttr( attr, "action2", "none" ); + DefaultAttr( attr, "tooltiptext1", "" ); + DefaultAttr( attr, "tooltiptext2", "" ); + DefaultAttr( attr, "help", "" ); const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, - attr["lefttop"], attr["rightbottom"], attr["visible"], + attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["visible"], attr["up1"], attr["down1"], attr["over1"], attr["up2"], attr["down2"], attr["over2"], attr["state"], attr["action1"], attr["action2"], attr["tooltiptext1"], attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId, - m_curLayoutId ); + m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listCheckbox.push_back( checkbox ); } else if( rName == "Font" ) { - RequireDefault( "id" ); - RequireDefault( "file" ); - CheckDefault( "size", "12" ); + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "file" ); + DefaultAttr( attr, "size", "12" ); const BuilderData::Font fontData( uniqueId( attr["id"] ), attr["file"], atoi( attr["size"] ) ); @@ -194,8 +264,8 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) else if( rName == "Group" ) { - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); m_xOffset += atoi( attr["x"] ); m_yOffset += atoi( attr["y"] ); @@ -205,35 +275,43 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) else if( rName == "Image" ) { - RequireDefault( "image" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "action", "none" ); - CheckDefault( "resize", "mosaic" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "image" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "action", "none" ); + DefaultAttr( attr, "action2", "none" ); + DefaultAttr( attr, "resize", "mosaic" ); + DefaultAttr( attr, "help", "" ); + DefaultAttr( attr, "art", "false" ); const BuilderData::Image imageData( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, - attr["lefttop"], attr["rightbottom"], attr["visible"], - attr["image"], attr["action"], attr["resize"], attr["help"], - m_curLayer, m_curWindowId, m_curLayoutId ); + attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["visible"], + attr["image"], attr["action"], attr["action2"], attr["resize"], + attr["help"], convertBoolean( attr["art"] ), + m_curLayer, m_curWindowId, m_curLayoutId, + m_panelStack.back() ); m_curLayer++; m_pData->m_listImage.push_back( imageData ); } else if( rName == "Layout" ) { - RequireDefault( "width" ); - RequireDefault( "height" ); - CheckDefault( "id", "none" ); - CheckDefault( "minwidth", "-1" ); - CheckDefault( "maxwidth", "-1" ); - CheckDefault( "minheight", "-1" ); - CheckDefault( "maxheight", "-1" ); + RequireAttr( attr, rName, "width" ); + RequireAttr( attr, rName, "height" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "minwidth", "-1" ); + DefaultAttr( attr, "maxwidth", "-1" ); + DefaultAttr( attr, "minheight", "-1" ); + DefaultAttr( attr, "maxheight", "-1" ); m_curLayoutId = uniqueId( attr["id"] ); const BuilderData::Layout layout( m_curLayoutId, atoi( attr["width"] ), @@ -244,190 +322,253 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) m_curLayer = 0; } + else if( rName == "Panel" ) + { + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + RequireAttr( attr, rName, "width" ); + RequireAttr( attr, rName, "height" ); + + string panelId = uniqueId( "none" ); + const BuilderData::Panel panel( panelId, + atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, + attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), + atoi( attr["width"] ), atoi( attr["height" ] ), + m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); + m_curLayer++; + m_pData->m_listPanel.push_back( panel ); + // Add the panel to the stack + m_panelStack.push_back( panelId ); + } + else if( rName == "Playlist" ) { - RequireDefault( "id" ); - RequireDefault( "font" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "width", "0" ); - CheckDefault( "height", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "bgimage", "none" ); - CheckDefault( "fgcolor", "#000000" ); - CheckDefault( "playcolor", "#FF0000" ); - CheckDefault( "bgcolor1", "#FFFFFF" ); - CheckDefault( "bgcolor2", "#FFFFFF" ); - CheckDefault( "selcolor", "#0000FF" ); - CheckDefault( "help", "" ); - - m_curListId = uniqueId( attr["id"] ); - const BuilderData::List listData( m_curListId, atoi( attr["x"] ) + + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "font" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "flat", "true" ); // Only difference here + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "width", "0" ); + DefaultAttr( attr, "height", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "bgimage", "none" ); + DefaultAttr( attr, "itemimage", "none" ); + DefaultAttr( attr, "openimage", "none" ); + DefaultAttr( attr, "closedimage", "none" ); + DefaultAttr( attr, "fgcolor", "#000000" ); + DefaultAttr( attr, "playcolor", "#FF0000" ); + DefaultAttr( attr, "bgcolor1", "#FFFFFF" ); + DefaultAttr( attr, "bgcolor2", "#FFFFFF" ); + DefaultAttr( attr, "selcolor", "#0000FF" ); + DefaultAttr( attr, "help", "" ); + + m_curTreeId = uniqueId( attr["id"] ); + const BuilderData::Tree treeData( m_curTreeId, atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"], + attr["flat"], atoi( attr["width"]), atoi( attr["height"] ), attr["lefttop"], attr["rightbottom"], - attr["font"], "playlist", attr["bgimage"], - convertColor( attr["fgcolor"] ), - convertColor( attr["playcolor"] ), - convertColor( attr["bgcolor1"] ), - convertColor( attr["bgcolor2"] ), - convertColor( attr["selcolor"] ), attr["help"], - m_curLayer, m_curWindowId, m_curLayoutId ); + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), + attr["font"], "playtree", + attr["bgimage"], attr["itemimage"], + attr["openimage"], attr["closedimage"], + attr["fgcolor"], + attr["playcolor"], + attr["bgcolor1"], + attr["bgcolor2"], + attr["selcolor"], attr["help"], + m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; - m_pData->m_listList.push_back( listData ); + m_pData->m_listTree.push_back( treeData ); } - else if( rName == "Playtree" ) { - RequireDefault( "id" ); - RequireDefault( "font" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "width", "0" ); - CheckDefault( "height", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "bgimage", "none" ); - CheckDefault( "itemimage", "none" ); - CheckDefault( "openimage", "none" ); - CheckDefault( "closedimage", "none" ); - CheckDefault( "fgcolor", "#000000" ); - CheckDefault( "playcolor", "#FF0000" ); - CheckDefault( "bgcolor1", "#FFFFFF" ); - CheckDefault( "bgcolor2", "#FFFFFF" ); - CheckDefault( "selcolor", "#0000FF" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "id" ); + RequireAttr( attr, rName, "font" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "flat", "false" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "width", "0" ); + DefaultAttr( attr, "height", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "bgimage", "none" ); + DefaultAttr( attr, "itemimage", "none" ); + DefaultAttr( attr, "openimage", "none" ); + DefaultAttr( attr, "closedimage", "none" ); + DefaultAttr( attr, "fgcolor", "#000000" ); + DefaultAttr( attr, "playcolor", "#FF0000" ); + DefaultAttr( attr, "bgcolor1", "#FFFFFF" ); + DefaultAttr( attr, "bgcolor2", "#FFFFFF" ); + DefaultAttr( attr, "selcolor", "#0000FF" ); + DefaultAttr( attr, "help", "" ); m_curTreeId = uniqueId( attr["id"] ); const BuilderData::Tree treeData( m_curTreeId, atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"], + attr["flat"], atoi( attr["width"]), atoi( attr["height"] ), attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["font"], "playtree", attr["bgimage"], attr["itemimage"], attr["openimage"], attr["closedimage"], - convertColor( attr["fgcolor"] ), - convertColor( attr["playcolor"] ), - convertColor( attr["bgcolor1"] ), - convertColor( attr["bgcolor2"] ), - convertColor( attr["selcolor"] ), attr["help"], - m_curLayer, m_curWindowId, m_curLayoutId ); + attr["fgcolor"], attr["playcolor"], + attr["bgcolor1"], attr["bgcolor2"], + attr["selcolor"], attr["help"], + m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listTree.push_back( treeData ); } else if( rName == "RadialSlider" ) { - RequireDefault( "sequence" ); - RequireDefault( "nbimages" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "minangle", "0" ); - CheckDefault( "maxangle", "360" ); - CheckDefault( "value", "none" ); - CheckDefault( "tooltiptext", "" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "sequence" ); + RequireAttr( attr, rName, "nbimages" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "minangle", "0" ); + DefaultAttr( attr, "maxangle", "360" ); + DefaultAttr( attr, "value", "none" ); + DefaultAttr( attr, "tooltiptext", "" ); + DefaultAttr( attr, "help", "" ); const BuilderData::RadialSlider radial( uniqueId( attr["id"] ), attr["visible"], atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, - attr["lefttop"], attr["rightbottom"], attr["sequence"], + attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["sequence"], atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI /180, atof( attr["maxAngle"] ) * M_PI / 180, attr["value"], attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId, - m_curLayoutId ); + m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listRadialSlider.push_back( radial ); } else if( rName == "Slider" ) { - RequireDefault( "up" ); - RequireDefault( "points" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "width", "0" ); - CheckDefault( "height", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "down", "none" ); - CheckDefault( "over", "none" ); - CheckDefault( "thickness", "10" ); - CheckDefault( "value", "none" ); - CheckDefault( "background", "none" ); - CheckDefault( "nbimages", "1" ); - CheckDefault( "tooltiptext", "" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "up" ); + RequireAttr( attr, rName, "points" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "down", "none" ); + DefaultAttr( attr, "over", "none" ); + DefaultAttr( attr, "thickness", "10" ); + DefaultAttr( attr, "value", "none" ); + DefaultAttr( attr, "tooltiptext", "" ); + DefaultAttr( attr, "help", "" ); string newValue = attr["value"]; - if( m_curListId != "" ) - { - // Slider associated to a list - newValue = "playlist.slider"; - } - else if( m_curTreeId != "" ) + if( m_curTreeId != "" ) { // Slider associated to a tree newValue = "playtree.slider"; } const BuilderData::Slider slider( uniqueId( attr["id"] ), - attr["visible"], - atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, - attr["lefttop"], attr["rightbottom"], attr["up"], attr["down"], + attr["visible"], atoi( attr["x"] ) + m_xOffset, + atoi( attr["y"] ) + m_yOffset, attr["lefttop"], + attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"], attr["over"], attr["points"], atoi( attr["thickness"] ), - newValue, attr["background"], atoi( attr["nbimages"] ), - attr["tooltiptext"], attr["help"], m_curLayer, - m_curWindowId, m_curLayoutId ); + newValue, "none", 0, 0, 0, 0, attr["tooltiptext"], + attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, + m_panelStack.back() ); m_curLayer++; m_pData->m_listSlider.push_back( slider ); } + else if( rName == "SliderBackground" ) + { + RequireAttr( attr, rName, "image" ); + DefaultAttr( attr, "nbhoriz", "1" ); + DefaultAttr( attr, "nbvert", "1" ); + DefaultAttr( attr, "padhoriz", "0" ); + DefaultAttr( attr, "padvert", "0" ); + + // Retrieve the current slider data + BuilderData::Slider &slider = m_pData->m_listSlider.back(); + + slider.m_imageId = attr["image"]; + slider.m_nbHoriz = atoi( attr["nbhoriz"] ); + slider.m_nbVert = atoi( attr["nbvert"] ); + slider.m_padHoriz = atoi( attr["padhoriz"] ); + slider.m_padVert = atoi( attr["padvert"] ); + } + else if( rName == "Text" ) { - RequireDefault( "font" ); - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "text", "" ); - CheckDefault( "color", "#000000" ); - CheckDefault( "width", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "help", "" ); + RequireAttr( attr, rName, "font" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "text", "" ); + DefaultAttr( attr, "color", "#000000" ); + DefaultAttr( attr, "scrolling", "auto" ); + DefaultAttr( attr, "alignment", "left" ); + DefaultAttr( attr, "width", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "help", "" ); const BuilderData::Text textData( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"], attr["font"], attr["text"], atoi( attr["width"] ), attr["lefttop"], attr["rightbottom"], - convertColor( attr["color"] ), attr["help"], m_curLayer, - m_curWindowId, m_curLayoutId ); + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), + convertColor( attr["color"] ), + attr["scrolling"], attr["alignment"], + attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, + m_panelStack.back() ); m_curLayer++; m_pData->m_listText.push_back( textData ); } else if( rName == "Theme" ) { - RequireDefault( "version" ); - CheckDefault( "tooltipfont", "defaultfont" ); - CheckDefault( "magnet", "15" ); - CheckDefault( "alpha", "255" ); - CheckDefault( "movealpha", "255" ); + RequireAttr( attr, rName, "version" ); + DefaultAttr( attr, "tooltipfont", "defaultfont" ); + DefaultAttr( attr, "magnet", "15" ); + DefaultAttr( attr, "alpha", "255" ); + DefaultAttr( attr, "movealpha", "255" ); // Check the version if( strcmp( attr["version"], SKINS_DTD_VERSION ) ) { - msg_Err( getIntf(), "Bad theme version : %s (you need version %s)", + msg_Err( getIntf(), "bad theme version : %s (you need version %s)", attr["version"], SKINS_DTD_VERSION ); m_errors = true; return; @@ -441,41 +582,50 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) else if( rName == "ThemeInfo" ) { + DefaultAttr( attr, "name", "" ); + DefaultAttr( attr, "author", "" ); + DefaultAttr( attr, "email", "" ); + DefaultAttr( attr, "website", "" ); msg_Info( getIntf(), "skin: %s author: %s", attr["name"], attr["author"] ); } else if( rName == "Video" ) { - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "width", "0" ); - CheckDefault( "height", "0" ); - CheckDefault( "lefttop", "lefttop" ); - CheckDefault( "rightbottom", "lefttop" ); - CheckDefault( "autoresize", "false" ); - CheckDefault( "help", "" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "width", "0" ); + DefaultAttr( attr, "height", "0" ); + DefaultAttr( attr, "lefttop", "lefttop" ); + DefaultAttr( attr, "rightbottom", "lefttop" ); + DefaultAttr( attr, "xkeepratio", "false" ); + DefaultAttr( attr, "ykeepratio", "false" ); + DefaultAttr( attr, "autoresize", "false" ); + DefaultAttr( attr, "help", "" ); const BuilderData::Video videoData( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, atoi( attr["width"] ), atoi( attr["height" ]), attr["lefttop"], attr["rightbottom"], + convertBoolean( attr["xkeepratio"] ), + convertBoolean( attr["ykeepratio"] ), attr["visible"], convertBoolean( attr["autoresize"] ), - attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); + attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, + m_panelStack.back() ); m_curLayer++; m_pData->m_listVideo.push_back( videoData ); } else if( rName == "Window" ) { - CheckDefault( "id", "none" ); - CheckDefault( "visible", "true" ); - CheckDefault( "x", "0" ); - CheckDefault( "y", "0" ); - CheckDefault( "dragdrop", "true" ); - CheckDefault( "playondrop", "true" ); + DefaultAttr( attr, "id", "none" ); + DefaultAttr( attr, "visible", "true" ); + DefaultAttr( attr, "x", "0" ); + DefaultAttr( attr, "y", "0" ); + DefaultAttr( attr, "dragdrop", "true" ); + DefaultAttr( attr, "playondrop", "true" ); m_curWindowId = uniqueId( attr["id"] ); const BuilderData::Window window( m_curWindowId, @@ -485,6 +635,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) convertBoolean( attr["playondrop"] ) ); m_pData->m_listWindow.push_back( window ); } +#undef RequireAttr } @@ -497,13 +648,18 @@ void SkinParser::handleEndElement( const string &rName ) m_xOffsetList.pop_back(); m_yOffsetList.pop_back(); } - else if( rName == "Playlist" ) + else if( rName == "Playtree" || rName == "Playlist" ) { - m_curListId = ""; + m_curTreeId = ""; } - else if( rName == "Playtree" ) + else if( rName == "Popup" ) { - m_curTreeId = ""; + m_curPopupId = ""; + m_popupPosList.pop_back(); + } + else if( rName == "Panel" ) + { + m_panelStack.pop_back(); } } @@ -514,8 +670,9 @@ bool SkinParser::convertBoolean( const char *value ) const } -int SkinParser::convertColor( const char *transcolor ) const +int SkinParser::convertColor( const char *transcolor ) { + // TODO: move to the builder unsigned long iRed, iGreen, iBlue; iRed = iGreen = iBlue = 0; sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue ); @@ -530,14 +687,14 @@ int SkinParser::convertInRange( const char *value, int minValue, int maxValue, if( intValue < minValue ) { - msg_Warn( getIntf(), "Value of \"%s\" attribute (%i) is out of the " + msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the " "expected range [%i, %i], using %i instead", rAttribute.c_str(), intValue, minValue, maxValue, minValue ); return minValue; } else if( intValue > maxValue ) { - msg_Warn( getIntf(), "Value of \"%s\" attribute (%i) is out of the " + msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the " "expected range [%i, %i], using %i instead", rAttribute.c_str(), intValue, minValue, maxValue, maxValue ); return maxValue; @@ -571,7 +728,7 @@ const string SkinParser::uniqueId( const string &id ) // The id was already used if( id != "none" ) { - msg_Warn( getIntf(), "Non unique id: %s", id.c_str() ); + msg_Warn( getIntf(), "non-unique id: %s", id.c_str() ); } newId = generateId(); }