Просмотр исходного кода

Color of UIMultilineLabel is now set directly to the labels

Joachim Meyer 11 лет назад
Родитель
Сommit
6bea25ddac

+ 24 - 0
Modules/Contents/UI/Include/PolyUIElement.h

@@ -125,6 +125,30 @@ namespace Polycode {
         void setText(const String& text);
         String getText();
         
+		/**
+		* Sets the color of the Labels as normalized floating point values.
+		* @param r Red value as a 0-1 floating point number.
+		* @param g Green value as a 0-1 floating point number.
+		* @param b Blue value as a 0-1 floating point number.
+		* @param a Alpha value as a 0-1 floating point number.
+		*/
+		void setColor(Number r, Number g, Number b, Number a);
+
+		/**
+		* Sets the color of the entity as 0-255 integers.
+		* @param r Red value as a 0-255 integer.
+		* @param g Green value as a 0-255 integer.
+		* @param b Blue value as a 0-255 integer.
+		* @param a Alpha value as a 0-255 integer.
+		*/
+		void setColorInt(int r, int g, int b, int a);
+
+		/**
+		* Sets the color of the entity.
+		* @param color Color to set the entity color to.
+		*/
+		void setColor(Color color);
+
         ~UIMultilineLabel();
     protected:
         

+ 18 - 0
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -70,6 +70,24 @@ String UIMultilineLabel::getText() {
     return text;
 }
 
+void UIMultilineLabel::setColor(Color color) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColor(&color);
+	}
+}
+
+void UIMultilineLabel::setColorInt(int r, int g, int b, int a) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColorRGBA(r, g, b, a);
+	}
+}
+
+void UIMultilineLabel::setColor(Number r, Number g, Number b, Number a) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColor(r, g, b, a);
+	}
+}
+
 void UIMultilineLabel::clearLabels() {
     for(int i=0; i < labels.size(); i++) {
         removeChild(labels[i]);