mirror of
https://github.com/kepler155c/opus
synced 2024-11-15 13:14:49 +00:00
41 lines
729 B
Lua
41 lines
729 B
Lua
|
local class = require('class')
|
||
|
local UI = require('ui')
|
||
|
|
||
|
UI.Image = class(UI.Window)
|
||
|
UI.Image.defaults = {
|
||
|
UIElement = 'Image',
|
||
|
event = 'button_press',
|
||
|
}
|
||
|
function UI.Image:setParent()
|
||
|
if self.image then
|
||
|
self.height = #self.image
|
||
|
end
|
||
|
if self.image and not self.width then
|
||
|
self.width = #self.image[1]
|
||
|
end
|
||
|
UI.Window.setParent(self)
|
||
|
end
|
||
|
|
||
|
function UI.Image:draw()
|
||
|
self:clear()
|
||
|
if self.image then
|
||
|
for y = 1, #self.image do
|
||
|
local line = self.image[y]
|
||
|
for x = 1, #line do
|
||
|
local ch = line[x]
|
||
|
if type(ch) == 'number' then
|
||
|
if ch > 0 then
|
||
|
self:write(x, y, ' ', ch)
|
||
|
end
|
||
|
else
|
||
|
self:write(x, y, ch)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function UI.Image:setImage(image)
|
||
|
self.image = image
|
||
|
end
|