bug fixes and updates

This commit is contained in:
Elmārs Āboliņš 2021-06-16 07:05:54 +03:00
parent 43e307295e
commit 8615cb7edc
7 changed files with 17 additions and 9 deletions

View File

@ -18,7 +18,7 @@ setmetatable(element, {
self = setmetatable({}, element) self = setmetatable({}, element)
self.parentFunc = func self.parentFunc = func
self:new(param,nil, w, h) self:new(param,nil, w, h, flags)
self:createProxies() self:createProxies()
---@type Element ---@type Element
@ -213,6 +213,11 @@ function element:setParam(p)
self.context:bubbleUpdate() self.context:bubbleUpdate()
end end
function element:setSize(w, h)
self.view.w = w or self.view.w
self.view.h = h or self.view.h
end
function element:setCalculatedSize(w, h) function element:setCalculatedSize(w, h)
self.view.minW = w or self.view.minW self.view.minW = w or self.view.minW
self.view.minH = h or self.view.minH self.view.minH = h or self.view.minH
@ -312,7 +317,9 @@ function element:externalRender()
if self.settings.hasCanvas then if self.settings.hasCanvas then
lg.translate(self.view.x, self.view.y) lg.translate(self.view.x, self.view.y)
setColor(1, 1, 1, 1) setColor(1, 1, 1, 1)
lg.setBlendMode('alpha','premultiplied')
draw(self.canvas, self.quad, 0, 0) draw(self.canvas, self.quad, 0, 0)
lg.setBlendMode('alpha','alphamultiply')
end end
lg.setScissor() lg.setScissor()
@ -320,6 +327,7 @@ function element:externalRender()
end end
function element:externalUpdate() function element:externalUpdate()
self.context:set()
self.context:zIndex() self.context:zIndex()
if not self.settings.failedCanvas if not self.settings.failedCanvas
and self.settings.testRenderPasses == 0 and self.settings.testRenderPasses == 0
@ -355,6 +363,7 @@ function element:externalUpdate()
self.deferRepos = false self.deferRepos = false
end end
self.context:unset()
return self.settings.remove return self.settings.remove
end end

View File

@ -167,11 +167,11 @@ function subscription:emit(...)
end end
function subscription:checkInside(x, y) function subscription:checkInside(x, y)
return x>self.x and x<self.x+self.w and y>self.y and y<self.y+self.h return x>self.stack.absX and x<self.stack.absX+self.w and y>self.stack.absY and y<self.stack.absY+self.h
end end
function subscription:checkOutside(x, y) function subscription:checkOutside(x, y)
return not (x>self.x and x<self.x+self.w and y>self.y and y<self.y+self.h) return not (x>self.stack.absX and x<self.stack.absX+self.w and y>self.stack.absY and y<self.stack.absY+self.h)
end end
---@alias InputMouseClickSubscriptionCallback fun(x:number, y:number, mouseButton:string) ---@alias InputMouseClickSubscriptionCallback fun(x:number, y:number, mouseButton:string)

View File

@ -11,5 +11,5 @@ return function (callback)
activeContext.element.callbacks.onUpdate = {} activeContext.element.callbacks.onUpdate = {}
end end
activeContext.element.callbacks.onUpdate[activeContext.element.callbacks.onUpdate+1] = callback activeContext.element.callbacks.onUpdate[#activeContext.element.callbacks.onUpdate+1] = callback
end end

View File

@ -1,4 +1,4 @@
local path = string.sub(..., 1, string.len(...) - string.len(".control.size")) local path = string.sub(..., 1, string.len(...) - string.len(".hooks.setPos"))
local stack = require(path..'.core.stack') local stack = require(path..'.core.stack')
--Sets the relative position --Sets the relative position

View File

@ -1,8 +1,8 @@
local path = string.sub(..., 1, string.len(...) - string.len(".control.size")) local path = string.sub(..., 1, string.len(...) - string.len(".hooks.setSize"))
local stack = require(path..'.core.stack') local stack = require(path..'.core.stack')
--Sets the computed/minimum size of an element to be used with layout calculations and rendering --Sets the computed/minimum size of an element to be used with layout calculations and rendering
return function(w, h) return function(w, h)
local currentStack = stack.getContext() local currentStack = stack.getContext()
currentStack.element:setCalculatedSize(w, h) currentStack.element:setSize(w, h)
end end

View File

@ -187,7 +187,6 @@ function grid:draw(xRoot, yRoot, width, height, children)
if (not autoRows) and (not autoCols) then if (not autoRows) and (not autoCols) then
if self.gridLayout.layout then if self.gridLayout.layout then
local layout = {} local layout = {}
--flip layout table --flip layout table
for x = 1, #self.gridLayout.layout[1] do for x = 1, #self.gridLayout.layout[1] do