Browse Source

Fix vertical tooltip clamping (#942)

diath 3 years ago
parent
commit
7967bd4385
1 changed files with 14 additions and 3 deletions
  1. 14
    3
      modules/corelib/ui/tooltip.lua

+ 14
- 3
modules/corelib/ui/tooltip.lua View File

@@ -10,13 +10,24 @@ local function moveToolTip(first)
10 10
   if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end
11 11
 
12 12
   local pos = g_window.getMousePosition()
13
+  local windowSize = g_window.getSize()
14
+  local labelSize = toolTipLabel:getSize()
15
+
16
+  pos.x = pos.x + 1
13 17
   pos.y = pos.y + 1
14
-  local xdif = g_window.getSize().width - (pos.x + toolTipLabel:getWidth())
15
-  if xdif < 10 then
16
-    pos.x = pos.x - toolTipLabel:getWidth() - 3
18
+
19
+  if windowSize.width - (pos.x + labelSize.width) < 10 then
20
+    pos.x = pos.x - labelSize.width - 3
17 21
   else
18 22
     pos.x = pos.x + 10
19 23
   end
24
+
25
+  if windowSize.height - (pos.y + labelSize.height) < 10 then
26
+    pos.y = pos.y - labelSize.height - 3
27
+  else
28
+    pos.y = pos.y + 10
29
+  end
30
+
20 31
   toolTipLabel:setPosition(pos)
21 32
 end
22 33
 

Loading…
Cancel
Save