From 0460690ec8e9f9aaf8f86abce9ece2ff16233424 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 18 Jun 2016 13:09:26 +0200 Subject: added valign bottom for vertical loops --- coreengine/definitions.h | 1 + coreengine/functions.c | 21 +++++++++++++++++++++ coreengine/functions.h | 1 + 3 files changed, 23 insertions(+) (limited to 'coreengine') diff --git a/coreengine/definitions.h b/coreengine/definitions.h index 5d8ecc0..e2a8e4d 100644 --- a/coreengine/definitions.h +++ b/coreengine/definitions.h @@ -1785,6 +1785,7 @@ enum class eLoopAttribs { rowheight, name, orientation, + valign, overflow, maxitems, count diff --git a/coreengine/functions.c b/coreengine/functions.c index dd5ecfe..928abf3 100644 --- a/coreengine/functions.c +++ b/coreengine/functions.c @@ -1170,6 +1170,8 @@ void cFuncLoop::Set(vector &attributes) { SetOrientation(id, attVal); } else if (IdEqual(id, (int)eLoopAttribs::overflow)) { SetOverflow(id, attVal); + } else if (IdEqual(id, (int)eLoopAttribs::valign)) { + SetAlign(id, attVal); } else { attribCtors[id] = new cNumericExpr(attVal); } @@ -1235,6 +1237,7 @@ void cFuncLoop::Render(cPixmap *p, int x0, int y0, int cw, int rh) { int maxItems = GetValue((int)eLoopAttribs::maxitems); eOrientation orientation = (eOrientation)GetValue((int)eLoopAttribs::orientation); eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow); + eAlign vAlign = (eAlign)GetValue((int)eLoopAttribs::valign); int loopWidth = Width(); if (loopWidth <= 0) @@ -1251,6 +1254,22 @@ void cFuncLoop::Render(cPixmap *p, int x0, int y0, int cw, int rh) { int loopY = Y(); int x = (loopX > 0) ? loopX : 0; int y = (loopY > 0) ? loopY : 0; + + //set y position for vertical loop with valign bottom + if (orientation == eOrientation::vertical && vAlign == eAlign::bottom) { + int actRowheight = (rowHeight > 0) ? rowHeight : RowHeight(); + if (actRowheight > 0) { + float fTotalItems = (float)loopHeight / (float)actRowheight; + int totalItems = (int)fTotalItems; + if (fTotalItems - (float)totalItems > 0.5f) + totalItems++; + if (maxItems > 0 && maxItems < totalItems) + totalItems = maxItems; + if (numRows < totalItems) + y += (totalItems - numRows) * actRowheight; + } + } + for (int row = 0; row < numRows; ++row) { if (maxItems > 0 && row >= maxItems) { break; @@ -1371,12 +1390,14 @@ void cFuncLoop::SetAttributesDefs(void) { attribIDs.insert(pair("rowheight", (int)eLoopAttribs::rowheight)); attribIDs.insert(pair("name", (int)eLoopAttribs::name)); attribIDs.insert(pair("orientation", (int)eLoopAttribs::orientation)); + attribIDs.insert(pair("valign", (int)eLoopAttribs::valign)); attribIDs.insert(pair("overflow", (int)eLoopAttribs::overflow)); attribIDs.insert(pair("maxitems", (int)eLoopAttribs::maxitems)); attribNames.insert(pair((int)eLoopAttribs::columnwidth, "columnwidth")); attribNames.insert(pair((int)eLoopAttribs::rowheight, "rowheight")); attribNames.insert(pair((int)eLoopAttribs::name, "name")); attribNames.insert(pair((int)eLoopAttribs::orientation, "orientation")); + attribNames.insert(pair((int)eLoopAttribs::valign, "valign")); attribNames.insert(pair((int)eLoopAttribs::overflow, "overflow")); attribNames.insert(pair((int)eLoopAttribs::maxitems, "maxitems")); } diff --git a/coreengine/functions.h b/coreengine/functions.h index 90d2045..1607618 100644 --- a/coreengine/functions.h +++ b/coreengine/functions.h @@ -187,6 +187,7 @@ public: void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0); int FuncWidth(void); int FuncHeight(void); + int Valign(void) { return GetValue((int)eLoopAttribs::valign); }; void Debug(void); }; -- cgit v1.2.3