Skip to content

Commit

Permalink
Merge pull request #26484 from Andrettin/Configurable-Tooltip-Offset
Browse files Browse the repository at this point in the history
Make the Tooltip Position Offset Configurable
  • Loading branch information
akien-mga authored Mar 13, 2019
2 parents cad371d + 30c07c1 commit 775e74e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@
<member name="display/mouse_cursor/custom_image_hotspot" type="Vector2" setter="" getter="">
Hotspot for the custom mouse cursor image.
</member>
<member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="">
Position offset for tooltips, relative to the hotspot of the mouse cursor.
</member>
<member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="">
Allow HiDPI display on Windows and OSX. On Desktop Linux, this can't be enabled or disabled.
</member>
Expand Down
1 change: 1 addition & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
3 changes: 2 additions & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,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;
Expand Down

0 comments on commit 775e74e

Please sign in to comment.