Commit 524b6573 authored by Cyril Deguet's avatar Cyril Deguet

* agressive backport of [15248]

parent 8f4538a6
...@@ -113,6 +113,8 @@ SOURCES_skins2 = \ ...@@ -113,6 +113,8 @@ SOURCES_skins2 = \
src/generic_layout.hpp \ src/generic_layout.hpp \
src/generic_window.cpp \ src/generic_window.cpp \
src/generic_window.hpp \ src/generic_window.hpp \
src/ini_file.cpp \
src/ini_file.hpp \
src/logger.cpp \ src/logger.cpp \
src/logger.hpp \ src/logger.hpp \
src/os_factory.cpp \ src/os_factory.cpp \
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "builder.hpp" #include "builder.hpp"
#include "builder_data.hpp" #include "builder_data.hpp"
#include "interpreter.hpp" #include "interpreter.hpp"
#include "skin_parser.hpp"
#include "../src/file_bitmap.hpp" #include "../src/file_bitmap.hpp"
#include "../src/os_factory.hpp" #include "../src/os_factory.hpp"
#include "../src/generic_bitmap.hpp" #include "../src/generic_bitmap.hpp"
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
#include "../src/anchor.hpp" #include "../src/anchor.hpp"
#include "../src/bitmap_font.hpp" #include "../src/bitmap_font.hpp"
#include "../src/ft2_font.hpp" #include "../src/ft2_font.hpp"
#include "../src/ini_file.hpp"
#include "../src/generic_layout.hpp" #include "../src/generic_layout.hpp"
#include "../src/popup.hpp" #include "../src/popup.hpp"
#include "../src/theme.hpp" #include "../src/theme.hpp"
...@@ -94,6 +96,7 @@ Theme *Builder::build() ...@@ -94,6 +96,7 @@ Theme *Builder::build()
// Create everything from the data in the XML // Create everything from the data in the XML
ADD_OBJECTS( Theme ); ADD_OBJECTS( Theme );
ADD_OBJECTS( IniFile );
ADD_OBJECTS( Bitmap ); ADD_OBJECTS( Bitmap );
ADD_OBJECTS( SubBitmap ); ADD_OBJECTS( SubBitmap );
ADD_OBJECTS( BitmapFont ); ADD_OBJECTS( BitmapFont );
...@@ -153,6 +156,14 @@ void Builder::addTheme( const BuilderData::Theme &rData ) ...@@ -153,6 +156,14 @@ void Builder::addTheme( const BuilderData::Theme &rData )
} }
void Builder::addIniFile( const BuilderData::IniFile &rData )
{
// Parse the INI file
IniFile iniFile( getIntf(), rData.m_id, getFilePath( rData.m_file ) );
iniFile.parseFile();
}
void Builder::addBitmap( const BuilderData::Bitmap &rData ) void Builder::addBitmap( const BuilderData::Bitmap &rData )
{ {
GenericBitmap *pBmp = GenericBitmap *pBmp =
...@@ -816,10 +827,16 @@ void Builder::addList( const BuilderData::List &rData ) ...@@ -816,10 +827,16 @@ void Builder::addList( const BuilderData::List &rData )
// XXX check when it is null // XXX check when it is null
VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme ); VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
// Get the color values
uint32_t fgColor = getColor( rData.m_fgColor );
uint32_t playColor = getColor( rData.m_playColor );
uint32_t bgColor1 = getColor( rData.m_bgColor1 );
uint32_t bgColor2 = getColor( rData.m_bgColor2 );
uint32_t selColor = getColor( rData.m_selColor );
// Create the list control // Create the list control
CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont, pBgBmp, CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont, pBgBmp,
rData.m_fgColor, rData.m_playColor, rData.m_bgColor1, fgColor, playColor, bgColor1, bgColor2, selColor,
rData.m_bgColor2, rData.m_selColor,
UString( getIntf(), rData.m_help.c_str() ), pVisible ); UString( getIntf(), rData.m_help.c_str() ), pVisible );
// Compute the position of the control // Compute the position of the control
...@@ -873,11 +890,17 @@ void Builder::addTree( const BuilderData::Tree &rData ) ...@@ -873,11 +890,17 @@ void Builder::addTree( const BuilderData::Tree &rData )
VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme ); VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
VarBool *pFlat = pInterpreter->getVarBool( rData.m_flat, m_pTheme ); VarBool *pFlat = pInterpreter->getVarBool( rData.m_flat, m_pTheme );
// Get the color values
uint32_t fgColor = getColor( rData.m_fgColor );
uint32_t playColor = getColor( rData.m_playColor );
uint32_t bgColor1 = getColor( rData.m_bgColor1 );
uint32_t bgColor2 = getColor( rData.m_bgColor2 );
uint32_t selColor = getColor( rData.m_selColor );
// Create the list control // Create the list control
CtrlTree *pTree = new CtrlTree( getIntf(), *pVar, *pFont, pBgBmp, CtrlTree *pTree = new CtrlTree( getIntf(), *pVar, *pFont, pBgBmp,
pItemBmp, pOpenBmp, pClosedBmp, pItemBmp, pOpenBmp, pClosedBmp,
rData.m_fgColor, rData.m_playColor, rData.m_bgColor1, fgColor, playColor, bgColor1, bgColor2, selColor,
rData.m_bgColor2, rData.m_selColor,
UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat ); UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat );
// Compute the position of the control // Compute the position of the control
...@@ -1069,3 +1092,14 @@ Bezier *Builder::getPoints( const char *pTag ) const ...@@ -1069,3 +1092,14 @@ Bezier *Builder::getPoints( const char *pTag ) const
return new Bezier( getIntf(), xBez, yBez ); return new Bezier( getIntf(), xBez, yBez );
} }
uint32_t Builder::getColor( const string &rVal ) const
{
// Check it the value is a registered constant
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
string val = pInterpreter->getConstant( rVal );
// Convert to an int value
return SkinParser::convertColor( val.c_str() );
}
...@@ -65,6 +65,7 @@ class Builder: public SkinObject ...@@ -65,6 +65,7 @@ class Builder: public SkinObject
Theme *m_pTheme; Theme *m_pTheme;
void addTheme( const BuilderData::Theme &rData ); void addTheme( const BuilderData::Theme &rData );
void addIniFile( const BuilderData::IniFile &rData );
void addBitmap( const BuilderData::Bitmap &rData ); void addBitmap( const BuilderData::Bitmap &rData );
void addSubBitmap( const BuilderData::SubBitmap &rData ); void addSubBitmap( const BuilderData::SubBitmap &rData );
void addBitmapFont( const BuilderData::BitmapFont &rData ); void addBitmapFont( const BuilderData::BitmapFont &rData );
...@@ -100,6 +101,9 @@ class Builder: public SkinObject ...@@ -100,6 +101,9 @@ class Builder: public SkinObject
/// Function to parse "points" tags /// Function to parse "points" tags
Bezier *getPoints( const char *pTag ) const; Bezier *getPoints( const char *pTag ) const;
/// Compute a color value
uint32_t getColor( const string &rVal ) const;
/// Image handler (used to load image files) /// Image handler (used to load image files)
image_handler_t *m_pImageHandler; image_handler_t *m_pImageHandler;
}; };
......
...@@ -12,9 +12,10 @@ Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string ...@@ -12,9 +12,10 @@ Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string
Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string Button id:string xPos:int yPos:int leftTop:string rightBottom:string 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 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 Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string 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 visible:string bmpId:string actionId:string action2Id:string resize:string help:string layer:int windowId:string layoutId:string Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string action2Id:string resize:string help:string layer:int windowId:string layoutId: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 color:uint32_t scrolling:string alignment:string help:string layer:int windowId:string layoutId:string Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string 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 sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string 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 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 Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string 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 fontId:string var:string bgImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t 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 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 fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t 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 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 visible:string autoResize:bool help:string layer:int windowId:string layoutId:string Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string autoResize:bool help:string layer:int windowId:string layoutId:string
...@@ -279,6 +279,18 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( ...@@ -279,6 +279,18 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom(
/// List /// List
list<Image> m_listImage; list<Image> m_listImage;
/// Type definition
struct IniFile
{
IniFile( const string & id, const string & file ):
m_id( id ), m_file( file ) {}
string m_id;
string m_file;
};
/// List
list<IniFile> m_listIniFile;
/// Type definition /// Type definition
struct Text struct Text
{ {
...@@ -366,7 +378,7 @@ m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( lef ...@@ -366,7 +378,7 @@ m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( lef
/// Type definition /// Type definition
struct List struct List
{ {
List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ): List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
string m_id; string m_id;
...@@ -380,11 +392,11 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ...@@ -380,11 +392,11 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width
string m_fontId; string m_fontId;
string m_var; string m_var;
string m_bgImageId; string m_bgImageId;
uint32_t m_fgColor; string m_fgColor;
uint32_t m_playColor; string m_playColor;
uint32_t m_bgColor1; string m_bgColor1;
uint32_t m_bgColor2; string m_bgColor2;
uint32_t m_selColor; string m_selColor;
string m_help; string m_help;
int m_layer; int m_layer;
string m_windowId; string m_windowId;
...@@ -396,7 +408,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ...@@ -396,7 +408,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width
/// Type definition /// Type definition
struct Tree struct Tree
{ {
Tree( const string & id, int xPos, int yPos, const string & visible, const string & flat, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ): Tree( const string & id, int xPos, int yPos, const string & visible, const string & flat, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, const string & fgColor, const string & playColor, const string & bgColor1, const string & bgColor2, const string & selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
string m_id; string m_id;
...@@ -414,11 +426,11 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ) ...@@ -414,11 +426,11 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat )
string m_itemImageId; string m_itemImageId;
string m_openImageId; string m_openImageId;
string m_closedImageId; string m_closedImageId;
uint32_t m_fgColor; string m_fgColor;
uint32_t m_playColor; string m_playColor;
uint32_t m_bgColor1; string m_bgColor1;
uint32_t m_bgColor2; string m_bgColor2;
uint32_t m_selColor; string m_selColor;
string m_help; string m_help;
int m_layer; int m_layer;
string m_windowId; string m_windowId;
......
...@@ -416,3 +416,17 @@ VarTree *Interpreter::getVarTree( const string &rName, Theme *pTheme ) ...@@ -416,3 +416,17 @@ VarTree *Interpreter::getVarTree( const string &rName, Theme *pTheme )
VarTree *pVar = (VarTree*)pVarManager->getVar( rName, "tree" ); VarTree *pVar = (VarTree*)pVarManager->getVar( rName, "tree" );
return pVar; return pVar;
} }
string Interpreter::getConstant( const string &rValue )
{
// Check if the value is a registered constant
string val = VarManager::instance( getIntf() )->getConst( rValue );
if( val.empty() )
{
// if not, keep the value as is
val = rValue;
}
return val;
}
...@@ -63,6 +63,9 @@ class Interpreter: public SkinObject ...@@ -63,6 +63,9 @@ class Interpreter: public SkinObject
/// Returns the tree variable corresponding to the given name /// Returns the tree variable corresponding to the given name
VarTree *getVarTree( const string &rName, Theme *pTheme ); VarTree *getVarTree( const string &rName, Theme *pTheme );
/// Get a constant value
string getConstant( const string &rValue );
private: private:
/// Map of global commands /// Map of global commands
map<string, CmdGenericPtr> m_commandMap; map<string, CmdGenericPtr> m_commandMap;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "skin_parser.hpp" #include "skin_parser.hpp"
#include "../src/os_factory.hpp" #include "../src/os_factory.hpp"
#include "interpreter.hpp"
#include <math.h> #include <math.h>
SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName, SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName,
...@@ -72,6 +73,16 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -72,6 +73,16 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
subParser.parse(); subParser.parse();
} }
else if( rName == "IniFile" )
{
RequireDefault( "id" );
RequireDefault( "file" );
const BuilderData::IniFile iniFile( attr["id"],
attr["file"] );
m_pData->m_listIniFile.push_back( iniFile );
}
else if( rName == "Anchor" ) else if( rName == "Anchor" )
{ {
RequireDefault( "priority" ); RequireDefault( "priority" );
...@@ -304,13 +315,10 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -304,13 +315,10 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
const BuilderData::List listData( m_curListId, atoi( attr["x"] ) + const BuilderData::List listData( m_curListId, atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"], m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],
atoi( attr["width"]), atoi( attr["height"] ), atoi( attr["width"]), atoi( attr["height"] ),
attr["lefttop"], attr["rightbottom"], attr["lefttop"], attr["rightbottom"], attr["font"],
attr["font"], "playlist", attr["bgimage"], "playlist", attr["bgimage"], attr["fgcolor"],
convertColor( attr["fgcolor"] ), attr["playcolor"], attr["bgcolor1"], attr["bgcolor2"],
convertColor( attr["playcolor"] ), attr["selcolor"], attr["help"],
convertColor( attr["bgcolor1"] ),
convertColor( attr["bgcolor2"] ),
convertColor( attr["selcolor"] ), attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId ); m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++; m_curLayer++;
m_pData->m_listList.push_back( listData ); m_pData->m_listList.push_back( listData );
...@@ -348,11 +356,9 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -348,11 +356,9 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
attr["font"], "playtree", attr["font"], "playtree",
attr["bgimage"], attr["itemimage"], attr["bgimage"], attr["itemimage"],
attr["openimage"], attr["closedimage"], attr["openimage"], attr["closedimage"],
convertColor( attr["fgcolor"] ), attr["fgcolor"], attr["playcolor"],
convertColor( attr["playcolor"] ), attr["bgcolor1"], attr["bgcolor2"],
convertColor( attr["bgcolor1"] ), attr["selcolor"], attr["help"],
convertColor( attr["bgcolor2"] ),
convertColor( attr["selcolor"] ), attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId ); m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++; m_curLayer++;
m_pData->m_listTree.push_back( treeData ); m_pData->m_listTree.push_back( treeData );
...@@ -576,8 +582,9 @@ bool SkinParser::convertBoolean( const char *value ) const ...@@ -576,8 +582,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; unsigned long iRed, iGreen, iBlue;
iRed = iGreen = iBlue = 0; iRed = iGreen = iBlue = 0;
sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue ); sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue );
......
...@@ -40,6 +40,8 @@ class SkinParser: public XMLParser ...@@ -40,6 +40,8 @@ class SkinParser: public XMLParser
const BuilderData &getData() const { return *m_pData; } const BuilderData &getData() const { return *m_pData; }
static int convertColor( const char *transcolor );
private: private:
/// Path of the theme /// Path of the theme
const string m_path; const string m_path;
...@@ -72,7 +74,6 @@ class SkinParser: public XMLParser ...@@ -72,7 +74,6 @@ class SkinParser: public XMLParser
/// Helper functions /// Helper functions
//@{ //@{
bool convertBoolean( const char *value ) const; bool convertBoolean( const char *value ) const;
int convertColor( const char *transcolor ) const;
/// Transform to int, and check that it is in the given range (if not, /// Transform to int, and check that it is in the given range (if not,
/// the closest range boundary will be used) /// the closest range boundary will be used)
int convertInRange( const char *value, int minValue, int maxValue, int convertInRange( const char *value, int minValue, int maxValue,
......
...@@ -37,8 +37,6 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler, ...@@ -37,8 +37,6 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
fmt_out.i_chroma = VLC_FOURCC('R','V','3','2'); fmt_out.i_chroma = VLC_FOURCC('R','V','3','2');
fprintf(stderr,"FILE %s\n", fileName.c_str());
pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_in, &fmt_out ); pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_in, &fmt_out );
if( !pPic ) return; if( !pPic ) return;
......
/*****************************************************************************
* ini_file.cpp
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ini_file.hpp"
#include "var_manager.hpp"
#include <fstream>
IniFile::IniFile( intf_thread_t *pIntf, const string &rName,
const string &rPath ):
SkinObject( pIntf ), m_name( rName ), m_path( rPath )
{
}
void IniFile::parseFile()
{
VarManager *pVarManager = VarManager::instance( getIntf() );
// Open the file
fstream fs( m_path.c_str(), fstream::in );
if( fs.is_open() )
{
string section;
string line;
while( !fs.eof() )
{
// Read the next line
fs >> line;
switch( line[0] )
{
// "[section]" line ?
case '[':
section = line.substr( 1, line.size() - 2);
break;
// Comment
case ';':
case '#':
break;
// Variable declaration
default:
size_t eqPos = line.find( '=' );
string var = line.substr( 0, eqPos );
string val = line.substr( eqPos + 1, line.size() - eqPos - 1);
// register the value in the var manager
pVarManager->registerConst( m_name + "." + section + "." + var,
val );
}
}
fs.close();
}
else
{
msg_Err( getIntf(), "Failed to open INI file %s", m_path.c_str() );
}
}
/*****************************************************************************
* ini_file.hpp
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef INI_FILE_HPP
#define INI_FILE_HPP
#include "skin_common.hpp"
#include <string>
#include <map>
/// INI file parser
class IniFile: public SkinObject
{
public:
IniFile( intf_thread_t *pIntf, const string &rName,
const string &rPath );
virtual ~IniFile() {}
/// Parse the INI file and fill the VarManager
void parseFile();
private:
string m_name;
string m_path;
};
#endif
...@@ -131,3 +131,15 @@ Variable *VarManager::getVar( const string &rName, const string &rType ) ...@@ -131,3 +131,15 @@ Variable *VarManager::getVar( const string &rName, const string &rType )
} }
} }
void VarManager::registerConst( const string &rName, const string &rValue)
{
m_constMap[rName] = rValue;
}
string VarManager::getConst( const string &rName )
{
return m_constMap[rName];
}
...@@ -57,6 +57,12 @@ class VarManager: public SkinObject ...@@ -57,6 +57,12 @@ class VarManager: public SkinObject
/// Get the help text variable /// Get the help text variable
VarText &getHelpText() { return *m_pHelpText; } VarText &getHelpText() { return *m_pHelpText; }
/// Register a constant value
void registerConst( const string &rName, const string &rValue);
/// Get a constant value by its name
string getConst( const string &rName );
private: private:
/// Tooltip text /// Tooltip text
VarText *m_pTooltipText; VarText *m_pTooltipText;
...@@ -68,6 +74,8 @@ class VarManager: public SkinObject ...@@ -68,6 +74,8 @@ class VarManager: public SkinObject
list<string> m_varList; list<string> m_varList;
/// List of anonymous registed variables /// List of anonymous registed variables
list<VariablePtr> m_anonVarList; list<VariablePtr> m_anonVarList;
/// Map of constant values
map<string, string> m_constMap;
/// Private because it is a singleton /// Private because it is a singleton
VarManager( intf_thread_t *pIntf ); VarManager( intf_thread_t *pIntf );
......
...@@ -43,15 +43,7 @@ VarText::~VarText() ...@@ -43,15 +43,7 @@ VarText::~VarText()
if( m_substVars ) if( m_substVars )
{ {
// Remove the observers // Remove the observers
VlcProc *pVlcProc = VlcProc::instance( getIntf() ); delObservers();
pVlcProc->getTimeVar().delObserver( this );
pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
} }
} }
...@@ -149,15 +141,10 @@ void VarText::set( const UString &rText ) ...@@ -149,15 +141,10 @@ void VarText::set( const UString &rText )
if( m_substVars ) if( m_substVars )
{ {
// Stop observing other variables // Stop observing other variables
delObservers();
VlcProc *pVlcProc = VlcProc::instance( getIntf() ); VlcProc *pVlcProc = VlcProc::instance( getIntf() );
pVlcProc->getTimeVar().delObserver( this );
pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
// Observe needed variables // Observe needed variables
if( m_text.find( "$H" ) != UString::npos ) if( m_text.find( "$H" ) != UString::npos )
...@@ -228,3 +215,18 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg ) ...@@ -228,3 +215,18 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
} }
} }
void VarText::delObservers()
{
// Stop observing other variables
VlcProc *pVlcProc = VlcProc::instance( getIntf() );
pVlcProc->getTimeVar().delObserver( this );
pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
}
...@@ -53,6 +53,9 @@ class VarText: public Variable, public Subject<VarText, void*>, ...@@ -53,6 +53,9 @@ class VarText: public Variable, public Subject<VarText, void*>,
virtual void onUpdate( Subject<VarText, void*> &rVariable, void* ); virtual void onUpdate( Subject<VarText, void*> &rVariable, void* );
private: private:
/// Stop observing other variables
void delObservers();
/// Variable type /// Variable type
static const string m_type; static const string m_type;
/// The text of the variable /// The text of the variable
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
--> -->
<!ELEMENT Theme (ThemeInfo,(Include|Bitmap|BitmapFont|Font|PopupMenu|Window)*)> <!ELEMENT Theme (ThemeInfo,(Include|IniFile|Bitmap|BitmapFont|Font|PopupMenu|Window)*)>
<!ATTLIST Theme <!ATTLIST Theme
version CDATA #REQUIRED version CDATA #REQUIRED
tooltipfont CDATA "defaultfont" tooltipfont CDATA "defaultfont"
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
> >
<!-- main elements --> <!-- main elements -->
<!ELEMENT IniFile EMPTY>
<!ATTLIST IniFile
id CDATA #REQUIRED
file CDATA #REQUIRED
>
<!ELEMENT Include EMPTY> <!ELEMENT Include EMPTY>
<!ATTLIST Include <!ATTLIST Include
file CDATA #REQUIRED file CDATA #REQUIRED
......
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
<BitmapFont id="digits_font" file="nums_ex.bmp" type="digits" /> <BitmapFont id="digits_font" file="nums_ex.bmp" type="digits" />
<BitmapFont id="digits_font_2" file="numbers.bmp" type="digits" /> <BitmapFont id="digits_font_2" file="numbers.bmp" type="digits" />
<BitmapFont id="text_font" file="text.bmp" type="text" /> <BitmapFont id="text_font" file="text.bmp" type="text" />
<IniFile id="pledit" file="pledit.txt" />
<Window id="main_window" x="100" y="100"> <Window id="main_window" x="100" y="100">
<Layout id="small_layout" width="275" height="14"> <Layout id="small_layout" width="275" height="14">
...@@ -342,7 +343,7 @@ ...@@ -342,7 +343,7 @@
<Image x="255" y="96" image="pl_resize" action="resizeSE" lefttop="rightbottom" rightbottom="rightbottom" /> <Image x="255" y="96" image="pl_resize" action="resizeSE" lefttop="rightbottom" rightbottom="rightbottom" />
<Button x="254" y="3" up="pl_switch_up" down="pl_switch_down" over="pl_switch_up" action="playlist_window.setLayout(pl_small_layout)" tooltiptext="Switch" lefttop="righttop" rightbottom="righttop" /> <Button x="254" y="3" up="pl_switch_up" down="pl_switch_down" over="pl_switch_up" action="playlist_window.setLayout(pl_small_layout)" tooltiptext="Switch" lefttop="righttop" rightbottom="righttop" />
<Button x="264" y="3" up="pl_close_up" down="pl_close_down" over="pl_close_up" action="playlist_window.hide()" tooltiptext="Close the window" lefttop="righttop" rightbottom="righttop" /> <Button x="264" y="3" up="pl_close_up" down="pl_close_down" over="pl_close_up" action="playlist_window.hide()" tooltiptext="Close the window" lefttop="righttop" rightbottom="righttop" />
<Playlist id="playlist" x="10" y="20" width="240" height="58" lefttop="lefttop" rightbottom="rightbottom" font="playlist_font" fgcolor="#dfdfff" playcolor="#ffffff" bgcolor1="#000000" bgcolor2="#000000" selcolor="#404040" > <Playlist id="playlist" x="10" y="20" width="240" height="58" lefttop="lefttop" rightbottom="rightbottom" font="playlist_font" fgcolor="pledit.Text.Normal" playcolor="pledit.Text.Current" bgcolor1="pledit.Text.NormalBG" bgcolor2="pledit.Text.NormalBG" selcolor="pledit.Text.SelectedBG" >
<Slider id="playlist_slider" x="264" y="28" lefttop="righttop" rightbottom="rightbottom" up="pl_slider_up" down="pl_slider_down" points="(0,40),(0,0)" /> <Slider id="playlist_slider" x="264" y="28" lefttop="righttop" rightbottom="rightbottom" up="pl_slider_up" down="pl_slider_down" points="(0,40),(0,0)" />
</Playlist> </Playlist>
<Button x="14" y="86" up="pl_add_up" down="pl_add_down" over="pl_add_up" action="playlist.add()" lefttop="leftbottom" rightbottom="leftbottom" /> <Button x="14" y="86" up="pl_add_up" down="pl_add_down" over="pl_add_up" action="playlist.add()" lefttop="leftbottom" rightbottom="leftbottom" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment