From 10e551d7604d4e3c871f74174fdd535fb9c8e61a Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 30 Mar 2015 18:05:53 +0200 Subject: [PATCH] fixed bug that parameters with both dynamic tokens and relative width, height, posx or posy values are not parsed correctly --- HISTORY | 3 ++- libtemplate/templatepixmap.c | 49 ++++++++++++++++++++++++++++++------ libtemplate/templatepixmap.h | 8 +++--- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/HISTORY b/HISTORY index 27b9a7b..95deb82 100644 --- a/HISTORY +++ b/HISTORY @@ -241,4 +241,5 @@ Version 0.3.3 - added viewelement with information about 5 newest recordings in main menu - +- fixed bug that parameters with both dynamic tokens and relative width, + height, posx or posy values are not parsed correctly diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c index 1490236..2dfba83 100644 --- a/libtemplate/templatepixmap.c +++ b/libtemplate/templatepixmap.c @@ -206,10 +206,27 @@ void cTemplatePixmap::ParseDynamicFunctionParameters(map *string return; } - ReplaceWidthFunctions(); - ReplaceHeightFunctions(); - ReplacePosXFunctions(); - ReplacePosYFunctions(); + bool replacedWidth = ReplaceWidthFunctions(); + bool replacedHeight = ReplaceHeightFunctions(); + bool replacedPosX = ReplacePosXFunctions(); + bool replacedPosY = ReplacePosYFunctions(); + + if (!replacedWidth && !replacedHeight && !replacedPosX && !replacedPosY) + return; + + InitIterator(); + func = NULL; + while(func = GetNextFunction()) { + if (func->ParsedCompletely()) + continue; + func->SetStringTokens(stringTokens); + func->SetIntTokens(intTokens); + func->ParseParameters(); + if (func->Updated()) + func->CompleteParameters(); + func->UnsetIntTokens(); + func->UnsetStringTokens(); + } } bool cTemplatePixmap::CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens) { @@ -376,7 +393,8 @@ bool cTemplatePixmap::Ready(void) { return true; } -void cTemplatePixmap::ReplaceWidthFunctions(void) { +bool cTemplatePixmap::ReplaceWidthFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -397,14 +415,18 @@ void cTemplatePixmap::ReplaceWidthFunctions(void) { func->SetWidth(type, label, funcWidth); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } + return replaced; } -void cTemplatePixmap::ReplaceHeightFunctions(void) { +bool cTemplatePixmap::ReplaceHeightFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -425,14 +447,18 @@ void cTemplatePixmap::ReplaceHeightFunctions(void) { func->SetHeight(type, label, funcHeight); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } + return replaced; } -void cTemplatePixmap::ReplacePosXFunctions(void) { +bool cTemplatePixmap::ReplacePosXFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -454,15 +480,19 @@ void cTemplatePixmap::ReplacePosXFunctions(void) { func->SetX(type, label, funcX); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } } + return replaced; } -void cTemplatePixmap::ReplacePosYFunctions(void) { +bool cTemplatePixmap::ReplacePosYFunctions(void) { + bool replaced = false; InitIterator(); cTemplateFunction *func = NULL; while(func = GetNextFunction()) { @@ -484,12 +514,15 @@ void cTemplatePixmap::ReplacePosYFunctions(void) { func->SetY(type, label, funcY); if (func->Updated()) { func->CompleteParameters(); + } else { + replaced = true; } } } } } } + return replaced; } void cTemplatePixmap::Debug(void) { diff --git a/libtemplate/templatepixmap.h b/libtemplate/templatepixmap.h index a5d8f83..3be1816 100644 --- a/libtemplate/templatepixmap.h +++ b/libtemplate/templatepixmap.h @@ -31,11 +31,11 @@ protected: int containerHeight; cGlobals *globals; //functions replacing {width(label)} and {height(label)} tokens - void ReplaceWidthFunctions(void); - void ReplaceHeightFunctions(void); + bool ReplaceWidthFunctions(void); + bool ReplaceHeightFunctions(void); //functions replacing {posx(label)} and {posy(label)} tokens - void ReplacePosXFunctions(void); - void ReplacePosYFunctions(void); + bool ReplacePosXFunctions(void); + bool ReplacePosYFunctions(void); //Get Scrolling Function cTemplateFunction *GetScrollFunction(void); public: