Skip to content

Commit 82ddbe7

Browse files
committed
Fix scrollbar render with RTL scroll following visible
1 parent 0fdb93c commit 82ddbe7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

scene/gui/rich_text_label.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,11 @@ RID RichTextLabel::get_focused_accessibility_element() const {
23032303
return get_accessibility_element();
23042304
}
23052305

2306+
void RichTextLabel::_prepare_scroll_anchor() {
2307+
scroll_w = vscroll->get_combined_minimum_size().width;
2308+
vscroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_w);
2309+
}
2310+
23062311
void RichTextLabel::_notification(int p_what) {
23072312
switch (p_what) {
23082313
case NOTIFICATION_ACCESSIBILITY_INVALIDATE: {
@@ -2417,6 +2422,10 @@ void RichTextLabel::_notification(int p_what) {
24172422
queue_redraw();
24182423
} break;
24192424

2425+
case NOTIFICATION_READY: {
2426+
_prepare_scroll_anchor();
2427+
} break;
2428+
24202429
case NOTIFICATION_THEME_CHANGED: {
24212430
_stop_thread();
24222431
main->first_invalid_font_line.store(0); // Invalidate all lines.
@@ -2588,6 +2597,7 @@ void RichTextLabel::_notification(int p_what) {
25882597
from_line++;
25892598
}
25902599
if (scroll_follow_visible_characters && scroll_active) {
2600+
scroll_visible = follow_vc_pos > 0;
25912601
vscroll->set_visible(follow_vc_pos > 0);
25922602
}
25932603
if (has_focus() && get_tree()->is_accessibility_enabled()) {
@@ -3726,9 +3736,8 @@ _FORCE_INLINE_ float RichTextLabel::_update_scroll_exceeds(float p_total_height,
37263736
if (exceeds != scroll_visible) {
37273737
if (exceeds) {
37283738
scroll_visible = true;
3729-
scroll_w = vscroll->get_combined_minimum_size().width;
3739+
_prepare_scroll_anchor();
37303740
vscroll->show();
3731-
vscroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_w);
37323741
} else {
37333742
scroll_visible = false;
37343743
scroll_w = 0;

scene/gui/rich_text_label.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ class RichTextLabel : public Control {
591591
void _invalidate_accessibility();
592592
void _invalidate_current_line(ItemFrame *p_frame);
593593

594+
void _prepare_scroll_anchor();
595+
594596
void _thread_function(void *p_userdata);
595597
void _thread_end();
596598
void _stop_thread();

0 commit comments

Comments
 (0)