Ver código fonte

Notifying containers about changes to child components automatically.

David Piuva 2 anos atrás
pai
commit
2911296c37

+ 18 - 0
Source/DFPSR/gui/VisualComponent.cpp

@@ -102,8 +102,17 @@ IRect VisualComponent::getLocation() {
 	return this->location;
 }
 
+void VisualComponent::changedAttribute(const ReadableString &name) {
+	if (this->parent) {
+		this->parent->childChanged = true;
+	}
+}
+
 void VisualComponent::setRegion(const FlexRegion &newRegion) {
 	this->region = newRegion;
+	if (this->parent) {
+		this->parent->childChanged = true;
+	}
 }
 
 FlexRegion VisualComponent::getRegion() const {
@@ -112,6 +121,9 @@ FlexRegion VisualComponent::getRegion() const {
 
 void VisualComponent::setVisible(bool visible) {
 	this->visible.value = visible;
+	if (this->parent) {
+		this->parent->childChanged = true;
+	}
 }
 
 bool VisualComponent::getVisible() const {
@@ -120,6 +132,9 @@ bool VisualComponent::getVisible() const {
 
 void VisualComponent::setName(const String& newName) {
 	this->name.value = newName;
+	if (this->parent) {
+		this->parent->childChanged = true;
+	}
 }
 
 String VisualComponent::getName() const {
@@ -128,6 +143,9 @@ String VisualComponent::getName() const {
 
 void VisualComponent::setIndex(int newIndex) {
 	this->index.value = newIndex;
+	if (this->parent) {
+		this->parent->childChanged = true;
+	}
 }
 
 int VisualComponent::getIndex() const {

+ 1 - 1
Source/DFPSR/gui/VisualComponent.h

@@ -268,7 +268,7 @@ public:
 	// Notifies when the theme has been changed, so that temporary data depending on the theme can be replaced.
 	virtual void changedTheme(VisualTheme newTheme);
 	// Override to be notified about individual attribute changes
-	virtual void changedAttribute(const ReadableString &name) {};
+	virtual void changedAttribute(const ReadableString &name);
 	// Override to be notified about location changes
 	virtual void changedLocation(const IRect &oldLocation, const IRect &newLocation) {};
 	// Custom call handler to manipulate components across a generic API

+ 1 - 0
Source/DFPSR/gui/components/Button.cpp

@@ -136,6 +136,7 @@ void Button::changedAttribute(const ReadableString &name) {
 	if (!string_caseInsensitiveMatch(name, U"Visible")) {
 		this->hasImages = false;
 	}
+	VisualComponent::changedAttribute(name);
 }
 
 IVector2D Button::getDesiredDimensions() {

+ 1 - 0
Source/DFPSR/gui/components/ListBox.cpp

@@ -212,6 +212,7 @@ void ListBox::changedAttribute(const ReadableString &name) {
 	}
 	this->limitSelection(false);
 	this->limitScrolling();
+	VisualComponent::changedAttribute(name);
 }
 
 void ListBox::setSelectedIndex(int64_t index, bool forceUpdate) {

+ 1 - 0
Source/DFPSR/gui/components/Menu.cpp

@@ -187,6 +187,7 @@ void Menu::changedAttribute(const ReadableString &name) {
 	if (!string_caseInsensitiveMatch(name, U"Visible")) {
 		this->hasImages = false;
 	}
+	VisualComponent::changedAttribute(name);
 }
 
 void Menu::updateStateEvent(ComponentState oldState, ComponentState newState) {

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

@@ -99,4 +99,5 @@ void Panel::changedAttribute(const ReadableString &name) {
 	if (!string_caseInsensitiveMatch(name, U"Visible")) {
 		this->hasImages = false;
 	}
+	VisualComponent::changedAttribute(name);
 }

+ 1 - 0
Source/DFPSR/gui/components/Picture.cpp

@@ -110,4 +110,5 @@ void Picture::changedAttribute(const ReadableString &name) {
 	if (!string_caseInsensitiveMatch(name, U"Visible")) {
 		this->hasImages = false;
 	}
+	VisualComponent::changedAttribute(name);
 }

+ 1 - 0
Source/DFPSR/gui/components/TextBox.cpp

@@ -540,6 +540,7 @@ void TextBox::changedAttribute(const ReadableString &name) {
 			this->limitScrolling(true);
 		}
 	}
+	VisualComponent::changedAttribute(name);
 }
 
 void TextBox::updateScrollRange() {

+ 1 - 0
Source/DFPSR/gui/components/Toolbar.cpp

@@ -105,6 +105,7 @@ void Toolbar::changedAttribute(const ReadableString &name) {
 	if (!string_caseInsensitiveMatch(name, U"Visible")) {
 		this->hasImages = false;
 	}
+	VisualComponent::changedAttribute(name);
 }
 
 void Toolbar::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {