Browse Source

Inheriting theme from parent when adding new components to an interface.

David Piuva 6 months ago
parent
commit
3a33829d63
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Source/DFPSR/implementation/gui/VisualComponent.cpp

+ 4 - 0
Source/DFPSR/implementation/gui/VisualComponent.cpp

@@ -265,6 +265,8 @@ void VisualComponent::addChildComponent(Handle<VisualComponent> child) {
 		child->detachFromParent();
 		child->detachFromParent();
 		// Update layout based on the new parent size
 		// Update layout based on the new parent size
 		child->applyLayout(IRect(0, 0, this->location.width(), this->location.height()));
 		child->applyLayout(IRect(0, 0, this->location.width(), this->location.height()));
+		// Let the new component inherit the theme from its parent.
+		child->applyTheme(this->getTheme());
 		// Connect to the new parent
 		// Connect to the new parent
 		this->children.push(child);
 		this->children.push(child);
 		this->childChanged = true;
 		this->childChanged = true;
@@ -281,6 +283,8 @@ bool VisualComponent::addChild(Handle<Persistent> child) {
 		return false; // Wrong type!
 		return false; // Wrong type!
 	} else {
 	} else {
 		this->addChildComponent(visualComponent);
 		this->addChildComponent(visualComponent);
+		// Let the new component inherit the theme from its parent.
+		visualComponent->applyTheme(this->getTheme());
 		return true; // Success!
 		return true; // Success!
 	}
 	}
 }
 }