Merge pull request #48771 from LightningAA/scrollcontainer-ensure-item-visible-3.x

[3.x] ScrollContainer: Expose `_ensure_focused_visible` to the scripting API and rename it to `ensure_control_visible`
This commit is contained in:
Rémi Verschelde
2021-06-01 12:58:56 +02:00
committed by GitHub
4 changed files with 31 additions and 32 deletions

View File

@ -1442,16 +1442,7 @@ Vector<ProjectList::Item> ProjectList::get_selected_projects() const {
void ProjectList::ensure_project_visible(int p_index) {
const Item &item = _projects[p_index];
int item_top = item.control->get_position().y;
int item_bottom = item.control->get_position().y + item.control->get_size().y;
if (item_top < get_v_scroll()) {
set_v_scroll(item_top);
} else if (item_bottom > get_v_scroll() + get_size().y) {
set_v_scroll(item_bottom - get_size().y);
}
ensure_control_visible(item.control);
}
int ProjectList::get_single_selected_index() const {