summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-03-03 16:00:29 -0300
committerJuan Linietsky <juan@godotengine.org>2019-03-03 16:00:56 -0300
commit6b8b1cabae3d17c0ad36c067ffb42cb03d9f5c8f (patch)
treec894ff0d728c4601ca819ad446df6f18d53c2913 /scene/gui
parent9357d691a2b15eb11b68d1d0d3f4ead588c0f28b (diff)
Add a warning when using plain Container, as many users seem to misunderstand what this is.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/container.cpp13
-rw-r--r--scene/gui/container.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 2579321773..7f1ca58d58 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -169,6 +169,19 @@ void Container::_notification(int p_what) {
}
}
+String Container::get_configuration_warning() const {
+
+ String warning = Control::get_configuration_warning();
+
+ if (get_class() == "Container" && get_script().is_null()) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("Container by itself serves no purpose unless a script configures it's children placement behavior.\nIf you dont't intend to add a script, then please use a plain 'Control' node instead.");
+ }
+ return warning;
+}
+
void Container::_bind_methods() {
ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children);
diff --git a/scene/gui/container.h b/scene/gui/container.h
index 0b014137f4..80d3f6ee5d 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -57,6 +57,8 @@ public:
void fit_child_in_rect(Control *p_child, const Rect2 &p_rect);
+ virtual String get_configuration_warning() const;
+
Container();
};