From: Cyril Deguet Date: Thu, 10 Nov 2005 20:42:48 +0000 (+0000) Subject: * winamp2.xml: added the Equalizer and Playlist windows. X-Git-Tag: 0.9.0-test0~13344 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=85fad441ea3f7a343c9a3b8bed0a6c3ec8b5e224;p=vlc * winamp2.xml: added the Equalizer and Playlist windows. Now it starts to really look cool ;-) * builder.cpp: look for fonts in the resource path if the font file cannot be found in the theme itself * ctrl_slider.cpp: fixed the hack for winamp: the bar images are separated by 2 rows, not 3... --- diff --git a/modules/gui/skins2/controls/ctrl_slider.cpp b/modules/gui/skins2/controls/ctrl_slider.cpp index 73edd8cb2e..744d3f806a 100644 --- a/modules/gui/skins2/controls/ctrl_slider.cpp +++ b/modules/gui/skins2/controls/ctrl_slider.cpp @@ -387,9 +387,9 @@ void CtrlSliderBg::draw( OSGraphics &rImage, int xDest, int yDest ) if( m_pImgSeq ) { // Draw the background image - // XXX the "-3" is a hack for winamp skins... + // XXX the "-2" is a hack for winamp skins... rImage.drawGraphics( *m_pImgSeq, 0, m_position * m_bgHeight, - xDest, yDest, m_bgWidth, m_bgHeight - 3); + xDest, yDest, m_bgWidth, m_bgHeight - 2); } } diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index ef1b93f1f9..ab7bb28088 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -52,8 +52,9 @@ #include "vlc_image.h" -Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData ): - SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL ) +Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData, + const string &rPath ): + SkinObject( pIntf ), m_rData( rData ), m_path( rPath ), m_pTheme( NULL ) { m_pImageHandler = image_HandlerCreate( pIntf ); } @@ -145,7 +146,7 @@ void Builder::addBitmap( const BuilderData::Bitmap &rData ) { GenericBitmap *pBmp = new FileBitmap( getIntf(), m_pImageHandler, - rData.m_fileName, rData.m_alphaColor ); + getFilePath( rData.m_fileName ), rData.m_alphaColor ); if( !pBmp->getData() ) { // Invalid bitmap @@ -181,7 +182,8 @@ void Builder::addSubBitmap( const BuilderData::SubBitmap &rData ) void Builder::addBitmapFont( const BuilderData::BitmapFont &rData ) { GenericBitmap *pBmp = - new FileBitmap( getIntf(), m_pImageHandler, rData.m_file, 0 ); + new FileBitmap( getIntf(), m_pImageHandler, + getFilePath( rData.m_file ), 0 ); if( !pBmp->getData() ) { // Invalid bitmap @@ -205,7 +207,9 @@ void Builder::addBitmapFont( const BuilderData::BitmapFont &rData ) void Builder::addFont( const BuilderData::Font &rData ) { - GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontFile, + // Try to load the font from the theme directory + GenericFont *pFont = new FT2Font( getIntf(), + getFilePath( rData.m_fontFile ), rData.m_size ); if( pFont->init() ) { @@ -214,6 +218,28 @@ void Builder::addFont( const BuilderData::Font &rData ) else { delete pFont; + + // Font not found; try in the resource path + OSFactory *pOSFactory = OSFactory::instance( getIntf() ); + const list &resPath = pOSFactory->getResourcePath(); + const string &sep = pOSFactory->getDirSeparator(); + + list::const_iterator it; + for( it = resPath.begin(); it != resPath.end(); it++ ) + { + string path = (*it) + sep + "fonts" + sep + rData.m_fontFile; + pFont = new FT2Font( getIntf(), path, rData.m_size ); + if( pFont->init() ) + { + // Font loaded successfully + m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont ); + break; + } + else + { + delete pFont; + } + } } } @@ -865,6 +891,14 @@ GenericFont *Builder::getFont( const string &fontId ) } +string Builder::getFilePath( const string &rFileName ) const +{ + OSFactory *pFactory = OSFactory::instance( getIntf() ); + return m_path + pFactory->getDirSeparator() + rFileName; +} + + + Bezier *Builder::getPoints( const char *pTag ) const { vector xBez, yBez; diff --git a/modules/gui/skins2/parser/builder.hpp b/modules/gui/skins2/parser/builder.hpp index f041d56ee4..80c80a1032 100644 --- a/modules/gui/skins2/parser/builder.hpp +++ b/modules/gui/skins2/parser/builder.hpp @@ -46,7 +46,8 @@ class Theme; class Builder: public SkinObject { public: - Builder( intf_thread_t *pIntf, const BuilderData &rData ); + Builder( intf_thread_t *pIntf, const BuilderData &rData, + const string &rPath ); virtual ~Builder(); /// Create a Theme object, ready to use. @@ -59,6 +60,8 @@ class Builder: public SkinObject private: /// Data from the XML const BuilderData &m_rData; + /// Path of the theme + const string m_path; /// Theme under construction Theme *m_pTheme; @@ -87,6 +90,9 @@ class Builder: public SkinObject int xPos, int yPos, int width, int height, const Box &rBox ) const; + // Build the full path of a file + string getFilePath( const string &fileName ) const; + /// Get a font from its id GenericFont *getFont( const string &fontId ); diff --git a/modules/gui/skins2/parser/skin_parser.cpp b/modules/gui/skins2/parser/skin_parser.cpp index d7996a70f5..c04bf090f9 100644 --- a/modules/gui/skins2/parser/skin_parser.cpp +++ b/modules/gui/skins2/parser/skin_parser.cpp @@ -27,8 +27,8 @@ SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName, const string &rPath, bool useDTD, BuilderData *pData ): - XMLParser( pIntf, rFileName, useDTD ), m_pData(pData), - m_ownData(pData == NULL), m_xOffset( 0 ), m_yOffset( 0 ), m_path( rPath ) + XMLParser( pIntf, rFileName, useDTD ), m_path( rPath), m_pData(pData), + m_ownData(pData == NULL), m_xOffset( 0 ), m_yOffset( 0 ) { // Make sure the data is allocated if( m_pData == NULL ) @@ -62,12 +62,13 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) if( rName == "Include" ) { RequireDefault( "file" ); - msg_Dbg( getIntf(), "Opening included XML file: %s", - convertFileName( attr["file"] ).c_str() ); + + OSFactory *pFactory = OSFactory::instance( getIntf() ); + string fullPath = m_path + pFactory->getDirSeparator() + attr["file"]; + 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(), convertFileName( attr["file"] ), - m_path, false, m_pData ); + SkinParser subParser( getIntf(), fullPath.c_str(), false, m_pData ); subParser.parse(); } @@ -93,8 +94,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) m_curBitmapId = uniqueId( attr["id"] ); const BuilderData::Bitmap bitmap( m_curBitmapId, - convertFileName( attr["file"] ), - convertColor( attr["alphacolor"] ) ); + attr["file"], convertColor( attr["alphacolor"] ) ); m_pData->m_listBitmap.push_back( bitmap ); } @@ -119,8 +119,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) CheckDefault( "type", "digits" ); const BuilderData::BitmapFont font( attr["id"], - convertFileName( attr["file"] ), - attr["type"] ); + attr["file"], attr["type"] ); m_pData->m_listBitmapFont.push_back( font ); } @@ -189,8 +188,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) CheckDefault( "size", "12" ); const BuilderData::Font fontData( uniqueId( attr["id"] ), - convertFileName( attr["file"] ), - atoi( attr["size"] ) ); + attr["file"], atoi( attr["size"] ) ); m_pData->m_listFont.push_back( fontData ); } @@ -525,13 +523,6 @@ int SkinParser::convertColor( const char *transcolor ) const } -string SkinParser::convertFileName( const char *fileName ) const -{ - OSFactory *pFactory = OSFactory::instance( getIntf() ); - return m_path + pFactory->getDirSeparator() + string( fileName ); -} - - int SkinParser::convertInRange( const char *value, int minValue, int maxValue, const string &rAttribute ) const { diff --git a/modules/gui/skins2/parser/skin_parser.hpp b/modules/gui/skins2/parser/skin_parser.hpp index 116989d207..df251b4f72 100644 --- a/modules/gui/skins2/parser/skin_parser.hpp +++ b/modules/gui/skins2/parser/skin_parser.hpp @@ -41,6 +41,8 @@ class SkinParser: public XMLParser const BuilderData &getData() const { return *m_pData; } private: + /// Path of the theme + const string m_path; /// Container for mapping data from the XML BuilderData *m_pData; /// Indicate whether the class owns the data @@ -58,8 +60,6 @@ class SkinParser: public XMLParser int m_curLayer; /// Set of used id set m_idSet; - /// Path of the XML file being parsed - const string m_path; /// Callbacks virtual void handleBeginElement( const string &rName, @@ -70,7 +70,6 @@ class SkinParser: public XMLParser //@{ bool convertBoolean( const char *value ) const; int convertColor( const char *transcolor ) const; - string convertFileName( const char *fileName ) const; /// Transform to int, and check that it is in the given range (if not, /// the closest range boundary will be used) int convertInRange( const char *value, int minValue, int maxValue, diff --git a/modules/gui/skins2/src/theme_loader.cpp b/modules/gui/skins2/src/theme_loader.cpp index 899613f667..7d8cc3e62a 100644 --- a/modules/gui/skins2/src/theme_loader.cpp +++ b/modules/gui/skins2/src/theme_loader.cpp @@ -200,7 +200,7 @@ bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir ) // Convert the file name to lower case, because some winamp skins // use the wrong case... - for( int i=0; i< strlen( filenameInZip ); i++) + for( size_t i=0; i< strlen( filenameInZip ); i++) { filenameInZip[i] = tolower( filenameInZip[i] ); } @@ -359,7 +359,7 @@ bool ThemeLoader::parse( const string &path, const string &xmlFile ) } // Build and store the theme - Builder builder( getIntf(), parser.getData() ); + Builder builder( getIntf(), parser.getData(), path ); getIntf()->p_sys->p_theme = builder.build(); return true; diff --git a/share/Makefile.am b/share/Makefile.am index 4242138653..73791b97eb 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -78,6 +78,7 @@ DIST_skins2 = \ skins2/default.vlt \ \ skins2/fonts/FreeSans.ttf \ + skins2/fonts/FreeSansBold.ttf \ skins2/skin.dtd \ skins2/skin.catalog \ skins2/winamp2.xml \ diff --git a/share/skins2/fonts/FreeSansBold.ttf b/share/skins2/fonts/FreeSansBold.ttf new file mode 100644 index 0000000000..0cae657e90 Binary files /dev/null and b/share/skins2/fonts/FreeSansBold.ttf differ diff --git a/share/skins2/winamp2.xml b/share/skins2/winamp2.xml index 715e4adabf..8c51326dfc 100644 --- a/share/skins2/winamp2.xml +++ b/share/skins2/winamp2.xml @@ -18,12 +18,28 @@ + + + + + + + + + + + + + + + + @@ -36,36 +52,92 @@ + + + + + + + + + - - + + + + + + - -