diff --git a/theme.lua b/theme.lua index 9611515..d0dd376 100644 --- a/theme.lua +++ b/theme.lua @@ -18,9 +18,9 @@ function theme.getColorForState(opt) return (opt.color and opt.color[opt.state]) or theme.color[s] end -function theme.drawBox(x,y,w,h, opt, colors) +function theme.drawBox(x,y,w,h, colors, cornerRadius) local colors = colors or theme.getColorForState(opt) - local cornerRadius = opt.cornerRadius or theme.cornerRadius + cornerRadius = cornerRadius or theme.cornerRadius love.graphics.setColor(colors.bg) love.graphics.rectangle('fill', x,y, w,h, cornerRadius) @@ -48,7 +48,7 @@ end function theme.Button(text, opt, x,y,w,h) local c = theme.getColorForState(opt) - theme.drawBox(x,y,w,h, opt) + theme.drawBox(x,y,w,h, c, opt.cornerRadius) love.graphics.setColor(c.fg) love.graphics.setFont(opt.font) @@ -60,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, opt) + theme.drawBox(x+h/10,y+h/10,h*.8,h*.8, c, opt.cornerRadius) love.graphics.setColor(c.fg) if chk.checked then love.graphics.setLineStyle('smooth') @@ -88,8 +88,8 @@ function theme.Slider(fraction, opt, x,y,w,h) end local c = theme.getColorForState(opt) - theme.drawBox(x,y,w,h, opt) - theme.drawBox(x,yb,wb,hb, opt, {bg=c.fg}) + theme.drawBox(x,y,w,h, c, opt.cornerRadius) + theme.drawBox(x,yb,wb,hb, {bg=c.fg}, opt.cornerRadius) 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) @@ -103,7 +103,7 @@ end function theme.Input(input, opt, x,y,w,h) local utf8 = require 'utf8' - theme.drawBox(x,y,w,h, opt, (opt.color and opt.color.normal) or theme.color.normal) + theme.drawBox(x,y,w,h, (opt.color and opt.color.normal) or theme.color.normal, opt.cornerRadius) x = x + 3 w = w - 6 @@ -115,7 +115,7 @@ function theme.Input(input, opt, x,y,w,h) x = x - input.text_draw_offset -- text - love.graphics.setColor(opt.color and opt.color.normal.fg or theme.color.normal.fg) + love.graphics.setColor((opt.color and opt.color.normal and opt.color.normal.fg) or theme.color.normal.fg) love.graphics.setFont(opt.font) love.graphics.print(input.text, x, y+(h-th)/2)