remove drawing methods from window

This commit is contained in:
airstruck
2015-10-23 02:03:48 -04:00
parent 03f0a48ff8
commit efc161ea2e
3 changed files with 33 additions and 42 deletions

View File

@@ -17,17 +17,23 @@ function Renderer:loadImage (path)
end
function Renderer:renderBackground (widget, window)
local bg = widget.background
if not bg then return end
local bend = widget.bend
if not widget.background then return end
local x1, y1, x2, y2 = widget:getRectangle(true)
window:fill(x1, y1, x2, y2, bg)
love.graphics.push('all')
love.graphics.setColor(widget.background)
love.graphics.rectangle('fill', x1, y1, x2 - x1, y2 - y1)
love.graphics.pop()
end
function Renderer:renderOutline (widget, window)
if not widget.outline then return end
local x1, y1, x2, y2 = widget:getRectangle(true)
window:outline(x1, y1, x2, y2, widget.outline)
love.graphics.push('all')
love.graphics.setColor(widget.outline)
love.graphics.rectangle('line', x1, y1, x2 - x1, y2 - y1)
love.graphics.pop()
end
-- returns icon coordinates and rectangle with remaining space

View File

@@ -22,27 +22,36 @@ function Slider:constructor(layout, data)
self:onDisplay(function(event)
local x1, y1, x2, y2 = self:getRectangle(true, true)
local padding = self.padding or 0
self.layout.window:fill(
love.graphics.push('all')
love.graphics.setColor(self.outline)
love.graphics.rectangle('fill',
x1,
y1 + (y2 - y1) / 2 - padding / 2,
x2,
y1 + (y2 - y1) / 2 + padding / 2,
self.outline
y1 + ((y2 - y1) / 2) - padding / 2,
x2 - x1,
padding
)
self.layout.window:fill(
love.graphics.rectangle('line',
x1 + position * (x2 - x1) - padding,
y1 + padding,
x1 + position * (x2 - x1) + padding,
y2 - padding,
self.background
padding * 2,
y2 - y1 - padding
)
self.layout.window:outline(
love.graphics.setColor(self.background)
love.graphics.rectangle('fill',
x1 + position * (x2 - x1) - padding,
y1 + padding,
x1 + position * (x2 - x1) + padding,
y2 - padding,
self.outline
padding * 2,
y2 - y1 - padding
)
love.graphics.pop()
return false
end)

View File

@@ -75,30 +75,6 @@ function Window:hide ()
self:unhook()
end
function Window:fill (x1, y1, x2, y2, color)
love.graphics.push('all')
love.graphics.setColor(color)
love.graphics.rectangle('fill', x1, y1, x2 - x1, y2 - y1)
love.graphics.pop()
end
function Window:outline (x1, y1, x2, y2, color)
love.graphics.push('all')
love.graphics.setColor(color)
love.graphics.rectangle('line', x1, y1, x2 - x1, y2 - y1)
love.graphics.pop()
end
function Window:write (x, y, x1, y1, x2, y2, text, font)
local layout = font.layout
love.graphics.push('all')
love.graphics.setFont(font.font)
love.graphics.setColor(font.color)
love.graphics.printf(text, x, y, layout.width or x2 - x1, layout.align)
love.graphics.pop()
end
function Window:update (reshape)
if reshape then
for i, widget in ipairs(self.input.layout.widgets) do