diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-28 09:03:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 09:03:15 +0100 |
commit | a6751e6c58e73d6b8d04e98bba5fb6e380fdf34f (patch) | |
tree | bf22de8b8d89dee6a3b59c22adacff8f62a8d5eb /scene/gui/box_container.cpp | |
parent | bd846001327dacd35a84b0759f8b7ca8b892e841 (diff) | |
parent | 7e2c0ffd1a19d5806a7fcf57e25d2465f7a8f8b6 (diff) |
Merge pull request #41100 from bruvzg/ctl_text_server_interface
[Complex Text Layouts] Implement TextServer interface.
Diffstat (limited to 'scene/gui/box_container.cpp')
-rw-r--r-- | scene/gui/box_container.cpp | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 33e030a573..fdd88d155f 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -44,6 +44,7 @@ void BoxContainer::_resort() { Size2i new_size = get_size(); int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer"); + bool rtl = is_layout_rtl(); bool first = true; int children_count = 0; @@ -152,22 +153,53 @@ void BoxContainer::_resort() { int ofs = 0; if (!has_stretched) { - switch (align) { - case ALIGN_BEGIN: - break; - case ALIGN_CENTER: - ofs = stretch_diff / 2; - break; - case ALIGN_END: - ofs = stretch_diff; - break; + if (!vertical) { + switch (align) { + case ALIGN_BEGIN: + if (rtl) { + ofs = stretch_diff; + } + break; + case ALIGN_CENTER: + ofs = stretch_diff / 2; + break; + case ALIGN_END: + if (!rtl) { + ofs = stretch_diff; + } + break; + } + } else { + switch (align) { + case ALIGN_BEGIN: + break; + case ALIGN_CENTER: + ofs = stretch_diff / 2; + break; + case ALIGN_END: + ofs = stretch_diff; + break; + } } } first = true; int idx = 0; - for (int i = 0; i < get_child_count(); i++) { + int start; + int end; + int delta; + if (!rtl || vertical) { + start = 0; + end = get_child_count(); + delta = +1; + } else { + start = get_child_count() - 1; + end = -1; + delta = -1; + } + + for (int i = start; i != end; i += delta) { Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) { continue; @@ -265,6 +297,10 @@ void BoxContainer::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { minimum_size_changed(); } break; + case NOTIFICATION_TRANSLATION_CHANGED: + case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { + queue_sort(); + } break; } } |