Merge pull request #61346 from AaronRecord/fix-scrollbars-initializing

This commit is contained in:
Rémi Verschelde 2022-06-10 14:24:27 +02:00 committed by GitHub
commit 4987cd43bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 53 deletions

View File

@ -251,18 +251,7 @@ void ScrollContainer::ensure_control_visible(Control *p_control) {
set_v_scroll(get_v_scroll() + (diff.y - global_rect.position.y)); set_v_scroll(get_v_scroll() + (diff.y - global_rect.position.y));
} }
void ScrollContainer::_notification(int p_what) { void ScrollContainer::_update_dimensions() {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
call_deferred("_update_scrollbar_position");
};
if (p_what == NOTIFICATION_READY) {
Viewport *viewport = get_viewport();
ERR_FAIL_COND(!viewport);
viewport->connect("gui_focus_changed", this, "_gui_focus_changed");
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
child_max_size = Size2(0, 0); child_max_size = Size2(0, 0);
Size2 size = get_size(); Size2 size = get_size();
Point2 ofs; Point2 ofs;
@ -316,6 +305,22 @@ void ScrollContainer::_notification(int p_what) {
} }
update(); update();
}
void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
call_deferred("_update_scrollbar_position");
};
if (p_what == NOTIFICATION_READY) {
Viewport *viewport = get_viewport();
ERR_FAIL_COND(!viewport);
viewport->connect("gui_focus_changed", this, "_gui_focus_changed");
_update_dimensions();
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
_update_dimensions();
}; };
if (p_what == NOTIFICATION_DRAW) { if (p_what == NOTIFICATION_DRAW) {

View File

@ -70,6 +70,7 @@ protected:
void _gui_input(const Ref<InputEvent> &p_gui_input); void _gui_input(const Ref<InputEvent> &p_gui_input);
void _gui_focus_changed(Control *p_control); void _gui_focus_changed(Control *p_control);
void _update_dimensions();
void _notification(int p_what); void _notification(int p_what);
void _scroll_moved(float); void _scroll_moved(float);