[3.x] Allow ScrollBar params of a ScrollContainer to be modified from _ready()
Cherrypicks b8610dbd31
This commit is contained in:
parent
5f9bc7ea5a
commit
ae9e523025
2 changed files with 59 additions and 53 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue