Merge pull request #30 from tesselode/override-radius
Add more options to override theme properties
This commit is contained in:
commit
0947b08ff7
2 changed files with 13 additions and 7 deletions
|
@ -166,6 +166,9 @@ Common Options
|
|||
``color``
|
||||
A table to overwrite the color. Undefined colors default to the theme colors.
|
||||
|
||||
``cornerRadius``
|
||||
The corner radius for boxes. Overwrites the theme corner radius.
|
||||
|
||||
``draw``
|
||||
A function to replace the drawing function. Refer to :doc:`themes` for more information about the function signatures.
|
||||
|
||||
|
|
17
theme.lua
17
theme.lua
|
@ -18,9 +18,12 @@ function theme.getColorForState(opt)
|
|||
return (opt.color and opt.color[opt.state]) or theme.color[s]
|
||||
end
|
||||
|
||||
function theme.drawBox(x,y,w,h, colors)
|
||||
function theme.drawBox(x,y,w,h, opt, colors)
|
||||
local colors = colors or theme.getColorForState(opt)
|
||||
local cornerRadius = opt.cornerRadius or theme.cornerRadius
|
||||
|
||||
love.graphics.setColor(colors.bg)
|
||||
love.graphics.rectangle('fill', x,y, w,h, theme.cornerRadius)
|
||||
love.graphics.rectangle('fill', x,y, w,h, cornerRadius)
|
||||
end
|
||||
|
||||
function theme.getVerticalOffsetForAlign(valign, font, h)
|
||||
|
@ -45,7 +48,7 @@ end
|
|||
function theme.Button(text, opt, x,y,w,h)
|
||||
local c = theme.getColorForState(opt)
|
||||
|
||||
theme.drawBox(x,y,w,h, c)
|
||||
theme.drawBox(x,y,w,h, opt)
|
||||
love.graphics.setColor(c.fg)
|
||||
love.graphics.setFont(opt.font)
|
||||
|
||||
|
@ -57,7 +60,7 @@ function theme.Checkbox(chk, opt, x,y,w,h)
|
|||
local c = theme.getColorForState(opt)
|
||||
local th = opt.font:getHeight()
|
||||
|
||||
theme.drawBox(x+h/10,y+h/10,h*.8,h*.8, c)
|
||||
theme.drawBox(x+h/10,y+h/10,h*.8,h*.8, opt)
|
||||
love.graphics.setColor(c.fg)
|
||||
if chk.checked then
|
||||
love.graphics.setLineStyle('smooth')
|
||||
|
@ -85,8 +88,8 @@ function theme.Slider(fraction, opt, x,y,w,h)
|
|||
end
|
||||
|
||||
local c = theme.getColorForState(opt)
|
||||
theme.drawBox(x,y,w,h, c)
|
||||
theme.drawBox(x,yb,wb,hb, {bg=c.fg})
|
||||
theme.drawBox(x,y,w,h, opt)
|
||||
theme.drawBox(x,yb,wb,hb, opt, {bg=c.fg})
|
||||
|
||||
if opt.state ~= nil and opt.state ~= "normal" then
|
||||
love.graphics.setColor((opt.color and opt.color.active or {}).fg or theme.color.active.fg)
|
||||
|
@ -100,7 +103,7 @@ end
|
|||
|
||||
function theme.Input(input, opt, x,y,w,h)
|
||||
local utf8 = require 'utf8'
|
||||
theme.drawBox(x,y,w,h, (opt.color and opt.color.normal) or theme.color.normal)
|
||||
theme.drawBox(x,y,w,h, opt, (opt.color and opt.color.normal) or theme.color.normal)
|
||||
x = x + 3
|
||||
w = w - 6
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue