Skip to content

Commit a69be0d

Browse files
committed
Merge pull request #508 from fodinabor/UIMultilineLabelFixes
Ui multiline label fixes
2 parents 713fe07 + 6bea25d commit a69be0d

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Modules/Contents/UI/Include/PolyUIElement.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,30 @@ namespace Polycode {
125125
void setText(const String& text);
126126
String getText();
127127

128+
/**
129+
* Sets the color of the Labels as normalized floating point values.
130+
* @param r Red value as a 0-1 floating point number.
131+
* @param g Green value as a 0-1 floating point number.
132+
* @param b Blue value as a 0-1 floating point number.
133+
* @param a Alpha value as a 0-1 floating point number.
134+
*/
135+
void setColor(Number r, Number g, Number b, Number a);
136+
137+
/**
138+
* Sets the color of the entity as 0-255 integers.
139+
* @param r Red value as a 0-255 integer.
140+
* @param g Green value as a 0-255 integer.
141+
* @param b Blue value as a 0-255 integer.
142+
* @param a Alpha value as a 0-255 integer.
143+
*/
144+
void setColorInt(int r, int g, int b, int a);
145+
146+
/**
147+
* Sets the color of the entity.
148+
* @param color Color to set the entity color to.
149+
*/
150+
void setColor(Color color);
151+
128152
~UIMultilineLabel();
129153
protected:
130154

Modules/Contents/UI/Source/PolyUIElement.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ void UIMultilineLabel::setText(const String& text) {
5151
} else {
5252
UILabel *label = new UILabel(lines[i], labelSize, labelFontName, labelAAMode);
5353
lineSize = label->getHeight();
54-
addChild(label);
5554
label->setPositionY(yPos);
5655
yPos += label->getHeight() + spacing;
5756
addChild(label);
57+
labels.push_back(label);
5858
}
5959
}
6060
}
@@ -70,6 +70,24 @@ String UIMultilineLabel::getText() {
7070
return text;
7171
}
7272

73+
void UIMultilineLabel::setColor(Color color) {
74+
for (int i = 0; i < labels.size(); i++) {
75+
labels[i]->color.setColor(&color);
76+
}
77+
}
78+
79+
void UIMultilineLabel::setColorInt(int r, int g, int b, int a) {
80+
for (int i = 0; i < labels.size(); i++) {
81+
labels[i]->color.setColorRGBA(r, g, b, a);
82+
}
83+
}
84+
85+
void UIMultilineLabel::setColor(Number r, Number g, Number b, Number a) {
86+
for (int i = 0; i < labels.size(); i++) {
87+
labels[i]->color.setColor(r, g, b, a);
88+
}
89+
}
90+
7391
void UIMultilineLabel::clearLabels() {
7492
for(int i=0; i < labels.size(); i++) {
7593
removeChild(labels[i]);

0 commit comments

Comments
 (0)