1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-16 10:19:59 +00:00

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) function UI.Window:addLayer(bg, fg)
local canvas = self:getCanvas() 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) canvas:clear(bg or self.backgroundColor, fg or self.textColor)
return canvas return canvas
end end
@ -2263,6 +2273,7 @@ end
function UI.Tabs:enable() function UI.Tabs:enable()
self.enabled = true self.enabled = true
self.transitionHint = nil
self.tabBar:enable() self.tabBar:enable()
local menuItem = Util.find(self.tabBar.children, 'selected', true) local menuItem = Util.find(self.tabBar.children, 'selected', true)
@ -2308,18 +2319,20 @@ UI.Tab.defaults = {
} }
function UI.Tab:setParent() function UI.Tab:setParent()
UI.Window.setParent(self) UI.Window.setParent(self)
--self.canvas = self:addLayer() self.canvas = self:addLayer()
end end
function UI.Tab:enable(...) function UI.Tab:enable(...)
--self.canvas:setVisible(true) self.canvas:setVisible(true)
UI.Window.enable(self, ...) UI.Window.enable(self, ...)
--self:addTransition(self.parent.transitionHint or 'slideLeft') if self.parent.transitionHint then
self:addTransition(self.parent.transitionHint)
end
self:focusFirst() self:focusFirst()
end end
function UI.Tab:disable() function UI.Tab:disable()
--self.canvas:setVisible(false) self.canvas:setVisible(false)
UI.Window.disable(self) UI.Window.disable(self)
end end

View File

@ -111,9 +111,9 @@ end
function Canvas:setVisible(visible) function Canvas:setVisible(visible)
self.visible = visible self.visible = visible
if not visible then if not visible and self.parent then
self.parent:dirty() 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
end end
@ -244,6 +244,11 @@ function Canvas:dirty()
for _, line in pairs(self.lines) do for _, line in pairs(self.lines) do
line.dirty = true line.dirty = true
end end
if self.layers then
for _, canvas in pairs(self.layers) do
canvas:dirty()
end
end
end end
function Canvas:clean() function Canvas:clean()

View File

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