canvas use in UI overhaul

This commit is contained in:
kepler155c@gmail.com 2019-01-30 16:27:09 -05:00
parent 817c345672
commit 89400ac1bd
3 changed files with 26 additions and 8 deletions

View File

@ -860,7 +860,17 @@ end
function UI.Window:addLayer(bg, fg)
local canvas = self:getCanvas()
canvas = canvas:addLayer(self, bg, fg)
local x, y = self.x, self.y
local parent = self.parent
while parent and not parent.canvas do
x = x + parent.x - 1
y = y + parent.y - 1
parent = parent.parent
end
canvas = canvas:addLayer({
x = x, y = y, height = self.height, width = self.width
}, bg, fg)
canvas:clear(bg or self.backgroundColor, fg or self.textColor)
return canvas
end
@ -2263,6 +2273,7 @@ end
function UI.Tabs:enable()
self.enabled = true
self.transitionHint = nil
self.tabBar:enable()
local menuItem = Util.find(self.tabBar.children, 'selected', true)
@ -2308,18 +2319,20 @@ UI.Tab.defaults = {
}
function UI.Tab:setParent()
UI.Window.setParent(self)
--self.canvas = self:addLayer()
self.canvas = self:addLayer()
end
function UI.Tab:enable(...)
--self.canvas:setVisible(true)
self.canvas:setVisible(true)
UI.Window.enable(self, ...)
--self:addTransition(self.parent.transitionHint or 'slideLeft')
if self.parent.transitionHint then
self:addTransition(self.parent.transitionHint)
end
self:focusFirst()
end
function UI.Tab:disable()
--self.canvas:setVisible(false)
self.canvas:setVisible(false)
UI.Window.disable(self)
end

View File

@ -111,9 +111,9 @@ end
function Canvas:setVisible(visible)
self.visible = visible
if not visible then
if not visible and self.parent then
self.parent:dirty()
-- set parent's lines to dirty for each line in self
-- TODO: set parent's lines to dirty for each line in self
end
end
@ -244,6 +244,11 @@ function Canvas:dirty()
for _, line in pairs(self.lines) do
line.dirty = true
end
if self.layers then
for _, canvas in pairs(self.layers) do
canvas:dirty()
end
end
end
function Canvas:clean()

View File

@ -545,7 +545,7 @@ function page.editor:eventHandler(event)
elseif event.type == 'form_complete' then
local values = self.form.values
UI:setPreviousPage()
self:hide()
self:updateApplications(values)
--page:refresh()
--page:draw()