Text widget: intersect scissor.

Fixes a visual bug where text would display outside widget boundary.
Mved intersectScissor to Backend.
This commit is contained in:
airstruck
2016-02-08 11:52:10 -05:00
parent a4a34ce787
commit 971afaf1e7
4 changed files with 27 additions and 23 deletions

View File

@@ -1,8 +1,27 @@
local ROOT = (...):gsub('[^.]*$', '')
local Backend
if _G.love and _G.love._version_minor > 8 then
return require(ROOT .. 'backend.love')
Backend = require(ROOT .. 'backend.love')
else
return require(ROOT .. 'backend.ffisdl')
Backend = require(ROOT .. 'backend.ffisdl')
end
Backend.intersectScissor = Backend.intersectScissor or function (x, y, w, h)
local sx, sy, sw, sh = Backend.getScissor()
if not sx then
return Backend.setScissor(x, y, w, h)
end
local x1 = math.max(sx, x)
local y1 = math.max(sy, y)
local x2 = math.min(sx + sw, x + w)
local y2 = math.min(sy + sh, y + h)
if x2 > x1 and y2 > y1 then
Backend.setScissor(x1, y1, x2 - x1, y2 - y1)
else
-- HACK
Backend.setScissor(-100, -100, 1, 1)
end
end
return Backend