Fix vertical tooltip clamping (#942)

master
diath 6 years ago committed by Ahmed Samy
parent cb508c6b9f
commit 7967bd4385

@ -10,13 +10,24 @@ local function moveToolTip(first)
if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end
local pos = g_window.getMousePosition() local pos = g_window.getMousePosition()
local windowSize = g_window.getSize()
local labelSize = toolTipLabel:getSize()
pos.x = pos.x + 1
pos.y = pos.y + 1 pos.y = pos.y + 1
local xdif = g_window.getSize().width - (pos.x + toolTipLabel:getWidth())
if xdif < 10 then if windowSize.width - (pos.x + labelSize.width) < 10 then
pos.x = pos.x - toolTipLabel:getWidth() - 3 pos.x = pos.x - labelSize.width - 3
else else
pos.x = pos.x + 10 pos.x = pos.x + 10
end end
if windowSize.height - (pos.y + labelSize.height) < 10 then
pos.y = pos.y - labelSize.height - 3
else
pos.y = pos.y + 10
end
toolTipLabel:setPosition(pos) toolTipLabel:setPosition(pos)
end end

Loading…
Cancel
Save