summaryrefslogtreecommitdiff
path: root/scene/gui/tree.cpp
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2020-01-01 22:20:12 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2020-01-01 22:47:42 +0800
commita77e869b87383be8949cd9f246dda37ed96a3c8e (patch)
treedb5936d6bcca1f3824815586c06cfa02678259eb /scene/gui/tree.cpp
parent85fa17d3c29156011109f6ac375bedd9c69a5115 (diff)
Ensures cursor visible for Tree with title
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r--scene/gui/tree.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index b6ac3448fb..f9d1b9e49a 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3462,8 +3462,13 @@ void Tree::ensure_cursor_is_visible() {
int ofs = get_item_offset(selected);
if (ofs == -1)
return;
+
+ const int tbh = _get_title_button_height();
+ ofs -= tbh;
+
+ const int marginh = cache.bg->get_margin(MARGIN_TOP) + cache.bg->get_margin(MARGIN_BOTTOM);
int h = compute_item_height(selected) + cache.vseparation;
- int screenh = get_size().height - h_scroll->get_combined_minimum_size().height;
+ int screenh = get_size().height - h_scroll->get_combined_minimum_size().height - marginh - tbh;
if (h > screenh) { //screen size is too small, maybe it was not resized yet.
v_scroll->set_value(ofs);