summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-07-27 12:37:03 +0200
committerGitHub <noreply@github.com>2022-07-27 12:37:03 +0200
commit950750fb983ac6bf11d31999e6bfa7bde2aeb6fc (patch)
treee02d6d3d7848c113caa8c2a2f840c4129e135f9e /scene/main
parentbb94e16bd85b27fc94048e859b9eca2b2d1f2c1d (diff)
parent46346cfaa59cf604d45684d097ee5b5f3af98903 (diff)
Merge pull request #63355 from YeldhamDev/directional_tooltip
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c2fa1ace8d..7876b00202 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1234,13 +1234,23 @@ void Viewport::_gui_show_tooltip() {
Rect2i vr = window->get_usable_parent_rect();
if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
- r.position.x = vr.position.x + vr.size.x - r.size.x;
+ // Place it in the opposite direction. If it fails, just hug the border.
+ r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x;
+
+ if (r.position.x < vr.position.x) {
+ r.position.x = vr.position.x + vr.size.x - r.size.x;
+ }
} else if (r.position.x < vr.position.x) {
r.position.x = vr.position.x;
}
if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
- r.position.y = vr.position.y + vr.size.y - r.size.y;
+ // Same as above.
+ r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y;
+
+ if (r.position.y < vr.position.y) {
+ r.position.y = vr.position.y + vr.size.y - r.size.y;
+ }
} else if (r.position.y < vr.position.y) {
r.position.y = vr.position.y;
}