added valign bottom for vertical loops

This commit is contained in:
louis 2016-06-18 13:09:26 +02:00
parent 97a9c7e40f
commit 0460690ec8
4 changed files with 26 additions and 2 deletions

View File

@ -1785,6 +1785,7 @@ enum class eLoopAttribs {
rowheight, rowheight,
name, name,
orientation, orientation,
valign,
overflow, overflow,
maxitems, maxitems,
count count

View File

@ -1170,6 +1170,8 @@ void cFuncLoop::Set(vector<stringpair> &attributes) {
SetOrientation(id, attVal); SetOrientation(id, attVal);
} else if (IdEqual(id, (int)eLoopAttribs::overflow)) { } else if (IdEqual(id, (int)eLoopAttribs::overflow)) {
SetOverflow(id, attVal); SetOverflow(id, attVal);
} else if (IdEqual(id, (int)eLoopAttribs::valign)) {
SetAlign(id, attVal);
} else { } else {
attribCtors[id] = new cNumericExpr(attVal); 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); int maxItems = GetValue((int)eLoopAttribs::maxitems);
eOrientation orientation = (eOrientation)GetValue((int)eLoopAttribs::orientation); eOrientation orientation = (eOrientation)GetValue((int)eLoopAttribs::orientation);
eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow); eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow);
eAlign vAlign = (eAlign)GetValue((int)eLoopAttribs::valign);
int loopWidth = Width(); int loopWidth = Width();
if (loopWidth <= 0) if (loopWidth <= 0)
@ -1251,6 +1254,22 @@ void cFuncLoop::Render(cPixmap *p, int x0, int y0, int cw, int rh) {
int loopY = Y(); int loopY = Y();
int x = (loopX > 0) ? loopX : 0; int x = (loopX > 0) ? loopX : 0;
int y = (loopY > 0) ? loopY : 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) { for (int row = 0; row < numRows; ++row) {
if (maxItems > 0 && row >= maxItems) { if (maxItems > 0 && row >= maxItems) {
break; break;
@ -1371,12 +1390,14 @@ void cFuncLoop::SetAttributesDefs(void) {
attribIDs.insert(pair<string, int>("rowheight", (int)eLoopAttribs::rowheight)); attribIDs.insert(pair<string, int>("rowheight", (int)eLoopAttribs::rowheight));
attribIDs.insert(pair<string, int>("name", (int)eLoopAttribs::name)); attribIDs.insert(pair<string, int>("name", (int)eLoopAttribs::name));
attribIDs.insert(pair<string, int>("orientation", (int)eLoopAttribs::orientation)); attribIDs.insert(pair<string, int>("orientation", (int)eLoopAttribs::orientation));
attribIDs.insert(pair<string, int>("valign", (int)eLoopAttribs::valign));
attribIDs.insert(pair<string, int>("overflow", (int)eLoopAttribs::overflow)); attribIDs.insert(pair<string, int>("overflow", (int)eLoopAttribs::overflow));
attribIDs.insert(pair<string, int>("maxitems", (int)eLoopAttribs::maxitems)); attribIDs.insert(pair<string, int>("maxitems", (int)eLoopAttribs::maxitems));
attribNames.insert(pair<int, string>((int)eLoopAttribs::columnwidth, "columnwidth")); attribNames.insert(pair<int, string>((int)eLoopAttribs::columnwidth, "columnwidth"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::rowheight, "rowheight")); attribNames.insert(pair<int, string>((int)eLoopAttribs::rowheight, "rowheight"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::name, "name")); attribNames.insert(pair<int, string>((int)eLoopAttribs::name, "name"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::orientation, "orientation")); attribNames.insert(pair<int, string>((int)eLoopAttribs::orientation, "orientation"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::valign, "valign"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::overflow, "overflow")); attribNames.insert(pair<int, string>((int)eLoopAttribs::overflow, "overflow"));
attribNames.insert(pair<int, string>((int)eLoopAttribs::maxitems, "maxitems")); attribNames.insert(pair<int, string>((int)eLoopAttribs::maxitems, "maxitems"));
} }

View File

@ -187,6 +187,7 @@ public:
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0); void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
int FuncWidth(void); int FuncWidth(void);
int FuncHeight(void); int FuncHeight(void);
int Valign(void) { return GetValue((int)eLoopAttribs::valign); };
void Debug(void); void Debug(void);
}; };

View File

@ -50,8 +50,8 @@
<!ELEMENT loop (drawtext|drawtextbox|drawtextvertical|drawimage|drawrectangle|drawellipse|drawslope)+> <!ELEMENT loop (drawtext|drawtextbox|drawtextvertical|drawimage|drawrectangle|drawellipse|drawslope)+>
<!ATTLIST loop <!ATTLIST loop
x CDATA #REQUIRED x CDATA #IMPLIED
y CDATA #REQUIRED y CDATA #IMPLIED
width CDATA #IMPLIED width CDATA #IMPLIED
height CDATA #IMPLIED height CDATA #IMPLIED
columnwidth CDATA #IMPLIED columnwidth CDATA #IMPLIED
@ -60,6 +60,7 @@
orientation (horizontal|vertical|absolute) #REQUIRED orientation (horizontal|vertical|absolute) #REQUIRED
overflow (linewrap|cut) #IMPLIED overflow (linewrap|cut) #IMPLIED
maxitems CDATA #IMPLIED maxitems CDATA #IMPLIED
valign (top|bottom) #IMPLIED
debug (true|false) #IMPLIED debug (true|false) #IMPLIED
> >