Bläddra i källkod

Panels now have the "Plain" attribute to quickly fill with a color instead of generating a huge image from the theme.

David Piuva 3 år sedan
förälder
incheckning
4643d54e00

+ 9 - 3
Source/DFPSR/gui/components/Panel.cpp

@@ -30,12 +30,15 @@ PERSISTENT_DEFINITION(Panel)
 void Panel::declareAttributes(StructureDefinition &target) const {
 	VisualComponent::declareAttributes(target);
 	target.declareAttribute(U"Solid");
+	target.declareAttribute(U"Plain");
 	target.declareAttribute(U"Color");
 }
 
 Persistent* Panel::findAttribute(const ReadableString &name) {
 	if (string_caseInsensitiveMatch(name, U"Solid")) {
 		return &(this->solid);
+	} else if (string_caseInsensitiveMatch(name, U"Plain")) {
+		return &(this->plain);
 	} else if (string_caseInsensitiveMatch(name, U"Color") || string_caseInsensitiveMatch(name, U"BackColor")) {
 		// Both color and backcolor is accepted as names for the only color.
 		return &(this->color);
@@ -65,9 +68,12 @@ void Panel::generateGraphics() {
 // Fill the background with a solid color
 void Panel::drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) {
 	if (this->solid.value) {
-		this->generateGraphics();
-		draw_copy(targetImage, this->imageBackground, relativeLocation.left(), relativeLocation.top());
-		//draw_rectangle(targetImage, relativeLocation, ColorRgbaI32(this->color.value, 255));
+		if (this->plain.value) {
+			draw_rectangle(targetImage, relativeLocation, ColorRgbaI32(this->color.value, 255));
+		} else {
+			this->generateGraphics();
+			draw_copy(targetImage, this->imageBackground, relativeLocation.left(), relativeLocation.top());
+		}
 	}
 }
 

+ 1 - 0
Source/DFPSR/gui/components/Panel.h

@@ -33,6 +33,7 @@ PERSISTENT_DECLARATION(Panel)
 public:
 	// Attributes
 	PersistentBoolean solid; // If true, the panel itself will be drawn.
+	PersistentBoolean plain; // If true, a solid color will be drawn instead of a buffered image to save time and memory.
 	PersistentColor color; // The color being used when drawn is set to true.
 	void declareAttributes(StructureDefinition &target) const override;
 	Persistent* findAttribute(const ReadableString &name) override;

+ 1 - 0
Source/tools/wizard/media/Interface.lof

@@ -12,6 +12,7 @@
 		Solid = 1
 		Top = 50
 		Color = 0,0,0
+		Plain = 1
 		Begin : Picture
 			Name = "previewPicture"
 			Interpolation = 1