yui/core.lua
Lorenzo Cogotti 1d42498ee7 [*] General code improvement.
* Rework navigation allowing direct management and triggering for grabkeyboard widgets.
* Navigation code now behaves better with deeply nested layouts.
* Allow widget hierarchies deeper than 2 (__call() is implemented for every Widget metatable).
* Make BASE locals more secure (match '<filename>$' in regexp)
2022-08-24 11:18:48 +02:00

28 lines
668 B
Lua

local BASE = (...):gsub('core$', '')
local core = { theme = require(BASE..'theme') }
core.__index = core
-- Helpers for drawing
function core.verticalOffsetForAlign(valign, font, h)
if valign == 'top' then
return 0
elseif valign == 'bottom' then
return h - font:getHeight()
end
-- else: "middle"
return (h - font:getHeight()) / 2
end
function core.drawBox(x,y,w,h, color, cornerRadius)
w = math.max(cornerRadius/2, w)
if h < cornerRadius/2 then
y,h = y - (cornerRadius - h), cornerRadius/2
end
love.graphics.setColor(color.bg)
love.graphics.rectangle('fill', x,y, w,h, cornerRadius)
end
return core