Coding style changes
This commit is contained in:
parent
f9ee40d53d
commit
c65c67cc63
1 changed files with 8 additions and 8 deletions
16
theme.lua
16
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue