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

View File

@ -167,11 +167,11 @@ function subscription:emit(...)
end
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
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
---@alias InputMouseClickSubscriptionCallback fun(x:number, y:number, mouseButton:string)

View File

@ -11,5 +11,5 @@ return function (callback)
activeContext.element.callbacks.onUpdate = {}
end
activeContext.element.callbacks.onUpdate[activeContext.element.callbacks.onUpdate+1] = callback
activeContext.element.callbacks.onUpdate[#activeContext.element.callbacks.onUpdate+1] = callback
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')
--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')
--Sets the computed/minimum size of an element to be used with layout calculations and rendering
return function(w, h)
local currentStack = stack.getContext()
currentStack.element:setCalculatedSize(w, h)
currentStack.element:setSize(w, h)
end

View File

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

View File

@ -147,7 +147,7 @@ function layout:draw()
height = math.min(stack:normX(self.vars.width), maxW-x)
x = 0
end
self.callback(self.binder, x, y, width, height, children, self.vars.hpad, self.vars.vpad)
end