mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-10 08:18:22 +00:00
remove drawing methods from window
This commit is contained in:
@@ -17,17 +17,23 @@ function Renderer:loadImage (path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Renderer:renderBackground (widget, window)
|
function Renderer:renderBackground (widget, window)
|
||||||
local bg = widget.background
|
if not widget.background then return end
|
||||||
if not bg then return end
|
|
||||||
local bend = widget.bend
|
|
||||||
local x1, y1, x2, y2 = widget:getRectangle(true)
|
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
|
end
|
||||||
|
|
||||||
function Renderer:renderOutline (widget, window)
|
function Renderer:renderOutline (widget, window)
|
||||||
if not widget.outline then return end
|
if not widget.outline then return end
|
||||||
local x1, y1, x2, y2 = widget:getRectangle(true)
|
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
|
end
|
||||||
|
|
||||||
-- returns icon coordinates and rectangle with remaining space
|
-- returns icon coordinates and rectangle with remaining space
|
||||||
|
|||||||
@@ -22,27 +22,36 @@ function Slider:constructor(layout, data)
|
|||||||
self:onDisplay(function(event)
|
self:onDisplay(function(event)
|
||||||
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
||||||
local padding = self.padding or 0
|
local padding = self.padding or 0
|
||||||
self.layout.window:fill(
|
|
||||||
|
love.graphics.push('all')
|
||||||
|
|
||||||
|
love.graphics.setColor(self.outline)
|
||||||
|
|
||||||
|
love.graphics.rectangle('fill',
|
||||||
x1,
|
x1,
|
||||||
y1 + (y2 - y1) / 2 - padding / 2,
|
y1 + ((y2 - y1) / 2) - padding / 2,
|
||||||
x2,
|
x2 - x1,
|
||||||
y1 + (y2 - y1) / 2 + padding / 2,
|
padding
|
||||||
self.outline
|
|
||||||
)
|
)
|
||||||
self.layout.window:fill(
|
|
||||||
|
love.graphics.rectangle('line',
|
||||||
x1 + position * (x2 - x1) - padding,
|
x1 + position * (x2 - x1) - padding,
|
||||||
y1 + padding,
|
y1 + padding,
|
||||||
x1 + position * (x2 - x1) + padding,
|
padding * 2,
|
||||||
y2 - padding,
|
y2 - y1 - padding
|
||||||
self.background
|
|
||||||
)
|
)
|
||||||
self.layout.window:outline(
|
|
||||||
|
love.graphics.setColor(self.background)
|
||||||
|
|
||||||
|
love.graphics.rectangle('fill',
|
||||||
x1 + position * (x2 - x1) - padding,
|
x1 + position * (x2 - x1) - padding,
|
||||||
y1 + padding,
|
y1 + padding,
|
||||||
x1 + position * (x2 - x1) + padding,
|
padding * 2,
|
||||||
y2 - padding,
|
y2 - y1 - padding
|
||||||
self.outline
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
love.graphics.pop()
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -75,30 +75,6 @@ function Window:hide ()
|
|||||||
self:unhook()
|
self:unhook()
|
||||||
end
|
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)
|
function Window:update (reshape)
|
||||||
if reshape then
|
if reshape then
|
||||||
for i, widget in ipairs(self.input.layout.widgets) do
|
for i, widget in ipairs(self.input.layout.widgets) do
|
||||||
|
|||||||
Reference in New Issue
Block a user