From 17871b8811baa9478b2b3247e340aa21bb64e06e Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 30 May 2015 16:43:59 +0200 Subject: implemented Skin Repositories --- libtemplate/template.c | 2 ++ libtemplate/templatefunction.c | 11 +++++++---- libtemplate/templatefunction.h | 2 +- libtemplate/templateloopfunction.c | 19 +++++++++++++++++-- libtemplate/templateloopfunction.h | 1 + libtemplate/templatepixmap.c | 8 ++++---- libtemplate/templatepixmap.h | 4 ++-- libtemplate/xmlparser.c | 8 ++++---- 8 files changed, 38 insertions(+), 17 deletions(-) (limited to 'libtemplate') diff --git a/libtemplate/template.c b/libtemplate/template.c index 189efd0..c542d13 100644 --- a/libtemplate/template.c +++ b/libtemplate/template.c @@ -70,6 +70,8 @@ bool cTemplate::ReadFromXML(string xmlfile) { templateName << "plug-" << plugName << "-" << it->second.c_str(); if (parser.ReadPluginView(plugName, templateNumber, templateName.str())) { ok = parser.ParsePluginView(plugName, templateNumber); + } else { + dsyslog("skindesigner: template %s for plugin %s not available", templateName.str().c_str(), plugName.c_str()); } } } diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index 246db23..b2bad34 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -548,7 +548,7 @@ int cTemplateFunction::GetWidth(bool cutted) { return funcWidth; } -int cTemplateFunction::GetHeight(void) { +int cTemplateFunction::GetHeight(map < string, vector< map< string, string > > > *loopTokens) { int funcHeight = 0; switch (type) { case ftDrawText: @@ -578,9 +578,12 @@ int cTemplateFunction::GetHeight(void) { textboxHeight = funcHeight; } break; } - case ftLoop: - //TODO: to be implemented - break; + case ftLoop: { + cTemplateLoopFunction *loopFunc = dynamic_cast(this); + if (loopFunc) { + funcHeight = loopFunc->CalculateHeight(loopTokens); + } + break; } default: esyslog("skindesigner: GetHeight not implemented for funcType %d", type); break; diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index 43cb106..a000110 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -246,7 +246,7 @@ public: string GetParamName(eParamType pt); //Dynamic width or height parameter int GetWidth(bool cutted = true); - int GetHeight(void); + int GetHeight(map < string, vector< map< string, string > > > *loopTokens = NULL); int GetContainerWidth(void) { return containerWidth; }; int GetContainerHeight(void) { return containerHeight; }; void GetNeededWidths(multimap *widths); diff --git a/libtemplate/templateloopfunction.c b/libtemplate/templateloopfunction.c index 4de9ec4..07219ac 100644 --- a/libtemplate/templateloopfunction.c +++ b/libtemplate/templateloopfunction.c @@ -21,8 +21,8 @@ void cTemplateLoopFunction::AddFunction(string name, vector if (!name.compare("drawtext")) { type = ftDrawText; } else if (!name.compare("drawtextbox")) { - type = ftDrawTextBox; - } else if (!name.compare("drawimage")) { + type = ftDrawTextBox; + } else if (!name.compare("drawimage")) { type = ftDrawImage; } else if (!name.compare("drawrectangle")) { type = ftDrawRectangle; @@ -149,6 +149,21 @@ int cTemplateLoopFunction::GetLoopElementsHeight(void) { return maxHeight; } +int cTemplateLoopFunction::CalculateHeight(map < string, vector< map< string, string > > > *loopTokens) { + if (!loopTokens) { + return 0; + } + int rowHeight = GetLoopElementsHeight(); + string loopName = GetParameter(ptName); + map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopName); + if (hit == loopTokens->end()) + return 0; + vector< map< string, string > > toks = hit->second; + int numElements = toks.size(); + + return numElements * rowHeight; +} + bool cTemplateLoopFunction::ReplaceWidthFunctions(void) { bool replaced = false; InitIterator(); diff --git a/libtemplate/templateloopfunction.h b/libtemplate/templateloopfunction.h index 599dfcb..1a28c65 100644 --- a/libtemplate/templateloopfunction.h +++ b/libtemplate/templateloopfunction.h @@ -26,6 +26,7 @@ public: int GetLoopElementsHeight(void); int GetContainerWidth(void) { return containerWidth; }; int GetContainerHeight(void) { return containerHeight; }; + int CalculateHeight(map < string, vector< map< string, string > > > *loopTokens); bool Ready(void); void Debug(void); }; diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c index 473561a..d6866b5 100644 --- a/libtemplate/templatepixmap.c +++ b/libtemplate/templatepixmap.c @@ -187,7 +187,7 @@ void cTemplatePixmap::ClearDynamicFunctionParameters(void) { } } -void cTemplatePixmap::ParseDynamicFunctionParameters(map *stringTokens, map *intTokens) { +void cTemplatePixmap::ParseDynamicFunctionParameters(map *stringTokens, map *intTokens, map < string, vector< map< string, string > > > *loopTokens) { InitIterator(); cTemplateFunction *func = NULL; bool completelyParsed = true; @@ -208,7 +208,7 @@ void cTemplatePixmap::ParseDynamicFunctionParameters(map *string } bool replacedWidth = ReplaceWidthFunctions(); - bool replacedHeight = ReplaceHeightFunctions(); + bool replacedHeight = ReplaceHeightFunctions(loopTokens); bool replacedPosX = ReplacePosXFunctions(); bool replacedPosY = ReplacePosYFunctions(); @@ -425,7 +425,7 @@ bool cTemplatePixmap::ReplaceWidthFunctions(void) { return replaced; } -bool cTemplatePixmap::ReplaceHeightFunctions(void) { +bool cTemplatePixmap::ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens) { bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; @@ -443,7 +443,7 @@ bool cTemplatePixmap::ReplaceHeightFunctions(void) { cTemplateFunction *myFunc = *it; string myFuncName = myFunc->GetParameter(ptName); if (!myFuncName.compare(label)) { - funcHeight = myFunc->GetHeight(); + funcHeight = myFunc->GetHeight(loopTokens); func->SetHeight(type, label, funcHeight); if (func->Updated()) { func->CompleteParameters(); diff --git a/libtemplate/templatepixmap.h b/libtemplate/templatepixmap.h index fd2d3ce..5f16f21 100644 --- a/libtemplate/templatepixmap.h +++ b/libtemplate/templatepixmap.h @@ -32,7 +32,7 @@ protected: cGlobals *globals; //functions replacing {width(label)} and {height(label)} tokens bool ReplaceWidthFunctions(void); - bool ReplaceHeightFunctions(void); + bool ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens); //functions replacing {posx(label)} and {posy(label)} tokens bool ReplacePosXFunctions(void); bool ReplacePosYFunctions(void); @@ -65,7 +65,7 @@ public: //Parse pixmap parameters with dynamically set Tokens void ParseDynamicParameters(map *stringTokens, map *intTokens, bool initFuncs); //Parse all function parameters with dynamically set Tokens - void ParseDynamicFunctionParameters(map *stringTokens, map *intTokens); + void ParseDynamicFunctionParameters(map *stringTokens, map *intTokens, map < string, vector< map< string, string > > > *loopTokens); //Calculate size of drawport in case area scrolls bool CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens = NULL); //Set max width for text in scrollarea diff --git a/libtemplate/xmlparser.c b/libtemplate/xmlparser.c index 4aa0a81..4db7ce5 100644 --- a/libtemplate/xmlparser.c +++ b/libtemplate/xmlparser.c @@ -320,13 +320,13 @@ string cXmlParser::GetPath(string xmlFile) { string activeTheme = Setup.OSDTheme; string path = ""; if (!xmlFile.compare("globals.xml")) { - path = *cString::sprintf("%s%s/%s", *config.skinPath, activeSkin.c_str(), xmlFile.c_str()); + path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); } else if (!xmlFile.compare("theme.xml")) { - path = *cString::sprintf("%s%s/themes/%s/%s", *config.skinPath, activeSkin.c_str(), activeTheme.c_str(), xmlFile.c_str()); + path = *cString::sprintf("%s%s/themes/%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), activeTheme.c_str(), xmlFile.c_str()); } else if (!xmlFile.compare("setup.xml")) { - path = *cString::sprintf("%s%s/%s", *config.skinPath, activeSkin.c_str(), xmlFile.c_str()); + path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); } else { - path = *cString::sprintf("%s%s/xmlfiles/%s", *config.skinPath, activeSkin.c_str(), xmlFile.c_str()); + path = *cString::sprintf("%s%s/xmlfiles/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); } return path; } -- cgit v1.2.3