From 30c07c1ae16e13113cde92da8ecacdfe6fcde1d9 Mon Sep 17 00:00:00 2001 From: Andrettin Date: Sat, 2 Mar 2019 12:11:42 +0100 Subject: [PATCH] Made the tooltip position offset configurable --- doc/classes/ProjectSettings.xml | 3 +++ main/main.cpp | 1 + scene/main/viewport.cpp | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 1782edf25d6..aa7339445fd 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -319,6 +319,9 @@ Hotspot for the custom mouse cursor image. + + Position offset for tooltips, relative to the hotspot of the mouse cursor. + Allow HiDPI display on Windows and OSX. On Desktop Linux, this can't be enabled or disabled. diff --git a/main/main.cpp b/main/main.cpp index 9b062d39515..96117cdc97c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1209,6 +1209,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { GLOBAL_DEF("display/mouse_cursor/custom_image", String()); GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2()); + GLOBAL_DEF("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); ProjectSettings::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image", PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp")); if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) { diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 090e6bdcb0a..0fa36cc308e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1486,7 +1486,8 @@ void Viewport::_gui_show_tooltip() { gui.tooltip_popup->set_as_toplevel(true); //gui.tooltip_popup->hide(); - Rect2 r(gui.tooltip_pos + Point2(10, 10), gui.tooltip_popup->get_minimum_size()); + Point2 tooltip_offset = ProjectSettings::get_singleton()->get("display/mouse_cursor/tooltip_position_offset"); + Rect2 r(gui.tooltip_pos + tooltip_offset, gui.tooltip_popup->get_minimum_size()); Rect2 vr = gui.tooltip_popup->get_viewport_rect(); if (r.size.x + r.position.x > vr.size.x) r.position.x = vr.size.x - r.size.x;