From 6872e29fe6d628acd95a5f5eded6f372102fea31 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 11 Apr 2015 16:21:33 +0200 Subject: added possibility to draw a debug grid in views --- libtemplate/templatefunction.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libtemplate/templatefunction.c') diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index 2e6a743..7b76539 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -49,6 +49,10 @@ void cTemplateFunction::SetParameters(vector > params) { debug = true; } continue; + } else if (!name.compare("debuggrid")) { + string value = it->second; + SetDebugGrid(value); + continue; } else if (!name.compare("condition")) { p.first = ptCond; } else if (!name.compare("name")) { @@ -429,6 +433,8 @@ int cTemplateFunction::GetNumericParameter(eParamType type) { return 0; else if (type == ptBackground) return 0; + else if (type == ptDrawDebugGrid) + return 0; else if (type == ptDirection) return diBottomUp; return -1; @@ -1119,6 +1125,25 @@ bool cTemplateFunction::SetDirection(string value) { return true; } +void cTemplateFunction::SetDebugGrid(string value) { + int numGridsX = 0; + int numGridsY = 0; + size_t posSep = value.find("x"); + if (posSep != string::npos) { + string x = value.substr(0, posSep); + string y = value.substr(posSep+1); + numGridsX = atoi(x.c_str()); + numGridsY = atoi(y.c_str()); + } + if (numGridsX < 1) + numGridsX = 10; + if (numGridsY < 1) + numGridsY = 10; + numericParameters.insert(pair(ptDebugGridX, numGridsX)); + numericParameters.insert(pair(ptDebugGridY, numGridsY)); + numericParameters.insert(pair(ptDrawDebugGrid, 1)); +} + void cTemplateFunction::ParseStringParameters(void) { //first replace stringtokens in Text (drawText) stringstream text; -- cgit v1.2.3