summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-07-20 21:49:32 +0200
committerGitHub <noreply@github.com>2021-07-20 21:49:32 +0200
commit693f9b4e20f76d56ead91f8a8cad204516d2d953 (patch)
treeeb98d46ce7bdef9fce187af3bcef7ebea7961a34 /scene/gui
parent3478690c0fd67efc4f269c08dc7093c04fbf86db (diff)
parenta6adb584934a885adf6ca775f2ef7118b66f684e (diff)
Merge pull request #50655 from JFonS/sname_opt
Editor StringName and Viewport optimizations
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/container.cpp6
-rw-r--r--scene/gui/control.cpp12
-rw-r--r--scene/gui/control.h2
3 files changed, 14 insertions, 6 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index dea69aae6b..c97434f69b 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -47,9 +47,9 @@ void Container::add_child_notify(Node *p_child) {
return;
}
- control->connect("size_flags_changed", callable_mp(this, &Container::queue_sort));
- control->connect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed));
- control->connect("visibility_changed", callable_mp(this, &Container::_child_minsize_changed));
+ control->connect(SNAME("size_flags_changed"), callable_mp(this, &Container::queue_sort));
+ control->connect(SNAME("minimum_size_changed"), callable_mp(this, &Container::_child_minsize_changed));
+ control->connect(SNAME("visibility_changed"), callable_mp(this, &Container::_child_minsize_changed));
minimum_size_changed();
queue_sort();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 718e754514..032533d4a9 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -446,6 +446,10 @@ Control *Control::get_parent_control() const {
return data.parent;
}
+Window *Control::get_parent_window() const {
+ return data.parent_window;
+}
+
void Control::set_layout_direction(Control::LayoutDirection p_direction) {
ERR_FAIL_INDEX((int)p_direction, 4);
@@ -459,21 +463,21 @@ Control::LayoutDirection Control::get_layout_direction() const {
bool Control::is_layout_rtl() const {
if (data.layout_dir == LAYOUT_DIRECTION_INHERITED) {
- Window *parent_window = Object::cast_to<Window>(get_parent());
+ Window *parent_window = get_parent_window();
Control *parent_control = get_parent_control();
if (parent_control) {
return parent_control->is_layout_rtl();
} else if (parent_window) {
return parent_window->is_layout_rtl();
} else {
- if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) {
+ if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) {
return true;
}
String locale = TranslationServer::get_singleton()->get_tool_locale();
return TS->is_locale_right_to_left(locale);
}
} else if (data.layout_dir == LAYOUT_DIRECTION_LOCALE) {
- if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) {
+ if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) {
return true;
}
String locale = TranslationServer::get_singleton()->get_tool_locale();
@@ -543,6 +547,7 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_ENTER_CANVAS: {
data.parent = Object::cast_to<Control>(get_parent());
+ data.parent_window = Object::cast_to<Window>(get_parent());
Node *parent = this; //meh
Control *parent_control = nullptr;
@@ -607,6 +612,7 @@ void Control::_notification(int p_notification) {
data.parent = nullptr;
data.parent_canvas_item = nullptr;
+ data.parent_window = nullptr;
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index fb01295668..51b454b334 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -202,6 +202,7 @@ private:
Ref<Theme> theme;
Control *theme_owner = nullptr;
Window *theme_owner_window = nullptr;
+ Window *parent_window = nullptr;
StringName theme_type_variation;
String tooltip;
@@ -342,6 +343,7 @@ public:
Size2 get_custom_minimum_size() const;
Control *get_parent_control() const;
+ Window *get_parent_window() const;
void set_layout_direction(LayoutDirection p_direction);
LayoutDirection get_layout_direction() const;