summaryrefslogtreecommitdiffstats
path: root/scene/gui/control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r--scene/gui/control.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index ed54bd000c..84ca6bac5b 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -197,6 +197,12 @@ void Control::reparent(Node *p_parent, bool p_keep_global_transform) {
// Editor integration.
+int Control::root_layout_direction = 0;
+
+void Control::set_root_layout_direction(int p_root_dir) {
+ root_layout_direction = p_root_dir;
+}
+
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
ERR_READ_THREAD_GUARD;
Node::get_argument_options(p_function, p_idx, r_options);
@@ -3024,10 +3030,35 @@ bool Control::is_layout_rtl() const {
if (data.is_rtl_dirty) {
const_cast<Control *>(this)->data.is_rtl_dirty = false;
if (data.layout_dir == LAYOUT_DIRECTION_INHERITED) {
+#ifdef TOOLS_ENABLED
+ if (is_part_of_edited_scene() && GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) {
+ const_cast<Control *>(this)->data.is_rtl = true;
+ return data.is_rtl;
+ }
+ if (is_inside_tree()) {
+ Node *edited_scene_root = get_tree()->get_edited_scene_root();
+ if (edited_scene_root == this) {
+ int proj_root_layout_direction = GLOBAL_GET(SNAME("internationalization/rendering/root_node_layout_direction"));
+ if (proj_root_layout_direction == 1) {
+ const_cast<Control *>(this)->data.is_rtl = false;
+ } else if (proj_root_layout_direction == 2) {
+ const_cast<Control *>(this)->data.is_rtl = true;
+ } else if (proj_root_layout_direction == 3) {
+ String locale = OS::get_singleton()->get_locale();
+ const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale);
+ } else {
+ String locale = TranslationServer::get_singleton()->get_tool_locale();
+ const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale);
+ }
+ return data.is_rtl;
+ }
+ }
+#else
if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) {
const_cast<Control *>(this)->data.is_rtl = true;
return data.is_rtl;
}
+#endif
Node *parent_node = get_parent();
while (parent_node) {
Control *parent_control = Object::cast_to<Control>(parent_node);
@@ -3044,11 +3075,13 @@ bool Control::is_layout_rtl() const {
parent_node = parent_node->get_parent();
}
- int root_dir = GLOBAL_GET(SNAME("internationalization/rendering/root_node_layout_direction"));
- if (root_dir == 1) {
+ if (root_layout_direction == 1) {
const_cast<Control *>(this)->data.is_rtl = false;
- } else if (root_dir == 2) {
+ } else if (root_layout_direction == 2) {
const_cast<Control *>(this)->data.is_rtl = true;
+ } else if (root_layout_direction == 3) {
+ String locale = OS::get_singleton()->get_locale();
+ const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale);
} else {
String locale = TranslationServer::get_singleton()->get_tool_locale();
const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale);