help
This commit is contained in:
parent
32befc1a89
commit
3bd423243e
@ -3,5 +3,6 @@ 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)
|
||||
end
|
||||
@ -1,8 +1,8 @@
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".control.state"))
|
||||
local context = require(path.. ".core.context")
|
||||
local context = require(path.. ".core.stack")
|
||||
|
||||
return function (base)
|
||||
local base = base or {}
|
||||
base = base or {}
|
||||
local fakeBase = {}
|
||||
local activeContext = context.getContext()
|
||||
return setmetatable({},{
|
||||
|
||||
@ -87,14 +87,23 @@ function element:new(param)
|
||||
self.context = context.new(self)
|
||||
end
|
||||
|
||||
function element:setCalculatedSize(w, h)
|
||||
self.view.minW = w or self.view.minW
|
||||
self.view.minH = h or self.view.minH
|
||||
self.view.w = math.max(self.view.minW, self.view.w)
|
||||
self.view.h = math.max(self.view.minH, self.view.h)
|
||||
end
|
||||
|
||||
function element:updateInputCtx()
|
||||
self.context.inputContext:update()
|
||||
if self.settings.canvasW then
|
||||
--If canvas too small make a bigger one
|
||||
if self.settings.canvasW < self.view.w or self.settings.canvasH < self.view.h then
|
||||
self.settings.canvasW = self.view.w*1.25
|
||||
self.settings.canvasH = self.view.h*1.25
|
||||
|
||||
self.canvas = love.graphics.newCanvas(self.view.w*1.25, self.view.h*1.25)
|
||||
--If canvas too big make a smaller one
|
||||
elseif self.settings.canvasW > self.view.w*1.50 or self.settings.canvasH > self.view.h*1.50 then
|
||||
self.settings.canvasW = self.view.w*1.25
|
||||
self.settings.canvasH = self.view.h*1.25
|
||||
@ -246,10 +255,12 @@ local insert = table.insert
|
||||
--Acts as the entrypoint for beginning rendering
|
||||
---@param x number
|
||||
---@param y number
|
||||
function element:draw(x, y)
|
||||
function element:draw(x, y, w, h)
|
||||
if not self.view.lock then
|
||||
if x then self.view.x = x end
|
||||
if y then self.view.y = y end
|
||||
if w then self.view.w = self.view.minW<=w and w or self.view.minW end
|
||||
if h then self.view.h = self.view.minH<=h and h or self.view.minH end
|
||||
end
|
||||
|
||||
if self.settings.firstDraw then
|
||||
|
||||
8
init.lua
8
init.lua
@ -12,10 +12,16 @@ helium.input = require(path..".core.input")
|
||||
helium.loader = require(path..".loader")
|
||||
helium.elementBuffer = {}
|
||||
helium.__index = helium
|
||||
|
||||
setmetatable(helium, {__call = function(s, chunk)
|
||||
return function(param,w,h)
|
||||
return {
|
||||
__call = function(s, param, w, h)
|
||||
return helium.element(chunk, nil, w, h, param)
|
||||
end,
|
||||
draw = function (param, x, y, w, h)
|
||||
return helium.element.immediate(param, chunk, x, y, w, h)
|
||||
end
|
||||
}
|
||||
end})
|
||||
|
||||
function helium.render()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user